diff --git a/.claude/skills/dedalus-cli-sdk/SKILL.md b/.claude/skills/dedalus-cli-sdk/SKILL.md
index 1c4f14b..9c72c9c 100644
--- a/.claude/skills/dedalus-cli-sdk/SKILL.md
+++ b/.claude/skills/dedalus-cli-sdk/SKILL.md
@@ -10,18 +10,14 @@ Generated CLI client for Dedalus API, published as `dedalus-cli`. Use the genera
## Install
```sh
-# npm (requires Node.js)
-npm install -g dedalus-cli
+# macOS, Linux, and Windows (requires Node.js 20+ and pnpm)
+pnpm add --global dedalus-cli
-# Homebrew — standalone binary, no Node.js required
+# Homebrew installs Node and the same CLI package
brew install dedalus-labs/tap/dedalus
-# Direct download — standalone binary, no Node.js required
-curl -fsSL "https://github.com/dedalus-labs/dedalus-cli/releases/latest/download/dedalus-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/x64/;s/aarch64/arm64/').tar.gz" | tar xz dedalus
-sudo mv dedalus /usr/local/bin/
-
-# Windows — download and extract dedalus-windows-x64.zip, then add it to PATH
-# https://github.com/dedalus-labs/dedalus-cli/releases/latest/download/dedalus-windows-x64.zip
+# macOS and Linux installer (requires Node.js 20+ and pnpm)
+curl -fsSL https://www.dedaluslabs.ai/install/dedalus | bash
```
## Client setup and authentication
@@ -65,7 +61,7 @@ Failed requests print a structured error to standard error and exit with a statu
## Requirements
-- Node.js 20 or newer — for the npm install only; the standalone binaries bundle their own runtime.
+- Node.js 20 or newer and pnpm. Homebrew installs its own Node dependency.
## Reference files
diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml
index 5b5c5d4..ab19d9b 100644
--- a/.github/workflows/release-please.yml
+++ b/.github/workflows/release-please.yml
@@ -58,48 +58,30 @@ jobs:
with:
node-version: "24"
registry-url: https://registry.npmjs.org
- - run: npm install
+ - uses: pnpm/action-setup@a15d269cd4658e1107c09f1fabf4cbd7bd1f308a
+ with:
+ version: 10.20.0
+ - name: Install dependencies
+ run: pnpm install --frozen-lockfile --ignore-scripts
shell: bash
- - run: npm run build
+ - name: Build CLI
+ run: pnpm run build
shell: bash
- - name: Read package version
- run: echo "PKG_VERSION=$(node -p 'require("./package.json").version')" >> "$GITHUB_ENV"
+ - name: Pack Node CLI
+ run: pnpm pack --pack-destination release-packages
shell: bash
- run: npm install -g npm@11
shell: bash
- name: Publish to npm
run: node scripts/publish-npm.mjs
shell: bash
- - name: Set up Bun
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
- with:
- bun-version: 1.4.0
- - name: Compile standalone binaries
- run: |
- ROOT="$PWD"
- mkdir -p release-binaries
- for target in linux-x64 linux-arm64 darwin-x64 darwin-arm64 windows-x64; do
- rm -rf compile-out && mkdir -p compile-out
- case "$target" in
- windows-*)
- bun build src/bin.ts --compile --minify --target="bun-${target}" --outfile "compile-out/dedalus.exe"
- (cd compile-out && zip -q "$ROOT/release-binaries/dedalus-${target}.zip" "dedalus.exe")
- ;;
- *)
- bun build src/bin.ts --compile --minify --target="bun-${target}" --outfile "compile-out/dedalus"
- tar -czf "release-binaries/dedalus-${target}.tar.gz" -C compile-out "dedalus"
- ;;
- esac
- done
- rm -rf compile-out
- shell: bash
- - name: Attach binaries to the release
- run: node scripts/publish-binaries.mjs
+ - name: Attach Node package to the release
+ run: node scripts/publish-package.mjs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
- name: Open Homebrew release PR
+ run: node scripts/update-homebrew.mjs
env:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- run: node scripts/update-homebrew.mjs
shell: bash
diff --git a/.github/workflows/sdk-ci.yml b/.github/workflows/sdk-ci.yml
index df11bf3..1a4ea19 100644
--- a/.github/workflows/sdk-ci.yml
+++ b/.github/workflows/sdk-ci.yml
@@ -25,7 +25,7 @@ jobs:
run: pnpm run ci:generate
shell: bash
- name: Check generated workflows
- run: git diff --exit-code -- .github/workflows/sdk-ci.yml
+ run: git diff --exit-code -- .github/workflows
shell: bash
- name: Build CLI
run: pnpm run build
@@ -33,13 +33,6 @@ jobs:
- name: Install and test staging package
run: node scripts/verify-staging-package.mjs
shell: bash
- - name: Set up Bun
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
- with:
- bun-version: 1.4.0
- - name: Test native standalone binary
- run: node scripts/verify-standalone.mjs
- shell: bash
- name: Upload tested staging package
uses: actions/upload-artifact@v7
with:
diff --git a/.github/workflows/sdk-release.yml b/.github/workflows/sdk-release.yml
index 0e4f1c7..3263f7e 100644
--- a/.github/workflows/sdk-release.yml
+++ b/.github/workflows/sdk-release.yml
@@ -19,48 +19,30 @@ jobs:
with:
node-version: "24"
registry-url: https://registry.npmjs.org
- - run: npm install
+ - uses: pnpm/action-setup@a15d269cd4658e1107c09f1fabf4cbd7bd1f308a
+ with:
+ version: 10.20.0
+ - name: Install dependencies
+ run: pnpm install --frozen-lockfile --ignore-scripts
shell: bash
- - run: npm run build
+ - name: Build CLI
+ run: pnpm run build
shell: bash
- - name: Read package version
- run: echo "PKG_VERSION=$(node -p 'require("./package.json").version')" >> "$GITHUB_ENV"
+ - name: Pack Node CLI
+ run: pnpm pack --pack-destination release-packages
shell: bash
- run: npm install -g npm@11
shell: bash
- name: Publish to npm
run: node scripts/publish-npm.mjs
shell: bash
- - name: Set up Bun
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
- with:
- bun-version: 1.4.0
- - name: Compile standalone binaries
- run: |
- ROOT="$PWD"
- mkdir -p release-binaries
- for target in linux-x64 linux-arm64 darwin-x64 darwin-arm64 windows-x64; do
- rm -rf compile-out && mkdir -p compile-out
- case "$target" in
- windows-*)
- bun build src/bin.ts --compile --minify --target="bun-${target}" --outfile "compile-out/dedalus.exe"
- (cd compile-out && zip -q "$ROOT/release-binaries/dedalus-${target}.zip" "dedalus.exe")
- ;;
- *)
- bun build src/bin.ts --compile --minify --target="bun-${target}" --outfile "compile-out/dedalus"
- tar -czf "release-binaries/dedalus-${target}.tar.gz" -C compile-out "dedalus"
- ;;
- esac
- done
- rm -rf compile-out
- shell: bash
- - name: Attach binaries to the release
- run: node scripts/publish-binaries.mjs
+ - name: Attach Node package to the release
+ run: node scripts/publish-package.mjs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
- name: Open Homebrew release PR
+ run: node scripts/update-homebrew.mjs
env:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- run: node scripts/update-homebrew.mjs
shell: bash
diff --git a/.gitignore b/.gitignore
index 6434b0e..74eafb2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,5 +7,6 @@ node_modules/
/apple-codesign-*/
/compile-out/
/release-binaries/
+/release-packages/
/tap/
/artifacts/
diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 7e08ec6..ee2bfff 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.9.2"
+ ".": "0.9.3"
}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e1bce1e..f691916 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,16 @@
# Changelog
+## [0.9.3](https://github.com/dedalus-labs/dedalus-cli/compare/v0.9.2...v0.9.3) (2026-11-25)
+
+
+### ⚠ BREAKING CHANGES
+
+* **cli:** distribute the cli through pnpm ([#135](https://github.com/dedalus-labs/dedalus-cli/issues/135))
+
+### Features
+
+* **cli:** distribute the cli through pnpm ([#135](https://github.com/dedalus-labs/dedalus-cli/issues/135)) ([8cd8956](https://github.com/dedalus-labs/dedalus-cli/commit/8cd89563f422f33684fbfa4a4de3b4ef6912f8ae))
+
## [0.9.2](https://github.com/dedalus-labs/dedalus-cli/compare/v0.9.1...v0.9.2) (2026-11-24)
diff --git a/README.md b/README.md
index 88676bc..1fb41f5 100644
--- a/README.md
+++ b/README.md
@@ -32,29 +32,27 @@ The full API of this library can be found in [api.md](./api.md).
## Installation
```sh
-# npm (requires Node.js)
-npm install -g dedalus-cli
+# macOS, Linux, and Windows (requires Node.js 20+ and pnpm)
+pnpm add --global dedalus-cli
-# Homebrew — standalone binary, no Node.js required
+# Homebrew installs Node and the same CLI package
brew install dedalus-labs/tap/dedalus
-# Direct download — standalone binary, no Node.js required
-curl -fsSL "https://github.com/dedalus-labs/dedalus-cli/releases/latest/download/dedalus-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/x64/;s/aarch64/arm64/').tar.gz" | tar xz dedalus
-sudo mv dedalus /usr/local/bin/
-
-# Windows — download and extract dedalus-windows-x64.zip, then add it to PATH
-# https://github.com/dedalus-labs/dedalus-cli/releases/latest/download/dedalus-windows-x64.zip
+# macOS and Linux installer (requires Node.js 20+ and pnpm)
+curl -fsSL https://www.dedaluslabs.ai/install/dedalus | bash
```
### Upgrading
-Run `dedalus upgrade --check` to check for a release, then `dedalus upgrade` to
-install it. Package-manager installations use their owning manager. Standalone
-macOS and Linux installations download the release archive and verify its
-`checksums.txt` before replacing the executable.
+Run `pnpm add --global dedalus-cli@latest` to upgrade a pnpm installation.
+`dedalus upgrade --check` checks for a release, and `dedalus upgrade` uses the
+package manager that owns the installation. Homebrew installations use Homebrew.
-If your CLI does not recognize `dedalus upgrade`, reinstall it using one of the
-methods above. Older Go CLI versions do not support this command.
+New releases ship a Node package instead of native executables. Existing direct
+downloads must migrate with the installation command above. Remove the old
+executable if it takes precedence over pnpm's `dedalus` on your `PATH`.
+If pnpm reports that its global bin directory is missing, run `pnpm setup` and
+open a new shell before installing.
@@ -203,6 +201,10 @@ directory, runs the tests against the installed package, and uploads the
`dedalus-cli-staging` artifact. The artifact contains a `.tgz` and its checksum
record. This workflow does not publish to npm or Homebrew.
+CI builds and tests the Node package with pnpm on Linux. Releases use
+GitHub-hosted Ubuntu for npm trusted publishing and attach the same Node package
+archive to GitHub. Homebrew installs that archive through pnpm and supplies Node.
+
Test packages are marked private and retain the production API default.
Set `DEDALUS_TEST_BASE_URL` to your test API and pass it explicitly:
@@ -218,6 +220,9 @@ Set `DEDALUS_API_KEY` to a staging credential before submitting. To reproduce CI
locally, run `pnpm install --frozen-lockfile`, `pnpm build`, and `pnpm test:package`.
Custom feedback code lives under `src/feedback` and is integrated on `scalar-next`.
Validate Scalar regeneration there before promoting a release.
+Release workflow customizations live under `ci/`. After merging generated output,
+run `pnpm ci:generate` and the package checks before releasing. CI rejects drift
+in any generated workflow, including the release workflows.
## Shell Completion
@@ -317,7 +322,7 @@ Paginated commands fetch subsequent pages for you. Use `--max-items ` to
## Requirements
-- Node.js 20 or newer — for the npm install only; the standalone binaries bundle their own runtime.
+- Node.js 20 or newer and pnpm. Homebrew installs its own Node dependency.
Powered by Scalar.
diff --git a/SKILL.md b/SKILL.md
index 8198270..f7f2e43 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -10,18 +10,14 @@ Generated CLI client for Dedalus API, published as `dedalus-cli`. Use the genera
## Install
```sh
-# npm (requires Node.js)
-npm install -g dedalus-cli
+# macOS, Linux, and Windows (requires Node.js 20+ and pnpm)
+pnpm add --global dedalus-cli
-# Homebrew — standalone binary, no Node.js required
+# Homebrew installs Node and the same CLI package
brew install dedalus-labs/tap/dedalus
-# Direct download — standalone binary, no Node.js required
-curl -fsSL "https://github.com/dedalus-labs/dedalus-cli/releases/latest/download/dedalus-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/x64/;s/aarch64/arm64/').tar.gz" | tar xz dedalus
-sudo mv dedalus /usr/local/bin/
-
-# Windows — download and extract dedalus-windows-x64.zip, then add it to PATH
-# https://github.com/dedalus-labs/dedalus-cli/releases/latest/download/dedalus-windows-x64.zip
+# macOS and Linux installer (requires Node.js 20+ and pnpm)
+curl -fsSL https://www.dedaluslabs.ai/install/dedalus | bash
```
## Client setup and authentication
@@ -65,7 +61,7 @@ Failed requests print a structured error to standard error and exit with a statu
## Requirements
-- Node.js 20 or newer — for the npm install only; the standalone binaries bundle their own runtime.
+- Node.js 20 or newer and pnpm. Homebrew installs its own Node dependency.
## Reference files
diff --git a/VERSIONING.md b/VERSIONING.md
index f9cf7dd..5556348 100644
--- a/VERSIONING.md
+++ b/VERSIONING.md
@@ -27,6 +27,12 @@ branch — so the PR diff shows the full pending release — and are versioned f
release, publishes it, and syncs the version bump and changelog back to `scalar-next`.
Pre-1.0, breaking changes bump the minor version.
+CLI distribution is customized on `scalar-next`: pnpm builds and packs the Node
+package, and the release workflow publishes it to npm and GitHub. No native
+executable compilation is required. Workflow sources live under `ci/`; regenerate
+them with `pnpm ci:generate` after integrating generated output, then run
+`pnpm build` and `pnpm test:package` before promoting the release.
+
### Choosing an exact version
To release a specific version — `1.0.0`, a hotfix number, anything the commit history would
diff --git a/ci/publish-steps.ts b/ci/publish-steps.ts
index d155748..ea7e3b4 100644
--- a/ci/publish-steps.ts
+++ b/ci/publish-steps.ts
@@ -1,79 +1,38 @@
import { command, unsafeShell, type GitHubWorkflowStep } from '@dedalus-labs/hollywood';
-// npm trusted publishing requires a GitHub-hosted runner.
+// pnpm publish uses npm's trusted-publishing client on a GitHub-hosted runner.
export const publishSteps = [
- {
- uses: 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1',
- },
+ { uses: 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' },
{
uses: 'actions/setup-node@820762786026740c76f36085b0efc47a31fe5020',
- with: {
- 'node-version': '24',
- 'registry-url': 'https://registry.npmjs.org',
- },
- },
- {
- run: unsafeShell(`npm install`),
- shell: 'bash',
+ with: { 'node-version': '24', 'registry-url': 'https://registry.npmjs.org' },
},
{
- run: unsafeShell(`npm run build`),
- shell: 'bash',
+ uses: 'pnpm/action-setup@a15d269cd4658e1107c09f1fabf4cbd7bd1f308a',
+ with: { version: '10.20.0' },
},
{
- name: 'Read package version',
- run: unsafeShell(`echo "PKG_VERSION=$(node -p 'require("./package.json").version')" >> "$GITHUB_ENV"`),
- shell: 'bash',
+ name: 'Install dependencies',
+ run: command({ file: 'pnpm', args: ['install', '--frozen-lockfile', '--ignore-scripts'] }),
},
+ { name: 'Build CLI', run: command({ file: 'pnpm', args: ['run', 'build'] }) },
{
- run: unsafeShell(`npm install -g npm@11`),
- shell: 'bash',
+ name: 'Pack Node CLI',
+ run: command({ file: 'pnpm', args: ['pack', '--pack-destination', 'release-packages'] }),
},
+ { run: unsafeShell('npm install -g npm@11'), shell: 'bash' },
{
name: 'Publish to npm',
- run: unsafeShell(`node scripts/publish-npm.mjs`),
- shell: 'bash',
- },
- {
- name: 'Set up Bun',
- uses: 'oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6',
- with: {
- 'bun-version': '1.4.0',
- },
- },
- {
- name: 'Compile standalone binaries',
- run: unsafeShell(`ROOT="$PWD"
-mkdir -p release-binaries
-for target in linux-x64 linux-arm64 darwin-x64 darwin-arm64 windows-x64; do
- rm -rf compile-out && mkdir -p compile-out
- case "$target" in
- windows-*)
- bun build src/bin.ts --compile --minify --target="bun-\${target}" --outfile "compile-out/dedalus.exe"
- (cd compile-out && zip -q "$ROOT/release-binaries/dedalus-\${target}.zip" "dedalus.exe")
- ;;
- *)
- bun build src/bin.ts --compile --minify --target="bun-\${target}" --outfile "compile-out/dedalus"
- tar -czf "release-binaries/dedalus-\${target}.tar.gz" -C compile-out "dedalus"
- ;;
- esac
-done
-rm -rf compile-out
-`),
- shell: 'bash',
+ run: command({ file: 'node', args: ['scripts/publish-npm.mjs'] }),
},
{
- name: 'Attach binaries to the release',
- run: command({ file: 'node', args: ['scripts/publish-binaries.mjs'] }),
- env: {
- GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}',
- },
+ name: 'Attach Node package to the release',
+ run: command({ file: 'node', args: ['scripts/publish-package.mjs'] }),
+ env: { GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}' },
},
{
name: 'Open Homebrew release PR',
- env: {
- HOMEBREW_TAP_TOKEN: '${{ secrets.HOMEBREW_TAP_TOKEN }}',
- },
run: command({ file: 'node', args: ['scripts/update-homebrew.mjs'] }),
+ env: { HOMEBREW_TAP_TOKEN: '${{ secrets.HOMEBREW_TAP_TOKEN }}' },
},
] as const satisfies readonly GitHubWorkflowStep[];
diff --git a/ci/sdk-ci.ts b/ci/sdk-ci.ts
index dae0f74..a2a64d5 100644
--- a/ci/sdk-ci.ts
+++ b/ci/sdk-ci.ts
@@ -33,7 +33,7 @@ export const sdkCI = workflow({
name: 'Check generated workflows',
run: command({
file: 'git',
- args: ['diff', '--exit-code', '--', '.github/workflows/sdk-ci.yml'],
+ args: ['diff', '--exit-code', '--', '.github/workflows'],
}),
},
{ name: 'Build CLI', run: command({ file: 'pnpm', args: ['run', 'build'] }) },
@@ -41,15 +41,6 @@ export const sdkCI = workflow({
name: 'Install and test staging package',
run: command({ file: 'node', args: ['scripts/verify-staging-package.mjs'] }),
},
- {
- name: 'Set up Bun',
- uses: 'oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6',
- with: { 'bun-version': '1.4.0' },
- },
- {
- name: 'Test native standalone binary',
- run: command({ file: 'node', args: ['scripts/verify-standalone.mjs'] }),
- },
{
name: 'Upload tested staging package',
uses: 'actions/upload-artifact@v7',
diff --git a/package.json b/package.json
index dc3e6e7..7d7a25d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "dedalus-cli",
- "version": "0.9.2",
+ "version": "0.9.3",
"description": "Controlplane API for Dedalus Cloud Services (DCS).",
"author": "Dedalus",
"repository": {
@@ -8,6 +8,10 @@
"url": "git+https://github.com/dedalus-labs/dedalus-cli.git"
},
"type": "module",
+ "packageManager": "pnpm@10.20.0",
+ "engines": {
+ "node": ">=20"
+ },
"bin": {
"dedalus": "./dist/esm/bin.js"
},
diff --git a/scripts/install.sh b/scripts/install.sh
index 7ff355b..1db47ad 100644
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -3,73 +3,55 @@
set -euo pipefail
main() (
- local repo='https://github.com/dedalus-labs/dedalus-cli'
- local install_dir="${DEDALUS_INSTALL_DIR:-$HOME/.local/bin}"
- local version="${DEDALUS_VERSION:-}" os arch stage probe watchdog actual
+ local version="${DEDALUS_VERSION:-}" spec='dedalus-cli@latest'
+ local install_dir="${DEDALUS_INSTALL_DIR:-}" global_bin actual stage
- case "$(uname -s)" in
- Darwin) os=darwin ;;
- Linux) os=linux ;;
- *) echo 'Unsupported OS; this installer supports macOS and Linux.' >&2; exit 1 ;;
- esac
- case "$(uname -m)" in
- x86_64|amd64) arch=x64 ;;
- arm64|aarch64) arch=arm64 ;;
- *) echo 'Unsupported architecture; expected x64 or arm64.' >&2; exit 1 ;;
- esac
-
- if [[ -z "$version" ]]; then
- version=$(curl -fsSL --connect-timeout 10 --max-time 30 -o /dev/null \
- -w '%{url_effective}' "$repo/releases/latest")
- version=${version##*/}
+ if ! command -v node >/dev/null || ! node -e 'process.exit(Number(process.versions.node.split(".")[0]) >= 20 ? 0 : 1)'; then
+ echo 'Node.js 20 or newer is required. Install it from https://nodejs.org/ and retry.' >&2
+ exit 1
fi
- if [[ ! "$version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
- echo "Invalid release tag: $version" >&2
+ if ! command -v pnpm >/dev/null; then
+ echo 'pnpm is required. Install it from https://pnpm.io/installation and retry.' >&2
exit 1
fi
-
- mkdir -p "$install_dir"
- install_dir=$(cd "$install_dir" && pwd -P)
- if [[ -L "$install_dir/dedalus" || -d "$install_dir/dedalus" ]]; then
+ if [[ -n "$version" ]]; then
+ if [[ ! "$version" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
+ echo "Invalid package version: $version" >&2
+ exit 1
+ fi
+ spec="dedalus-cli@${version#v}"
+ fi
+ if [[ -n "$install_dir" && ( -L "$install_dir/dedalus" || -d "$install_dir/dedalus" ) ]]; then
echo 'Refusing to replace a symlink or directory; use the original package manager.' >&2
exit 1
fi
- # Stage beside the destination so the final rename stays on one filesystem.
- stage=$(mktemp -d "$install_dir/.dedalus-install.XXXXXX")
- trap 'rm -rf "$stage"' EXIT
- trap 'exit 130' INT
- trap 'exit 143' TERM
- local asset="dedalus-${os}-${arch}.tar.gz"
- echo "Downloading $version ($os/$arch)..."
- curl -fsSL --connect-timeout 10 --max-time 300 \
- "$repo/releases/download/$version/$asset" -o "$stage/archive.tar.gz"
- tar -xzf "$stage/archive.tar.gz" -C "$stage" dedalus
- if [[ ! -f "$stage/dedalus" || -L "$stage/dedalus" ]]; then
- echo "$asset did not contain a regular dedalus executable." >&2
+ if ! global_bin=$(pnpm bin --global) || [[ -z "$global_bin" ]]; then
+ echo 'Configure pnpm global installs with pnpm setup, then retry in a new shell.' >&2
exit 1
fi
- chmod 755 "$stage/dedalus"
- # Verify both compatibility and version before replacing the working CLI.
- "$stage/dedalus" --version > "$stage/version" &
- probe=$!
- (sleep 10; kill -KILL "$probe" 2>/dev/null || true) >/dev/null 2>&1 &
- watchdog=$!
- if ! wait "$probe"; then
- kill "$watchdog" 2>/dev/null || true
- echo 'Downloaded CLI failed its version check; existing CLI left unchanged.' >&2
+ pnpm add --global --ignore-scripts "$spec"
+ actual=$("$global_bin/dedalus" --version)
+ if [[ -n "$version" && "$actual" != "${version#v}" ]]; then
+ echo "Expected ${version#v}, received $actual." >&2
exit 1
fi
- kill "$watchdog" 2>/dev/null || true
- actual=$(cat "$stage/version")
- if [[ "$actual" != "${version#v}" ]]; then
- echo "Expected ${version#v}, received $actual; existing CLI left unchanged." >&2
- exit 1
+ # Older Go updaters request their original executable's directory.
+ if [[ -n "$install_dir" ]]; then
+ mkdir -p "$install_dir"
+ install_dir=$(cd "$install_dir" && pwd -P)
+ global_bin=$(cd "$global_bin" && pwd -P)
+ if [[ "$install_dir" != "$global_bin" ]]; then
+ stage=$(mktemp -d "$install_dir/.dedalus-install.XXXXXX")
+ trap 'rm -rf "$stage"' EXIT
+ printf '#!/usr/bin/env bash\nexec %q "$@"\n' "$global_bin/dedalus" > "$stage/dedalus"
+ chmod 755 "$stage/dedalus"
+ mv -f "$stage/dedalus" "$install_dir/dedalus"
+ fi
fi
- mv -f "$stage/dedalus" "$install_dir/dedalus"
- echo "Installed dedalus $version to $install_dir/dedalus"
- echo 'For future updates, run: dedalus upgrade'
+ echo "Installed dedalus $actual with pnpm ($global_bin/dedalus)."
+ echo 'For future updates, run: pnpm add --global dedalus-cli@latest'
)
-# Read the entire script before doing work when invoked by the legacy curl | bash.
+# Read the entire script before doing work when invoked by curl | bash.
main "$@"
diff --git a/scripts/publish-npm.mjs b/scripts/publish-npm.mjs
index 894443f..3d4268a 100644
--- a/scripts/publish-npm.mjs
+++ b/scripts/publish-npm.mjs
@@ -34,11 +34,11 @@ export const npmDistTagForVersion = (version) => {
return /^[a-z][a-z0-9-]*$/.test(candidate) ? candidate : 'next';
};
-/** Runs one npm command with inherited CI credentials and output. */
-const runNpm = (args, stdio = 'inherit') => spawnSync('npm', args, { stdio });
+/** Runs one pnpm command with inherited CI credentials and output. */
+const runPnpm = (args, stdio = 'inherit') => spawnSync('pnpm', args, { stdio });
/** Publishes the repository package once, applying a derived prerelease dist-tag when needed. */
-export const publishNpm = (runner = runNpm, metadata = readPackageMetadata()) => {
+export const publishNpm = (runner = runPnpm, metadata = readPackageMetadata()) => {
const { name, version } = metadata;
const packageSpec = `${name}@${version}`;
if (runner(['view', packageSpec, 'version'], 'ignore').status === 0) {
@@ -65,7 +65,8 @@ export const publishNpm = (runner = runNpm, metadata = readPackageMetadata()) =>
: stableTags.includes(derived)
? `${derived}-prerelease`
: derived;
- const args = ['publish', '--access', ACCESS, ...(tag ? ['--tag', tag] : [])];
+ const archive = `./release-packages/${name.replace('@', '').replace('/', '-')}-${version}.tgz`;
+ const args = ['publish', archive, '--no-git-checks', '--access', ACCESS, ...(tag ? ['--tag', tag] : [])];
console.log(
tag ? `Publishing ${packageSpec} to npm with dist-tag ${tag}` : `Publishing ${packageSpec} to npm`,
);
diff --git a/scripts/publish-binaries.mjs b/scripts/publish-package.mjs
similarity index 83%
rename from scripts/publish-binaries.mjs
rename to scripts/publish-package.mjs
index 607c01f..9bcda4d 100644
--- a/scripts/publish-binaries.mjs
+++ b/scripts/publish-package.mjs
@@ -1,4 +1,4 @@
-// Both release workflows call this after compilation. Published archives stay
+// Both release workflows call this after packing. Published archives stay
// immutable; retries fill missing assets and download the bytes Homebrew hashes.
import { spawnSync } from 'node:child_process';
import { createHash } from 'node:crypto';
@@ -10,13 +10,7 @@ const { version } = JSON.parse(readFileSync('package.json', 'utf8'));
const repository = process.env.GITHUB_REPOSITORY;
if (!repository) throw new Error('GITHUB_REPOSITORY is required');
const tag = `v${version}`;
-const archives = [
- 'dedalus-linux-x64.tar.gz',
- 'dedalus-linux-arm64.tar.gz',
- 'dedalus-darwin-x64.tar.gz',
- 'dedalus-darwin-arm64.tar.gz',
- 'dedalus-windows-x64.zip',
-];
+const archives = [`dedalus-cli-${version}.tgz`];
const run = (args, capture = false) => {
const result = spawnSync('gh', args, {
encoding: 'utf8',
@@ -31,7 +25,7 @@ const published = new Set(assets.map(({ name }) => name));
for (const archive of archives) {
if (published.has(archive)) continue;
// Never replace an asset: a merged Homebrew formula may already pin its bytes.
- run(['release', 'upload', tag, join('release-binaries', archive), '--repo', repository]);
+ run(['release', 'upload', tag, join('release-packages', archive), '--repo', repository]);
}
const directory = mkdtempSync(join(tmpdir(), 'dedalus-release-'));
@@ -41,9 +35,9 @@ try {
}
// Hash the published assets, including any reused from a previous attempt.
for (const archive of archives) {
- copyFileSync(join(directory, archive), join('release-binaries', archive));
+ copyFileSync(join(directory, archive), join('release-packages', archive));
}
- // The standalone upgrade command requires checksums for the published bytes.
+ // Record checksums for the package actually published to GitHub.
const checksums = archives
.map(
(archive) =>
diff --git a/scripts/update-homebrew.mjs b/scripts/update-homebrew.mjs
index 6739eae..564b889 100644
--- a/scripts/update-homebrew.mjs
+++ b/scripts/update-homebrew.mjs
@@ -6,12 +6,6 @@ import { join, resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
const tap = 'dedalus-labs/homebrew-tap';
-const platforms = [
- ['macos', 'arm', 'darwin-arm64'],
- ['macos', 'intel', 'darwin-x64'],
- ['linux', 'arm', 'linux-arm64'],
- ['linux', 'intel', 'linux-x64'],
-];
export function renderFormula(version, repository, directory) {
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(version)) {
@@ -26,27 +20,18 @@ export function renderFormula(version, repository, directory) {
' homepage "https://docs.dedaluslabs.ai"',
` version "${version}"`,
' license "Apache-2.0"',
+ ` url "https://github.com/${repository}/releases/download/v${version}/dedalus-cli-${version}.tgz"`,
+ ` sha256 "${createHash('sha256').update(readFileSync(join(directory, `dedalus-cli-${version}.tgz`))).digest('hex')}"`,
+ ' depends_on "node"',
+ ' depends_on "pnpm" => :build',
];
- for (const os of ['macos', 'linux']) {
- lines.push('', ` on_${os} do`);
- for (const [, architecture, target] of platforms.filter(([name]) => name === os)) {
- const archive = `dedalus-${target}.tar.gz`;
- const digest = createHash('sha256')
- .update(readFileSync(join(directory, archive)))
- .digest('hex');
- lines.push(
- ` on_${architecture} do`,
- ` url "https://github.com/${repository}/releases/download/v${version}/${archive}"`,
- ` sha256 "${digest}"`,
- ' end',
- );
- }
- lines.push(' end');
- }
lines.push(
'',
' def install',
- ' bin.install "dedalus"',
+ ' libexec.mkpath',
+ ' system "pnpm", "add", "--dir", libexec, "--prod", "--ignore-scripts", cached_download.to_s',
+ ' (bin/"dedalus").write_env_script libexec/"node_modules/.bin/dedalus", PATH: "#{Formula["node"].opt_bin}:$PATH"',
+ ' man1.install Dir[libexec/"node_modules/dedalus-cli/man/*.1"]',
' end',
'',
' test do',
@@ -60,7 +45,7 @@ export function renderFormula(version, repository, directory) {
export function updateHomebrew() {
const { version } = JSON.parse(readFileSync('package.json', 'utf8'));
- const formula = renderFormula(version, process.env.GITHUB_REPOSITORY, 'release-binaries');
+ const formula = renderFormula(version, process.env.GITHUB_REPOSITORY, 'release-packages');
if (process.argv.includes('--dry-run')) {
process.stdout.write(formula);
return;
@@ -118,7 +103,7 @@ export function updateHomebrew() {
const body = join(directory, 'release-pr-body.txt');
writeFileSync(
body,
- `Update the standalone CLI formula to ${version}. All four platform archives are pinned to the SHA-256 digests of the binaries uploaded by this release.\n`,
+ `Update the Node CLI formula to ${version}. The package archive is pinned to the SHA-256 digest uploaded by this release. Homebrew installs Node and uses pnpm to install the CLI.\n`,
);
run('gh', [
'pr',
diff --git a/scripts/verify-standalone.mjs b/scripts/verify-standalone.mjs
deleted file mode 100644
index bb8b926..0000000
--- a/scripts/verify-standalone.mjs
+++ /dev/null
@@ -1,17 +0,0 @@
-import assert from 'node:assert/strict';
-import { execFileSync } from 'node:child_process';
-import { mkdtempSync, rmSync } from 'node:fs';
-import { tmpdir } from 'node:os';
-import { join } from 'node:path';
-
-const directory = mkdtempSync(join(tmpdir(), 'dedalus-standalone-'));
-try {
- const binary = join(directory, process.platform === 'win32' ? 'dedalus.exe' : 'dedalus');
- execFileSync('bun', ['build', 'src/bin.ts', '--compile', '--minify', '--outfile', binary], { stdio: 'inherit' });
- const output = execFileSync(binary, ['doctor', '--json'], {
- env: { PATH: process.env.PATH, HOME: directory, USERPROFILE: directory }, encoding: 'utf8',
- });
- assert.equal(JSON.parse(output).install_method, 'standalone');
-} finally {
- rmSync(directory, { recursive: true, force: true });
-}
diff --git a/src/cli/upgrade.ts b/src/cli/upgrade.ts
index 8a3f427..2641c92 100644
--- a/src/cli/upgrade.ts
+++ b/src/cli/upgrade.ts
@@ -32,7 +32,7 @@ const RELEASE = {
repo: 'dedalus-labs/dedalus-cli',
npmPackage: 'dedalus-cli',
brewFormula: 'dedalus',
- windowsArchive: true,
+ windowsArchive: false,
} as {
/**
* The destination repository as `owner/repo`, which every GitHub Release request is addressed by.
@@ -146,19 +146,15 @@ const detectInstall = (binaryName: string, distTag = stableDistTag()): InstallKi
const executable = process.execPath;
// A compiled standalone executable *is* the command; running under `node`/`bun` instead means this
// is the npm package (or a checkout of it), and the script's own path says which manager owns it.
- if (!runsCompiled(executable, binaryName)) return detectPackageInstall(distTag);
-
- const path = resolvedPath(executable);
-
- // `Caskroom` as well as `Cellar`, and that is not redundant with the `homebrew`/`linuxbrew` segments
- // beside it: on an **Intel** Mac Homebrew's prefix is `/usr/local`, so a cask stages its executable
- // at `/usr/local/Caskroom///` — a path carrying none of the other three. Without
- // this, such an install classified as self-managed and `upgrade` renamed a downloaded binary over the
- // file inside the Caskroom, which is admin-owned on Intel Homebrew and so writable without `sudo`.
- // Brew went on recording the old version and reverted the binary on the next `brew upgrade`. Apple
- // Silicon and Linux casks were caught only because `/opt/homebrew` and `/home/linuxbrew` happen to
- // contain a matching segment.
- if (/\/(Cellar|Caskroom|homebrew|linuxbrew)\//u.test(path) && RELEASE.brewFormula) {
+ const compiled = runsCompiled(executable, binaryName);
+ const path = resolvedPath(compiled ? executable : process.argv[1] ?? '');
+
+ // Node packages belong to Homebrew only inside this formula's keg. npm and pnpm
+ // global installations can share Homebrew's prefix without belonging to the formula.
+ const homebrewOwned = compiled
+ ? /\/(Cellar|Caskroom|homebrew|linuxbrew)\//u.test(path)
+ : /\/(?:Cellar|Caskroom)\/([^/]+)\/[^/]+\//u.exec(path)?.[1] === RELEASE.brewFormula;
+ if (homebrewOwned && RELEASE.brewFormula) {
// A cask is upgraded and removed through `--cask`. The token is the formula's own lowercased name,
// which is what the generated cask is declared under, so one value serves both spellings.
const cask = /\/Caskroom\//u.test(path);
@@ -185,6 +181,8 @@ const detectInstall = (binaryName: string, distTag = stableDistTag()): InstallKi
: {}),
};
}
+ if (!compiled) return detectPackageInstall(distTag);
+
// `/usr/bin` is where a distro package manager installs; the documented direct download goes to
// `/usr/local/bin`, so it does not land here.
//
diff --git a/src/commands/index.ts b/src/commands/index.ts
index 66ff329..b6fa0dc 100644
--- a/src/commands/index.ts
+++ b/src/commands/index.ts
@@ -1582,7 +1582,7 @@ export const getProgram = (): Command => {
createProgram({
SDK,
binaryName: 'dedalus',
- version: '0.9.2', // x-release-please-version
+ version: '0.9.3', // x-release-please-version
description: 'CLI for Dedalus',
defaultFormat: 'json',
defaultErrorFormat: 'json',
@@ -1607,6 +1607,6 @@ export const getProgram = (): Command => {
clientOptions,
auth,
);
- addUpgradeCommands(program, 'dedalus', '0.9.2'); // x-release-please-version
+ addUpgradeCommands(program, 'dedalus', '0.9.3'); // x-release-please-version
return program;
};
diff --git a/src/sdk/version.ts b/src/sdk/version.ts
index f32304c..3303be1 100644
--- a/src/sdk/version.ts
+++ b/src/sdk/version.ts
@@ -1,3 +1,3 @@
// File generated from our OpenAPI spec by Scalar. See README.md for details.
-export const VERSION = '0.9.2'; // x-release-please-version
+export const VERSION = '0.9.3'; // x-release-please-version
diff --git a/tests/homebrew-release.test.mjs b/tests/homebrew-release.test.mjs
index db8df41..7396938 100644
--- a/tests/homebrew-release.test.mjs
+++ b/tests/homebrew-release.test.mjs
@@ -8,18 +8,18 @@ import { test } from 'node:test';
import { parse } from 'yaml';
import { renderFormula } from '../scripts/update-homebrew.mjs';
-const targets = ['darwin-arm64', 'darwin-x64', 'linux-arm64', 'linux-x64'];
+const archive = 'dedalus-cli-0.7.0.tgz';
-test('invariant_formulas_pin_every_platform_archive_before_updating_the_tap', () => {
+test('invariant_formulas_pin_the_node_package_before_updating_the_tap', () => {
const directory = mkdtempSync(join(tmpdir(), 'homebrew-archives-'));
try {
- for (const target of targets) writeFileSync(join(directory, `dedalus-${target}.tar.gz`), target);
+ writeFileSync(join(directory, archive), 'node package');
const formula = renderFormula('0.7.0', 'dedalus-labs/dedalus-cli', directory);
- for (const target of targets) {
- assert.ok(formula.includes(`/v0.7.0/dedalus-${target}.tar.gz`));
- assert.ok(formula.includes(createHash('sha256').update(target).digest('hex')));
- }
- rmSync(join(directory, 'dedalus-linux-arm64.tar.gz'));
+ assert.ok(formula.includes(`/v0.7.0/${archive}`));
+ assert.ok(formula.includes(createHash('sha256').update('node package').digest('hex')));
+ assert.ok(formula.includes('depends_on "node"'));
+ assert.ok(formula.includes('system "pnpm", "add"'));
+ rmSync(join(directory, archive));
assert.throws(() => renderFormula('0.7.0', 'dedalus-labs/dedalus-cli', directory), /ENOENT/);
} finally {
rmSync(directory, { recursive: true, force: true });
@@ -37,8 +37,8 @@ function verifyPublication(workflow) {
readFileSync(new URL(`../.github/workflows/${workflow}.yml`, import.meta.url), 'utf8'),
);
const steps = definition.jobs[workflow === 'release-please' ? 'publish' : 'release'].steps;
- const compile = steps.find((step) => step.name === 'Compile standalone binaries').run;
- const upload = steps.find((step) => step.name === 'Attach binaries to the release').run;
+ const pack = steps.find((step) => step.name === 'Pack Node CLI').run;
+ const upload = steps.find((step) => step.name === 'Attach Node package to the release').run;
const homebrew = steps.find((step) => step.name === 'Open Homebrew release PR').run;
const state = join(root, 'prs.json');
const env = {
@@ -71,18 +71,18 @@ function verifyPublication(workflow) {
cpSync(new URL('../scripts', import.meta.url), join(release, 'scripts'), {
recursive: true,
});
- const bun = join(binaries, 'bun');
+ const pnpm = join(binaries, 'pnpm');
writeFileSync(
- bun,
+ pnpm,
`#!${process.execPath}
const fs = require('node:fs');
const args = process.argv.slice(2);
-const output = args[args.indexOf('--outfile') + 1];
-fs.writeFileSync(output, args.find(arg => arg.startsWith('--target=')));
-fs.utimesSync(output, Number(process.env.BUILD_EPOCH), Number(process.env.BUILD_EPOCH));
+require('node:assert/strict').deepEqual(args, ['pack', '--pack-destination', 'release-packages']);
+fs.mkdirSync('release-packages', { recursive: true });
+fs.writeFileSync('release-packages/dedalus-cli-0.7.0.tgz', 'package ' + process.env.BUILD_EPOCH);
`,
);
- chmodSync(bun, 0o755);
+ chmodSync(pnpm, 0o755);
git(['init', '--bare', '--initial-branch=main', bare]);
git(['init', '--initial-branch=main'], seed);
git(['config', 'user.name', 'Fixture'], seed);
@@ -137,18 +137,17 @@ else if (action === 'create') {
chmodSync(gh, 0o755);
writeFileSync(join(release, 'package.json'), '{"version":"0.7.0"}\n');
const shell = (command) => run('bash', ['-e', '-o', 'pipefail', '-c', command], release);
- const archive = 'dedalus-linux-x64.tar.gz';
- // A previous attempt published only one platform before failing.
- shell(compile);
- const original = readFileSync(join(release, 'release-binaries', archive));
+ // A previous attempt uploaded the package before failing later in the release.
+ shell(pack);
+ const original = readFileSync(join(release, 'release-packages', archive));
if (workflow === 'release-please')
- cpSync(join(release, 'release-binaries', archive), join(published, archive));
+ cpSync(join(release, 'release-packages', archive), join(published, archive));
env.BUILD_EPOCH = '1700000060';
- shell(compile);
+ shell(pack);
shell(upload);
shell(homebrew);
const assets = new Map(
- [...targets.map((target) => `dedalus-${target}.tar.gz`), 'dedalus-windows-x64.zip'].map((name) => [
+ [archive].map((name) => [
name,
readFileSync(join(published, name)),
]),
@@ -160,7 +159,7 @@ else if (action === 'create') {
for (const [name, bytes] of assets) {
assert.deepEqual(readFileSync(join(published, name)), bytes, `${name}: published bytes`);
assert.deepEqual(
- readFileSync(join(release, 'release-binaries', name)),
+ readFileSync(join(release, 'release-packages', name)),
bytes,
`${name}: formula input`,
);
@@ -173,13 +172,13 @@ else if (action === 'create') {
assert.equal(git(['--git-dir', bare, 'rev-parse', 'main']), main);
assert.equal(JSON.parse(readFileSync(state, 'utf8')).creates, 1);
- // The same compiled payload gets a different archive timestamp on retry.
+ // A retry must reuse the uploaded package even if local bytes have changed.
const retry = (epoch) => {
env.BUILD_EPOCH = String(epoch);
- shell(compile);
+ shell(pack);
assert.notDeepEqual(
- readFileSync(join(release, 'release-binaries/dedalus-darwin-arm64.tar.gz')),
- assets.get('dedalus-darwin-arm64.tar.gz'),
+ readFileSync(join(release, 'release-packages', archive)),
+ assets.get(archive),
);
shell(upload);
assertPublishedBytes();
@@ -196,11 +195,11 @@ else if (action === 'create') {
if (workflow === 'sdk-release') git(['--git-dir', bare, 'update-ref', '-d', branch]);
assert.match(retry(1700000240), /already contains/);
const formula = git(['--git-dir', bare, 'show', 'main:Formula/dedalus.rb']);
- for (const target of targets) {
+ for (const name of assets.keys()) {
const digest = createHash('sha256')
- .update(assets.get(`dedalus-${target}.tar.gz`))
+ .update(assets.get(name))
.digest('hex');
- assert.ok(formula.includes(digest), `${target}: merged formula checksum`);
+ assert.ok(formula.includes(digest), `${name}: merged formula checksum`);
}
assert.equal(git(['--git-dir', bare, 'rev-parse', 'main']), first);
assert.equal(JSON.parse(readFileSync(state, 'utf8')).creates, 1);
diff --git a/tests/legacy-installer.test.mjs b/tests/legacy-installer.test.mjs
index 1b3a04a..5cd4e7d 100644
--- a/tests/legacy-installer.test.mjs
+++ b/tests/legacy-installer.test.mjs
@@ -1,149 +1,111 @@
import assert from 'node:assert/strict';
import { spawnSync } from 'node:child_process';
-import {
- chmodSync,
- mkdirSync,
- mkdtempSync,
- readFileSync,
- readdirSync,
- rmSync,
- symlinkSync,
- writeFileSync,
-} from 'node:fs';
+import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { test } from 'node:test';
const installer = new URL('../scripts/install.sh', import.meta.url);
-function fixture(t, { os = 'Darwin', arch = 'arm64', failure = '', version = 'v0.7.0' } = {}) {
- const root = mkdtempSync(join(tmpdir(), 'dedalus-installer-'));
+function fixture(t, { failure = '', version = 'v0.9.2', legacy = true } = {}) {
+ const root = mkdtempSync(join(tmpdir(), 'dedalus-pnpm-installer-'));
t.after(() => rmSync(root, { recursive: true, force: true }));
const bin = join(root, 'tools');
const destination = join(root, 'custom bin');
- const payload = join(root, 'payload');
- for (const path of [bin, destination, payload]) mkdirSync(path);
+ const globalBin = join(root, "pnpm's bin");
+ for (const path of [bin, destination, globalBin]) mkdirSync(path);
writeFileSync(join(destination, 'dedalus'), 'old executable');
const executable = (path, content) => {
writeFileSync(path, content);
chmodSync(path, 0o755);
};
- executable(
- join(payload, 'dedalus'),
- failure === 'timeout'
- ? '#!/bin/sh\nwhile :; do :; done\n'
- : failure === 'cannot-run'
- ? '#!/bin/sh\nexit 126\n'
- : `#!/bin/sh\nprintf '%s\\n' '${failure === 'wrong-version' ? '9.9.9' : '0.7.0'}'\n`,
- );
- const archive = join(root, 'archive.tar.gz');
- if (failure === 'missing-binary') rmSync(join(payload, 'dedalus'));
- const packed = spawnSync('tar', [
- '-czf',
- archive,
- '-C',
- payload,
- failure === 'missing-binary' ? '.' : 'dedalus',
- ]);
- assert.equal(packed.status, 0);
- if (failure === 'corrupt') writeFileSync(archive, 'not an archive');
- executable(join(bin, 'uname'), `#!/bin/sh\ncase "$1" in -s) echo '${os}';; -m) echo '${arch}';; esac\n`);
- executable(
- join(bin, 'curl'),
- `#!${process.execPath}
+ if (failure === 'old-node') executable(join(bin, 'node'), '#!/bin/sh\nexit 1\n');
+ else if (failure !== 'missing-node') symlinkSync(process.execPath, join(bin, 'node'));
+ if (failure !== 'missing-pnpm') executable(join(bin, 'pnpm'), `#!${process.execPath}
+const assert = require('node:assert/strict');
const fs = require('node:fs');
+const path = require('node:path');
const args = process.argv.slice(2);
-const url = args.find(arg => arg.startsWith('https://'));
-fs.appendFileSync(process.env.INSTALL_TEST_LOG, url + '\\n');
-if (process.env.INSTALL_TEST_FAILURE === 'download') process.exit(22);
-if (url.endsWith('/releases/latest')) {
- console.log('https://github.com/dedalus-labs/dedalus-cli/releases/tag/v0.7.0');
+fs.appendFileSync(process.env.INSTALL_TEST_LOG, JSON.stringify(args) + '\\n');
+if (args[0] === 'bin') {
+ assert.deepEqual(args, ['bin', '--global']);
+ if (process.env.INSTALL_TEST_FAILURE === 'unconfigured') process.exit(1);
+ console.log(process.env.INSTALL_TEST_GLOBAL_BIN);
} else {
- fs.copyFileSync(process.env.INSTALL_TEST_ARCHIVE, args[args.indexOf('-o') + 1]);
+ assert.deepEqual(args.slice(0, 3), ['add', '--global', '--ignore-scripts']);
+ if (process.env.INSTALL_TEST_FAILURE === 'install') process.exit(1);
+ const binary = path.join(process.env.INSTALL_TEST_GLOBAL_BIN, 'dedalus');
+ const version = process.env.INSTALL_TEST_FAILURE === 'wrong-version' ? '9.9.9' : '0.9.2';
+ fs.writeFileSync(binary, '#!/bin/sh\\nif [ "$1" = --version ]; then echo ' + version + '; else printf "%s\\\\n" "$@"; fi\\n');
+ fs.chmodSync(binary, 0o755);
}
-`,
- );
+`);
+ const log = join(root, 'commands');
const env = {
...process.env,
- PATH: `${bin}:${process.env.PATH}`,
- DEDALUS_INSTALL_DIR: destination,
+ PATH: ['missing-node', 'missing-pnpm'].includes(failure) ? bin : `${bin}:${process.env.PATH}`,
DEDALUS_VERSION: version,
- INSTALL_TEST_LOG: join(root, 'requests'),
- INSTALL_TEST_ARCHIVE: archive,
+ INSTALL_TEST_LOG: log,
+ INSTALL_TEST_GLOBAL_BIN: globalBin,
INSTALL_TEST_FAILURE: failure,
};
+ delete env.DEDALUS_INSTALL_DIR;
+ if (legacy) env.DEDALUS_INSTALL_DIR = destination;
return {
- destination,
- run: () =>
- spawnSync('bash', ['-c', 'bash < "$1"', 'installer-test', installer.pathname], {
- env,
- encoding: 'utf8',
- timeout: 20000,
- }),
- requests: () => readFileSync(env.INSTALL_TEST_LOG, 'utf8'),
+ destination, globalBin,
+ run: () => spawnSync('/bin/bash', ['-c', '/bin/bash < "$1"', 'installer-test', installer.pathname], {
+ env, encoding: 'utf8', timeout: 20000,
+ }),
+ commands: () => existsSync(log) ? readFileSync(log, 'utf8').trim().split('\n').map(JSON.parse) : [],
};
}
-for (const [os, arch, target] of [
- ['Darwin', 'arm64', 'darwin-arm64'],
- ['Darwin', 'x86_64', 'darwin-x64'],
- ['Linux', 'aarch64', 'linux-arm64'],
- ['Linux', 'x86_64', 'linux-x64'],
-]) {
- test(`legacy installer replaces the pinned ${target} executable in its original directory`, (t) => {
- const f = fixture(t, { os, arch });
- const result = f.run();
- assert.equal(result.status, 0, result.stderr);
- assert.equal(
- f.requests(),
- `https://github.com/dedalus-labs/dedalus-cli/releases/download/v0.7.0/dedalus-${target}.tar.gz\n`,
- );
- assert.equal(
- spawnSync(join(f.destination, 'dedalus'), ['--version'], { encoding: 'utf8' }).stdout.trim(),
- '0.7.0',
- );
- assert.deepEqual(readdirSync(f.destination), ['dedalus']);
- });
-}
+test('invariant_installer_delegates_the_pinned_version_to_pnpm_and_preserves_legacy_command_paths', (t) => {
+ const f = fixture(t);
+ const result = f.run();
+ assert.equal(result.status, 0, result.stderr);
+ assert.deepEqual(f.commands(), [['bin', '--global'], ['add', '--global', '--ignore-scripts', 'dedalus-cli@0.9.2']]);
+ assert.equal(spawnSync(join(f.destination, 'dedalus'), ['--version'], { encoding: 'utf8' }).stdout.trim(), '0.9.2');
+ assert.equal(spawnSync(join(f.destination, 'dedalus'), ['two words', '$literal'], { encoding: 'utf8' }).stdout, 'two words\n$literal\n');
+ assert.deepEqual(readdirSync(f.destination), ['dedalus']);
+});
+
+test('invariant_new_installs_use_the_pnpm_global_command', (t) => {
+ const f = fixture(t, { version: '', legacy: false });
+ const result = f.run();
+ assert.equal(result.status, 0, result.stderr);
+ assert.deepEqual(f.commands()[1], ['add', '--global', '--ignore-scripts', 'dedalus-cli@latest']);
+ assert.equal(readFileSync(join(f.destination, 'dedalus'), 'utf8'), 'old executable');
+});
-for (const failure of ['download', 'corrupt', 'missing-binary', 'cannot-run', 'wrong-version', 'timeout']) {
- test(`legacy installer preserves the working binary after ${failure} failure`, (t) => {
+for (const failure of ['missing-node', 'old-node', 'missing-pnpm', 'unconfigured', 'install', 'wrong-version']) {
+ test(`invariant_failed_install_preserves_the_legacy_executable (${failure})`, (t) => {
const f = fixture(t, { failure });
const result = f.run();
assert.equal(result.error, undefined);
assert.notEqual(result.status, 0);
assert.equal(readFileSync(join(f.destination, 'dedalus'), 'utf8'), 'old executable');
assert.deepEqual(readdirSync(f.destination), ['dedalus']);
- assert.doesNotMatch(result.stdout, /Installed/);
+ assert.doesNotMatch(result.stdout, /Installed dedalus/);
+ if (failure === 'missing-node' || failure === 'old-node') assert.match(result.stderr, /Node.js 20/);
+ if (failure === 'missing-pnpm') assert.match(result.stderr, /pnpm is required/);
+ if (failure === 'unconfigured') assert.match(result.stderr, /pnpm setup/);
});
}
-test('an unpinned install resolves latest before choosing its archive', (t) => {
- const f = fixture(t, { version: '' });
- const result = f.run();
- assert.equal(result.status, 0, result.stderr);
- assert.match(f.requests(), /releases\/latest\n.*\/v0\.7\.0\/dedalus-darwin-arm64.tar.gz\n/);
-});
-
-test('an unsupported platform fails without replacing the executable', (t) => {
- const f = fixture(t, { os: 'FreeBSD' });
- const result = f.run();
- assert.notEqual(result.status, 0);
- assert.equal(readFileSync(join(f.destination, 'dedalus'), 'utf8'), 'old executable');
+test('invariant_installer_rejects_invalid_versions_before_running_pnpm', (t) => {
+ const f = fixture(t, { version: '../../latest' });
+ assert.notEqual(f.run().status, 0);
+ assert.deepEqual(f.commands(), []);
});
-test('installer refuses a package-manager symlink', (t) => {
+test('invariant_installer_does_not_replace_another_package_managers_symlink', (t) => {
const f = fixture(t);
const managed = join(f.destination, 'managed');
writeFileSync(managed, 'managed executable');
rmSync(join(f.destination, 'dedalus'));
symlinkSync(managed, join(f.destination, 'dedalus'));
assert.notEqual(f.run().status, 0);
+ assert.deepEqual(f.commands(), []);
assert.equal(readFileSync(managed, 'utf8'), 'managed executable');
});
-
-test('installer rejects invalid release tags before downloading', (t) => {
- const f = fixture(t, { version: '../../latest' });
- assert.notEqual(f.run().status, 0);
- assert.throws(f.requests, { code: 'ENOENT' });
-});
diff --git a/tests/publish-package.test.mjs b/tests/publish-package.test.mjs
new file mode 100644
index 0000000..fffa4b0
--- /dev/null
+++ b/tests/publish-package.test.mjs
@@ -0,0 +1,27 @@
+import assert from 'node:assert/strict';
+import { test } from 'node:test';
+import { publishNpm } from '../scripts/publish-npm.mjs';
+
+for (const [version, tag] of [['0.9.3', undefined], ['0.10.0-rc.1', 'rc'], ['0.10.0-latest.1', 'latest-prerelease']]) {
+ test(`invariant_publishing_uses_the_packed_node_archive_and_preserves_release_channels (${version})`, () => {
+ const calls = [];
+ publishNpm((args) => {
+ calls.push(args);
+ return { status: args[0] === 'view' ? 1 : 0 };
+ }, { name: 'dedalus-cli', version });
+ assert.deepEqual(calls, [
+ ['view', `dedalus-cli@${version}`, 'version'],
+ ['publish', `./release-packages/dedalus-cli-${version}.tgz`, '--no-git-checks', '--access', 'public', ...(tag ? ['--tag', tag] : [])],
+ ]);
+ });
+}
+
+test('invariant_a_failed_publish_never_reports_success', () => {
+ assert.throws(() => publishNpm(() => ({ status: 1 }), { name: 'dedalus-cli', version: '0.9.3' }), /publish failed/);
+});
+
+test('invariant_an_existing_registry_version_is_not_republished', () => {
+ const calls = [];
+ publishNpm((args) => { calls.push(args); return { status: 0 }; }, { name: 'dedalus-cli', version: '0.9.3' });
+ assert.deepEqual(calls, [['view', 'dedalus-cli@0.9.3', 'version']]);
+});
diff --git a/tests/upgrade-package.test.mjs b/tests/upgrade-package.test.mjs
new file mode 100644
index 0000000..df21820
--- /dev/null
+++ b/tests/upgrade-package.test.mjs
@@ -0,0 +1,86 @@
+import assert from 'node:assert/strict';
+import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { delimiter, join } from 'node:path';
+import { test } from 'node:test';
+import { pathToFileURL } from 'node:url';
+import { Command } from 'commander';
+
+const root = process.env.CLI_PACKAGE_ROOT ?? new URL('..', import.meta.url).pathname;
+const { addUpgradeCommands } = await import(pathToFileURL(join(root, 'dist/esm/cli/upgrade.js')));
+
+test('invariant_homebrew_owns_upgrades_of_its_node_package_installation', async (t) => {
+ const directory = mkdtempSync(join(tmpdir(), 'dedalus-homebrew-node-'));
+ const bin = join(directory, 'bin');
+ const script = join(directory, 'Cellar/dedalus/0.9.2/libexec/node_modules/dedalus-cli/dist/esm/bin.js');
+ mkdirSync(bin);
+ const log = join(directory, 'commands');
+ const brew = join(bin, 'brew');
+ writeFileSync(brew, `#!${process.execPath}
+const fs = require('node:fs');
+fs.appendFileSync(${JSON.stringify(log)}, JSON.stringify(process.argv.slice(2)) + '\\n');
+if (process.argv[2] === 'list') console.log('dedalus 0.9.3');
+`);
+ chmodSync(brew, 0o755);
+ const original = process.argv[1];
+ process.argv[1] = script;
+ t.after(() => { process.argv[1] = original; rmSync(directory, { recursive: true, force: true }); });
+ const program = new Command();
+ addUpgradeCommands(program, 'dedalus', '0.9.2');
+ await program.parseAsync(['node', 'dedalus', 'upgrade']);
+ assert.deepEqual(readFileSync(log, 'utf8').trim().split('\n').map(JSON.parse), [
+ ['update'], ['upgrade', 'dedalus'], ['list', '--versions', 'dedalus'],
+ ]);
+});
+
+for (const [location, manager] of [['prefix', 'npm'], ['node-keg', 'npm'], ['pnpm-global', 'pnpm']]) {
+ test(`invariant_package_managers_keep_ownership_under_homebrews_prefix (${location})`, async (t) => {
+ const directory = mkdtempSync(join(tmpdir(), 'dedalus-package-ownership-'));
+ const prefix = join(directory, 'opt/homebrew');
+ const bin = join(prefix, 'bin');
+ const packageRoot = location === 'node-keg'
+ ? join(prefix, 'Cellar/node/24.0.0/lib/node_modules')
+ : location === 'pnpm-global'
+ ? join(prefix, 'pnpm/global/5/node_modules')
+ : join(prefix, 'lib/node_modules');
+ const script = join(packageRoot, 'dedalus-cli/dist/esm/bin.js');
+ const log = join(directory, 'commands');
+ mkdirSync(bin, { recursive: true });
+ for (const name of ['npm', 'pnpm', 'brew']) {
+ const executable = join(bin, name);
+ writeFileSync(executable, `#!${process.execPath}
+const fs = require('node:fs');
+const args = process.argv.slice(2);
+fs.appendFileSync(${JSON.stringify(log)}, JSON.stringify([${JSON.stringify(name)}, ...args]) + '\\n');
+if (args[0] === 'root') console.log(${JSON.stringify(packageRoot)});
+if (args[0] === 'list') console.log('dedalus 0.9.3');
+`);
+ chmodSync(executable, 0o755);
+ }
+ const original = { script: process.argv[1], executable: process.execPath, path: process.env.PATH, stderr: process.stderr.write };
+ let output = '';
+ t.after(() => {
+ process.argv[1] = original.script;
+ process.execPath = original.executable;
+ process.env.PATH = original.path;
+ process.stderr.write = original.stderr;
+ rmSync(directory, { recursive: true, force: true });
+ });
+ process.argv[1] = script;
+ process.execPath = join(bin, 'node');
+ process.env.PATH = `${bin}${delimiter}${original.path}`;
+ process.stderr.write = (chunk) => { output += String(chunk); return true; };
+ for (const command of ['upgrade', 'uninstall']) {
+ const program = new Command();
+ addUpgradeCommands(program, 'dedalus', '0.9.2');
+ await program.parseAsync(['node', 'dedalus', command]);
+ }
+ assert.match(output, new RegExp(`installed with ${manager}`));
+ assert.doesNotMatch(output, /installed with Homebrew|brew uninstall|brew upgrade/);
+ assert.ok(output.includes(manager === 'npm' ? 'npm uninstall -g dedalus-cli' : 'pnpm remove -g dedalus-cli'));
+ const commands = existsSync(log) ? readFileSync(log, 'utf8').trim().split('\n').map(JSON.parse) : [];
+ assert.deepEqual(commands, manager === 'npm' ? [
+ ['npm', 'root', '-g'], ['npm', 'i', '-g', 'dedalus-cli@latest'], ['npm', 'root', '-g'],
+ ] : [['pnpm', 'add', '-g', 'dedalus-cli@latest']]);
+ });
+}