@anakonn/ankk 0.1.0-beta.0 → 0.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +31 -3
  2. package/dist/index.js +110 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -18,11 +18,38 @@ bun install -g @anakonn/ankk
18
18
  ankk --json health
19
19
  ```
20
20
 
21
+ ## Upgrade
22
+
23
+ Global Bun installs can upgrade through the CLI:
24
+
25
+ ```bash
26
+ ankk upgrade
27
+ ankk upgrade --tag beta
28
+ ankk upgrade --tag latest
29
+ ankk upgrade --dry-run
30
+ ```
31
+
32
+ The default tag follows the installed CLI version: prerelease builds upgrade
33
+ from `beta`, and stable builds upgrade from `latest`.
34
+
21
35
  ## Publish
22
36
 
23
- Public npm publish runs only from the repository `main` branch. After `preview`
24
- is promoted to `main`, run the manual GitLab CI job `publish:cli:npm:beta` with
25
- a masked, protected `NPM_TOKEN` variable configured.
37
+ Public npm publish runs from protected CLI release tags only. After `preview` is
38
+ promoted to `main`, update `apps/cli/package.json` to the release version, merge
39
+ that version to `main`, then push a matching tag:
40
+
41
+ ```bash
42
+ git fetch origin main
43
+ git switch main
44
+ git pull --ff-only origin main
45
+ git tag ankk-cli-v0.1.0-beta.1
46
+ git push origin ankk-cli-v0.1.0-beta.1
47
+ ```
48
+
49
+ The CI job `publish:cli:npm` validates that the tag version matches
50
+ `apps/cli/package.json`, that the tag commit is contained in `origin/main`, and
51
+ that the version is not already published. Pre-release versions publish with npm
52
+ dist-tag `beta`; stable versions publish with `latest`.
26
53
 
27
54
  The current repository is hosted on self-managed GitLab. npm Trusted Publishing
28
55
  is preferred, but npm currently documents GitLab support for GitLab.com shared
@@ -35,6 +62,7 @@ npm token with the smallest practical scope:
35
62
  - Organization access: none unless npm requires it for the `@anakonn` scope.
36
63
  - Expiration: finite.
37
64
  - GitLab variable: `NPM_TOKEN`, masked and protected.
65
+ - GitLab protected tag pattern: `ankk-cli-v*`.
38
66
 
39
67
  If this is the first ever publish and npm cannot scope a token to an
40
68
  unpublished package, publish `@anakonn/ankk` once manually with 2FA, then
package/dist/index.js CHANGED
@@ -2154,6 +2154,57 @@ var {
2154
2154
  Option,
2155
2155
  Help
2156
2156
  } = import__.default;
2157
+ // package.json
2158
+ var package_default = {
2159
+ name: "@anakonn/ankk",
2160
+ version: "0.1.0-beta.1",
2161
+ description: "Bun-first CLI for the ankk public API.",
2162
+ private: false,
2163
+ license: "UNLICENSED",
2164
+ type: "module",
2165
+ bin: {
2166
+ ankk: "dist/index.js"
2167
+ },
2168
+ exports: "./dist/index.js",
2169
+ files: [
2170
+ "dist",
2171
+ "README.md",
2172
+ "package.json"
2173
+ ],
2174
+ publishConfig: {
2175
+ access: "public",
2176
+ registry: "https://registry.npmjs.org/"
2177
+ },
2178
+ engines: {
2179
+ bun: ">=1.3.0"
2180
+ },
2181
+ scripts: {
2182
+ build: "bun build src/entry/index.ts --target=bun --outdir=dist",
2183
+ check: "tsc --noEmit",
2184
+ "coverage:openapi": "bun src/coverage-check.ts",
2185
+ dev: "bun run src/entry/index.ts",
2186
+ format: "prettier --write .",
2187
+ "generate:openapi": "bun run generate:openapi:snapshot && bun run generate:openapi:types && bun run generate:openapi:format",
2188
+ "generate:openapi:format": "prettier --write src/generated/api-public-openapi.json src/generated/api-public-schema.ts",
2189
+ "generate:openapi:live": "bun run src/entry/index.ts openapi pull && bun run generate:openapi:types && bun run generate:openapi:format",
2190
+ "generate:openapi:snapshot": "bun ../../scripts/api-public/generate-openapi-snapshot.ts",
2191
+ "generate:openapi:types": "openapi-typescript src/generated/api-public-openapi.json -o src/generated/api-public-schema.ts",
2192
+ lint: "tsc --noEmit",
2193
+ "pack:smoke": "bun run build && npm pack --dry-run",
2194
+ prepack: "bun run build",
2195
+ "smoke:dogfood": "bun src/dogfood-smoke.ts",
2196
+ test: "bun test"
2197
+ },
2198
+ dependencies: {
2199
+ commander: "^14.0.3",
2200
+ "openapi-fetch": "^0.15.0",
2201
+ zod: "^4.4.3"
2202
+ },
2203
+ devDependencies: {
2204
+ "@repo/tsconfig": "workspace:*",
2205
+ "openapi-typescript": "^7.10.1"
2206
+ }
2207
+ };
2157
2208
 
2158
2209
  // ../../node_modules/.bun/openapi-fetch@0.15.2/node_modules/openapi-fetch/dist/index.mjs
2159
2210
  var PATH_PARAM_RE = /\{[^{}]+\}/g;
@@ -17031,8 +17082,14 @@ var writeError = (io, error51) => {
17031
17082
  };
17032
17083
 
17033
17084
  // src/program.ts
17034
- var runCli = async ({ argv, env = process.env, fetch = globalThis.fetch, io = defaultIo }) => {
17035
- const program2 = createProgram({ env, fetch, io });
17085
+ var runCli = async ({
17086
+ argv,
17087
+ commandRunner = runProcess,
17088
+ env = process.env,
17089
+ fetch = globalThis.fetch,
17090
+ io = defaultIo
17091
+ }) => {
17092
+ const program2 = createProgram({ commandRunner, env, fetch, io });
17036
17093
  try {
17037
17094
  await program2.parseAsync(argv, { from: "user" });
17038
17095
  return 0;
@@ -17042,6 +17099,7 @@ var runCli = async ({ argv, env = process.env, fetch = globalThis.fetch, io = de
17042
17099
  }
17043
17100
  };
17044
17101
  var createProgram = ({
17102
+ commandRunner = runProcess,
17045
17103
  env = process.env,
17046
17104
  fetch = globalThis.fetch,
17047
17105
  io = defaultIo
@@ -17056,6 +17114,15 @@ var createProgram = ({
17056
17114
  });
17057
17115
  writeOutput(context.io, context.outputMode, result, `${result.service}: ${result.status}`);
17058
17116
  });
17117
+ program2.command("upgrade").description("Upgrade the ankk CLI global installation").option("--tag <tag>", "npm dist-tag to install (beta or latest)").option("--dry-run", "Print the upgrade command without running it").action(async (options) => {
17118
+ const outputMode = program2.opts().json ? "json" : "human";
17119
+ const result = await upgradeCli({
17120
+ commandRunner,
17121
+ dryRun: Boolean(options.dryRun),
17122
+ tag: options.tag
17123
+ });
17124
+ writeOutput(io, outputMode, result, options.dryRun ? `Would run: ${result.command.join(" ")}` : `Upgraded ${result.package} via ${result.tag}`);
17125
+ });
17059
17126
  const brands = program2.command("brands").description("Manage brands available to the API key");
17060
17127
  brands.command("list").description("List brands available to the API key").action(async () => {
17061
17128
  const context = await resolveCommandContext({ env, fetch, io, program: program2 });
@@ -17432,6 +17499,47 @@ var resolveCommandContext = async ({
17432
17499
  };
17433
17500
  };
17434
17501
  var safeDefaultConfigPath = (env) => defaultConfigPath({ env });
17502
+ var packageName = package_default.name;
17503
+ var packageVersion = package_default.version;
17504
+ var upgradeCli = async ({
17505
+ commandRunner,
17506
+ dryRun,
17507
+ tag
17508
+ }) => {
17509
+ const resolvedTag = resolveUpgradeTag(tag, packageVersion);
17510
+ const command = ["bun", "install", "-g", `${packageName}@${resolvedTag}`];
17511
+ const result = {
17512
+ command,
17513
+ current_version: packageVersion,
17514
+ dry_run: dryRun,
17515
+ package: packageName,
17516
+ tag: resolvedTag
17517
+ };
17518
+ if (dryRun)
17519
+ return result;
17520
+ const exitCode = await commandRunner(command[0] ?? "bun", command.slice(1));
17521
+ if (exitCode !== 0) {
17522
+ throw new Error(`Upgrade command failed with exit code ${exitCode}.`);
17523
+ }
17524
+ return result;
17525
+ };
17526
+ var resolveUpgradeTag = (tag, currentVersion) => {
17527
+ if (tag === undefined) {
17528
+ return currentVersion.includes("-") ? "beta" : "latest";
17529
+ }
17530
+ if (tag === "beta" || tag === "latest") {
17531
+ return tag;
17532
+ }
17533
+ throw new Error('Upgrade tag must be either "beta" or "latest".');
17534
+ };
17535
+ var runProcess = async (command, args) => {
17536
+ const process3 = Bun.spawn([command, ...args], {
17537
+ stderr: "inherit",
17538
+ stdin: "inherit",
17539
+ stdout: "inherit"
17540
+ });
17541
+ return process3.exited;
17542
+ };
17435
17543
  var withBrandRef = (command) => command.requiredOption("--brand-ref <brand_ref>", "Brand reference");
17436
17544
  var queryParams = (query) => ({
17437
17545
  query: Object.fromEntries(Object.entries(query).filter(([, value]) => value !== undefined))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anakonn/ankk",
3
- "version": "0.1.0-beta.0",
3
+ "version": "0.1.0-beta.1",
4
4
  "description": "Bun-first CLI for the ankk public API.",
5
5
  "private": false,
6
6
  "license": "UNLICENSED",