Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0.0-rc.15 - Work in progress #51

Merged
merged 14 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/deno.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:

strategy:
matrix:
deno-version: [1.38.0, "v1.x"]
deno-version: [1.42.0, "v1.x"]

steps:
- name: Git Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Deno Version ${{ matrix.deno-version }}
uses: denoland/setup-deno@v1
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/jsr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Publish to jsr.io
on:
release:
types: [released]
workflow_dispatch:

jobs:
publish:
permissions:
contents: read
id-token: write
uses: cross-org/workflows/.github/workflows/jsr-publish.yml@main
4 changes: 2 additions & 2 deletions .github/workflows/pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Pages
uses: actions/configure-pages@v3

- name: Install Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.37.1
deno-version: v1.42.0

- name: Run Lume
run: deno task lume
Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,11 @@ core
# Test coverage
cov_profile
*.lcov

# Lumocs generated site
_site
_site

# Node files
.npmrc
package-lock.json
package.json
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"/pup.json",
"/pup.jsonc"
],
"url": "https://deno.land/x/pup/docs/pup.schema.json"
"url": "https://jsr.io/@pup/pup/docs/pup.schema.json"
}
]
}
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,46 @@ _For detailed documentation, visit [pup.56k.guru](https://pup.56k.guru)._

### Installation

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:
To install Pup, open your terminal and execute the following command:

```bash
deno run -Ar https://deno.land/x/pup/pup.ts setup --channel prerelease
deno run -Ar @pup/pup setup --channel prerelease
```

This command downloads the latest version of Pup and installs it on your system. The `--channel prerelease` option is included as there is no stable version of Pup yet. Read more abour release
channels [here](https://pup.56k.guru/installation.html#release-channels).
channels [here](https://hexagon.github.io/pup/installation.html#release-channels).

### Configuration

1. Start by generating a new configuration file called pup.json at your project root. This can be achieved using Pup's built-in helper with the following command:
Pup revolves around instance (ecosystem) configuration files, each process belongs to an instance defined by a `pup.json`. This file can either be created manually, or by the command line helpers. To
create a simple instance running a single process:

`pup init --id "my-server" --cmd "deno run -A server.ts" --autostart`
`pup init --id "my-server" --autostart --cmd "deno run -A server.ts"`

2. (Optional) In case you have an additional task to execute, such as a cleanup script, you can make use of `pup append`. The following example shows how to add an extra task that use the cron start
policy:

`pup append --id "my-task" --cmd "deno run -A task.ts" --cron "0 0 * * * *"`

3. Now, start your ecosystem:
3. (Optional) Test run your instance (ecosystem):

`pup run`
`pup foreground`

4. (Optional) To make your ecosystem function as a system service, install it using `pup install`. This works with systemd, sysvinit, upstart, launchd, and Windows service manager:
4. To make your instance run at boot, enable it using `pup enable-service`.

`pup install --name my-service`
`pup enable-service`

You can pass `-n my-custom-name` to give the service a name different from `pup`

For the full manual, see <https://pup.56k.guru>

#### Single command example

It is also possible to use pup to keep a process alive temporary, without a `pup.json` or system service.

To achieve this, use `pup run` with `--cmd` and a start policy, for example `--autostart`.
To achieve this, use `pup foreground` with `--cmd` and a start policy, the default restart policy is `--autostart`.

`pup run --cmd "deno run server.ts" --autostart`
`pup foreground --cmd "deno run server.ts"`

## Example setups

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.14",
url: "https://deno.land/x/pup@$VERSION/pup.ts",
version: "1.0.0-rc.15",
url: "https://jsr.io/@pup/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-* flags) */
deno_unstable: "1.38.0", /* Minimum version of Deno required to run Pup (with --unstable-* flags) */
deno_unstable: "1.42.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
30 changes: 28 additions & 2 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,47 @@
{
"name": "@pup/pup",
"version": "1.0.0-rc.15",
"exports": "./pup.ts",

"fmt": {
"lineWidth": 200,
"semiColons": false,
"exclude": ["cov_profile", "docs/_site"]
},

"lint": {
"exclude": ["plugins/web-interface/static/js", "cov_profile", "docs/_site"]
"exclude": ["plugins/web-interface/static/js", "cov_profile", "docs/_site"],
"rules": {
"exclude": ["verbatim-module-syntax"]
}
},

"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",
"update-deps": "deno run --allow-read=. --allow-net=jsr.io,registry.npmjs.org jsr:@check/deps",
"check": "deno fmt --check && deno lint && deno check --unstable-kv 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 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"
},

"imports": {
"@cross/fs": "jsr:@cross/fs@^0.0.9",
"@cross/service": "jsr:@cross/service@^1.0.0",
"@cross/test": "jsr:@cross/test@^0.0.9",
"@cross/utils": "jsr:@cross/utils@^0.11.0",
"@hexagon/croner": "jsr:@hexagon/croner@^8.0.1",
"@std/assert": "jsr:@std/assert@^0.222.1",
"@std/async": "jsr:@std/async@^0.222.1",
"@std/io": "jsr:@std/io@^0.222.1",
"@std/path": "jsr:@std/path@^0.222.1",
"@std/semver": "jsr:@std/semver@^0.222.1",
"@std/testing": "jsr:@std/testing@^0.222.1",
"@std/uuid": "jsr:@std/uuid@^0.222.1",
"dax-sh": "npm:dax-sh@^0.40.0",
"json5": "npm:json5@^2.2.3",
"zod": "npm:zod@^3.22.4",
"zod-to-json-schema": "npm:zod-to-json-schema@^3.22.5"
}
}
49 changes: 0 additions & 49 deletions deps.ts

This file was deleted.

5 changes: 3 additions & 2 deletions docs/pup.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@
},
"env": {
"type": "object",
"properties": {},
"additionalProperties": false
"additionalProperties": {
"type": "string"
}
},
"cluster": {
"type": "object",
Expand Down
10 changes: 7 additions & 3 deletions docs/src/_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"url": "https://deno.land/x/pup"
},
{
"icon": "fab fa-npm",
"title": "NPM Library",
"url": "https://npmjs.com/package/pup"
"icon": "fas fa-cube",
"title": "jsr.io",
"url": "https://jsr.io/@pup/pup"
}
],
"nav_links": [
Expand All @@ -33,6 +33,10 @@
{
"title": "Deno.land/x",
"url": "https://deno.land/x/pup"
},
{
"title": "JSR.io",
"url": "https://jsr.io/@pup/pup"
}
]
}
33 changes: 33 additions & 0 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,39 @@ nav_order: 13

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

## [1.0.0-rc.15] - 2024-04-11

- **Minimum Deno Version:** Pup now require Deno version `1.42.0` or later. If you're using an older version, you'll need to upgrade Deno before upgrading Pup.

### Breaking Changes

- [x] change(cli): Rename cli command run to foreground to not be confused with starting as a service
- [x] change(cli): Rename cli command install to enable-service to separate from actual pup installation
- [x] change(cli): Rename cli command uninstall to disable-service to separate from actual pup uninstallation
- [x] change(config): Support JSON5.
- [x] change(core): Move .pup.jsonc-tmp, .pup.jsonc-data into .pup
- [x] change(packaging): Move default installation docs/references from `deno.land/x` to JSR.io

### Non-breaking

- [x] fix(core): Foreground command did not keep an autostarted process running, fixed by refing the watchdog timer.
- [x] fix(cli): Controlled output of manual rests after installing/uninstalling as service.
- [x] fix(docs): Docs incorrectly stated that `**/_._` is default for watcher config. `**/*.*` is correct.
- [x] fix(schema): Expect Record<string, string> for process.env in json schema.
- [x] change(core): Make most code cross runtime, preparing for Node and Bun support.

## Maintenance

- [x] chore(deps): Replace `deno.land/x/udd` with `@check/deps`
- [x] chore(deps): Use `@cross/deps` for cross-runtime filesystem operations
- [x] chore(deps): Replace `deno.land/x/hexagon/service` with `@cross/service` for cross-runtime service installation
- [x] chore(deps): Replace `deno.land/x/std/` with `@std/` from jsr
- [x] chore(deps): Replace `deno.land/x/dax` with `dax-sh` for a cross runtime shell
- [x] chore(deps): Replace `deno.land/x/zod` with `npm:zod`
- [x] chore(deps): Utilize `@cross/utils` instead of Deno built-ins for cross runtime ansi console output, argument parsing, process management and more.
- [x] chore(deps): Use `@cross/env` to handle enviroment variables across runtimes.
- [x] chore(testing): Use `@cross/test` insted of Deno test runner, to utilize the native test runners of Node, Deno and Bun.

## [1.0.0-rc.14] - 2024-04-07

- fix(loadbalancer): Fixes an issue with the loadbalancer introduced in `1.0.0-rc.13`
Expand Down
6 changes: 3 additions & 3 deletions docs/src/examples/basic-webinterface/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ nav_order: 3
The example at [/docs/src/examples/basic-webinterface](https://github.com/Hexagon/pup/tree/main/docs/src/examples/basic-webinterface) borrows the server.ts and task.ts from the basic example. Both
processes have logging configurations, with the second process having custom logger settings which enable the periodic process to write its logs to separate files.

The web interface plugin is enabled by `pup.jsonc` and available at <http://localhost:5000/>
The web interface plugin is enabled by `pup.json` and available at <http://localhost:5000/>

## Example Files

Expand All @@ -27,7 +27,7 @@ To activate the web interface plugin, set up the `plugins:`-section of your `pup
"processes": [/* ... */],
"plugins": [
{
"url": "https://deno.land/x/pup@$VERSION/plugins/web-interface/mod.ts",
"url": "jsr:@pup/pup@$VERSION/plugins/web-interface/mod.ts",
"options": {
"port": 5000
}
Expand All @@ -43,7 +43,7 @@ intallation, you **can not** use the `$VERSION` variable, and should give an abs

`cd` to `/docs/src/examples/basic-webinterface` directory.

Start example by running `pup run` if pup is installed, or something like `deno run -A ../../../pup.ts run` if not.
Start example by running `pup foreground` if pup is installed, or something like `deno run -A ../../../pup.ts foreground` if not.

Browse to <http://localhost:5000/>

Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ its logs to separate files.

`cd` to `/docs/src/examples/basic` directory.

Start example by running `pup run` if pup is installed, or something like `deno run -A ../../../pup.ts run` if not.
Start example by running `pup foreground` if pup is installed, or something like `deno run -A ../../../pup.ts foreground` if not.

Success!
2 changes: 1 addition & 1 deletion docs/src/examples/basic/pup.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
// Completely optional: Include $schema to get auto completion in VS Code etc...
"$schema": "https://deno.land/x/pup/docs/pup.schema.json",
"$schema": "https://jsr.io/@pup/pup/docs/pup.schema.json",

// Global logger configuration, all options can be ovverridden per process
"logger": {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/basic/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if (Math.random() > 0.9) {
throw new Error("Fatal error")
} else if (Math.random() > 0.85) {
console.error("Not so fatal, but still error")
Deno.exit(1)
exit(1)
} else {
console.log("Finished!")
}
2 changes: 1 addition & 1 deletion docs/src/examples/cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Detailed documentation available at [5. Scaling applications](https://hexagon.gi

`cd` to `/docs/src/examples/cluster` directory.

Run using command `pup run`
Run using command `pup foreground`

Browse to `http://localhost:3456`

Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN mkdir /app
COPY . /app/

# Install pup - Pin this url to a specific version in production
RUN ["deno","install","-An","pup", "https://deno.land/x/pup/pup.ts"]
RUN ["deno","install","-An","pup", "jsr:@pup/pup"]

# Go!
ENTRYPOINT ["sh", "-c", "cd /app && pup run"]
2 changes: 1 addition & 1 deletion docs/src/examples/plugins/log-interceptor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LogEvent, PluginApi, PluginConfiguration, PluginImplementation } from "../../../mod.ts"
import { type LogEvent, type PluginApi, type PluginConfiguration, PluginImplementation } from "../../../mod.ts"

export class PupPlugin extends PluginImplementation {
constructor(pup: PluginApi, config: PluginConfiguration) {
Expand Down
Loading