create-svc 0.1.47 → 0.1.48
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
|
@@ -2,9 +2,9 @@ import { describe, expect, test } from "bun:test";
|
|
|
2
2
|
import {
|
|
3
3
|
buildDeploymentVerificationCommands,
|
|
4
4
|
buildLocalVerificationCommands,
|
|
5
|
+
buildLocalPreparationCommands,
|
|
5
6
|
buildPostScaffoldCommands,
|
|
6
7
|
buildPreGitBootstrapCommands,
|
|
7
|
-
shouldRunLocalMigrate,
|
|
8
8
|
} from "./post-scaffold";
|
|
9
9
|
|
|
10
10
|
describe("buildPostScaffoldCommands", () => {
|
|
@@ -38,10 +38,16 @@ describe("buildPreGitBootstrapCommands", () => {
|
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
describe("
|
|
42
|
-
test("
|
|
43
|
-
expect(
|
|
44
|
-
|
|
41
|
+
describe("buildLocalPreparationCommands", () => {
|
|
42
|
+
test("starts local Postgres before migrating Workers dev", () => {
|
|
43
|
+
expect(buildLocalPreparationCommands({ target: "workers" })).toEqual([
|
|
44
|
+
{ command: "bun", args: ["run", "./scripts/ensure-local-db.ts"] },
|
|
45
|
+
{ command: "bun", args: ["run", "migrate"] },
|
|
46
|
+
]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("runs migrations directly for Cloud Run dev", () => {
|
|
50
|
+
expect(buildLocalPreparationCommands({ target: "cloudrun" })).toEqual([{ command: "bun", args: ["run", "migrate"] }]);
|
|
45
51
|
});
|
|
46
52
|
});
|
|
47
53
|
|
package/src/post-scaffold.ts
CHANGED
|
@@ -58,8 +58,8 @@ export function runPreGitBootstrapFlow(config: Pick<ScaffoldConfig, "framework">
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
async function startLocalDevelopment(config: Pick<ScaffoldConfig, "target">, cwd: string) {
|
|
61
|
-
|
|
62
|
-
run(
|
|
61
|
+
for (const command of buildLocalPreparationCommands(config)) {
|
|
62
|
+
run(command.command, command.args, { cwd });
|
|
63
63
|
}
|
|
64
64
|
await mkdir(join(cwd, ".service"), { recursive: true });
|
|
65
65
|
const child = Bun.spawn(["sh", "-c", "exec bun run dev > .service/local-dev.log 2>&1 < /dev/null"], {
|
|
@@ -74,8 +74,14 @@ async function startLocalDevelopment(config: Pick<ScaffoldConfig, "target">, cwd
|
|
|
74
74
|
await Bun.write(join(cwd, ".service", "local-dev.pid"), `${child.pid}\n`);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
export function
|
|
78
|
-
|
|
77
|
+
export function buildLocalPreparationCommands(config: Pick<ScaffoldConfig, "target">): PostScaffoldCommand[] {
|
|
78
|
+
if (config.target === "workers") {
|
|
79
|
+
return [
|
|
80
|
+
{ command: "bun", args: ["run", "./scripts/ensure-local-db.ts"] },
|
|
81
|
+
{ command: "bun", args: ["run", "migrate"] },
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
return [{ command: "bun", args: ["run", "migrate"] }];
|
|
79
85
|
}
|
|
80
86
|
|
|
81
87
|
function runWithRetries(command: PostScaffoldCommand, options: CommandOptions, attempts: number, delayMs: number) {
|
package/src/scaffold.test.ts
CHANGED
|
@@ -307,7 +307,7 @@ test("scaffolds the workers target with wrangler lifecycle commands", async () =
|
|
|
307
307
|
|
|
308
308
|
const packageJson = await Bun.file(join(generatedRoot, "package.json")).text();
|
|
309
309
|
expect(packageJson).toContain('"@anmho/authctl": "0.1.1"');
|
|
310
|
-
expect(packageJson).toContain('"dev": "wrangler dev"');
|
|
310
|
+
expect(packageJson).toContain('"dev": "bun run ./scripts/dev.ts wrangler dev"');
|
|
311
311
|
expect(packageJson).toContain('"service": "service"');
|
|
312
312
|
expect(packageJson).toContain('"auth": "service auth"');
|
|
313
313
|
expect(packageJson).toContain('"wrangler"');
|
|
@@ -8,15 +8,20 @@ if (command.length === 0) {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
await ensureLocalPostgres();
|
|
11
|
+
const localEnv = await readLocalEnv();
|
|
12
|
+
const env = {
|
|
13
|
+
...Bun.env,
|
|
14
|
+
...localEnv,
|
|
15
|
+
};
|
|
16
|
+
if (env.DATABASE_URL && !env.CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE) {
|
|
17
|
+
env.CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE = env.DATABASE_URL;
|
|
18
|
+
}
|
|
11
19
|
|
|
12
20
|
const child = Bun.spawn(command, {
|
|
13
21
|
stdin: "inherit",
|
|
14
22
|
stdout: "inherit",
|
|
15
23
|
stderr: "inherit",
|
|
16
|
-
env
|
|
17
|
-
...Bun.env,
|
|
18
|
-
...(await readLocalEnv()),
|
|
19
|
-
},
|
|
24
|
+
env,
|
|
20
25
|
});
|
|
21
26
|
|
|
22
27
|
process.exit(await child.exited);
|