buncargo 1.0.29 → 3.0.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 +315 -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 +22 -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/tunnel.d.ts +33 -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/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-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-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-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-8bw1cmz4.js +531 -0
- package/dist/index-8hbbj1mp.js +120 -121
- package/dist/index-8xj2p5n5.js +118 -97
- package/dist/index-bj79tw5w.js +0 -0
- package/dist/index-bnk6nr0g.js +73 -0
- package/dist/index-brbbzyks.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-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-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-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-vhs88xhe.js +99 -95
- 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-xkvd0nsd.js +187 -0
- package/dist/index-yedqxm1z.js +80 -0
- package/dist/index-zfjzzjkf.js +240 -199
- package/dist/index.d.ts +12 -8
- package/dist/index.js +56 -35
- 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 +501 -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 +145 -140
- package/readme.md +349 -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} +95 -6
- 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/tunnel.ts +151 -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} +93 -130
- package/src/environment/index.ts +1 -0
- package/src/environment/logging.ts +101 -0
- package/src/environment/seeding.ts +57 -0
- package/{index.ts → src/index.ts} +49 -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} +130 -5
- 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-zfjzzjkf.js
CHANGED
|
@@ -1,225 +1,266 @@
|
|
|
1
|
-
import {
|
|
2
|
-
sleep
|
|
3
|
-
} from "./index-8xj2p5n5.js";
|
|
4
|
-
|
|
5
1
|
// core/docker.ts
|
|
6
2
|
import { execSync } from "node:child_process";
|
|
3
|
+
import { sleep } from "./index-8xj2p5n5.js";
|
|
4
|
+
|
|
7
5
|
var POLL_INTERVAL = 250;
|
|
8
6
|
var MAX_ATTEMPTS = 120;
|
|
9
|
-
var DOCKER_NOT_RUNNING_MESSAGE =
|
|
7
|
+
var DOCKER_NOT_RUNNING_MESSAGE =
|
|
8
|
+
"Docker is not running. Please start Docker and try again.";
|
|
10
9
|
async function isContainerRunning(project, service) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
try {
|
|
11
|
+
const result = execSync(
|
|
12
|
+
`docker ps --filter "label=com.docker.compose.project=${project}" --filter "label=com.docker.compose.service=${service}" --format "{{.State}}"`,
|
|
13
|
+
{ encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] },
|
|
14
|
+
);
|
|
15
|
+
return result.trim() === "running";
|
|
16
|
+
} catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
17
19
|
}
|
|
18
20
|
function isDockerRunning() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
try {
|
|
22
|
+
execSync('docker info --format "{{.ServerVersion}}"', {
|
|
23
|
+
encoding: "utf-8",
|
|
24
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
25
|
+
});
|
|
26
|
+
return true;
|
|
27
|
+
} catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
28
30
|
}
|
|
29
31
|
function assertDockerRunning() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
if (!isDockerRunning()) {
|
|
33
|
+
throw new Error(DOCKER_NOT_RUNNING_MESSAGE);
|
|
34
|
+
}
|
|
33
35
|
}
|
|
34
36
|
async function areContainersRunning(project, minCount = 1) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
try {
|
|
38
|
+
const result = execSync(
|
|
39
|
+
`docker ps --filter "label=com.docker.compose.project=${project}" --format "{{.State}}"`,
|
|
40
|
+
{ encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] },
|
|
41
|
+
);
|
|
42
|
+
const states = result
|
|
43
|
+
.trim()
|
|
44
|
+
.split(`
|
|
45
|
+
`)
|
|
46
|
+
.filter(Boolean);
|
|
47
|
+
if (states.length < minCount) return false;
|
|
48
|
+
return states.every((state) => state === "running");
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
45
52
|
}
|
|
46
53
|
function startContainers(root, projectName, envVars, options = {}) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (verbose)
|
|
60
|
-
console.log("✓ Containers started");
|
|
54
|
+
const { verbose = true, wait = true, composeFile } = options;
|
|
55
|
+
assertDockerRunning();
|
|
56
|
+
if (verbose) console.log("\uD83D\uDC33 Starting Docker containers...");
|
|
57
|
+
const composeArg = composeFile ? `-f ${composeFile}` : "";
|
|
58
|
+
const waitFlag = wait ? "--wait" : "";
|
|
59
|
+
const cmd = `docker compose ${composeArg} up -d ${waitFlag}`.trim();
|
|
60
|
+
execSync(cmd, {
|
|
61
|
+
cwd: root,
|
|
62
|
+
env: { ...process.env, ...envVars, COMPOSE_PROJECT_NAME: projectName },
|
|
63
|
+
stdio: verbose ? "inherit" : "ignore",
|
|
64
|
+
});
|
|
65
|
+
if (verbose) console.log("✓ Containers started");
|
|
61
66
|
}
|
|
62
67
|
function stopContainers(root, projectName, options = {}) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
const { verbose = true, removeVolumes = false, composeFile } = options;
|
|
69
|
+
assertDockerRunning();
|
|
70
|
+
if (verbose) {
|
|
71
|
+
console.log(
|
|
72
|
+
removeVolumes
|
|
73
|
+
? "\uD83D\uDDD1️ Stopping containers and removing volumes..."
|
|
74
|
+
: "\uD83D\uDED1 Stopping containers...",
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
const composeArg = composeFile ? `-f ${composeFile}` : "";
|
|
78
|
+
const volumeFlag = removeVolumes ? "-v" : "";
|
|
79
|
+
const cmd = `docker compose ${composeArg} down ${volumeFlag}`.trim();
|
|
80
|
+
execSync(cmd, {
|
|
81
|
+
cwd: root,
|
|
82
|
+
env: { ...process.env, COMPOSE_PROJECT_NAME: projectName },
|
|
83
|
+
stdio: verbose ? "inherit" : "ignore",
|
|
84
|
+
});
|
|
85
|
+
if (verbose) console.log("✓ Containers stopped");
|
|
78
86
|
}
|
|
79
87
|
function startService(root, projectName, serviceName, envVars, options = {}) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
});
|
|
88
|
+
const { verbose = true, composeFile } = options;
|
|
89
|
+
assertDockerRunning();
|
|
90
|
+
if (verbose) console.log(`\uD83D\uDC33 Starting ${serviceName}...`);
|
|
91
|
+
const composeArg = composeFile ? `-f ${composeFile}` : "";
|
|
92
|
+
const cmd = `docker compose ${composeArg} up -d ${serviceName}`.trim();
|
|
93
|
+
execSync(cmd, {
|
|
94
|
+
cwd: root,
|
|
95
|
+
env: { ...process.env, ...envVars, COMPOSE_PROJECT_NAME: projectName },
|
|
96
|
+
stdio: verbose ? "inherit" : "ignore",
|
|
97
|
+
});
|
|
91
98
|
}
|
|
92
99
|
function createBuiltInHealthCheck(type, serviceName, context = {}) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
100
|
+
const { projectName, root } = context;
|
|
101
|
+
switch (type) {
|
|
102
|
+
case "pg_isready":
|
|
103
|
+
return async () => {
|
|
104
|
+
try {
|
|
105
|
+
const projectArg = projectName ? `-p ${projectName}` : "";
|
|
106
|
+
execSync(
|
|
107
|
+
`docker compose ${projectArg} exec -T ${serviceName} pg_isready -U postgres`,
|
|
108
|
+
{
|
|
109
|
+
cwd: root,
|
|
110
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
111
|
+
},
|
|
112
|
+
);
|
|
113
|
+
return true;
|
|
114
|
+
} catch {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
case "redis-cli":
|
|
119
|
+
return async () => {
|
|
120
|
+
try {
|
|
121
|
+
const projectArg = projectName ? `-p ${projectName}` : "";
|
|
122
|
+
execSync(
|
|
123
|
+
`docker compose ${projectArg} exec -T ${serviceName} redis-cli ping`,
|
|
124
|
+
{
|
|
125
|
+
cwd: root,
|
|
126
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
127
|
+
},
|
|
128
|
+
);
|
|
129
|
+
return true;
|
|
130
|
+
} catch {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
case "http":
|
|
135
|
+
return async (port) => {
|
|
136
|
+
try {
|
|
137
|
+
const controller = new AbortController();
|
|
138
|
+
const timeoutId = setTimeout(() => controller.abort(), 2000);
|
|
139
|
+
try {
|
|
140
|
+
const response = await fetch(`http://localhost:${port}/`, {
|
|
141
|
+
signal: controller.signal,
|
|
142
|
+
});
|
|
143
|
+
clearTimeout(timeoutId);
|
|
144
|
+
return response.ok || response.status === 404;
|
|
145
|
+
} catch {
|
|
146
|
+
clearTimeout(timeoutId);
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
} catch {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
case "tcp":
|
|
154
|
+
return async (port) => {
|
|
155
|
+
try {
|
|
156
|
+
const controller = new AbortController();
|
|
157
|
+
const timeoutId = setTimeout(() => controller.abort(), 1000);
|
|
158
|
+
try {
|
|
159
|
+
await fetch(`http://localhost:${port}/`, {
|
|
160
|
+
signal: controller.signal,
|
|
161
|
+
});
|
|
162
|
+
clearTimeout(timeoutId);
|
|
163
|
+
return true;
|
|
164
|
+
} catch (error) {
|
|
165
|
+
clearTimeout(timeoutId);
|
|
166
|
+
if (
|
|
167
|
+
error instanceof Error &&
|
|
168
|
+
error.message.includes("ECONNREFUSED")
|
|
169
|
+
) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
} catch {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
default:
|
|
179
|
+
return async () => true;
|
|
180
|
+
}
|
|
165
181
|
}
|
|
166
182
|
async function waitForService(serviceName, config, port, options = {}) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
183
|
+
const {
|
|
184
|
+
maxAttempts = MAX_ATTEMPTS,
|
|
185
|
+
pollInterval = POLL_INTERVAL,
|
|
186
|
+
projectName,
|
|
187
|
+
root,
|
|
188
|
+
} = options;
|
|
189
|
+
if (config.healthCheck === false || config.healthCheck === undefined) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const healthCheckFn =
|
|
193
|
+
typeof config.healthCheck === "function"
|
|
194
|
+
? config.healthCheck
|
|
195
|
+
: createBuiltInHealthCheck(
|
|
196
|
+
config.healthCheck,
|
|
197
|
+
config.serviceName ?? serviceName,
|
|
198
|
+
{ projectName, root },
|
|
199
|
+
);
|
|
200
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
201
|
+
const isHealthy = await healthCheckFn(port);
|
|
202
|
+
if (isHealthy) return;
|
|
203
|
+
await sleep(pollInterval);
|
|
204
|
+
}
|
|
205
|
+
throw new Error(`Service ${serviceName} did not become ready in time`);
|
|
184
206
|
}
|
|
185
207
|
async function waitForAllServices(services, ports, options = {}) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
208
|
+
const { verbose = true, ...waitOptions } = options;
|
|
209
|
+
if (verbose) console.log("⏳ Waiting for services to be healthy...");
|
|
210
|
+
const promises = Object.entries(services).map(([name, config]) => {
|
|
211
|
+
const port = ports[name];
|
|
212
|
+
if (port === undefined) {
|
|
213
|
+
console.warn(
|
|
214
|
+
`⚠️ No port found for service ${name}, skipping health check`,
|
|
215
|
+
);
|
|
216
|
+
return Promise.resolve();
|
|
217
|
+
}
|
|
218
|
+
return waitForService(name, config, port, waitOptions);
|
|
219
|
+
});
|
|
220
|
+
await Promise.all(promises);
|
|
221
|
+
if (verbose) console.log("✓ All services healthy");
|
|
200
222
|
}
|
|
201
|
-
async function waitForServiceByType(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
+
async function waitForServiceByType(
|
|
224
|
+
serviceName,
|
|
225
|
+
healthCheckType,
|
|
226
|
+
port,
|
|
227
|
+
options = {},
|
|
228
|
+
) {
|
|
229
|
+
const {
|
|
230
|
+
maxAttempts = MAX_ATTEMPTS,
|
|
231
|
+
pollInterval = POLL_INTERVAL,
|
|
232
|
+
verbose = false,
|
|
233
|
+
projectName,
|
|
234
|
+
root,
|
|
235
|
+
} = options;
|
|
236
|
+
const healthCheckFn = createBuiltInHealthCheck(healthCheckType, serviceName, {
|
|
237
|
+
projectName,
|
|
238
|
+
root,
|
|
239
|
+
});
|
|
240
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
241
|
+
const isHealthy = await healthCheckFn(port);
|
|
242
|
+
if (isHealthy) {
|
|
243
|
+
if (verbose) console.log(`✓ ${serviceName} is ready`);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
await sleep(pollInterval);
|
|
247
|
+
}
|
|
248
|
+
throw new Error(`Service ${serviceName} did not become ready in time`);
|
|
223
249
|
}
|
|
224
250
|
|
|
225
|
-
export {
|
|
251
|
+
export {
|
|
252
|
+
POLL_INTERVAL,
|
|
253
|
+
MAX_ATTEMPTS,
|
|
254
|
+
DOCKER_NOT_RUNNING_MESSAGE,
|
|
255
|
+
isContainerRunning,
|
|
256
|
+
isDockerRunning,
|
|
257
|
+
assertDockerRunning,
|
|
258
|
+
areContainersRunning,
|
|
259
|
+
startContainers,
|
|
260
|
+
stopContainers,
|
|
261
|
+
startService,
|
|
262
|
+
createBuiltInHealthCheck,
|
|
263
|
+
waitForService,
|
|
264
|
+
waitForAllServices,
|
|
265
|
+
waitForServiceByType,
|
|
266
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
export { getFlagValue, hasFlag, runCli } from "./cli";
|
|
2
|
-
export { assertValidConfig, defineDevConfig, mergeConfigs, validateConfig, } from "./config";
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export
|
|
7
|
-
export {
|
|
1
|
+
export { getFlagValue, hasFlag, runCli } from "./cli/run-cli";
|
|
2
|
+
export { assertValidConfig, defineDevConfig, mergeConfigs, validateConfig, } from "./config/index";
|
|
3
|
+
export type { ClickhouseServiceOptions, CustomServiceOptions, PostgresServiceOptions, RedisServiceOptions, } from "./docker-compose/services";
|
|
4
|
+
export { service } from "./docker-compose/services";
|
|
5
|
+
export { createDevEnvironment } from "./environment/index";
|
|
6
|
+
export { clearDevEnvCache, getDevEnv, loadDevEnv } from "./loader/index";
|
|
7
|
+
export { runWorkspaceTypecheck, type TypecheckResult, type WorkspaceTypecheckOptions, type WorkspaceTypecheckResult, } from "./typecheck/index";
|
|
8
|
+
export type { AppConfig, BuiltInHealthCheck, CliOptions, ComputedPorts, ComputedPublicUrls, ComputedUrls, DevConfig, DevEnvironment, DevHooks, DevOptions, DevServerPids, DockerComposeGenerationOptions, DockerComposeHealthcheckRaw, DockerComposeNode, DockerComposeServiceRaw, DockerComposeVolumeRaw, DockerPresetName, DockerPresetServiceDefinition, DockerServiceDefinition, EnvVarsBuilder, ExecOptions, HealthCheckFn, HookContext, MigrationConfig, PrismaConfig, PrismaRunner, SeedCheckContext, SeedCheckHelpers, SeedConfig, ServiceConfig, StartOptions, StopOptions, UrlBuilderContext, UrlBuilderFn, } from "./types/index";
|
|
8
9
|
export { getLocalIp, isPortAvailable, waitForServer } from "./core/network";
|
|
9
|
-
export {
|
|
10
|
+
export { calculatePortOffset, computeDevIdentity, findMonorepoRoot, getProjectName, getWorktreeName, getWorktreeProjectSuffix, isWorktree, } from "./core/ports";
|
|
10
11
|
export { getProcessOnPort, isPortInUse, isProcessAlive, killProcessesOnAppPorts, killProcessOnPort, killProcessOnPortAndWait, } from "./core/process";
|
|
12
|
+
export { type PublicExposeTarget, type PublicTunnel, resolveExposeTargets, startPublicTunnels, stopPublicTunnels, } from "./core/tunnel";
|
|
11
13
|
export { getEnvVar, isCI, logApiUrl, logExpoApiUrl, logFrontendPort, sleep, } from "./core/utils";
|
|
12
14
|
export { getHeartbeatFile, getWatchdogPidFile, isWatchdogRunning, spawnWatchdog, startHeartbeat, stopHeartbeat, stopWatchdog, } from "./core/watchdog";
|
|
15
|
+
export { areContainersRunning, assertDockerRunning, DOCKER_NOT_RUNNING_MESSAGE, isContainerRunning, isDockerRunning, MAX_ATTEMPTS, POLL_INTERVAL, } from "./docker/index";
|
|
16
|
+
export { buildComposeModel, composeToYaml, DEFAULT_GENERATED_COMPOSE_FILE, getGeneratedComposePath, writeGeneratedComposeFile, } from "./docker-compose/index";
|
package/dist/index.js
CHANGED
|
@@ -1,43 +1,20 @@
|
|
|
1
|
+
import"./index-bj79tw5w.js";
|
|
1
2
|
import {
|
|
2
3
|
getFlagValue,
|
|
3
4
|
hasFlag,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "./index-
|
|
5
|
+
resolveExposeTargets,
|
|
6
|
+
runCli,
|
|
7
|
+
startPublicTunnels,
|
|
8
|
+
stopPublicTunnels
|
|
9
|
+
} from "./index-0kxnae3z.js";
|
|
9
10
|
import {
|
|
10
11
|
clearDevEnvCache,
|
|
11
12
|
getDevEnv,
|
|
12
13
|
loadDevEnv
|
|
13
|
-
} from "./index-
|
|
14
|
+
} from "./index-4xrxh8yv.js";
|
|
14
15
|
import {
|
|
15
16
|
createDevEnvironment
|
|
16
|
-
} from "./index-
|
|
17
|
-
import {
|
|
18
|
-
getHeartbeatFile,
|
|
19
|
-
getWatchdogPidFile,
|
|
20
|
-
isWatchdogRunning,
|
|
21
|
-
spawnWatchdog,
|
|
22
|
-
startHeartbeat,
|
|
23
|
-
stopHeartbeat,
|
|
24
|
-
stopWatchdog
|
|
25
|
-
} from "./index-ggq3yryx.js";
|
|
26
|
-
import {
|
|
27
|
-
getProcessOnPort,
|
|
28
|
-
isPortInUse,
|
|
29
|
-
isProcessAlive,
|
|
30
|
-
killProcessOnPort,
|
|
31
|
-
killProcessOnPortAndWait,
|
|
32
|
-
killProcessesOnAppPorts
|
|
33
|
-
} from "./index-1yvbwj4k.js";
|
|
34
|
-
import {
|
|
35
|
-
assertValidConfig,
|
|
36
|
-
defineDevConfig,
|
|
37
|
-
mergeConfigs,
|
|
38
|
-
validateConfig
|
|
39
|
-
} from "./index-tjqw9vtj.js";
|
|
40
|
-
import"./index-qfphr2fd.js";
|
|
17
|
+
} from "./index-ma6tgdb2.js";
|
|
41
18
|
import {
|
|
42
19
|
DOCKER_NOT_RUNNING_MESSAGE,
|
|
43
20
|
MAX_ATTEMPTS,
|
|
@@ -46,7 +23,7 @@ import {
|
|
|
46
23
|
assertDockerRunning,
|
|
47
24
|
isContainerRunning,
|
|
48
25
|
isDockerRunning
|
|
49
|
-
} from "./index-
|
|
26
|
+
} from "./index-d8tyv5se.js";
|
|
50
27
|
import {
|
|
51
28
|
getEnvVar,
|
|
52
29
|
getLocalIp,
|
|
@@ -57,7 +34,7 @@ import {
|
|
|
57
34
|
logFrontendPort,
|
|
58
35
|
sleep,
|
|
59
36
|
waitForServer
|
|
60
|
-
} from "./index-
|
|
37
|
+
} from "./index-c0dr6mcv.js";
|
|
61
38
|
import {
|
|
62
39
|
calculatePortOffset,
|
|
63
40
|
computeDevIdentity,
|
|
@@ -66,18 +43,58 @@ import {
|
|
|
66
43
|
getWorktreeName,
|
|
67
44
|
getWorktreeProjectSuffix,
|
|
68
45
|
isWorktree
|
|
69
|
-
} from "./index-
|
|
46
|
+
} from "./index-fb29934k.js";
|
|
47
|
+
import {
|
|
48
|
+
DEFAULT_GENERATED_COMPOSE_FILE,
|
|
49
|
+
buildComposeModel,
|
|
50
|
+
composeToYaml,
|
|
51
|
+
getGeneratedComposePath,
|
|
52
|
+
service,
|
|
53
|
+
writeGeneratedComposeFile
|
|
54
|
+
} from "./index-5t9jxqm0.js";
|
|
55
|
+
import"./index-bnk6nr0g.js";
|
|
56
|
+
import {
|
|
57
|
+
getHeartbeatFile,
|
|
58
|
+
getWatchdogPidFile,
|
|
59
|
+
isWatchdogRunning,
|
|
60
|
+
spawnWatchdog,
|
|
61
|
+
startHeartbeat,
|
|
62
|
+
stopHeartbeat,
|
|
63
|
+
stopWatchdog
|
|
64
|
+
} from "./index-mam0bcyz.js";
|
|
65
|
+
import {
|
|
66
|
+
getProcessOnPort,
|
|
67
|
+
isPortInUse,
|
|
68
|
+
isProcessAlive,
|
|
69
|
+
killProcessOnPort,
|
|
70
|
+
killProcessOnPortAndWait,
|
|
71
|
+
killProcessesOnAppPorts
|
|
72
|
+
} from "./index-mm412dkp.js";
|
|
73
|
+
import {
|
|
74
|
+
assertValidConfig,
|
|
75
|
+
defineDevConfig,
|
|
76
|
+
mergeConfigs,
|
|
77
|
+
validateConfig
|
|
78
|
+
} from "./index-t0fj6gg1.js";
|
|
79
|
+
import {
|
|
80
|
+
runWorkspaceTypecheck
|
|
81
|
+
} from "./index-h70tce00.js";
|
|
70
82
|
import"./index-qnx9j3qa.js";
|
|
71
83
|
export {
|
|
84
|
+
writeGeneratedComposeFile,
|
|
72
85
|
waitForServer,
|
|
73
86
|
validateConfig,
|
|
74
87
|
stopWatchdog,
|
|
88
|
+
stopPublicTunnels,
|
|
75
89
|
stopHeartbeat,
|
|
90
|
+
startPublicTunnels,
|
|
76
91
|
startHeartbeat,
|
|
77
92
|
spawnWatchdog,
|
|
78
93
|
sleep,
|
|
94
|
+
service,
|
|
79
95
|
runWorkspaceTypecheck,
|
|
80
96
|
runCli,
|
|
97
|
+
resolveExposeTargets,
|
|
81
98
|
mergeConfigs,
|
|
82
99
|
logFrontendPort,
|
|
83
100
|
logExpoApiUrl,
|
|
@@ -102,6 +119,7 @@ export {
|
|
|
102
119
|
getProcessOnPort,
|
|
103
120
|
getLocalIp,
|
|
104
121
|
getHeartbeatFile,
|
|
122
|
+
getGeneratedComposePath,
|
|
105
123
|
getFlagValue,
|
|
106
124
|
getEnvVar,
|
|
107
125
|
getDevEnv,
|
|
@@ -109,12 +127,15 @@ export {
|
|
|
109
127
|
defineDevConfig,
|
|
110
128
|
createDevEnvironment,
|
|
111
129
|
computeDevIdentity,
|
|
130
|
+
composeToYaml,
|
|
112
131
|
clearDevEnvCache,
|
|
113
132
|
calculatePortOffset,
|
|
133
|
+
buildComposeModel,
|
|
114
134
|
assertValidConfig,
|
|
115
135
|
assertDockerRunning,
|
|
116
136
|
areContainersRunning,
|
|
117
137
|
POLL_INTERVAL,
|
|
118
138
|
MAX_ATTEMPTS,
|
|
119
|
-
DOCKER_NOT_RUNNING_MESSAGE
|
|
139
|
+
DOCKER_NOT_RUNNING_MESSAGE,
|
|
140
|
+
DEFAULT_GENERATED_COMPOSE_FILE
|
|
120
141
|
};
|