diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb8ef69..69f624c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,5 +19,6 @@ jobs: - run: npm ci - run: npm run lint + - run: npm run format:check - run: npm test - run: npm run build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..7e71b18 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,30 @@ +name: Publish to npm + +on: + push: + tags: + - "v*" + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + registry-url: https://registry.npmjs.org + + - run: npm ci + - run: npm run lint + - run: npm run format:check + - run: npm test + - run: npm run build + - run: npm publish --provenance --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package-lock.json b/package-lock.json index 8acef5a..bb5cf77 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "crucible-cli", - "version": "0.1.0", + "version": "0.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "crucible-cli", - "version": "0.1.0", + "version": "0.1.3", "license": "MIT", "dependencies": { "@azure/identity": "^4.6.0", diff --git a/package.json b/package.json index 8b672bd..86af8c0 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "crucible-cli", - "version": "0.1.0", + "version": "0.1.3", "description": "The kubectl of Azure Service Bus — CLI for message operations, DLQ management, and namespace monitoring", "type": "module", "bin": { - "crucible": "./dist/cli.js" + "crucible": "dist/cli.js" }, "files": [ "dist", @@ -35,7 +35,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/broediger/crucible-cli.git" + "url": "git+https://github.com/broediger/crucible-cli.git" }, "homepage": "https://github.com/broediger/crucible-cli", "bugs": { diff --git a/src/cli.ts b/src/cli.ts index e1ad89b..fbd1ede 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,4 +1,8 @@ +import { createRequire } from "node:module"; import { Command } from "commander"; + +const require = createRequire(import.meta.url); +const { version } = require("../package.json") as { version: string }; import { configCommand } from "./commands/config.js"; import { loginCommand } from "./commands/login.js"; import { statusCommand } from "./commands/status.js"; @@ -25,7 +29,7 @@ program .description( "The kubectl of Azure Service Bus — message operations, DLQ management, and namespace monitoring" ) - .version("0.1.0"); + .version(version); // --- Phase 1: Foundation --- program.addCommand(configCommand); @@ -56,7 +60,13 @@ program.addCommand(costsCommand); // --- Global error handler --- // Exit codes: 0 = success, 1 = error, 2 = warning/threshold (set by commands like diff) process.on("unhandledRejection", (err: unknown) => { - const msg = err instanceof Error ? err.message : String(err); + let msg: string; + if (err instanceof AggregateError && err.errors.length > 0) { + const unique = [...new Set(err.errors.map((e: Error) => e.message))]; + msg = unique.join("\n"); + } else { + msg = err instanceof Error ? err.message : String(err); + } console.error(`Error: ${msg}`); process.exit(1); });