From 20fbf3da5a2d3d7385410fd83bc6fb3c3ad1d935 Mon Sep 17 00:00:00 2001 From: zhenghaoz Date: Fri, 23 Oct 2026 22:24:22 +0800 Subject: [PATCH 1/3] feat: support npm installation --- .github/workflows/ci.yml | 6 ++ .github/workflows/release.yml | 30 ++++++++++ .gitignore | 6 ++ README.md | 36 ++++++++++++ npm/bin/gorse-cli.js | 31 +++++++++++ npm/package.json | 16 ++++++ npm/platforms.js | 10 ++++ npm/scripts/build-packages.js | 46 ++++++++++++++++ npm/test/package.test.js | 100 ++++++++++++++++++++++++++++++++++ 9 files changed, 281 insertions(+) create mode 100644 npm/bin/gorse-cli.js create mode 100644 npm/package.json create mode 100644 npm/platforms.js create mode 100644 npm/scripts/build-packages.js create mode 100644 npm/test/package.test.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 607073b..8c8d1f2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,3 +17,9 @@ jobs: - run: go vet ./... - run: go build -o gorse-cli . - run: sh -n install.sh + - uses: actions/setup-node@v4 + with: + node-version: 22 + - run: node --test npm/test/*.test.js + env: + GORSE_CLI_TEST_BINARY: ${{ github.workspace }}/gorse-cli diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 06e10bb..da3b5b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,3 +21,33 @@ jobs: args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + npm: + needs: binaries + runs-on: ubuntu-latest + permissions: + contents: read + env: + RELEASE_TAG: ${{ github.event.release.tag_name }} + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-node@v4 + with: + node-version: 22 + registry-url: https://registry.npmjs.org + - name: Download release binaries + run: gh release download "$RELEASE_TAG" --pattern 'gorse-cli_*' --dir dist/npm-binaries + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Stage npm packages + run: node npm/scripts/build-packages.js "$RELEASE_TAG" dist/npm-binaries dist/npm + - name: Publish platform packages before the launcher + run: | + set -e + tag=latest + if [[ "$RELEASE_TAG" == *-* ]]; then tag=next; fi + for package in dist/npm/cli-*; do + npm publish "./$package" --access public --tag "$tag" + done + npm publish ./dist/npm/cli --access public --tag "$tag" + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index a5bd233..9e8b5c5 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,12 @@ profile.cov go.work go.work.sum +# npm and release artifacts +node_modules/ +dist/ +*.tgz +/gorse-cli + # env file .env diff --git a/README.md b/README.md index 00977e6..49eddc8 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,24 @@ Command-line tools for managing Gorse clusters. Migrated from ## Install +With npm (Node.js 18 or later): + +```sh +npm install -g @gorse-io/cli +gorse-cli --help +``` + +Or run without a global installation: + +```sh +npx @gorse-io/cli --help +``` + +The npm package selects a prebuilt native binary through platform-specific optional +dependencies; no Go compiler or install scripts are required. Keep optional +dependencies enabled. Supported platforms match the standalone releases: Linux +(x64, arm64, loong64, riscv64), Windows (x64, arm64), and macOS (arm64). + Build from source: ```sh @@ -45,6 +63,24 @@ Contexts and API keys remain in the system keyring under the existing go test ./... go vet ./... go build -o gorse-cli . +GORSE_CLI_TEST_BINARY="$PWD/gorse-cli" node --test npm/test/*.test.js +``` + +### Publishing npm packages + +The release workflow packages the same binaries uploaded by GoReleaser and publishes +platform packages first, followed by `@gorse-io/cli` with exact-version optional +dependencies. Stable releases use npm's `latest` tag; prereleases use `next`. +Configure the repository's `NPM_TOKEN` secret with permission to publish all +`@gorse-io/cli*` packages in the npm organization before publishing a release. +The GitHub release tag must be a canonical npm SemVer version, optionally prefixed +with `v` (for example, `v1.2.3` or `v1.2.3-rc.1`). + +To inspect packages locally after downloading all release binaries: + +```sh +node npm/scripts/build-packages.js v1.2.3 dist/npm-binaries dist/npm +npm pack ./dist/npm/cli ``` Tests start a real local Gorse Master with temporary SQLite stores. The Gorse diff --git a/npm/bin/gorse-cli.js b/npm/bin/gorse-cli.js new file mode 100644 index 0000000..3f89668 --- /dev/null +++ b/npm/bin/gorse-cli.js @@ -0,0 +1,31 @@ +#!/usr/bin/env node +import { spawn } from "node:child_process"; +import { createRequire } from "node:module"; +import path from "node:path"; + +const require = createRequire(import.meta.url); +const packageName = `@gorse-io/cli-${process.platform}-${process.arch}`; +let binary; +try { + binary = path.join(path.dirname(require.resolve(`${packageName}/package.json`)), "bin", process.platform === "win32" ? "gorse-cli.exe" : "gorse-cli"); +} catch { + console.error(`Missing optional dependency ${packageName}. Check that your platform is supported and reinstall with optional dependencies enabled: npm install -g @gorse-io/cli`); + process.exit(1); +} + +const child = spawn(binary, process.argv.slice(2), { stdio: "inherit" }); +const handlers = new Map(); +for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) { + const handler = () => child.kill(signal); + handlers.set(signal, handler); + process.on(signal, handler); +} +child.on("error", (error) => { + console.error(`Unable to start gorse-cli: ${error.message}`); + process.exit(1); +}); +child.on("exit", (code, signal) => { + for (const [name, handler] of handlers) process.removeListener(name, handler); + if (signal) process.kill(process.pid, signal); + else process.exit(code ?? 1); +}); diff --git a/npm/package.json b/npm/package.json new file mode 100644 index 0000000..cbf60c1 --- /dev/null +++ b/npm/package.json @@ -0,0 +1,16 @@ +{ + "name": "@gorse-io/cli", + "version": "0.0.0-dev", + "description": "Command-line tools for managing Gorse clusters", + "license": "Apache-2.0", + "type": "module", + "bin": { "gorse-cli": "bin/gorse-cli.js" }, + "engines": { "node": ">=18" }, + "files": ["bin/gorse-cli.js"], + "repository": { + "type": "git", + "url": "git+https://github.com/gorse-io/cli.git", + "directory": "npm" + }, + "publishConfig": { "access": "public" } +} diff --git a/npm/platforms.js b/npm/platforms.js new file mode 100644 index 0000000..10db8e8 --- /dev/null +++ b/npm/platforms.js @@ -0,0 +1,10 @@ +// Keep aligned with the targets in .goreleaser.yaml. +export const platforms = [ + { os: "linux", cpu: "x64", goos: "linux", goarch: "amd64" }, + { os: "linux", cpu: "arm64", goos: "linux", goarch: "arm64" }, + { os: "linux", cpu: "loong64", goos: "linux", goarch: "loong64" }, + { os: "linux", cpu: "riscv64", goos: "linux", goarch: "riscv64" }, + { os: "win32", cpu: "x64", goos: "windows", goarch: "amd64" }, + { os: "win32", cpu: "arm64", goos: "windows", goarch: "arm64" }, + { os: "darwin", cpu: "arm64", goos: "darwin", goarch: "arm64" }, +]; diff --git a/npm/scripts/build-packages.js b/npm/scripts/build-packages.js new file mode 100644 index 0000000..6f8297d --- /dev/null +++ b/npm/scripts/build-packages.js @@ -0,0 +1,46 @@ +#!/usr/bin/env node +import { chmodSync, copyFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import { platforms } from "../platforms.js"; + +const [tag, binaries, output] = process.argv.slice(2); +const version = tag?.replace(/^v/, ""); +// npm versions must be canonical SemVer; reject build metadata (npm strips it). +const number = "(?:0|[1-9][0-9]*)"; +const identifier = `(?:${number}|[0-9]*[A-Za-z-][0-9A-Za-z-]*)`; +if (!version || !new RegExp(`^${number}\\.${number}\\.${number}(?:-${identifier}(?:\\.${identifier})*)?$`).test(version) || !binaries || !output) { + throw new Error("Usage: node npm/scripts/build-packages.js (version must be canonical SemVer)"); +} +const npmRoot = fileURLToPath(new URL("../", import.meta.url)); +const repoRoot = path.resolve(npmRoot, ".."); +const main = JSON.parse(readFileSync(path.join(npmRoot, "package.json"), "utf8")); +main.version = version; +main.optionalDependencies = {}; + +function stage(directory, manifest) { + mkdirSync(directory, { recursive: true }); + writeFileSync(path.join(directory, "package.json"), JSON.stringify(manifest, null, 2) + "\n"); + for (const file of ["README.md", "LICENSE"]) copyFileSync(path.join(repoRoot, file), path.join(directory, file)); +} + +for (const target of platforms) { + const name = `cli-${target.os}-${target.cpu}`; + const packageName = `@gorse-io/${name}`; + const directory = path.join(output, name); + const executable = target.os === "win32" ? "gorse-cli.exe" : "gorse-cli"; + mkdirSync(path.join(directory, "bin"), { recursive: true }); + copyFileSync(path.join(binaries, `gorse-cli_${target.goos}_${target.goarch}${target.os === "win32" ? ".exe" : ""}`), path.join(directory, "bin", executable)); + chmodSync(path.join(directory, "bin", executable), 0o755); + stage(directory, { + name: packageName, version, description: main.description, license: main.license, + repository: main.repository, publishConfig: main.publishConfig, + os: [target.os], cpu: [target.cpu], files: ["bin"], + }); + main.optionalDependencies[packageName] = version; +} +const directory = path.join(output, "cli"); +mkdirSync(path.join(directory, "bin"), { recursive: true }); +copyFileSync(path.join(npmRoot, "bin/gorse-cli.js"), path.join(directory, "bin/gorse-cli.js")); +chmodSync(path.join(directory, "bin/gorse-cli.js"), 0o755); +stage(directory, main); diff --git a/npm/test/package.test.js b/npm/test/package.test.js new file mode 100644 index 0000000..eaa52b6 --- /dev/null +++ b/npm/test/package.test.js @@ -0,0 +1,100 @@ +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { copyFileSync, mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, rmSync } from "node:fs"; +import os from "node:os"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import test from "node:test"; + +const root = fileURLToPath(new URL("../../", import.meta.url)); +const targets = [ + ["linux", "x64", "linux", "amd64"], + ["linux", "arm64", "linux", "arm64"], + ["linux", "loong64", "linux", "loong64"], + ["linux", "riscv64", "linux", "riscv64"], + ["win32", "x64", "windows", "amd64"], + ["win32", "arm64", "windows", "arm64"], + ["darwin", "arm64", "darwin", "arm64"], +]; + +function fixture(t) { + const dir = mkdtempSync(path.join(os.tmpdir(), "gorse-npm-")); + t.after(() => rmSync(dir, { recursive: true, force: true })); + const binaries = path.join(dir, "binaries"); + mkdirSync(binaries); + for (const [, , goos, goarch] of targets) { + writeFileSync(path.join(binaries, `gorse-cli_${goos}_${goarch}${goos === "windows" ? ".exe" : ""}`), "test payload"); + } + return { dir, binaries, output: path.join(dir, "packages") }; +} + +function build(f, version = "v1.2.3") { + return spawnSync(process.execPath, ["npm/scripts/build-packages.js", version, f.binaries, f.output], { cwd: root, encoding: "utf8" }); +} + +function manifest(dir) { + return JSON.parse(readFileSync(path.join(dir, "package.json"), "utf8")); +} + +test("stages exact-version optional packages for every release target", (t) => { + const f = fixture(t); + const result = build(f); + assert.equal(result.status, 0, result.stderr); + const main = manifest(path.join(f.output, "cli")); + assert.equal(main.name, "@gorse-io/cli"); + assert.equal(main.version, "1.2.3"); + assert.equal(main.bin["gorse-cli"], "bin/gorse-cli.js"); + assert.equal(Object.keys(main.optionalDependencies).length, targets.length); + assert.equal(main.scripts?.postinstall, undefined); + for (const [platform, arch] of targets) { + const pkg = manifest(path.join(f.output, `cli-${platform}-${arch}`)); + assert.equal(main.optionalDependencies[pkg.name], "1.2.3"); + assert.deepEqual(pkg.os, [platform]); + assert.deepEqual(pkg.cpu, [arch]); + assert.equal(pkg.version, main.version); + assert.ok(existsSync(path.join(f.output, `cli-${platform}-${arch}`, "bin", platform === "win32" ? "gorse-cli.exe" : "gorse-cli"))); + } +}); + +test("rejects invalid versions and missing release binaries", (t) => { + const f = fixture(t); + assert.notEqual(build(f, "../bad").status, 0); + rmSync(path.join(f.binaries, "gorse-cli_linux_arm64")); + const result = build(f); + assert.notEqual(result.status, 0); + assert.match(result.stderr, /gorse-cli_linux_arm64/); +}); + +test("packed npm install runs the real native CLI without lifecycle scripts", { skip: !process.env.GORSE_CLI_TEST_BINARY }, (t) => { + const f = fixture(t); + const target = targets.find(([platform, arch]) => platform === process.platform && arch === process.arch); + assert.ok(target, "host must be a release target"); + const [platform, arch, goos, goarch] = target; + copyFileSync(process.env.GORSE_CLI_TEST_BINARY, path.join(f.binaries, `gorse-cli_${goos}_${goarch}${platform === "win32" ? ".exe" : ""}`)); + const result = build(f); + assert.equal(result.status, 0, result.stderr); + const tarballs = []; + for (const name of ["cli", `cli-${platform}-${arch}`]) { + const packed = spawnSync("npm", ["pack", path.join(f.output, name), "--json", "--pack-destination", f.dir], { encoding: "utf8" }); + assert.equal(packed.status, 0, packed.stderr); + tarballs.push(path.join(f.dir, JSON.parse(packed.stdout)[0].filename)); + } + const prefix = path.join(f.dir, "installed"); + const installed = spawnSync("npm", ["install", "--global", "--prefix", prefix, "--offline", "--ignore-scripts", "--no-audit", "--no-fund", ...tarballs], { encoding: "utf8" }); + assert.equal(installed.status, 0, installed.stderr); + const executable = path.join(prefix, "bin", "gorse-cli"); + for (const arg of ["--help", "--version"]) { + const run = spawnSync(executable, [arg], { encoding: "utf8" }); + assert.equal(run.status, 0, run.stderr); + assert.match(run.stdout + run.stderr, arg === "--help" ? /gorse-cli/i : /API version:/); + } + const invalid = spawnSync(executable, ["nonexistent-command"], { encoding: "utf8" }); + assert.equal(invalid.status, 1); +}); + +test("launcher reports a missing optional dependency with reinstall instructions", () => { + const result = spawnSync(process.execPath, ["npm/bin/gorse-cli.js", "--help"], { cwd: root, encoding: "utf8" }); + assert.equal(result.status, 1); + assert.match(result.stderr, /Missing optional dependency/); + assert.match(result.stderr, /npm install -g @gorse-io\/cli/); +}); From 5f3bc7348a5deb7bbcadcf21eb8c6af91601cc24 Mon Sep 17 00:00:00 2001 From: zhenghaoz Date: Fri, 23 Oct 2026 22:46:49 +0800 Subject: [PATCH 2/3] test: remove npm package tests --- .github/workflows/ci.yml | 6 --- README.md | 1 - npm/test/package.test.js | 100 --------------------------------------- 3 files changed, 107 deletions(-) delete mode 100644 npm/test/package.test.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c8d1f2..607073b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,9 +17,3 @@ jobs: - run: go vet ./... - run: go build -o gorse-cli . - run: sh -n install.sh - - uses: actions/setup-node@v4 - with: - node-version: 22 - - run: node --test npm/test/*.test.js - env: - GORSE_CLI_TEST_BINARY: ${{ github.workspace }}/gorse-cli diff --git a/README.md b/README.md index 49eddc8..356fd52 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,6 @@ Contexts and API keys remain in the system keyring under the existing go test ./... go vet ./... go build -o gorse-cli . -GORSE_CLI_TEST_BINARY="$PWD/gorse-cli" node --test npm/test/*.test.js ``` ### Publishing npm packages diff --git a/npm/test/package.test.js b/npm/test/package.test.js deleted file mode 100644 index eaa52b6..0000000 --- a/npm/test/package.test.js +++ /dev/null @@ -1,100 +0,0 @@ -import assert from "node:assert/strict"; -import { spawnSync } from "node:child_process"; -import { copyFileSync, mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, rmSync } from "node:fs"; -import os from "node:os"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; -import test from "node:test"; - -const root = fileURLToPath(new URL("../../", import.meta.url)); -const targets = [ - ["linux", "x64", "linux", "amd64"], - ["linux", "arm64", "linux", "arm64"], - ["linux", "loong64", "linux", "loong64"], - ["linux", "riscv64", "linux", "riscv64"], - ["win32", "x64", "windows", "amd64"], - ["win32", "arm64", "windows", "arm64"], - ["darwin", "arm64", "darwin", "arm64"], -]; - -function fixture(t) { - const dir = mkdtempSync(path.join(os.tmpdir(), "gorse-npm-")); - t.after(() => rmSync(dir, { recursive: true, force: true })); - const binaries = path.join(dir, "binaries"); - mkdirSync(binaries); - for (const [, , goos, goarch] of targets) { - writeFileSync(path.join(binaries, `gorse-cli_${goos}_${goarch}${goos === "windows" ? ".exe" : ""}`), "test payload"); - } - return { dir, binaries, output: path.join(dir, "packages") }; -} - -function build(f, version = "v1.2.3") { - return spawnSync(process.execPath, ["npm/scripts/build-packages.js", version, f.binaries, f.output], { cwd: root, encoding: "utf8" }); -} - -function manifest(dir) { - return JSON.parse(readFileSync(path.join(dir, "package.json"), "utf8")); -} - -test("stages exact-version optional packages for every release target", (t) => { - const f = fixture(t); - const result = build(f); - assert.equal(result.status, 0, result.stderr); - const main = manifest(path.join(f.output, "cli")); - assert.equal(main.name, "@gorse-io/cli"); - assert.equal(main.version, "1.2.3"); - assert.equal(main.bin["gorse-cli"], "bin/gorse-cli.js"); - assert.equal(Object.keys(main.optionalDependencies).length, targets.length); - assert.equal(main.scripts?.postinstall, undefined); - for (const [platform, arch] of targets) { - const pkg = manifest(path.join(f.output, `cli-${platform}-${arch}`)); - assert.equal(main.optionalDependencies[pkg.name], "1.2.3"); - assert.deepEqual(pkg.os, [platform]); - assert.deepEqual(pkg.cpu, [arch]); - assert.equal(pkg.version, main.version); - assert.ok(existsSync(path.join(f.output, `cli-${platform}-${arch}`, "bin", platform === "win32" ? "gorse-cli.exe" : "gorse-cli"))); - } -}); - -test("rejects invalid versions and missing release binaries", (t) => { - const f = fixture(t); - assert.notEqual(build(f, "../bad").status, 0); - rmSync(path.join(f.binaries, "gorse-cli_linux_arm64")); - const result = build(f); - assert.notEqual(result.status, 0); - assert.match(result.stderr, /gorse-cli_linux_arm64/); -}); - -test("packed npm install runs the real native CLI without lifecycle scripts", { skip: !process.env.GORSE_CLI_TEST_BINARY }, (t) => { - const f = fixture(t); - const target = targets.find(([platform, arch]) => platform === process.platform && arch === process.arch); - assert.ok(target, "host must be a release target"); - const [platform, arch, goos, goarch] = target; - copyFileSync(process.env.GORSE_CLI_TEST_BINARY, path.join(f.binaries, `gorse-cli_${goos}_${goarch}${platform === "win32" ? ".exe" : ""}`)); - const result = build(f); - assert.equal(result.status, 0, result.stderr); - const tarballs = []; - for (const name of ["cli", `cli-${platform}-${arch}`]) { - const packed = spawnSync("npm", ["pack", path.join(f.output, name), "--json", "--pack-destination", f.dir], { encoding: "utf8" }); - assert.equal(packed.status, 0, packed.stderr); - tarballs.push(path.join(f.dir, JSON.parse(packed.stdout)[0].filename)); - } - const prefix = path.join(f.dir, "installed"); - const installed = spawnSync("npm", ["install", "--global", "--prefix", prefix, "--offline", "--ignore-scripts", "--no-audit", "--no-fund", ...tarballs], { encoding: "utf8" }); - assert.equal(installed.status, 0, installed.stderr); - const executable = path.join(prefix, "bin", "gorse-cli"); - for (const arg of ["--help", "--version"]) { - const run = spawnSync(executable, [arg], { encoding: "utf8" }); - assert.equal(run.status, 0, run.stderr); - assert.match(run.stdout + run.stderr, arg === "--help" ? /gorse-cli/i : /API version:/); - } - const invalid = spawnSync(executable, ["nonexistent-command"], { encoding: "utf8" }); - assert.equal(invalid.status, 1); -}); - -test("launcher reports a missing optional dependency with reinstall instructions", () => { - const result = spawnSync(process.execPath, ["npm/bin/gorse-cli.js", "--help"], { cwd: root, encoding: "utf8" }); - assert.equal(result.status, 1); - assert.match(result.stderr, /Missing optional dependency/); - assert.match(result.stderr, /npm install -g @gorse-io\/cli/); -}); From 3803a40795902ba4013feeaf2092f63004b25251 Mon Sep 17 00:00:00 2001 From: zhenghaoz Date: Fri, 23 Oct 2026 22:48:28 +0800 Subject: [PATCH 3/3] fix: use gorse npm organization --- README.md | 8 ++++---- npm/bin/gorse-cli.js | 4 ++-- npm/package.json | 2 +- npm/scripts/build-packages.js | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 356fd52..19f8477 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,14 @@ Command-line tools for managing Gorse clusters. Migrated from With npm (Node.js 18 or later): ```sh -npm install -g @gorse-io/cli +npm install -g @gorse/cli gorse-cli --help ``` Or run without a global installation: ```sh -npx @gorse-io/cli --help +npx @gorse/cli --help ``` The npm package selects a prebuilt native binary through platform-specific optional @@ -68,10 +68,10 @@ go build -o gorse-cli . ### Publishing npm packages The release workflow packages the same binaries uploaded by GoReleaser and publishes -platform packages first, followed by `@gorse-io/cli` with exact-version optional +platform packages first, followed by `@gorse/cli` with exact-version optional dependencies. Stable releases use npm's `latest` tag; prereleases use `next`. Configure the repository's `NPM_TOKEN` secret with permission to publish all -`@gorse-io/cli*` packages in the npm organization before publishing a release. +`@gorse/cli*` packages in the npm organization before publishing a release. The GitHub release tag must be a canonical npm SemVer version, optionally prefixed with `v` (for example, `v1.2.3` or `v1.2.3-rc.1`). diff --git a/npm/bin/gorse-cli.js b/npm/bin/gorse-cli.js index 3f89668..b4e1e67 100644 --- a/npm/bin/gorse-cli.js +++ b/npm/bin/gorse-cli.js @@ -4,12 +4,12 @@ import { createRequire } from "node:module"; import path from "node:path"; const require = createRequire(import.meta.url); -const packageName = `@gorse-io/cli-${process.platform}-${process.arch}`; +const packageName = `@gorse/cli-${process.platform}-${process.arch}`; let binary; try { binary = path.join(path.dirname(require.resolve(`${packageName}/package.json`)), "bin", process.platform === "win32" ? "gorse-cli.exe" : "gorse-cli"); } catch { - console.error(`Missing optional dependency ${packageName}. Check that your platform is supported and reinstall with optional dependencies enabled: npm install -g @gorse-io/cli`); + console.error(`Missing optional dependency ${packageName}. Check that your platform is supported and reinstall with optional dependencies enabled: npm install -g @gorse/cli`); process.exit(1); } diff --git a/npm/package.json b/npm/package.json index cbf60c1..f51715f 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,5 +1,5 @@ { - "name": "@gorse-io/cli", + "name": "@gorse/cli", "version": "0.0.0-dev", "description": "Command-line tools for managing Gorse clusters", "license": "Apache-2.0", diff --git a/npm/scripts/build-packages.js b/npm/scripts/build-packages.js index 6f8297d..89cf8a1 100644 --- a/npm/scripts/build-packages.js +++ b/npm/scripts/build-packages.js @@ -26,7 +26,7 @@ function stage(directory, manifest) { for (const target of platforms) { const name = `cli-${target.os}-${target.cpu}`; - const packageName = `@gorse-io/${name}`; + const packageName = `@gorse/${name}`; const directory = path.join(output, name); const executable = target.os === "win32" ? "gorse-cli.exe" : "gorse-cli"; mkdirSync(path.join(directory, "bin"), { recursive: true });