create-svc 0.1.75 → 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 +1 -1
- package/src/service-runtime/cloudrun/cli.ts +15 -0
- package/src/service.test.ts +6 -0
- package/src/service.ts +15 -1
package/package.json
CHANGED
|
@@ -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");
|
package/src/service.test.ts
CHANGED
|
@@ -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)) {
|