create-svc 0.1.73 → 0.1.75
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 +1 -1
- package/src/scaffold.test.ts +2 -2
- package/src/service-runtime/cloudrun/cli.ts +12 -2
- package/src/service-runtime/cloudrun/config.ts +1 -1
- package/src/service-runtime/cloudrun/sdk.test.ts +19 -11
- package/templates/shared/service.jsonc +1 -1
- package/templates/variants/go-connectrpc/buf.yaml +1 -1
package/package.json
CHANGED
package/src/scaffold.test.ts
CHANGED
|
@@ -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");
|
|
@@ -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}`;
|
|
@@ -450,7 +451,16 @@ async function writeSdkMode(mode: "local" | "remote", published?: PublishedSdk)
|
|
|
450
451
|
}
|
|
451
452
|
|
|
452
453
|
function bufModule() {
|
|
453
|
-
return config.buf.module || `buf.build/anmho/${config.serviceName}`;
|
|
454
|
+
return config.buf.module || `buf.build/anmho-services/${config.serviceName}`;
|
|
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 });
|
|
454
464
|
}
|
|
455
465
|
|
|
456
466
|
function resolveBufAuthEnv(): 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,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-services/sdk-proof" ]; then',
|
|
52
|
+
" exit 1",
|
|
53
|
+
"fi",
|
|
54
|
+
'if [ "$1 $2 $3 $4" = "registry module create buf.build/anmho-services/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
|
-
' 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"}]}\'',
|
|
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,15 +81,17 @@ 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
|
-
"
|
|
79
|
-
"registry module
|
|
84
|
+
"registry module info buf.build/anmho-services/sdk-proof",
|
|
85
|
+
"registry module create buf.build/anmho-services/sdk-proof --visibility private",
|
|
86
|
+
"push",
|
|
87
|
+
"registry module commit list buf.build/anmho-services/sdk-proof --format json --page-size 1",
|
|
80
88
|
].join("\n")
|
|
81
89
|
);
|
|
82
90
|
expect((await readFile(tokenLog, "utf8")).trim()).toBe("test-token");
|
|
83
91
|
const sdkState = JSON.parse(await Bun.file(join(generatedRoot, ".service", "sdk.json")).text());
|
|
84
92
|
expect(sdkState).toMatchObject({
|
|
85
93
|
mode: "remote",
|
|
86
|
-
module: "buf.build/anmho/sdk-proof",
|
|
94
|
+
module: "buf.build/anmho-services/sdk-proof",
|
|
87
95
|
localPath: "./gen/waitlist/v1",
|
|
88
96
|
remote: {
|
|
89
97
|
commit: "commit-123",
|
|
@@ -92,7 +100,7 @@ test("service sdk publish pushes the named Buf module and selects remote SDK mod
|
|
|
92
100
|
},
|
|
93
101
|
});
|
|
94
102
|
const bufConfig = await Bun.file(join(generatedRoot, "buf.yaml")).text();
|
|
95
|
-
expect(bufConfig).toContain("name: buf.build/anmho/sdk-proof");
|
|
103
|
+
expect(bufConfig).toContain("name: buf.build/anmho-services/sdk-proof");
|
|
96
104
|
});
|
|
97
105
|
|
|
98
106
|
test("formatSdkModeDetail reports the recorded remote SDK commit", () => {
|
|
@@ -100,15 +108,15 @@ test("formatSdkModeDetail reports the recorded remote SDK commit", () => {
|
|
|
100
108
|
formatSdkModeDetail(
|
|
101
109
|
{
|
|
102
110
|
mode: "remote",
|
|
103
|
-
module: "buf.build/anmho/sdk-proof",
|
|
111
|
+
module: "buf.build/anmho-services/sdk-proof",
|
|
104
112
|
remote: {
|
|
105
113
|
commit: "commit-123",
|
|
106
114
|
digest: "b5:abc123",
|
|
107
115
|
},
|
|
108
116
|
},
|
|
109
|
-
"buf.build/anmho/fallback"
|
|
117
|
+
"buf.build/anmho-services/fallback"
|
|
110
118
|
)
|
|
111
|
-
).toBe("remote: buf.build/anmho/sdk-proof@commit-123 (b5:abc123)");
|
|
119
|
+
).toBe("remote: buf.build/anmho-services/sdk-proof@commit-123 (b5:abc123)");
|
|
112
120
|
});
|
|
113
121
|
|
|
114
122
|
test("service sdk use-remote records the current Buf commit", async () => {
|
|
@@ -124,7 +132,7 @@ test("service sdk use-remote records the current Buf commit", async () => {
|
|
|
124
132
|
[
|
|
125
133
|
"#!/bin/sh",
|
|
126
134
|
'if [ "$1 $2 $3 $4" = "registry module commit list" ]; then',
|
|
127
|
-
' 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"}]}\'',
|
|
128
136
|
"fi",
|
|
129
137
|
"exit 0",
|
|
130
138
|
"",
|
|
@@ -164,7 +172,7 @@ test("service sdk publish leaves local SDK mode when Buf push fails", async () =
|
|
|
164
172
|
`${JSON.stringify(
|
|
165
173
|
{
|
|
166
174
|
mode: "local",
|
|
167
|
-
module: "buf.build/anmho/sdk-proof",
|
|
175
|
+
module: "buf.build/anmho-services/sdk-proof",
|
|
168
176
|
localPath: "./gen/waitlist/v1",
|
|
169
177
|
updatedAt: "2026-05-25T00:00:00.000Z",
|
|
170
178
|
},
|