buncargo 1.0.29 → 3.2.0
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/dist/bin.d.ts +1 -12
- package/dist/bin.js +261 -253
- package/dist/cli/bin.d.ts +13 -0
- package/dist/cli/bin.js +317 -0
- package/dist/cli/commands/help.d.ts +1 -0
- package/dist/cli/commands/runtime.d.ts +5 -0
- package/dist/cli/commands/version.d.ts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +14 -0
- package/dist/cli/run-cli.d.ts +30 -0
- package/dist/cli.d.ts +1 -22
- package/dist/cli.js +5 -13
- package/dist/config/config.d.ts +1 -0
- package/dist/config/define-config.d.ts +13 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +15 -0
- package/dist/config/merge-configs.d.ts +3 -0
- package/dist/config/validate-config.d.ts +3 -0
- package/dist/config.d.ts +1 -72
- package/dist/config.js +12 -12
- package/dist/core/docker.d.ts +1 -83
- package/dist/core/docker.js +35 -32
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +123 -118
- package/dist/core/network.js +2 -2
- package/dist/core/ports.js +1 -1
- package/dist/core/process.js +1 -1
- package/dist/core/quick-tunnel/cloudflared-process.d.ts +10 -0
- package/dist/core/quick-tunnel/constants.d.ts +9 -0
- package/dist/core/quick-tunnel/index.d.ts +17 -0
- package/dist/core/quick-tunnel/install.d.ts +1 -0
- package/dist/core/tunnel.d.ts +34 -0
- package/dist/core/utils.js +2 -2
- package/dist/core/watchdog-runner.js +45 -42
- package/dist/core/watchdog.d.ts +1 -0
- package/dist/core/watchdog.js +4 -2
- package/dist/docker/index.d.ts +1 -0
- package/dist/docker/index.js +38 -0
- package/dist/docker/runtime.d.ts +87 -0
- package/dist/docker/runtime.js +37 -0
- package/dist/docker-compose/compose.d.ts +1 -0
- package/dist/docker-compose/generated-file.d.ts +7 -0
- package/dist/docker-compose/index.d.ts +3 -0
- package/dist/docker-compose/index.js +15 -0
- package/dist/docker-compose/model.d.ts +6 -0
- package/dist/docker-compose/services/clickhouse.d.ts +16 -0
- package/dist/docker-compose/services/define-docker-service.d.ts +41 -0
- package/dist/docker-compose/services/index.d.ts +23 -0
- package/dist/docker-compose/services/index.js +17 -0
- package/dist/docker-compose/services/postgres.d.ts +12 -0
- package/dist/docker-compose/services/redis.d.ts +12 -0
- package/dist/docker-compose/services/shared.d.ts +7 -0
- package/dist/docker-compose/yaml.d.ts +2 -0
- package/dist/environment/create-dev-environment.d.ts +23 -0
- package/dist/environment/index.d.ts +1 -0
- package/dist/environment/index.js +15 -0
- package/dist/environment/logging.d.ts +17 -0
- package/dist/environment/only-apps.d.ts +10 -0
- package/dist/environment/seeding.d.ts +9 -0
- package/dist/environment.d.ts +1 -23
- package/dist/environment.js +12 -14
- package/dist/index-045jksh5.js +147 -0
- package/dist/index-08wa79cs.js +125 -117
- package/dist/index-0kxnae3z.js +335 -0
- package/dist/index-1mdrf7nz.js +51 -43
- package/dist/index-1yvbwj4k.js +262 -242
- package/dist/index-23ev345g.js +475 -0
- package/dist/index-2ckr49sf.js +228 -0
- package/dist/index-2f47khe5.js +376 -369
- package/dist/index-2fr3g85b.js +220 -183
- package/dist/index-38xnzpa6.js +450 -0
- package/dist/index-3eyrdxw9.js +577 -0
- package/dist/index-3h3dhtf2.js +51 -43
- package/dist/index-42x95209.js +51 -43
- package/dist/index-4gp0az1g.js +145 -0
- package/dist/index-4xrxh8yv.js +72 -0
- package/dist/index-5aq985p4.js +250 -0
- package/dist/index-5gmws6ah.js +181 -0
- package/dist/index-5hka0tff.js +78 -76
- package/dist/index-5rfqps4b.js +3 -0
- package/dist/index-5t9jxqm0.js +428 -0
- package/dist/index-6c1w1xk5.js +101 -0
- package/dist/index-6cmex7m5.js +72 -0
- package/dist/index-6d6x175r.js +572 -0
- package/dist/index-6fm7mvwj.js +118 -97
- package/dist/index-6srpc523.js +127 -128
- package/dist/index-731rzzfp.js +157 -142
- package/dist/index-75y4cg2z.js +51 -43
- package/dist/index-7ja4ywyj.js +126 -127
- package/dist/index-7v19es2e.js +666 -0
- package/dist/index-8bw1cmz4.js +531 -0
- package/dist/index-8hbbj1mp.js +120 -121
- package/dist/index-8xj2p5n5.js +118 -97
- package/dist/index-9wyhzw0h.js +574 -0
- package/dist/index-ag90ry8t.js +576 -0
- package/dist/index-bj79tw5w.js +0 -0
- package/dist/index-bnk6nr0g.js +73 -0
- package/dist/index-brbbzyks.js +72 -0
- package/dist/index-byeqyjrz.js +72 -0
- package/dist/index-c0dr6mcv.js +123 -0
- package/dist/index-cty0bcry.js +235 -218
- package/dist/index-d8tyv5se.js +228 -0
- package/dist/index-d9efy0n4.js +176 -150
- package/dist/index-enj4zdma.js +574 -0
- package/dist/index-etfmqjjf.js +427 -0
- package/dist/index-fb29934k.js +172 -0
- package/dist/index-g50jw1yf.js +72 -0
- package/dist/index-g6eb5wdw.js +118 -117
- package/dist/index-ggq3yryx.js +99 -95
- package/dist/index-h70tce00.js +177 -0
- package/dist/index-hkxtfqtc.js +333 -0
- package/dist/index-k370bech.js +72 -0
- package/dist/index-kf3dhser.js +146 -143
- package/dist/index-ma6tgdb2.js +500 -0
- package/dist/index-mam0bcyz.js +123 -0
- package/dist/index-mm412dkp.js +274 -0
- package/dist/index-n8v18aeb.js +0 -0
- package/dist/index-ndnmnsej.js +378 -371
- package/dist/index-p8wty0e2.js +389 -379
- package/dist/index-qa8akv6y.js +666 -0
- package/dist/index-qfphr2fd.js +78 -76
- package/dist/index-qqmms8rs.js +51 -43
- package/dist/index-qw4093g2.js +51 -43
- package/dist/index-qzwpzjbx.js +121 -122
- package/dist/index-segbnm0h.js +146 -143
- package/dist/index-t0fj6gg1.js +112 -0
- package/dist/index-thdkwnv7.js +122 -0
- package/dist/index-tjbx2r2t.js +270 -0
- package/dist/index-tjqw9vtj.js +62 -54
- package/dist/index-vbpb89jy.js +248 -0
- package/dist/index-vg55rq0y.js +250 -0
- package/dist/index-vhs88xhe.js +99 -95
- package/dist/index-vs81yaks.js +244 -0
- package/dist/index-w8zxnjka.js +249 -0
- package/dist/index-wk2na3t9.js +385 -375
- package/dist/index-wz9x8g7z.js +383 -373
- package/dist/index-x249gyde.js +388 -378
- package/dist/index-x54nbgs7.js +355 -0
- package/dist/index-xkvd0nsd.js +187 -0
- package/dist/index-yedqxm1z.js +80 -0
- package/dist/index-yz4jfz7z.js +338 -0
- package/dist/index-zfjzzjkf.js +240 -199
- package/dist/index.d.ts +12 -8
- package/dist/index.js +56 -34
- package/dist/lint.d.ts +1 -46
- package/dist/lint.js +3 -7
- package/dist/loader/cache.d.ts +4 -0
- package/dist/loader/find-config-file.d.ts +2 -0
- package/dist/loader/index.d.ts +5 -0
- package/dist/loader/index.js +24 -0
- package/dist/loader/load-dev-env.d.ts +5 -0
- package/dist/loader/loader.d.ts +1 -0
- package/dist/loader.d.ts +1 -45
- package/dist/loader.js +22 -20
- package/dist/prisma/index.d.ts +1 -0
- package/dist/prisma/prisma.d.ts +29 -0
- package/dist/prisma.d.ts +1 -29
- package/dist/prisma.js +6 -10
- package/dist/src/bin.js +309 -0
- package/dist/src/cli.js +5 -0
- package/dist/src/config.js +15 -0
- package/dist/src/core/docker.js +38 -0
- package/dist/src/core/index.js +130 -0
- package/dist/src/core/network.js +9 -0
- package/dist/src/core/ports.js +23 -0
- package/dist/src/core/process.js +31 -0
- package/dist/src/core/utils.js +11 -0
- package/dist/src/core/watchdog-runner.js +69 -0
- package/dist/src/core/watchdog.js +28 -0
- package/dist/src/docker/runtime.js +37 -0
- package/dist/src/docker-compose/index.js +16 -0
- package/dist/src/docker-compose/services/index.js +17 -0
- package/dist/src/environment.js +12 -0
- package/dist/src/index.js +122 -0
- package/dist/src/lint.js +3 -0
- package/dist/src/loader.js +25 -0
- package/dist/src/prisma.js +6 -0
- package/dist/src/types.js +0 -0
- package/dist/typecheck/index.d.ts +1 -0
- package/dist/typecheck/index.js +7 -0
- package/dist/typecheck/typecheck.d.ts +46 -0
- package/dist/types/all-types.d.ts +544 -0
- package/dist/types/cli.d.ts +1 -0
- package/dist/types/config.d.ts +6 -0
- package/dist/types/docker.d.ts +15 -0
- package/dist/types/environment.d.ts +8 -0
- package/dist/types/hooks.d.ts +9 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +0 -0
- package/dist/types/prisma.d.ts +1 -0
- package/dist/types.d.ts +1 -399
- package/package.json +55 -48
- package/readme.md +365 -109
- package/src/cli/bin.ts +77 -0
- package/src/cli/commands/help.ts +39 -0
- package/src/cli/commands/runtime.ts +72 -0
- package/src/cli/commands/version.ts +4 -0
- package/src/cli/index.ts +1 -0
- package/{cli.ts → src/cli/run-cli.ts} +114 -10
- package/src/config/define-config.ts +30 -0
- package/src/config/index.ts +3 -0
- package/src/config/merge-configs.ts +33 -0
- package/src/config/validate-config.ts +136 -0
- package/{core → src/core}/index.ts +2 -2
- package/{core → src/core}/ports.ts +5 -2
- package/{core → src/core}/process.ts +6 -2
- package/src/core/quick-tunnel/cloudflared-process.ts +83 -0
- package/src/core/quick-tunnel/constants.ts +31 -0
- package/src/core/quick-tunnel/index.ts +96 -0
- package/src/core/quick-tunnel/install.ts +160 -0
- package/src/core/tunnel.ts +165 -0
- package/{core → src/core}/utils.ts +1 -0
- package/{core → src/core}/watchdog.ts +5 -1
- package/src/docker/index.ts +1 -0
- package/{core/docker.ts → src/docker/runtime.ts} +11 -4
- package/src/docker-compose/generated-file.ts +45 -0
- package/src/docker-compose/index.ts +7 -0
- package/src/docker-compose/model.ts +197 -0
- package/src/docker-compose/services/clickhouse.ts +79 -0
- package/src/docker-compose/services/define-docker-service.ts +109 -0
- package/src/docker-compose/services/index.ts +67 -0
- package/src/docker-compose/services/postgres.ts +60 -0
- package/src/docker-compose/services/redis.ts +48 -0
- package/src/docker-compose/services/shared.ts +79 -0
- package/src/docker-compose/yaml.ts +88 -0
- package/{environment.ts → src/environment/create-dev-environment.ts} +214 -141
- package/src/environment/index.ts +1 -0
- package/src/environment/logging.ts +115 -0
- package/src/environment/only-apps.ts +34 -0
- package/src/environment/seeding.ts +57 -0
- package/{index.ts → src/index.ts} +52 -20
- package/src/loader/cache.ts +23 -0
- package/src/loader/find-config-file.ts +29 -0
- package/src/loader/index.ts +17 -0
- package/src/loader/load-dev-env.ts +38 -0
- package/src/prisma/index.ts +1 -0
- package/{prisma.ts → src/prisma/prisma.ts} +4 -2
- package/src/typecheck/index.ts +1 -0
- package/{types.ts → src/types/all-types.ts} +186 -8
- package/src/types/index.ts +1 -0
- package/bin.ts +0 -192
- package/config.ts +0 -194
- package/loader.ts +0 -126
- /package/{core → src/core}/network.ts +0 -0
- /package/{core → src/core}/watchdog-runner.ts +0 -0
- /package/{lint.ts → src/typecheck/typecheck.ts} +0 -0
package/dist/index-qfphr2fd.js
CHANGED
|
@@ -1,55 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isContainerRunning,
|
|
3
|
-
startService,
|
|
4
|
-
waitForServiceByType
|
|
5
|
-
} from "./index-zfjzzjkf.js";
|
|
6
|
-
|
|
7
1
|
// prisma.ts
|
|
8
2
|
import { spawn } from "node:child_process";
|
|
9
3
|
import { join } from "node:path";
|
|
4
|
+
import {
|
|
5
|
+
isContainerRunning,
|
|
6
|
+
startService,
|
|
7
|
+
waitForServiceByType,
|
|
8
|
+
} from "./index-zfjzzjkf.js";
|
|
9
|
+
|
|
10
10
|
function createPrismaRunner(env, config) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
11
|
+
const {
|
|
12
|
+
cwd = "packages/prisma",
|
|
13
|
+
service = "postgres",
|
|
14
|
+
urlEnvVar = "DATABASE_URL",
|
|
15
|
+
} = config;
|
|
16
|
+
const healthCheckTypes = {
|
|
17
|
+
postgres: "pg_isready",
|
|
18
|
+
redis: "redis-cli",
|
|
19
|
+
clickhouse: "http",
|
|
20
|
+
};
|
|
21
|
+
function getDatabaseUrl() {
|
|
22
|
+
const envVars = env.buildEnvVars();
|
|
23
|
+
const url = envVars[urlEnvVar];
|
|
24
|
+
if (!url) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`Environment variable ${urlEnvVar} not found. Make sure your dev config defines it in envVars.`,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return url;
|
|
30
|
+
}
|
|
31
|
+
async function ensureDatabase() {
|
|
32
|
+
const alreadyRunning = await isContainerRunning(env.projectName, service);
|
|
33
|
+
if (alreadyRunning) {
|
|
34
|
+
console.log(`✓ ${service} already running`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
console.log(`\uD83D\uDC33 Starting ${service}...`);
|
|
38
|
+
const envVars = env.buildEnvVars();
|
|
39
|
+
startService(env.root, env.projectName, service, envVars, {
|
|
40
|
+
verbose: false,
|
|
41
|
+
});
|
|
42
|
+
const port = env.ports[service];
|
|
43
|
+
if (!port) {
|
|
44
|
+
throw new Error(`Service ${service} not found in dev environment ports`);
|
|
45
|
+
}
|
|
46
|
+
const healthCheckType = healthCheckTypes[service] ?? "tcp";
|
|
47
|
+
console.log(`⏳ Waiting for ${service} to be healthy...`);
|
|
48
|
+
await waitForServiceByType(service, healthCheckType, port, {
|
|
49
|
+
verbose: true,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async function run(args) {
|
|
53
|
+
if (args.length === 0) {
|
|
54
|
+
console.log(`
|
|
53
55
|
Usage: bun prisma <command> [args...]
|
|
54
56
|
|
|
55
57
|
Examples:
|
|
@@ -59,40 +61,40 @@ Examples:
|
|
|
59
61
|
bun prisma studio # Open Prisma Studio
|
|
60
62
|
bun prisma migrate reset # Reset database
|
|
61
63
|
`);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
const port = env.ports[service];
|
|
67
|
+
console.log(`
|
|
66
68
|
\uD83D\uDD27 Prisma CLI
|
|
67
69
|
Project: ${env.projectName}
|
|
68
70
|
Database: localhost:${port}
|
|
69
71
|
${env.portOffset > 0 ? `(port offset +${env.portOffset})` : ""}
|
|
70
72
|
`);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
await ensureDatabase();
|
|
74
|
+
const envVars = env.buildEnvVars();
|
|
75
|
+
const workingDir = join(env.root, cwd);
|
|
76
|
+
const fullEnv = {
|
|
77
|
+
...process.env,
|
|
78
|
+
...envVars,
|
|
79
|
+
[urlEnvVar]: getDatabaseUrl(),
|
|
80
|
+
};
|
|
81
|
+
console.log(`\uD83D\uDD04 Running: prisma ${args.join(" ")}
|
|
80
82
|
`);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
83
|
+
return new Promise((resolve) => {
|
|
84
|
+
const proc = spawn("bunx", ["prisma", ...args], {
|
|
85
|
+
cwd: workingDir,
|
|
86
|
+
env: fullEnv,
|
|
87
|
+
stdio: "inherit",
|
|
88
|
+
});
|
|
89
|
+
proc.on("close", (code) => {
|
|
90
|
+
resolve(code ?? 0);
|
|
91
|
+
});
|
|
92
|
+
proc.on("error", () => {
|
|
93
|
+
resolve(1);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return { run, getDatabaseUrl, ensureDatabase };
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
export { createPrismaRunner };
|
package/dist/index-qqmms8rs.js
CHANGED
|
@@ -1,58 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createDevEnvironment
|
|
3
|
-
} from "./index-x249gyde.js";
|
|
4
|
-
|
|
5
1
|
// loader.ts
|
|
6
2
|
import { existsSync } from "node:fs";
|
|
7
3
|
import { dirname, join } from "node:path";
|
|
4
|
+
import { createDevEnvironment } from "./index-x249gyde.js";
|
|
5
|
+
|
|
8
6
|
var CONFIG_FILES = [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
"dev.config.ts",
|
|
8
|
+
"dev.config.js",
|
|
9
|
+
"dev-tools.config.ts",
|
|
10
|
+
"dev-tools.config.js",
|
|
13
11
|
];
|
|
14
12
|
function findConfigFile(startDir) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
let currentDir = startDir;
|
|
14
|
+
while (true) {
|
|
15
|
+
for (const file of CONFIG_FILES) {
|
|
16
|
+
const configPath = join(currentDir, file);
|
|
17
|
+
if (existsSync(configPath)) {
|
|
18
|
+
return configPath;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const parentDir = dirname(currentDir);
|
|
22
|
+
if (parentDir === currentDir) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
currentDir = parentDir;
|
|
26
|
+
}
|
|
29
27
|
}
|
|
30
28
|
var cachedEnv = null;
|
|
31
29
|
async function loadDevEnv(options) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
if (cachedEnv && !options?.reload) {
|
|
31
|
+
return cachedEnv;
|
|
32
|
+
}
|
|
33
|
+
const cwd = options?.cwd ?? process.cwd();
|
|
34
|
+
const configPath = findConfigFile(cwd);
|
|
35
|
+
if (configPath) {
|
|
36
|
+
const mod = await import(configPath);
|
|
37
|
+
const config = mod.default;
|
|
38
|
+
if (!config?.projectPrefix || !config?.services) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`Invalid config in "${configPath}". Use defineDevConfig() and export as default.`,
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
cachedEnv = createDevEnvironment(config);
|
|
44
|
+
return cachedEnv;
|
|
45
|
+
}
|
|
46
|
+
throw new Error(
|
|
47
|
+
`No config file found. Create dev.config.ts with: export default defineDevConfig({ ... })`,
|
|
48
|
+
);
|
|
47
49
|
}
|
|
48
50
|
function getDevEnv() {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
if (!cachedEnv) {
|
|
52
|
+
throw new Error("Dev environment not loaded. Call loadDevEnv() first.");
|
|
53
|
+
}
|
|
54
|
+
return cachedEnv;
|
|
53
55
|
}
|
|
54
56
|
function clearDevEnvCache() {
|
|
55
|
-
|
|
57
|
+
cachedEnv = null;
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
export {
|
|
60
|
+
export {
|
|
61
|
+
CONFIG_FILES,
|
|
62
|
+
findConfigFile,
|
|
63
|
+
loadDevEnv,
|
|
64
|
+
getDevEnv,
|
|
65
|
+
clearDevEnvCache,
|
|
66
|
+
};
|
package/dist/index-qw4093g2.js
CHANGED
|
@@ -1,58 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createDevEnvironment
|
|
3
|
-
} from "./index-2f47khe5.js";
|
|
4
|
-
|
|
5
1
|
// loader.ts
|
|
6
2
|
import { existsSync } from "node:fs";
|
|
7
3
|
import { dirname, join } from "node:path";
|
|
4
|
+
import { createDevEnvironment } from "./index-2f47khe5.js";
|
|
5
|
+
|
|
8
6
|
var CONFIG_FILES = [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
"dev.config.ts",
|
|
8
|
+
"dev.config.js",
|
|
9
|
+
"dev-tools.config.ts",
|
|
10
|
+
"dev-tools.config.js",
|
|
13
11
|
];
|
|
14
12
|
function findConfigFile(startDir) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
let currentDir = startDir;
|
|
14
|
+
while (true) {
|
|
15
|
+
for (const file of CONFIG_FILES) {
|
|
16
|
+
const configPath = join(currentDir, file);
|
|
17
|
+
if (existsSync(configPath)) {
|
|
18
|
+
return configPath;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const parentDir = dirname(currentDir);
|
|
22
|
+
if (parentDir === currentDir) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
currentDir = parentDir;
|
|
26
|
+
}
|
|
29
27
|
}
|
|
30
28
|
var cachedEnv = null;
|
|
31
29
|
async function loadDevEnv(options) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
if (cachedEnv && !options?.reload) {
|
|
31
|
+
return cachedEnv;
|
|
32
|
+
}
|
|
33
|
+
const cwd = options?.cwd ?? process.cwd();
|
|
34
|
+
const configPath = findConfigFile(cwd);
|
|
35
|
+
if (configPath) {
|
|
36
|
+
const mod = await import(configPath);
|
|
37
|
+
const config = mod.default;
|
|
38
|
+
if (!config?.projectPrefix || !config?.services) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`Invalid config in "${configPath}". Use defineDevConfig() and export as default.`,
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
cachedEnv = createDevEnvironment(config);
|
|
44
|
+
return cachedEnv;
|
|
45
|
+
}
|
|
46
|
+
throw new Error(
|
|
47
|
+
`No config file found. Create dev.config.ts with: export default defineDevConfig({ ... })`,
|
|
48
|
+
);
|
|
47
49
|
}
|
|
48
50
|
function getDevEnv() {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
if (!cachedEnv) {
|
|
52
|
+
throw new Error("Dev environment not loaded. Call loadDevEnv() first.");
|
|
53
|
+
}
|
|
54
|
+
return cachedEnv;
|
|
53
55
|
}
|
|
54
56
|
function clearDevEnvCache() {
|
|
55
|
-
|
|
57
|
+
cachedEnv = null;
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
export {
|
|
60
|
+
export {
|
|
61
|
+
CONFIG_FILES,
|
|
62
|
+
findConfigFile,
|
|
63
|
+
loadDevEnv,
|
|
64
|
+
getDevEnv,
|
|
65
|
+
clearDevEnvCache,
|
|
66
|
+
};
|
package/dist/index-qzwpzjbx.js
CHANGED
|
@@ -1,137 +1,136 @@
|
|
|
1
|
+
// cli.ts
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { killProcessesOnAppPorts } from "./index-1yvbwj4k.js";
|
|
1
4
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
spawnWatchdog,
|
|
6
|
+
startHeartbeat,
|
|
7
|
+
stopHeartbeat,
|
|
5
8
|
} from "./index-ggq3yryx.js";
|
|
6
|
-
import {
|
|
7
|
-
killProcessesOnAppPorts
|
|
8
|
-
} from "./index-1yvbwj4k.js";
|
|
9
9
|
|
|
10
|
-
// cli.ts
|
|
11
|
-
import { spawn } from "node:child_process";
|
|
12
10
|
async function runCli(env, options = {}) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
11
|
+
const {
|
|
12
|
+
args = process.argv.slice(2),
|
|
13
|
+
watchdog = true,
|
|
14
|
+
watchdogTimeout = 10,
|
|
15
|
+
devServersCommand,
|
|
16
|
+
} = options;
|
|
17
|
+
env.logInfo();
|
|
18
|
+
if (args.includes("--down")) {
|
|
19
|
+
await env.stop();
|
|
20
|
+
process.exit(0);
|
|
21
|
+
}
|
|
22
|
+
if (args.includes("--reset")) {
|
|
23
|
+
await env.stop({ removeVolumes: true });
|
|
24
|
+
process.exit(0);
|
|
25
|
+
}
|
|
26
|
+
await env.start({ startServers: false, wait: true });
|
|
27
|
+
if (args.includes("--migrate")) {
|
|
28
|
+
console.log("");
|
|
29
|
+
console.log("✅ Migrations applied successfully");
|
|
30
|
+
process.exit(0);
|
|
31
|
+
}
|
|
32
|
+
if (args.includes("--seed")) {
|
|
33
|
+
console.log("\uD83C\uDF31 Running seeders...");
|
|
34
|
+
const result = await env.exec("bun run run:seeder", {
|
|
35
|
+
throwOnError: false,
|
|
36
|
+
});
|
|
37
|
+
if (result.exitCode !== 0) {
|
|
38
|
+
console.error("❌ Seeding failed");
|
|
39
|
+
if (result.stderr) {
|
|
40
|
+
console.error(result.stderr);
|
|
41
|
+
}
|
|
42
|
+
if (result.stdout) {
|
|
43
|
+
console.error(result.stdout);
|
|
44
|
+
}
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
console.log("");
|
|
48
|
+
console.log("✅ Seeding complete");
|
|
49
|
+
process.exit(0);
|
|
50
|
+
}
|
|
51
|
+
if (args.includes("--up-only")) {
|
|
52
|
+
console.log("");
|
|
53
|
+
console.log("✅ Containers started. Environment ready.");
|
|
54
|
+
console.log("");
|
|
55
|
+
process.exit(0);
|
|
56
|
+
}
|
|
57
|
+
if (watchdog) {
|
|
58
|
+
await spawnWatchdog(env.projectName, env.root, {
|
|
59
|
+
timeoutMinutes: watchdogTimeout,
|
|
60
|
+
verbose: true,
|
|
61
|
+
});
|
|
62
|
+
startHeartbeat(env.projectName);
|
|
63
|
+
}
|
|
64
|
+
const command = devServersCommand ?? buildDevServersCommand(env.apps);
|
|
65
|
+
if (!command) {
|
|
66
|
+
console.log("✅ Containers ready. No apps configured.");
|
|
67
|
+
await new Promise(() => {});
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
await killProcessesOnAppPorts(env.apps, env.ports);
|
|
71
|
+
console.log("");
|
|
72
|
+
console.log("\uD83D\uDD27 Starting dev servers...");
|
|
73
|
+
console.log("");
|
|
74
|
+
await runCommand(command, env.root, env.buildEnvVars());
|
|
75
|
+
stopHeartbeat();
|
|
78
76
|
}
|
|
79
77
|
function buildDevServersCommand(apps) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
78
|
+
const appEntries = Object.entries(apps);
|
|
79
|
+
if (appEntries.length === 0) return null;
|
|
80
|
+
const commands = [];
|
|
81
|
+
const names = [];
|
|
82
|
+
const colors = ["blue", "green", "yellow", "magenta", "cyan", "red"];
|
|
83
|
+
for (const [name, config] of appEntries) {
|
|
84
|
+
names.push(name);
|
|
85
|
+
const cwdPart = config.cwd ? `--cwd ${config.cwd}` : "";
|
|
86
|
+
commands.push(
|
|
87
|
+
`"bun run ${cwdPart} ${config.devCommand}"`.replace(/\s+/g, " ").trim(),
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
const namesArg = `-n ${names.join(",")}`;
|
|
91
|
+
const colorsArg = `-c ${colors.slice(0, names.length).join(",")}`;
|
|
92
|
+
const commandsArg = commands.join(" ");
|
|
93
|
+
return `bun concurrently ${namesArg} ${colorsArg} ${commandsArg}`;
|
|
95
94
|
}
|
|
96
95
|
function runCommand(command, cwd, envVars) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
97
|
+
const proc = spawn(command, [], {
|
|
98
|
+
cwd,
|
|
99
|
+
env: { ...process.env, ...envVars },
|
|
100
|
+
stdio: "inherit",
|
|
101
|
+
shell: true,
|
|
102
|
+
});
|
|
103
|
+
proc.on("close", (code) => {
|
|
104
|
+
if (code === 0 || code === null) {
|
|
105
|
+
resolve();
|
|
106
|
+
} else {
|
|
107
|
+
reject(new Error(`Command exited with code ${code}`));
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
proc.on("error", reject);
|
|
111
|
+
const cleanup = () => {
|
|
112
|
+
proc.kill("SIGTERM");
|
|
113
|
+
};
|
|
114
|
+
process.on("SIGINT", cleanup);
|
|
115
|
+
process.on("SIGTERM", cleanup);
|
|
116
|
+
});
|
|
118
117
|
}
|
|
119
118
|
function hasFlag(args, flag) {
|
|
120
|
-
|
|
119
|
+
return args.includes(flag);
|
|
121
120
|
}
|
|
122
121
|
function getFlagValue(args, flag) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
122
|
+
const prefixed = args.find((arg) => arg.startsWith(`${flag}=`));
|
|
123
|
+
if (prefixed) {
|
|
124
|
+
return prefixed.split("=")[1];
|
|
125
|
+
}
|
|
126
|
+
const index = args.indexOf(flag);
|
|
127
|
+
if (index !== -1 && index + 1 < args.length) {
|
|
128
|
+
const nextArg = args[index + 1];
|
|
129
|
+
if (nextArg !== undefined && !nextArg.startsWith("-")) {
|
|
130
|
+
return nextArg;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return;
|
|
135
134
|
}
|
|
136
135
|
|
|
137
136
|
export { runCli, hasFlag, getFlagValue };
|