create-svc 0.1.74 → 0.1.76

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-svc",
3
- "version": "0.1.74",
3
+ "version": "0.1.76",
4
4
  "description": "Local microservice bootstrap CLI for Cloud Run and Workers services with Neon-backed data.",
5
5
  "module": "index.ts",
6
6
  "type": "module",
@@ -62,7 +62,7 @@ test("scaffolds all runtime/framework variants with shared cloudrun config", asy
62
62
  expect(serviceConfig).toContain('"kind": "microservice"');
63
63
  expect(serviceConfig).toContain(`"runtime": "${variant.runtime}"`);
64
64
  expect(serviceConfig).toContain(`"framework": "${variant.framework}"`);
65
- expect(serviceConfig).toContain('"module": "buf.build/anmho/dns-api"');
65
+ expect(serviceConfig).toContain('"module": "buf.build/anmho-services/dns-api"');
66
66
  expect(serviceConfig).toContain('"cloudflare_vault_path": "prod/providers/cloudflare"');
67
67
  expect(serviceConfig).toContain('"issuer": "https://auth.anmho.com/api/auth"');
68
68
  expect(serviceConfig).toContain('"audience": "api://dns-api"');
@@ -204,7 +204,7 @@ test("scaffolds all runtime/framework variants with shared cloudrun config", asy
204
204
  expect(mainGo).toContain("NewWaitlistService");
205
205
  expect(mainGo).toContain("WaitlistServiceName");
206
206
  const bufConfig = await Bun.file(join(generatedRoot, "buf.yaml")).text();
207
- expect(bufConfig).toContain("name: buf.build/anmho/dns-api");
207
+ expect(bufConfig).toContain("name: buf.build/anmho-services/dns-api");
208
208
  } else {
209
209
  expect(goMod).not.toContain("connectrpc.com/connect");
210
210
  expect(mainGo).toContain("NewWaitlistService");
@@ -300,6 +300,21 @@ async function runDoctor() {
300
300
  const state = JSON.parse(text) as SdkState;
301
301
  return formatSdkModeDetail(state, bufModule());
302
302
  });
303
+ await record(results, "SDK remote publish", "warn", async () => {
304
+ const text = await Bun.file(".service/sdk.json").text();
305
+ const state = JSON.parse(text) as SdkState;
306
+ const module = state.module || bufModule();
307
+ if (state.mode !== "remote") {
308
+ throw new Error(`SDK is in ${state.mode} mode; run service sdk publish to publish ${module}`);
309
+ }
310
+ const authEnv = resolveBufAuthEnv();
311
+ run("buf", ["registry", "module", "info", module], { env: authEnv });
312
+ const published = resolvePublishedSdk(authEnv);
313
+ if (state.remote?.commit && published.commit !== state.remote.commit) {
314
+ return `remote module readable; latest ${published.commit}, recorded ${state.remote.commit}`;
315
+ }
316
+ return `remote module readable at ${module}@${published.commit}`;
317
+ });
303
318
  }
304
319
 
305
320
  const output = results.map(formatDoctorResult).join("\n");
@@ -451,7 +466,7 @@ async function writeSdkMode(mode: "local" | "remote", published?: PublishedSdk)
451
466
  }
452
467
 
453
468
  function bufModule() {
454
- return config.buf.module || `buf.build/anmho/${config.serviceName}`;
469
+ return config.buf.module || `buf.build/anmho-services/${config.serviceName}`;
455
470
  }
456
471
 
457
472
  function ensureBufModule(authEnv: Record<string, string>) {
@@ -47,7 +47,7 @@ export const config = {
47
47
  vaultPath: vault.temporal_path || "prod/providers/temporal",
48
48
  },
49
49
  buf: {
50
- module: serviceConfig.buf?.module || `buf.build/anmho/${serviceConfig.service_id}`,
50
+ module: serviceConfig.buf?.module || `buf.build/anmho-services/${serviceConfig.service_id}`,
51
51
  vaultMount: vault.mount || "secret",
52
52
  vaultPath: vault.buf_path || "prod/providers/buf",
53
53
  },
@@ -48,14 +48,14 @@ test("service sdk publish pushes the named Buf module and selects remote SDK mod
48
48
  "#!/bin/sh",
49
49
  `echo "$@" >> "${bufLog}"`,
50
50
  `printf '%s' "$BUF_TOKEN" > "${tokenLog}"`,
51
- 'if [ "$1 $2 $3 $4" = "registry module info buf.build/anmho/sdk-proof" ]; then',
51
+ 'if [ "$1 $2 $3 $4" = "registry module info buf.build/anmho-services/sdk-proof" ]; then',
52
52
  " exit 1",
53
53
  "fi",
54
- 'if [ "$1 $2 $3 $4" = "registry module create buf.build/anmho/sdk-proof" ] && [ "$5 $6" = "--visibility private" ]; then',
54
+ 'if [ "$1 $2 $3 $4" = "registry module create buf.build/anmho-services/sdk-proof" ] && [ "$5 $6" = "--visibility private" ]; then',
55
55
  " exit 0",
56
56
  "fi",
57
57
  'if [ "$1 $2 $3 $4" = "registry module commit list" ]; then',
58
- ' printf \'{"commits":[{"name":"buf.build/anmho/sdk-proof:commit-123","digest":"b5:abc123","create_time":"2026-05-25T12:00:00Z"}]}\'',
58
+ ' printf \'{"commits":[{"name":"buf.build/anmho-services/sdk-proof:commit-123","digest":"b5:abc123","create_time":"2026-05-25T12:00:00Z"}]}\'',
59
59
  " exit 0",
60
60
  "fi",
61
61
  'if [ "$1" = "push" ]; then',
@@ -81,17 +81,17 @@ test("service sdk publish pushes the named Buf module and selects remote SDK mod
81
81
  expect(result.stderr.toString()).not.toContain("test-token");
82
82
  expect((await readFile(bufLog, "utf8")).trim()).toBe(
83
83
  [
84
- "registry module info buf.build/anmho/sdk-proof",
85
- "registry module create buf.build/anmho/sdk-proof --visibility private",
84
+ "registry module info buf.build/anmho-services/sdk-proof",
85
+ "registry module create buf.build/anmho-services/sdk-proof --visibility private",
86
86
  "push",
87
- "registry module commit list buf.build/anmho/sdk-proof --format json --page-size 1",
87
+ "registry module commit list buf.build/anmho-services/sdk-proof --format json --page-size 1",
88
88
  ].join("\n")
89
89
  );
90
90
  expect((await readFile(tokenLog, "utf8")).trim()).toBe("test-token");
91
91
  const sdkState = JSON.parse(await Bun.file(join(generatedRoot, ".service", "sdk.json")).text());
92
92
  expect(sdkState).toMatchObject({
93
93
  mode: "remote",
94
- module: "buf.build/anmho/sdk-proof",
94
+ module: "buf.build/anmho-services/sdk-proof",
95
95
  localPath: "./gen/waitlist/v1",
96
96
  remote: {
97
97
  commit: "commit-123",
@@ -100,7 +100,7 @@ test("service sdk publish pushes the named Buf module and selects remote SDK mod
100
100
  },
101
101
  });
102
102
  const bufConfig = await Bun.file(join(generatedRoot, "buf.yaml")).text();
103
- expect(bufConfig).toContain("name: buf.build/anmho/sdk-proof");
103
+ expect(bufConfig).toContain("name: buf.build/anmho-services/sdk-proof");
104
104
  });
105
105
 
106
106
  test("formatSdkModeDetail reports the recorded remote SDK commit", () => {
@@ -108,15 +108,15 @@ test("formatSdkModeDetail reports the recorded remote SDK commit", () => {
108
108
  formatSdkModeDetail(
109
109
  {
110
110
  mode: "remote",
111
- module: "buf.build/anmho/sdk-proof",
111
+ module: "buf.build/anmho-services/sdk-proof",
112
112
  remote: {
113
113
  commit: "commit-123",
114
114
  digest: "b5:abc123",
115
115
  },
116
116
  },
117
- "buf.build/anmho/fallback"
117
+ "buf.build/anmho-services/fallback"
118
118
  )
119
- ).toBe("remote: buf.build/anmho/sdk-proof@commit-123 (b5:abc123)");
119
+ ).toBe("remote: buf.build/anmho-services/sdk-proof@commit-123 (b5:abc123)");
120
120
  });
121
121
 
122
122
  test("service sdk use-remote records the current Buf commit", async () => {
@@ -132,7 +132,7 @@ test("service sdk use-remote records the current Buf commit", async () => {
132
132
  [
133
133
  "#!/bin/sh",
134
134
  'if [ "$1 $2 $3 $4" = "registry module commit list" ]; then',
135
- ' printf \'{"commits":[{"name":"buf.build/anmho/sdk-proof:commit-456","digest":"b5:def456"}]}\'',
135
+ ' printf \'{"commits":[{"name":"buf.build/anmho-services/sdk-proof:commit-456","digest":"b5:def456"}]}\'',
136
136
  "fi",
137
137
  "exit 0",
138
138
  "",
@@ -172,7 +172,7 @@ test("service sdk publish leaves local SDK mode when Buf push fails", async () =
172
172
  `${JSON.stringify(
173
173
  {
174
174
  mode: "local",
175
- module: "buf.build/anmho/sdk-proof",
175
+ module: "buf.build/anmho-services/sdk-proof",
176
176
  localPath: "./gen/waitlist/v1",
177
177
  updatedAt: "2026-05-25T00:00:00.000Z",
178
178
  },
@@ -7,6 +7,7 @@ import {
7
7
  formatOutsideServiceCommandError,
8
8
  generatedDependenciesInstalled,
9
9
  generatedServiceCommandHelp,
10
+ createSvcVersion,
10
11
  normalizeScaffoldArgs,
11
12
  } from "./service";
12
13
 
@@ -21,6 +22,11 @@ test("normalizeScaffoldArgs maps service help to generator help outside a servic
21
22
  expect(normalizeScaffoldArgs(["help", "--verbose"])).toEqual(["--help", "--verbose"]);
22
23
  });
23
24
 
25
+ test("createSvcVersion reports the package version", async () => {
26
+ const packageJson = await Bun.file(new URL("../package.json", import.meta.url)).json();
27
+ expect(createSvcVersion()).toBe(packageJson.version);
28
+ });
29
+
24
30
  test("formatOutsideServiceCommandError rejects repo-local commands outside generated services", () => {
25
31
  expect(formatOutsideServiceCommandError("destroy")).toContain("service destroy must be run inside a generated service repo");
26
32
  expect(formatOutsideServiceCommandError("deploy")).toContain("No service.jsonc was found");
package/src/service.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { existsSync } from "node:fs";
1
+ import { existsSync, readFileSync } from "node:fs";
2
2
  import { dirname, join } from "node:path";
3
3
  import { formatScaffoldHelp, run as runScaffoldCli } from "./cli";
4
4
  import { parseJsonc } from "./jsonc";
@@ -19,6 +19,11 @@ const GENERATED_SERVICE_COMMANDS = new Set([
19
19
  ]);
20
20
 
21
21
  export async function runServiceCommand(argv: string[], cwd = process.cwd()) {
22
+ if (isVersionCommand(argv)) {
23
+ console.log(createSvcVersion());
24
+ return;
25
+ }
26
+
22
27
  const serviceRoot = findGeneratedServiceRoot(cwd);
23
28
  if (serviceRoot) {
24
29
  await delegateToGeneratedService(serviceRoot, argv);
@@ -40,6 +45,15 @@ export async function runServiceCommand(argv: string[], cwd = process.cwd()) {
40
45
  process.exit(1);
41
46
  }
42
47
 
48
+ function isVersionCommand(argv: string[]) {
49
+ return argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v" || argv[0] === "version");
50
+ }
51
+
52
+ export function createSvcVersion() {
53
+ const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")) as { version?: string };
54
+ return packageJson.version || "unknown";
55
+ }
56
+
43
57
  export function normalizeScaffoldArgs(argv: string[]) {
44
58
  const [command, ...rest] = argv;
45
59
  if (command && SCAFFOLD_COMMANDS.has(command)) {
@@ -86,7 +86,7 @@
86
86
  },
87
87
 
88
88
  "buf": {
89
- "module": "buf.build/anmho/{{SERVICE_ID}}"
89
+ "module": "buf.build/anmho-services/{{SERVICE_ID}}"
90
90
  },
91
91
 
92
92
  "observability": {
@@ -1,7 +1,7 @@
1
1
  version: v2
2
2
  modules:
3
3
  - path: protos
4
- name: buf.build/anmho/{{SERVICE_ID}}
4
+ name: buf.build/anmho-services/{{SERVICE_ID}}
5
5
  lint:
6
6
  use:
7
7
  - STANDARD