Skip to content

Commit

Permalink
Release 1.0.0-rc.13
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexagon committed Apr 6, 2024
1 parent c88eab5 commit d7c4de5
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 84 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ _For detailed documentation, visit [pup.56k.guru](https://pup.56k.guru)._

### Installation

To install Pup, open your terminal and execute the following command:
To install Pup, make sure you have a fairly recent version of Deno installed (>=1.38.0), then open your terminal and execute the following command:

```bash
deno run -Ar https://deno.land/x/pup/pup.ts setup --channel prerelease
Expand Down
6 changes: 3 additions & 3 deletions application.meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

const Application = {
name: "pup",
version: "1.0.0-rc.12",
version: "1.0.0-rc.13",
url: "https://deno.land/x/pup@$VERSION/pup.ts",
canary_url: "https://raw.githubusercontent.com/Hexagon/pup/main/pup.ts",
deno: null, /* Minimum stable version of Deno required to run Pup (without --unstable flag) */
deno_unstable: "1.33.0", /* Minimum version of Deno required to run Pup (with --unstable flag) */
deno: null, /* Minimum stable version of Deno required to run Pup (without --unstable-* flags) */
deno_unstable: "1.38.0", /* Minimum version of Deno required to run Pup (with --unstable-* flags) */
repository: "https://github.com/hexagon/pup",
changelog: "https://hexagon.github.io/pup/changelog.html",
permissions: [
Expand Down
4 changes: 2 additions & 2 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

"tasks": {
"update-deps": "deno run --allow-read=. --allow-net=deno.land,cdn.deno.land https://deno.land/x/udd/main.ts --dry-run deno.json deps.ts test/deps.ts plugins/web-interface/deps.ts",
"check": "deno fmt --check && deno lint && deno check pup.ts --unstable && deno test --allow-read --allow-write --allow-env --allow-net --allow-sys --allow-run --unstable --coverage=cov_profile && echo \"Generating coverage\" && deno coverage cov_profile --exclude=pup/test --lcov --output=cov_profile.lcov",
"check": "deno fmt --check && deno lint && deno check pup.ts && deno test --allow-read --allow-write --allow-env --allow-net --allow-sys --allow-run --unstable-kv --coverage=cov_profile && echo \"Generating coverage\" && deno coverage cov_profile --exclude=pup/test --lcov --output=cov_profile.lcov",
"check-coverage": "deno task check && genhtml cov_profile.lcov --output-directory cov_profile/html && lcov --list cov_profile.lcov && deno run --allow-net --allow-read https://deno.land/std/http/file_server.ts cov_profile/html",
"build-schema": "deno run --allow-write --allow-read --allow-env=XDG_DATA_HOME,HOME tools/build-schema.ts && deno fmt",
"build-versions": "deno run --allow-read --allow-write --allow-env --unstable tools/release.ts && deno fmt",
"build-versions": "deno run --allow-read --allow-write --allow-env tools/release.ts && deno fmt",
"build-webinterface": "cd plugins/web-interface && rm static/bundle.json; deno run --allow-read --allow-write https://deno.land/x/bundlee/bundlee.ts --bundle static static/bundle.json && deno fmt",
"build": "deno task check && deno task build-schema && deno task build-webinterface && deno task build-versions"
}
Expand Down
38 changes: 18 additions & 20 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,37 @@
* - Always use the same version of all imports from deno.land/std
*/
// cli
export { parse } from "https://deno.land/std@0.207.0/flags/mod.ts"
export type { Args } from "https://deno.land/std@0.207.0/flags/mod.ts"
export * as path from "https://deno.land/std@0.207.0/path/mod.ts"
export * as uuid from "https://deno.land/std@0.207.0/uuid/mod.ts"
export { parse } from "https://deno.land/std@0.221.0/flags/mod.ts"
export type { Args } from "https://deno.land/std@0.221.0/flags/mod.ts"
export * as path from "https://deno.land/std@0.221.0/path/mod.ts"
export * as uuid from "https://deno.land/std@0.221.0/uuid/mod.ts"
// logger
export { stripColor } from "https://deno.land/std@0.207.0/fmt/colors.ts"
export { stripColor } from "https://deno.land/std@0.221.0/fmt/colors.ts"
// config
export * as jsonc from "https://deno.land/std@0.207.0/jsonc/mod.ts"
export * as jsonc from "https://deno.land/std@0.221.0/jsonc/mod.ts"
// watcher
export { deferred, delay } from "https://deno.land/std@0.207.0/async/mod.ts"
export { globToRegExp, relative } from "https://deno.land/std@0.207.0/path/mod.ts"
// load balancer
export { copy } from "https://deno.land/std@0.207.0/streams/mod.ts"
export { delay } from "https://deno.land/std@0.221.0/async/mod.ts"
export { globToRegExp, relative } from "https://deno.land/std@0.221.0/path/mod.ts"
// core - process
export { StringReader } from "https://deno.land/std@0.207.0/io/string_reader.ts"
export { readLines } from "https://deno.land/std@0.207.0/io/mod.ts"
export { StringReader } from "https://deno.land/std@0.221.0/io/string_reader.ts"
export { readLines } from "https://deno.land/std@0.221.0/io/mod.ts"
// service installer, release tool
export { existsSync } from "https://deno.land/std@0.207.0/fs/mod.ts"
export { existsSync } from "https://deno.land/std@0.221.0/fs/mod.ts"
// ipc
export { debounce } from "https://deno.land/std@0.207.0/async/mod.ts"
export { basename, dirname, join, resolve } from "https://deno.land/std@0.207.0/path/mod.ts"
export { debounce } from "https://deno.land/std@0.221.0/async/mod.ts"
export { basename, dirname, join, resolve } from "https://deno.land/std@0.221.0/path/mod.ts"
// upgrader
export { gt, lt, parse as parseVersion } from "https://deno.land/std@0.207.0/semver/mod.ts"
export type { SemVer } from "https://deno.land/std@0.207.0/semver/mod.ts"
export { greaterThan, lessThan, parse as parseVersion } from "https://deno.land/std@0.221.0/semver/mod.ts"
export type { SemVer } from "https://deno.land/std@0.221.0/semver/mod.ts"

/**
* Third party dependencies
*
* - Prefer deno.land/x when available
*/
export { Cron } from "https://deno.land/x/croner@7.0.5/dist/croner.js"
export { Cron } from "https://deno.land/x/croner@8.0.1/dist/croner.js"
export { z } from "https://deno.land/x/zod@v3.22.4/mod.ts"
export { installService, uninstallService } from "https://deno.land/x/service@1.0.0-rc.0/mod.ts"
export type { InstallServiceOptions, UninstallServiceOptions } from "https://deno.land/x/service@1.0.0-rc.0/mod.ts"
export { $ } from "https://deno.land/x/dax@0.35.0/mod.ts"
export { CommandChild } from "https://deno.land/x/dax@0.35.0/src/command.ts"
export { $ } from "https://deno.land/x/dax@0.39.2/mod.ts"
export { CommandChild } from "https://deno.land/x/dax@0.39.2/src/command.ts"
2 changes: 1 addition & 1 deletion docs/deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tasks": {
"lume": "echo \"import 'lume/cli.ts'\" | deno run --unstable -A -",
"lume": "echo \"import 'lume/cli.ts'\" | deno run -A -",
"build": "deno task lume",
"serve": "deno task lume -s --port=8000"
},
Expand Down
21 changes: 14 additions & 7 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ nav_order: 13

All notable changes to this project will be documented in this section.

## [1.0.0-rc.13] - 2024-04-06

- fix(core): Use `--unstable-kv` instead of the (to be) deprecated `--unstable`
- fix(cluster): Replace deprecated `Deno.serveHttp` with `Deno.serve` for the internal cluster server
- chore(ci): Remove `--unstable` in CI and
- chore(deps): Full dependency update. Replace `lt` with `lessThan`, `gt` with `greaterThan`, and `deferred` with native Promises.

## [1.0.0-rc.12] - 2023-11-22

- fix(logger): Store (sliced) log lines larger than Deno's KV limit of 64KiB
Expand Down Expand Up @@ -96,8 +103,8 @@ Pup has now achieved enough stability to enter the Release Candidate phase. Here

- A new maintenance loop was added to purge internal logs and status after a set number of hours.

- Breaking changes were introduced with the move to Deno KV for storing internal states and logs. This transition required a fresh install of Pup and the use of the --unstable flag in Deno. If you're
upgrading from an early version, run `pup upgrade --channel prerelease` twice to make sure you're all good.
- Breaking changes were introduced with the move to Deno KV for storing internal states and logs. This transition required a fresh install of Pup and the use of the --unstable-kv flag in Deno. If
you're upgrading from an early version, run `pup upgrade --channel prerelease` twice to make sure you're all good.

- The load balancer module was enhanced with features for backend health tracking, error handling, and redirection.

Expand All @@ -106,8 +113,8 @@ Pup has now achieved enough stability to enter the Release Candidate phase. Here
Moving forward, our focus will shift to bug hunting and overall stability improvements. We greatly appreciate any feedback from users during this final testing phase. Please be aware that while this
release candidate is close to the final version, it might still contain some bugs.

It's important to note that Pup can currently only operate with the --unstable flag. However, this is automatically managed by the installer/upgrader. As soon as Deno stabilizes KV, the --unstable
flag will be automatically removed during the upgrade process.
It's important to note that Pup can currently only operate with the --unstable-kv flag. However, this is automatically managed by the installer/upgrader. As soon as Deno stabilizes KV, the
--unstable-kv flag will be automatically removed during the upgrade process.

## [1.0.0-beta.37] - 2023-07-01

Expand Down Expand Up @@ -144,12 +151,12 @@ flag will be automatically removed during the upgrade process.
**A note on breaking changes**

This release contains breaking changes. Starting from this version, Deno KV is used for storing internal states and logs. Deno KV is an experimental feature that requires Deno to run with the
`--unstable` flag.
`--unstable-kv` flag.

You cannot update from a previous version using the built-in installer, as it would install Pup without the `--unstable` flag. Instead, please follow the instructions for a fresh install in the
You cannot update from a previous version using the built-in installer, as it would install Pup without the `--unstable-kv` flag. Instead, please follow the instructions for a fresh install in the
manual, and the old version of Pup will be overwritten.

From now on, the upgrader will check your installed Deno version and the need for using `--unstable`, and it will act/suggest actions accordingly.
From now on, the upgrader will check your installed Deno version and the need for using `--unstable-kv`, and it will act/suggest actions accordingly.

Also not that the `stable` installation channel will be empty until the first stable release. From now on, you will have to pass `--channel prerelease` when using the `setup` or `upgrade` commands.

Expand Down
4 changes: 2 additions & 2 deletions docs/src/contributing/packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ If you have experience with software packaging, your contribution can greatly en

- Pup can be compiled into an executable prior to packaging using `deno compile`. The procedure is described at
[https://deno.com/manual@v1.34.3/tools/compiler](https://deno.com/manual@v1.34.3/tools/compiler). The command should be similar to
`deno compile --allow-all --reload --unstable --output pup pup.ts --external-installer`. The `--unstable` flag should be included if the version you are packaging (mostly pre-releases) requires
unstable features according to `versions.json`.
`deno compile --allow-all --reload --unstable-kv --output pup pup.ts --external-installer`. The `--unstable-kv` flag should be included if the version you are packaging (mostly pre-releases)
requires unstable features according to `versions.json`.

- The `--external-installer` argument to the Pup script disables the built-in installer, hiding `setup` and `upgrade` options from `--help`.

Expand Down
15 changes: 6 additions & 9 deletions docs/src/examples/cluster/app.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
const PORT = parseInt(Deno.env.get("PUP_CLUSTER_PORT") || "8000", 10)

async function serveHttp(conn: Deno.Conn) {
const httpConn = Deno.serveHttp(conn)
for await (const requestEvent of httpConn) {
function serveHttp(conn: Deno.Conn) {
Deno.serve(conn, () => {
const body = `Response from HTTP webserver running on pup instance ${Deno.env.get("PUP_CLUSTER_INSTANCE")}.`
requestEvent.respondWith(
new Response(body, {
status: 200,
}),
)
}
return new Response(body, {
status: 200,
})
})
}

if (!isNaN(PORT)) {
Expand Down
10 changes: 5 additions & 5 deletions lib/cli/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import { Application } from "../../application.meta.ts"
import { gt, lt, parseVersion } from "../../deps.ts"
import { greaterThan, lessThan, parseVersion } from "../../deps.ts"

const VERSION_INVENTORY_URL = "https://deno.land/x/pup/versions.json"
const LOCAL_VERSION_INVENTORY_FILE = "./versions.json"
Expand Down Expand Up @@ -46,7 +46,7 @@ function denoVersionCheck(requiredVersion: string | null): boolean {
if (requiredVersion === null) return false
const denoVersion = parseVersion(Deno.version.deno)
const required = parseVersion(requiredVersion)
if (denoVersion !== null && required !== null && !lt(denoVersion, required)) {
if (denoVersion !== null && required !== null && !lessThan(denoVersion, required)) {
return true
} else {
return false
Expand All @@ -66,7 +66,7 @@ export async function upgrade(
// Determine the channel from the version if it's not specified
if (version && !channelName) {
const semver = parseVersion(version)
channelName = semver && semver.prerelease.length > 0 ? "prerelease" : "stable"
channelName = semver && semver.prerelease && semver.prerelease.length > 0 ? "prerelease" : "stable"
}

// Default channel to stable
Expand Down Expand Up @@ -140,7 +140,7 @@ export async function upgrade(
// Determine version to install
const upgradeOrDowngradingAction = freshInstall
? "Installing"
: (canaryInstall ? "Upgrading" : gt(parseVersion(Application.version), parseVersion((requestedVersion as Version).version)) ? "Downgrading" : "Upgrading")
: (canaryInstall ? "Upgrading" : greaterThan(parseVersion(Application.version), parseVersion((requestedVersion as Version).version)) ? "Downgrading" : "Upgrading")

// If upgrading to a version that requires --unstable, alert the user
if (unstableInstall) {
Expand Down Expand Up @@ -172,7 +172,7 @@ export async function upgrade(
installCmd.push(ignoreCertificateErrorsString)
}
if (unstableInstall) {
installCmd.push("--unstable")
installCmd.push("--unstable-kv")
}
installCmd.push("-n", "pup")
installCmd.push(canaryInstall ? versions.canary_url : (requestedVersion as Version).url)
Expand Down
17 changes: 11 additions & 6 deletions lib/core/loadbalancer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @license MIT
*/

import { copy } from "../../deps.ts"
import { LOAD_BALANCER_DEFAULT_VALIDATION_INTERVAL_S } from "./configuration.ts"

export enum BalancingStrategy {
Expand Down Expand Up @@ -116,13 +115,19 @@ export class LoadBalancer {

private async handleProxyCommunication(client: Deno.Conn, targetConn: Deno.Conn, backend: InternalBackend): Promise<void> {
try {
await Promise.all([
copy(client, targetConn),
copy(targetConn, client),
])
const clientReadable = client.readable
const targetWritable = targetConn.writable

// Pipe data from client to backend
await clientReadable.pipeTo(targetWritable)

// Pipe data from backend to client (assuming bidirectional communication)
const backendReadable = targetConn.readable
const clientWritable = client.writable
await backendReadable.pipeTo(clientWritable)
} catch (_err) {
// Handle transport error if needed
// logger("warn","loadbalancer", "Proxy error:", err)
// logger("warn", "loadbalancer", "Proxy error:", err)
} finally {
this.updateBackendConnectionStatus(backend, false)
client.close()
Expand Down
18 changes: 14 additions & 4 deletions lib/core/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @license MIT
*/

import { deferred, delay, globToRegExp, relative } from "../../deps.ts"
import { delay, globToRegExp, relative } from "../../deps.ts"

type FileAction = "any" | "access" | "create" | "modify" | "remove" | "other"

Expand All @@ -24,7 +24,8 @@ export interface WatcherConfig {
}

export class Watcher implements AsyncIterable<FileEvent[]> {
private signal = deferred()
private signal: Promise<void> // Change deferred to Promise<void>
private signalResolver!: (value?: void | PromiseLike<void>) => void // Add a resolver
private changes = new Map<string, FileAction[]>()
private paths: string[] = []
private interval = 350
Expand All @@ -37,6 +38,10 @@ export class Watcher implements AsyncIterable<FileEvent[]> {
constructor(config: WatcherConfig = {}) {
this.config = config
this.reload()
// Initialize signal
this.signal = new Promise((resolve) => {
this.signalResolver = resolve
})
}

reload(): void {
Expand Down Expand Up @@ -66,7 +71,10 @@ export class Watcher implements AsyncIterable<FileEvent[]> {

private reset(): void {
this.changes.clear()
this.signal = deferred()
// Reset signal
this.signal = new Promise((resolve) => {
this.signalResolver = resolve
})
}

private verifyPath(path: string): string {
Expand Down Expand Up @@ -101,7 +109,9 @@ export class Watcher implements AsyncIterable<FileEvent[]> {
let timer = 0
const debounce = () => {
clearTimeout(timer)
timer = setTimeout(this.signal.resolve, this.interval)
timer = setTimeout(() => {
this.signalResolver()
}, this.interval)
}

const run = async () => {
Expand Down
4 changes: 2 additions & 2 deletions plugins/web-interface/deps.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { Application, Router } from "https://deno.land/x/oak@v12.6.1/mod.ts"
export { dirname, fromFileUrl } from "https://deno.land/std@0.207.0/path/mod.ts"
export { Application, Router } from "https://deno.land/x/oak@14.2.0/mod.ts"
export { dirname, fromFileUrl } from "https://deno.land/std@0.221.0/path/mod.ts"
export { Bundlee } from "https://deno.land/x/bundlee@0.9.4/mod.ts"
Loading

0 comments on commit d7c4de5

Please sign in to comment.