create-svc 0.1.72 → 0.1.73

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.72",
3
+ "version": "0.1.73",
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",
@@ -348,9 +348,9 @@ async function runSdk(args: string[]) {
348
348
  const [subcommand] = args;
349
349
  if (subcommand === "publish") {
350
350
  requireCommand("buf");
351
- ensureBufAuth();
352
- run("buf", ["push"]);
353
- const published = resolvePublishedSdk();
351
+ const authEnv = resolveBufAuthEnv();
352
+ run("buf", ["push", "--create", "--create-visibility", "private"], { env: authEnv });
353
+ const published = resolvePublishedSdk(authEnv);
354
354
  await writeSdkMode("remote", published);
355
355
  return `Schema pushed to Buf Schema Registry and recorded for consumers: ${published.commit}`;
356
356
  }
@@ -373,8 +373,8 @@ async function runSdk(args: string[]) {
373
373
 
374
374
  if (subcommand === "use-remote") {
375
375
  requireCommand("buf");
376
- ensureBufAuth();
377
- const published = resolvePublishedSdk();
376
+ const authEnv = resolveBufAuthEnv();
377
+ const published = resolvePublishedSdk(authEnv);
378
378
  await writeSdkMode("remote", published);
379
379
  return `Remote Buf SDK recorded for consumers: ${bufModule()}@${published.commit}`;
380
380
  }
@@ -395,9 +395,9 @@ type PublishedSdk = {
395
395
  createTime?: string;
396
396
  };
397
397
 
398
- function resolvePublishedSdk(): PublishedSdk {
398
+ function resolvePublishedSdk(authEnv: Record<string, string> = {}): PublishedSdk {
399
399
  const module = bufModule();
400
- const result = run("buf", ["registry", "module", "commit", "list", module, "--format", "json", "--page-size", "1"]);
400
+ const result = run("buf", ["registry", "module", "commit", "list", module, "--format", "json", "--page-size", "1"], { env: authEnv });
401
401
  const parsed = JSON.parse(result.stdout) as {
402
402
  commits?: Array<Record<string, unknown>>;
403
403
  commit?: Record<string, unknown>;
@@ -453,14 +453,14 @@ function bufModule() {
453
453
  return config.buf.module || `buf.build/anmho/${config.serviceName}`;
454
454
  }
455
455
 
456
- function ensureBufAuth() {
456
+ function resolveBufAuthEnv(): Record<string, string> {
457
457
  const token =
458
458
  process.env.BUF_TOKEN?.trim() ||
459
459
  readVaultField(config.buf.vaultMount, config.buf.vaultPath, ["BUF_TOKEN", "buf.api_token", "buf_token", "api_token", "token"]);
460
460
  if (!token) {
461
- return;
461
+ return {};
462
462
  }
463
- run("buf", ["registry", "login", "buf.build", "--token-stdin"], { input: `${token}\n` });
463
+ return { BUF_TOKEN: token };
464
464
  }
465
465
 
466
466
  async function resolveLocalSdkPath() {
@@ -47,15 +47,12 @@ test("service sdk publish pushes the named Buf module and selects remote SDK mod
47
47
  [
48
48
  "#!/bin/sh",
49
49
  `echo "$@" >> "${bufLog}"`,
50
- 'if [ "$1 $2 $3 $4" = "registry login buf.build --token-stdin" ]; then',
51
- ` cat > "${tokenLog}"`,
52
- " exit 0",
53
- "fi",
50
+ `printf '%s' "$BUF_TOKEN" > "${tokenLog}"`,
54
51
  'if [ "$1 $2 $3 $4" = "registry module commit list" ]; then',
55
52
  ' printf \'{"commits":[{"name":"buf.build/anmho/sdk-proof:commit-123","digest":"b5:abc123","create_time":"2026-05-25T12:00:00Z"}]}\'',
56
53
  " exit 0",
57
54
  "fi",
58
- 'if [ "$1" = "push" ]; then',
55
+ 'if [ "$1 $2 $3 $4" = "push --create --create-visibility private" ]; then',
59
56
  " exit 0",
60
57
  "fi",
61
58
  "echo unexpected buf command: $@ >&2",
@@ -77,7 +74,10 @@ test("service sdk publish pushes the named Buf module and selects remote SDK mod
77
74
  expect(result.stdout.toString()).not.toContain("test-token");
78
75
  expect(result.stderr.toString()).not.toContain("test-token");
79
76
  expect((await readFile(bufLog, "utf8")).trim()).toBe(
80
- ["registry login buf.build --token-stdin", "push", "registry module commit list buf.build/anmho/sdk-proof --format json --page-size 1"].join("\n")
77
+ [
78
+ "push --create --create-visibility private",
79
+ "registry module commit list buf.build/anmho/sdk-proof --format json --page-size 1",
80
+ ].join("\n")
81
81
  );
82
82
  expect((await readFile(tokenLog, "utf8")).trim()).toBe("test-token");
83
83
  const sdkState = JSON.parse(await Bun.file(join(generatedRoot, ".service", "sdk.json")).text());