create-svc 0.1.16 → 0.1.17

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.16",
3
+ "version": "0.1.17",
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",
@@ -4,16 +4,16 @@ import { buildDeploymentVerificationCommands, buildPostScaffoldCommands } from "
4
4
  describe("buildPostScaffoldCommands", () => {
5
5
  test("runs create and deploy for HTTP services", () => {
6
6
  expect(buildPostScaffoldCommands({ framework: "hono" })).toEqual([
7
- { command: "bun", args: ["run", "service", "--", "create"] },
8
- { command: "bun", args: ["run", "service", "--", "deploy"] },
7
+ { command: "bun", args: ["./scripts/cloudrun/cli.ts", "create"] },
8
+ { command: "bun", args: ["./scripts/cloudrun/cli.ts", "deploy"] },
9
9
  ]);
10
10
  });
11
11
 
12
12
  test("builds SDK artifacts before create and deploy for ConnectRPC services", () => {
13
13
  expect(buildPostScaffoldCommands({ framework: "connectrpc" })).toEqual([
14
- { command: "bun", args: ["run", "service", "--", "sdk", "build"] },
15
- { command: "bun", args: ["run", "service", "--", "create"] },
16
- { command: "bun", args: ["run", "service", "--", "deploy"] },
14
+ { command: "bun", args: ["./scripts/cloudrun/cli.ts", "sdk", "build"] },
15
+ { command: "bun", args: ["./scripts/cloudrun/cli.ts", "create"] },
16
+ { command: "bun", args: ["./scripts/cloudrun/cli.ts", "deploy"] },
17
17
  ]);
18
18
  });
19
19
  });
@@ -55,9 +55,9 @@ export function buildDeploymentVerificationCommands(
55
55
 
56
56
  export function buildPostScaffoldCommands(config: Pick<ScaffoldConfig, "framework">): PostScaffoldCommand[] {
57
57
  return [
58
- ...(config.framework === "connectrpc" ? [{ command: "bun", args: ["run", "service", "--", "sdk", "build"] }] : []),
59
- { command: "bun", args: ["run", "service", "--", "create"] },
60
- { command: "bun", args: ["run", "service", "--", "deploy"] },
58
+ ...(config.framework === "connectrpc" ? [{ command: "bun", args: ["./scripts/cloudrun/cli.ts", "sdk", "build"] }] : []),
59
+ { command: "bun", args: ["./scripts/cloudrun/cli.ts", "create"] },
60
+ { command: "bun", args: ["./scripts/cloudrun/cli.ts", "deploy"] },
61
61
  ];
62
62
  }
63
63
 
@@ -97,7 +97,7 @@ export function runAuthCommand(args: string[]) {
97
97
 
98
98
  export function ensureAuthResourceServer() {
99
99
  const command = ensureResourceServerCommandAvailable();
100
- authctl([command.subject, command.mutationAction, ...defaultAuthResourceServerArgs(), "--json"]);
100
+ authctl([command.subject, command.mutationAction, ...defaultAuthResourceServerArgs(), "--json"], { quiet: true });
101
101
  return `Auth resource server ready: ${serviceConfig.auth.resource_server.audience}`;
102
102
  }
103
103
 
@@ -107,16 +107,19 @@ export function deleteAuthResourceServer() {
107
107
  return "authctl does not expose resource-server delete; auth resource server was not deleted";
108
108
  }
109
109
 
110
- authctl([
111
- command.subject,
112
- "delete",
113
- "--resource-server",
114
- serviceConfig.auth.resource_server.id,
115
- "--stage",
116
- serviceConfig.stage_default,
117
- "--force",
118
- "--json",
119
- ]);
110
+ authctl(
111
+ [
112
+ command.subject,
113
+ "delete",
114
+ "--resource-server",
115
+ serviceConfig.auth.resource_server.id,
116
+ "--stage",
117
+ serviceConfig.stage_default,
118
+ "--force",
119
+ "--json",
120
+ ],
121
+ { quiet: true }
122
+ );
120
123
  return `Auth resource server deleted: ${serviceConfig.auth.resource_server.id}`;
121
124
  }
122
125
 
@@ -17,13 +17,13 @@ import {
17
17
  runStep,
18
18
  } from "./lib";
19
19
 
20
- export async function bootstrap() {
20
+ export async function bootstrap(options: { skipProjectSetup?: boolean } = {}) {
21
21
  requireCommand("gcloud");
22
22
  requireGcloudAuth();
23
23
 
24
- await runStep("Ensuring GCP project", () => ensureProject());
25
- await runStep("Attaching billing", () => attachBilling());
26
- await runStep("Enabling required GCP APIs", () => gcloud(["services", "enable", ...config.requiredApis, "--project", config.project.id]));
24
+ if (!options.skipProjectSetup) {
25
+ await prepareGcpProject();
26
+ }
27
27
 
28
28
  await runStep("Ensuring runtime service account", () => {
29
29
  ensureServiceAccount(config.runtimeServiceAccount);
@@ -53,6 +53,12 @@ export async function bootstrap() {
53
53
  await runStep("Publishing Temporal secrets", () => publishTemporalSecrets());
54
54
  }
55
55
 
56
+ export async function prepareGcpProject() {
57
+ await runStep("Ensuring GCP project", () => ensureProject());
58
+ await runStep("Attaching billing", () => attachBilling());
59
+ await runStep("Enabling required GCP APIs", () => gcloud(["services", "enable", ...config.requiredApis, "--project", config.project.id]));
60
+ }
61
+
56
62
  function publishTemporalSecrets() {
57
63
  const temporal = resolveTemporalRuntimeConfig();
58
64
  const apiKey = process.env.TEMPORAL_API_KEY?.trim();
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { mkdir } from "node:fs/promises";
4
4
  import { ensureAuthResourceServer, runAuthCommand, runAuthDoctor } from "../authctl";
5
- import { bootstrap } from "./bootstrap";
5
+ import { bootstrap, prepareGcpProject } from "./bootstrap";
6
6
  import { cleanup } from "./cleanup";
7
7
  import { deploy } from "./deploy";
8
8
  import { config } from "./config";
@@ -35,8 +35,9 @@ async function main(argv = Bun.argv.slice(2)) {
35
35
  await runMain("Create", async () => {
36
36
  assertServiceNameAvailable(config.serviceName);
37
37
  assertProductionDomainAvailable(config.serviceName);
38
+ await prepareGcpProject();
38
39
  await runStep("Registering auth resource server", () => ensureAuthResourceServer());
39
- await bootstrap();
40
+ await bootstrap({ skipProjectSetup: true });
40
41
  const target = resolveDeploymentTarget("main");
41
42
  const databaseUrl = await runStep("Reading production database URL", () => accessSecretVersion(target.databaseSecretName));
42
43
  await runStep("Applying production migrations", () => runLanguageTask("migrate", { DATABASE_URL: databaseUrl }));