@anakonn/ankk 0.1.0-beta.0 → 0.1.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 +22 -4
  2. package/dist/index.js +95 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -18,11 +18,28 @@ 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 --dry-run
28
+ ```
29
+
30
+ The CLI uses the `latest` npm dist-tag. Release versions use three-part numeric
31
+ SemVer such as `0.1.1`.
32
+
21
33
  ## Publish
22
34
 
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.
35
+ Public npm publish runs automatically when CLI-related changes reach the
36
+ repository `main` branch. Before merging CLI changes to `main`, update
37
+ `apps/cli/package.json` to the release version.
38
+
39
+ The CI job `publish:cli:npm` validates that `apps/cli/package.json` uses
40
+ three-part numeric SemVer, that the version is not already published, and then
41
+ publishes with npm dist-tag `latest`. If the version was already published, the
42
+ job fails so the missing version bump is visible.
26
43
 
27
44
  The current repository is hosted on self-managed GitLab. npm Trusted Publishing
28
45
  is preferred, but npm currently documents GitLab support for GitLab.com shared
@@ -35,10 +52,11 @@ npm token with the smallest practical scope:
35
52
  - Organization access: none unless npm requires it for the `@anakonn` scope.
36
53
  - Expiration: finite.
37
54
  - GitLab variable: `NPM_TOKEN`, masked and protected.
55
+ - GitLab protected branch: `main`.
38
56
 
39
57
  If this is the first ever publish and npm cannot scope a token to an
40
58
  unpublished package, publish `@anakonn/ankk` once manually with 2FA, then
41
- replace CI with a package-scoped token for later beta publishes.
59
+ replace CI with a package-scoped token for later publishes.
42
60
 
43
61
  When publishing moves to a supported Trusted Publishing runner, configure npm
44
62
  Trusted Publisher with:
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.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,14 @@ 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("--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
+ });
17123
+ writeOutput(io, outputMode, result, options.dryRun ? `Would run: ${result.command.join(" ")}` : `Upgraded ${result.package} via ${result.tag}`);
17124
+ });
17059
17125
  const brands = program2.command("brands").description("Manage brands available to the API key");
17060
17126
  brands.command("list").description("List brands available to the API key").action(async () => {
17061
17127
  const context = await resolveCommandContext({ env, fetch, io, program: program2 });
@@ -17432,6 +17498,33 @@ var resolveCommandContext = async ({
17432
17498
  };
17433
17499
  };
17434
17500
  var safeDefaultConfigPath = (env) => defaultConfigPath({ env });
17501
+ var packageName = package_default.name;
17502
+ var packageVersion = package_default.version;
17503
+ var upgradeCli = async ({ commandRunner, dryRun }) => {
17504
+ const command = ["bun", "install", "-g", `${packageName}@latest`];
17505
+ const result = {
17506
+ command,
17507
+ current_version: packageVersion,
17508
+ dry_run: dryRun,
17509
+ package: packageName,
17510
+ tag: "latest"
17511
+ };
17512
+ if (dryRun)
17513
+ return result;
17514
+ const exitCode = await commandRunner(command[0] ?? "bun", command.slice(1));
17515
+ if (exitCode !== 0) {
17516
+ throw new Error(`Upgrade command failed with exit code ${exitCode}.`);
17517
+ }
17518
+ return result;
17519
+ };
17520
+ var runProcess = async (command, args) => {
17521
+ const process3 = Bun.spawn([command, ...args], {
17522
+ stderr: "inherit",
17523
+ stdin: "inherit",
17524
+ stdout: "inherit"
17525
+ });
17526
+ return process3.exited;
17527
+ };
17435
17528
  var withBrandRef = (command) => command.requiredOption("--brand-ref <brand_ref>", "Brand reference");
17436
17529
  var queryParams = (query) => ({
17437
17530
  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.1",
4
4
  "description": "Bun-first CLI for the ankk public API.",
5
5
  "private": false,
6
6
  "license": "UNLICENSED",