From 949a3a55c674da962922aeeac0dfd1c7fc6b45b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Haukur?= <1031637+ihs7@users.noreply.github.com> Date: Thu, 9 Apr 2026 19:20:09 +0000 Subject: [PATCH] chore: update @ihs7/umbra to 0.6.1 Switches from local file reference to npm package ^0.6.1 and adapts to the new API (CliCommandEntry, positional params, default values). --- bun.lock | 20 ++------------------ package.json | 6 ++---- src/commands/checkout.test.ts | 9 ++++++--- src/commands/checkout.ts | 21 +++++++++------------ src/index.ts | 14 +++++--------- 5 files changed, 24 insertions(+), 46 deletions(-) diff --git a/bun.lock b/bun.lock index 1d061ae..4503854 100644 --- a/bun.lock +++ b/bun.lock @@ -5,9 +5,7 @@ "": { "name": "kronan-cli", "dependencies": { - "@clack/prompts": "^1.2.0", - "@ihs7/umbra": "^0.5.0", - "commander": "^14.0.3", + "@ihs7/umbra": "^0.6.1", "yaml": "^2.8.3", "zod": "^4.3.6", }, @@ -24,11 +22,7 @@ }, }, "packages": { - "@clack/core": ["@clack/core@1.2.0", "", { "dependencies": { "fast-wrap-ansi": "^0.1.3", "sisteransi": "^1.0.5" } }, "sha512-qfxof/3T3t9DPU/Rj3OmcFyZInceqj/NVtO9rwIuJqCUgh32gwPjpFQQp/ben07qKlhpwq7GzfWpST4qdJ5Drg=="], - - "@clack/prompts": ["@clack/prompts@1.2.0", "", { "dependencies": { "@clack/core": "1.2.0", "fast-string-width": "^1.1.0", "fast-wrap-ansi": "^0.1.3", "sisteransi": "^1.0.5" } }, "sha512-4jmztR9fMqPMjz6H/UZXj0zEmE43ha1euENwkckKKel4XpSfokExPo5AiVStdHSAlHekz4d0CA/r45Ok1E4D3w=="], - - "@ihs7/umbra": ["@ihs7/umbra@0.5.0", "", { "peerDependencies": { "typescript": "^5", "yaml": "^2", "zod": "^4" }, "bin": { "umbra": "dist/generate.js" } }, "sha512-RXj3h9rSYV/u45GrJlHGZU5/1Nc5smsgWzpgUCAIZT2Ld35GAPHMwx4QgQH8h98NhGqlWjrdmn3bx3oihRegHw=="], + "@ihs7/umbra": ["@ihs7/umbra@0.6.1", "", { "peerDependencies": { "typescript": "^5", "yaml": "^2", "zod": "^4" }, "bin": { "umbra": "dist/generate.js" } }, "sha512-gCwNjUkfVUsU4zjzAJj0khMj73vGPVdH70j/hFmUZfOCul5Uj68MhC2/y5B5tyfx1w2VrLlMKB4lM3gJ5WkrsQ=="], "@oxfmt/binding-android-arm-eabi": ["@oxfmt/binding-android-arm-eabi@0.44.0", "", { "os": "android", "cpu": "arm" }, "sha512-5UvghMd9SA/yvKTWCAxMAPXS1d2i054UeOf4iFjZjfayTwCINcC3oaSXjtbZfCaEpxgJod7XiOjTtby5yEv/BQ=="], @@ -128,20 +122,10 @@ "bun-types": ["bun-types@1.3.11", "", { "dependencies": { "@types/node": "*" } }, "sha512-1KGPpoxQWl9f6wcZh57LvrPIInQMn2TQ7jsgxqpRzg+l0QPOFvJVH7HmvHo/AiPgwXy+/Thf6Ov3EdVn1vOabg=="], - "commander": ["commander@14.0.3", "", {}, "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw=="], - - "fast-string-truncated-width": ["fast-string-truncated-width@1.2.1", "", {}, "sha512-Q9acT/+Uu3GwGj+5w/zsGuQjh9O1TyywhIwAxHudtWrgF09nHOPrvTLhQevPbttcxjr/SNN7mJmfOw/B1bXgow=="], - - "fast-string-width": ["fast-string-width@1.1.0", "", { "dependencies": { "fast-string-truncated-width": "^1.2.0" } }, "sha512-O3fwIVIH5gKB38QNbdg+3760ZmGz0SZMgvwJbA1b2TGXceKE6A2cOlfogh1iw8lr049zPyd7YADHy+B7U4W9bQ=="], - - "fast-wrap-ansi": ["fast-wrap-ansi@0.1.6", "", { "dependencies": { "fast-string-width": "^1.1.0" } }, "sha512-HlUwET7a5gqjURj70D5jl7aC3Zmy4weA1SHUfM0JFI0Ptq987NH2TwbBFLoERhfwk+E+eaq4EK3jXoT+R3yp3w=="], - "oxfmt": ["oxfmt@0.44.0", "", { "dependencies": { "tinypool": "2.1.0" }, "optionalDependencies": { "@oxfmt/binding-android-arm-eabi": "0.44.0", "@oxfmt/binding-android-arm64": "0.44.0", "@oxfmt/binding-darwin-arm64": "0.44.0", "@oxfmt/binding-darwin-x64": "0.44.0", "@oxfmt/binding-freebsd-x64": "0.44.0", "@oxfmt/binding-linux-arm-gnueabihf": "0.44.0", "@oxfmt/binding-linux-arm-musleabihf": "0.44.0", "@oxfmt/binding-linux-arm64-gnu": "0.44.0", "@oxfmt/binding-linux-arm64-musl": "0.44.0", "@oxfmt/binding-linux-ppc64-gnu": "0.44.0", "@oxfmt/binding-linux-riscv64-gnu": "0.44.0", "@oxfmt/binding-linux-riscv64-musl": "0.44.0", "@oxfmt/binding-linux-s390x-gnu": "0.44.0", "@oxfmt/binding-linux-x64-gnu": "0.44.0", "@oxfmt/binding-linux-x64-musl": "0.44.0", "@oxfmt/binding-openharmony-arm64": "0.44.0", "@oxfmt/binding-win32-arm64-msvc": "0.44.0", "@oxfmt/binding-win32-ia32-msvc": "0.44.0", "@oxfmt/binding-win32-x64-msvc": "0.44.0" }, "bin": { "oxfmt": "bin/oxfmt" } }, "sha512-lnncqvHewyRvaqdrnntVIrZV2tEddz8lbvPsQzG/zlkfvgZkwy0HP1p/2u1aCDToeg1jb9zBpbJdfkV73Itw+w=="], "oxlint": ["oxlint@1.59.0", "", { "optionalDependencies": { "@oxlint/binding-android-arm-eabi": "1.59.0", "@oxlint/binding-android-arm64": "1.59.0", "@oxlint/binding-darwin-arm64": "1.59.0", "@oxlint/binding-darwin-x64": "1.59.0", "@oxlint/binding-freebsd-x64": "1.59.0", "@oxlint/binding-linux-arm-gnueabihf": "1.59.0", "@oxlint/binding-linux-arm-musleabihf": "1.59.0", "@oxlint/binding-linux-arm64-gnu": "1.59.0", "@oxlint/binding-linux-arm64-musl": "1.59.0", "@oxlint/binding-linux-ppc64-gnu": "1.59.0", "@oxlint/binding-linux-riscv64-gnu": "1.59.0", "@oxlint/binding-linux-riscv64-musl": "1.59.0", "@oxlint/binding-linux-s390x-gnu": "1.59.0", "@oxlint/binding-linux-x64-gnu": "1.59.0", "@oxlint/binding-linux-x64-musl": "1.59.0", "@oxlint/binding-openharmony-arm64": "1.59.0", "@oxlint/binding-win32-arm64-msvc": "1.59.0", "@oxlint/binding-win32-ia32-msvc": "1.59.0", "@oxlint/binding-win32-x64-msvc": "1.59.0" }, "peerDependencies": { "oxlint-tsgolint": ">=0.18.0" }, "optionalPeers": ["oxlint-tsgolint"], "bin": { "oxlint": "bin/oxlint" } }, "sha512-0xBLeGGjP4vD9pygRo8iuOkOzEU1MqOnfiOl7KYezL/QvWL8NUg6n03zXc7ZVqltiOpUxBk2zgHI3PnRIEdAvw=="], - "sisteransi": ["sisteransi@1.0.5", "", {}, "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg=="], - "tinypool": ["tinypool@2.1.0", "", {}, "sha512-Pugqs6M0m7Lv1I7FtxN4aoyToKg1C4tu+/381vH35y8oENM/Ai7f7C4StcoK4/+BSw9ebcS8jRiVrORFKCALLw=="], "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="], diff --git a/package.json b/package.json index b42c1d5..07cef88 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "type": "module", "scripts": { "generate": "umbra --openapi kronan-openapi.yaml --out generated/spec.ts --strip-prefix /api/v1", - "generate:docs": "umbra docs --openapi kronan-openapi.yaml --out COMMANDS.md --name kronan --strip-prefix /api/v1", + "docs": "umbra docs --openapi kronan-openapi.yaml --out COMMANDS.md --name kronan --strip-prefix /api/v1", "prebuild": "bun run generate", "build": "bun build --compile --sourcemap --define \"KRONAN_CLI_VERSION='$(jq -r .version package.json)'\" ./src/index.ts --outfile ${OUTFILE:-dist/kronan} ${TARGET:+--target=$TARGET}", "typecheck": "bunx tsgo", @@ -20,9 +20,7 @@ "install-local": "bun run build && mkdir -p ~/.local/bin && mv dist/kronan ~/.local/bin/kronan" }, "dependencies": { - "@clack/prompts": "^1.2.0", - "@ihs7/umbra": "^0.5.0", - "commander": "^14.0.3", + "@ihs7/umbra": "^0.6.1", "yaml": "^2.8.3", "zod": "^4.3.6" }, diff --git a/src/commands/checkout.test.ts b/src/commands/checkout.test.ts index 4169bcb..ac6feb2 100644 --- a/src/commands/checkout.test.ts +++ b/src/commands/checkout.test.ts @@ -13,17 +13,20 @@ describe("checkoutCommand", () => { const cmd = checkoutCommand(); const params = cmd.actions.add!.params!; expect(params).toHaveLength(2); - const skuParam = params.find((p) => p.name === "sku"); - const quantityParam = params.find((p) => p.name === "quantity"); + const skuParam = params.find((p: { name: string }) => p.name === "sku"); + const quantityParam = params.find((p: { name: string }) => p.name === "quantity"); expect(skuParam?.required).toBe(true); + expect(skuParam?.positional).toBe(true); expect(quantityParam?.required).toBe(false); + expect(quantityParam?.default).toBe(1); }); test("remove action has correct params", () => { const cmd = checkoutCommand(); const params = cmd.actions.remove!.params!; expect(params).toHaveLength(1); - const skuParam = params.find((p) => p.name === "sku"); + const skuParam = params.find((p: { name: string }) => p.name === "sku"); expect(skuParam?.required).toBe(true); + expect(skuParam?.positional).toBe(true); }); }); diff --git a/src/commands/checkout.ts b/src/commands/checkout.ts index c639cce..d53b738 100644 --- a/src/commands/checkout.ts +++ b/src/commands/checkout.ts @@ -1,7 +1,7 @@ import { checkout_lines_create, checkout_list } from "../../generated/spec"; -import type { CliResource } from "@ihs7/umbra"; +import type { CliCommandEntry } from "@ihs7/umbra"; -export function checkoutCommand(): CliResource { +export function checkoutCommand(): CliCommandEntry { return { name: "checkout", actions: { @@ -13,6 +13,7 @@ export function checkoutCommand(): CliResource { location: "body", kind: "string", required: true, + positional: true, description: "Product SKU", }, { @@ -20,16 +21,14 @@ export function checkoutCommand(): CliResource { location: "body", kind: "number", required: false, - description: "Quantity to add (default: 1)", + default: 1, + description: "Quantity to add", }, ], handler: async (args) => { - const body = args.body as { sku: string; quantity?: number }; + const { sku, quantity } = args.body as { sku: string; quantity: number }; return checkout_lines_create.handler({ - body: { - lines: [{ sku: body.sku, quantity: body.quantity ?? 1 }], - replace: false, - }, + body: { lines: [{ sku, quantity }], replace: false }, }); }, }, @@ -41,6 +40,7 @@ export function checkoutCommand(): CliResource { location: "body", kind: "string", required: true, + positional: true, description: "Product SKU", }, ], @@ -52,11 +52,8 @@ export function checkoutCommand(): CliResource { const lines = (checkout.lines ?? []).map((l) => ({ sku: l.product.sku, quantity: l.product.sku === sku ? 0 : l.quantity, - source: "checkout", })); - return checkout_lines_create.handler({ - body: { lines, force: false }, - }); + return checkout_lines_create.handler({ body: { lines, force: false } }); }, }, }, diff --git a/src/index.ts b/src/index.ts index 653db0d..961513d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,18 +7,14 @@ declare const KRONAN_CLI_VERSION: string; const version = typeof KRONAN_CLI_VERSION !== "undefined" ? KRONAN_CLI_VERSION : "dev"; const baseUrl = process.env.KRONAN_API_BASE_URL; -if (baseUrl) { - configure({ baseUrl }); -} - -const auth = { - keychain: "kronan-cli", - header: (token: string) => ({ Authorization: `AccessToken ${token}` }), -}; +if (baseUrl) configure({ baseUrl }); await createCli({ name: "kronan", version, - auth, + auth: { + keychain: "kronan-cli", + header: (token) => ({ Authorization: `AccessToken ${token}` }), + }, commands: [checkoutCommand()], }).run();