create-svc 0.1.73 → 0.1.74
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
|
@@ -349,7 +349,8 @@ async function runSdk(args: string[]) {
|
|
|
349
349
|
if (subcommand === "publish") {
|
|
350
350
|
requireCommand("buf");
|
|
351
351
|
const authEnv = resolveBufAuthEnv();
|
|
352
|
-
|
|
352
|
+
ensureBufModule(authEnv);
|
|
353
|
+
run("buf", ["push"], { env: authEnv });
|
|
353
354
|
const published = resolvePublishedSdk(authEnv);
|
|
354
355
|
await writeSdkMode("remote", published);
|
|
355
356
|
return `Schema pushed to Buf Schema Registry and recorded for consumers: ${published.commit}`;
|
|
@@ -453,6 +454,15 @@ function bufModule() {
|
|
|
453
454
|
return config.buf.module || `buf.build/anmho/${config.serviceName}`;
|
|
454
455
|
}
|
|
455
456
|
|
|
457
|
+
function ensureBufModule(authEnv: Record<string, string>) {
|
|
458
|
+
const module = bufModule();
|
|
459
|
+
const existing = run("buf", ["registry", "module", "info", module], { env: authEnv, allowFailure: true });
|
|
460
|
+
if (existing.success) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
run("buf", ["registry", "module", "create", module, "--visibility", "private"], { env: authEnv });
|
|
464
|
+
}
|
|
465
|
+
|
|
456
466
|
function resolveBufAuthEnv(): Record<string, string> {
|
|
457
467
|
const token =
|
|
458
468
|
process.env.BUF_TOKEN?.trim() ||
|
|
@@ -48,11 +48,17 @@ 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',
|
|
52
|
+
" exit 1",
|
|
53
|
+
"fi",
|
|
54
|
+
'if [ "$1 $2 $3 $4" = "registry module create buf.build/anmho/sdk-proof" ] && [ "$5 $6" = "--visibility private" ]; then',
|
|
55
|
+
" exit 0",
|
|
56
|
+
"fi",
|
|
51
57
|
'if [ "$1 $2 $3 $4" = "registry module commit list" ]; then',
|
|
52
58
|
' printf \'{"commits":[{"name":"buf.build/anmho/sdk-proof:commit-123","digest":"b5:abc123","create_time":"2026-05-25T12:00:00Z"}]}\'',
|
|
53
59
|
" exit 0",
|
|
54
60
|
"fi",
|
|
55
|
-
'if [ "$1
|
|
61
|
+
'if [ "$1" = "push" ]; then',
|
|
56
62
|
" exit 0",
|
|
57
63
|
"fi",
|
|
58
64
|
"echo unexpected buf command: $@ >&2",
|
|
@@ -75,7 +81,9 @@ test("service sdk publish pushes the named Buf module and selects remote SDK mod
|
|
|
75
81
|
expect(result.stderr.toString()).not.toContain("test-token");
|
|
76
82
|
expect((await readFile(bufLog, "utf8")).trim()).toBe(
|
|
77
83
|
[
|
|
78
|
-
"
|
|
84
|
+
"registry module info buf.build/anmho/sdk-proof",
|
|
85
|
+
"registry module create buf.build/anmho/sdk-proof --visibility private",
|
|
86
|
+
"push",
|
|
79
87
|
"registry module commit list buf.build/anmho/sdk-proof --format json --page-size 1",
|
|
80
88
|
].join("\n")
|
|
81
89
|
);
|