@barekey/cli 0.1.4 → 0.2.0

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.
package/AGENTS.md CHANGED
@@ -7,3 +7,8 @@
7
7
  - Use `bun run <script>` for project scripts.
8
8
  - Use `bun test` for tests.
9
9
  - Do not use `npm` or commit `package-lock.json`.
10
+
11
+ ## Releases
12
+
13
+ - If work includes merging changes to `/home/sander/barekey/sdk` on `master`, make sure the SDK `package.json` version is bumped before or with that merge whenever the SDK surface, generated types, runtime behavior, or published artifacts changed.
14
+ - Use semantic versioning for SDK version bumps: `patch` for backward-compatible fixes, `minor` for backward-compatible features, `major` for breaking changes.
package/bun.lock CHANGED
@@ -5,7 +5,7 @@
5
5
  "": {
6
6
  "name": "@barekey/cli",
7
7
  "dependencies": {
8
- "@barekey/sdk": "^0.1.3",
8
+ "@barekey/sdk": "^0.2.0",
9
9
  "@clack/prompts": "^0.11.0",
10
10
  "commander": "^14.0.1",
11
11
  "open": "^10.2.0",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  },
20
20
  "packages": {
21
- "@barekey/sdk": ["@barekey/sdk@0.1.3", "", {}, "sha512-Y5defUYsa6r6GnfR7i0zNnKVI6gXp/GJihVO7+kpijCA61Hnf5hheBTZQyEUma+G1U7MxLcQM/g+FNSHSOXeYQ=="],
21
+ "@barekey/sdk": ["@barekey/sdk@0.2.0", "", {}, "sha512-vSbxzJ6ZqR8ThBqe6DIweoQliF6nCfuDvUnuKHFFqBVagkcT26goZekD9NXfJBb/Obip9rdJvKG9zfFTV1UBgQ=="],
22
22
 
23
23
  "@clack/core": ["@clack/core@0.5.0", "", { "dependencies": { "picocolors": "^1.0.0", "sisteransi": "^1.0.5" } }, "sha512-p3y0FIOwaYRUPRcMO7+dlmLh8PSRcrjuTndsiA0WAFbWES0mLZlrjVoBRZ9DzkPFJZG6KGkJmoEAY0ZcVWTkow=="],
24
24
 
@@ -1,2 +1,4 @@
1
+ import type { BarekeyTypegenResult } from "@barekey/sdk/server";
1
2
  import { Command } from "commander";
3
+ export declare function formatTypegenResultMessage(result: BarekeyTypegenResult): string;
2
4
  export declare function registerTypegenCommand(program: Command): void;
@@ -1,5 +1,20 @@
1
1
  import { BarekeyClient } from "@barekey/sdk/server";
2
+ import pc from "picocolors";
2
3
  import { addTargetOptions, requireLocalSession, resolveTarget, } from "../command-utils.js";
4
+ export function formatTypegenResultMessage(result) {
5
+ const title = result.written
6
+ ? pc.green(pc.bold("Typegen complete"))
7
+ : pc.cyan(pc.bold("Typegen already up to date"));
8
+ const detail = result.written
9
+ ? "Fresh SDK types are ready in your installed @barekey/sdk package."
10
+ : "Your installed @barekey/sdk package already has the latest generated types.";
11
+ return [
12
+ title,
13
+ detail,
14
+ `${pc.bold("Server types")}: ${result.serverPath}`,
15
+ `${pc.bold("Public types")}: ${result.publicPath}`,
16
+ ].join("\n");
17
+ }
3
18
  async function runTypegen(options) {
4
19
  const local = await requireLocalSession();
5
20
  const target = await resolveTarget(options, local);
@@ -14,7 +29,7 @@ async function runTypegen(options) {
14
29
  typegen: false,
15
30
  });
16
31
  const result = await client.typegen();
17
- console.log(`${result.written ? "Updated" : "Unchanged"} ${result.path}`);
32
+ console.log(formatTypegenResultMessage(result));
18
33
  }
19
34
  export function registerTypegenCommand(program) {
20
35
  addTargetOptions(program
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barekey/cli",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "description": "Barekey command line interface",
5
5
  "type": "module",
6
6
  "bin": {
@@ -15,7 +15,7 @@
15
15
  "packageManager": "bun@1.2.22",
16
16
  "dependencies": {
17
17
  "@clack/prompts": "^0.11.0",
18
- "@barekey/sdk": "^0.1.3",
18
+ "@barekey/sdk": "^0.2.0",
19
19
  "commander": "^14.0.1",
20
20
  "open": "^10.2.0",
21
21
  "picocolors": "^1.1.1"
@@ -1,5 +1,7 @@
1
1
  import { BarekeyClient } from "@barekey/sdk/server";
2
+ import type { BarekeyTypegenResult } from "@barekey/sdk/server";
2
3
  import { Command } from "commander";
4
+ import pc from "picocolors";
3
5
 
4
6
  import {
5
7
  addTargetOptions,
@@ -8,6 +10,22 @@ import {
8
10
  type EnvTargetOptions,
9
11
  } from "../command-utils.js";
10
12
 
13
+ export function formatTypegenResultMessage(result: BarekeyTypegenResult): string {
14
+ const title = result.written
15
+ ? pc.green(pc.bold("Typegen complete"))
16
+ : pc.cyan(pc.bold("Typegen already up to date"));
17
+ const detail = result.written
18
+ ? "Fresh SDK types are ready in your installed @barekey/sdk package."
19
+ : "Your installed @barekey/sdk package already has the latest generated types.";
20
+
21
+ return [
22
+ title,
23
+ detail,
24
+ `${pc.bold("Server types")}: ${result.serverPath}`,
25
+ `${pc.bold("Public types")}: ${result.publicPath}`,
26
+ ].join("\n");
27
+ }
28
+
11
29
  async function runTypegen(options: EnvTargetOptions): Promise<void> {
12
30
  const local = await requireLocalSession();
13
31
  const target = await resolveTarget(options, local);
@@ -24,7 +42,7 @@ async function runTypegen(options: EnvTargetOptions): Promise<void> {
24
42
  });
25
43
  const result = await client.typegen();
26
44
 
27
- console.log(`${result.written ? "Updated" : "Unchanged"} ${result.path}`);
45
+ console.log(formatTypegenResultMessage(result));
28
46
  }
29
47
 
30
48
  export function registerTypegenCommand(program: Command): void {
@@ -0,0 +1,37 @@
1
+ import { describe, expect, test } from "bun:test";
2
+
3
+ import { formatTypegenResultMessage } from "../src/commands/typegen";
4
+
5
+ describe("formatTypegenResultMessage", () => {
6
+ test("renders a helpful success message when files were updated", () => {
7
+ const message = formatTypegenResultMessage({
8
+ written: true,
9
+ path: "/tmp/generated.server.d.ts",
10
+ serverPath: "/tmp/generated.server.d.ts",
11
+ publicPath: "/tmp/generated.public.d.ts",
12
+ manifestVersion: "manifest-1",
13
+ });
14
+
15
+ expect(message).toContain("Typegen complete");
16
+ expect(message).toContain("Fresh SDK types are ready");
17
+ expect(message).toContain("Server types");
18
+ expect(message).toContain("/tmp/generated.server.d.ts");
19
+ expect(message).toContain("Public types");
20
+ expect(message).toContain("/tmp/generated.public.d.ts");
21
+ });
22
+
23
+ test("renders a calm message when nothing changed", () => {
24
+ const message = formatTypegenResultMessage({
25
+ written: false,
26
+ path: "/tmp/generated.server.d.ts",
27
+ serverPath: "/tmp/generated.server.d.ts",
28
+ publicPath: "/tmp/generated.public.d.ts",
29
+ manifestVersion: "manifest-1",
30
+ });
31
+
32
+ expect(message).toContain("Typegen already up to date");
33
+ expect(message).toContain("already has the latest generated types");
34
+ expect(message).toContain("/tmp/generated.server.d.ts");
35
+ expect(message).toContain("/tmp/generated.public.d.ts");
36
+ });
37
+ });