buncargo 1.0.26 → 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 -252
- 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 -74
- package/dist/core/docker.js +35 -26
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +123 -108
- package/dist/core/network.js +2 -2
- package/dist/core/ports.d.ts +22 -0
- package/dist/core/ports.js +5 -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 +66 -0
- 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 +187 -0
- 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 +145 -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-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 +100 -0
- 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 +404 -0
- 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 +266 -0
- package/dist/index.d.ts +12 -8
- package/dist/index.js +66 -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 -393
- package/package.json +145 -140
- package/readme.md +358 -105
- 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 +68 -1
- 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} +40 -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} +101 -146
- 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 -15
- 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} +137 -6
- package/src/types/index.ts +1 -0
- package/bin.ts +0 -191
- 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-p8wty0e2.js
CHANGED
|
@@ -1,400 +1,410 @@
|
|
|
1
|
+
// environment.ts
|
|
2
|
+
import pc from "picocolors";
|
|
1
3
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "./index-ggq3yryx.js";
|
|
7
|
-
import {
|
|
8
|
-
buildApps,
|
|
9
|
-
execAsync,
|
|
10
|
-
startDevServers,
|
|
11
|
-
stopProcess
|
|
4
|
+
buildApps,
|
|
5
|
+
execAsync,
|
|
6
|
+
startDevServers,
|
|
7
|
+
stopProcess,
|
|
12
8
|
} from "./index-1yvbwj4k.js";
|
|
13
9
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} from "./index-5hka0tff.js";
|
|
19
|
-
import {
|
|
20
|
-
areContainersRunning,
|
|
21
|
-
startContainers,
|
|
22
|
-
stopContainers,
|
|
23
|
-
waitForAllServices
|
|
10
|
+
areContainersRunning,
|
|
11
|
+
startContainers,
|
|
12
|
+
stopContainers,
|
|
13
|
+
waitForAllServices,
|
|
24
14
|
} from "./index-2fr3g85b.js";
|
|
15
|
+
import { createPrismaRunner } from "./index-5hka0tff.js";
|
|
25
16
|
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
getLocalIp,
|
|
18
|
+
isCI,
|
|
19
|
+
logExpoApiUrl,
|
|
20
|
+
logFrontendPort,
|
|
21
|
+
waitForDevServers,
|
|
22
|
+
waitForServer,
|
|
32
23
|
} from "./index-6fm7mvwj.js";
|
|
33
24
|
import {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
calculatePortOffset,
|
|
26
|
+
computePorts,
|
|
27
|
+
computeUrls,
|
|
28
|
+
findMonorepoRoot,
|
|
29
|
+
getProjectName,
|
|
30
|
+
isWorktree,
|
|
40
31
|
} from "./index-08wa79cs.js";
|
|
32
|
+
import {
|
|
33
|
+
spawnWatchdog,
|
|
34
|
+
startHeartbeat,
|
|
35
|
+
stopHeartbeat,
|
|
36
|
+
stopWatchdog,
|
|
37
|
+
} from "./index-ggq3yryx.js";
|
|
38
|
+
import { assertValidConfig } from "./index-tjqw9vtj.js";
|
|
41
39
|
|
|
42
|
-
// environment.ts
|
|
43
|
-
import pc from "picocolors";
|
|
44
40
|
function formatUrl(url) {
|
|
45
|
-
|
|
41
|
+
return pc.cyan(
|
|
42
|
+
url.replace(/:(\d+)(\/?)/, (_, port, slash) => `:${pc.bold(port)}${slash}`),
|
|
43
|
+
);
|
|
46
44
|
}
|
|
47
45
|
function formatLabel(label, value, arrow = "➜") {
|
|
48
|
-
|
|
46
|
+
return ` ${pc.green(arrow)} ${pc.bold(label.padEnd(10))} ${value}`;
|
|
49
47
|
}
|
|
50
48
|
function formatDimLabel(label, value) {
|
|
51
|
-
|
|
49
|
+
return ` ${pc.dim("•")} ${pc.dim(label.padEnd(10))} ${pc.dim(value)}`;
|
|
52
50
|
}
|
|
53
51
|
function createDevEnvironment(config, options = {}) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
52
|
+
assertValidConfig(config);
|
|
53
|
+
const root = findMonorepoRoot();
|
|
54
|
+
const suffix = options.suffix;
|
|
55
|
+
const worktree = isWorktree(root);
|
|
56
|
+
const portOffset = calculatePortOffset(suffix, root);
|
|
57
|
+
const projectName = getProjectName(config.projectPrefix, suffix, root);
|
|
58
|
+
const localIp = getLocalIp();
|
|
59
|
+
const services = config.services;
|
|
60
|
+
const apps = config.apps ?? {};
|
|
61
|
+
const ports = computePorts(services, apps, portOffset);
|
|
62
|
+
const urls = computeUrls(services, apps, ports, localIp);
|
|
63
|
+
function buildEnvVars(production = false) {
|
|
64
|
+
const baseEnv = {
|
|
65
|
+
COMPOSE_PROJECT_NAME: projectName,
|
|
66
|
+
NODE_ENV: production ? "production" : "development",
|
|
67
|
+
};
|
|
68
|
+
for (const [name, port] of Object.entries(ports)) {
|
|
69
|
+
const envName = `${name.toUpperCase()}_PORT`;
|
|
70
|
+
baseEnv[envName] = String(port);
|
|
71
|
+
}
|
|
72
|
+
for (const [name, url] of Object.entries(urls)) {
|
|
73
|
+
const envName = `${name.toUpperCase()}_URL`;
|
|
74
|
+
baseEnv[envName] = url;
|
|
75
|
+
}
|
|
76
|
+
if (config.envVars) {
|
|
77
|
+
const userEnv = config.envVars(ports, urls, {
|
|
78
|
+
projectName,
|
|
79
|
+
localIp,
|
|
80
|
+
portOffset,
|
|
81
|
+
});
|
|
82
|
+
for (const [key, value] of Object.entries(userEnv)) {
|
|
83
|
+
baseEnv[key] = String(value);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return baseEnv;
|
|
87
|
+
}
|
|
88
|
+
let hookContext = null;
|
|
89
|
+
function getHookContext() {
|
|
90
|
+
if (!hookContext) {
|
|
91
|
+
hookContext = {
|
|
92
|
+
projectName,
|
|
93
|
+
ports,
|
|
94
|
+
urls,
|
|
95
|
+
root,
|
|
96
|
+
isCI: isCI(),
|
|
97
|
+
portOffset,
|
|
98
|
+
localIp,
|
|
99
|
+
exec: async (cmd, opts) => {
|
|
100
|
+
const envVars = buildEnvVars();
|
|
101
|
+
return execAsync(cmd, root, envVars, opts);
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return hookContext;
|
|
106
|
+
}
|
|
107
|
+
function exec(cmd, options2) {
|
|
108
|
+
const envVars = buildEnvVars();
|
|
109
|
+
return execAsync(cmd, root, envVars, options2);
|
|
110
|
+
}
|
|
111
|
+
async function start(startOptions = {}) {
|
|
112
|
+
const isCI2 = process.env.CI === "true";
|
|
113
|
+
const {
|
|
114
|
+
verbose = config.options?.verbose ?? true,
|
|
115
|
+
wait = true,
|
|
116
|
+
startServers: shouldStartServers = true,
|
|
117
|
+
productionBuild = isCI2,
|
|
118
|
+
skipSeed = false,
|
|
119
|
+
} = startOptions;
|
|
120
|
+
const envVars = buildEnvVars(productionBuild);
|
|
121
|
+
if (verbose) {
|
|
122
|
+
logInfo(productionBuild ? "Production Environment" : "Dev Environment");
|
|
123
|
+
}
|
|
124
|
+
const serviceCount = Object.keys(services).length;
|
|
125
|
+
const alreadyRunning = await areContainersRunning(
|
|
126
|
+
projectName,
|
|
127
|
+
serviceCount,
|
|
128
|
+
);
|
|
129
|
+
if (alreadyRunning) {
|
|
130
|
+
if (verbose) console.log("✓ Containers already running");
|
|
131
|
+
} else {
|
|
132
|
+
startContainers(root, projectName, envVars, {
|
|
133
|
+
verbose,
|
|
134
|
+
wait,
|
|
135
|
+
composeFile: config.options?.composeFile,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (wait) {
|
|
139
|
+
await waitForAllServices(services, ports, {
|
|
140
|
+
verbose,
|
|
141
|
+
projectName,
|
|
142
|
+
root,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const allMigrations = [
|
|
146
|
+
...(config.prisma
|
|
147
|
+
? [
|
|
148
|
+
{
|
|
149
|
+
name: "prisma",
|
|
150
|
+
command: "bunx prisma migrate deploy",
|
|
151
|
+
cwd: config.prisma.cwd ?? "packages/prisma",
|
|
152
|
+
},
|
|
153
|
+
]
|
|
154
|
+
: []),
|
|
155
|
+
...(config.migrations ?? []),
|
|
156
|
+
];
|
|
157
|
+
if (allMigrations.length > 0) {
|
|
158
|
+
if (verbose) console.log("\uD83D\uDCE6 Running migrations...");
|
|
159
|
+
const migrationResults = await Promise.all(
|
|
160
|
+
allMigrations.map(async (migration) => {
|
|
161
|
+
const result = await exec(migration.command, {
|
|
162
|
+
cwd: migration.cwd,
|
|
163
|
+
throwOnError: false,
|
|
164
|
+
});
|
|
165
|
+
return { name: migration.name, result };
|
|
166
|
+
}),
|
|
167
|
+
);
|
|
168
|
+
for (const { name, result } of migrationResults) {
|
|
169
|
+
if (result.exitCode !== 0) {
|
|
170
|
+
console.error(`❌ Migration "${name}" failed`);
|
|
171
|
+
if (result.stdout) {
|
|
172
|
+
console.error(result.stdout);
|
|
173
|
+
}
|
|
174
|
+
if (result.stderr) {
|
|
175
|
+
console.error(result.stderr);
|
|
176
|
+
}
|
|
177
|
+
throw new Error(`Migration "${name}" failed`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (verbose) console.log("✓ Migrations complete");
|
|
181
|
+
}
|
|
182
|
+
if (config.hooks?.afterContainersReady) {
|
|
183
|
+
await config.hooks.afterContainersReady(getHookContext());
|
|
184
|
+
}
|
|
185
|
+
if (config.seed && !skipSeed) {
|
|
186
|
+
let shouldSeed = true;
|
|
187
|
+
if (config.seed.check) {
|
|
188
|
+
const checkTable = async (tableName, service) => {
|
|
189
|
+
const serviceName = service ?? "postgres";
|
|
190
|
+
const serviceUrl = urls[serviceName];
|
|
191
|
+
if (!serviceUrl) {
|
|
192
|
+
console.warn(`⚠️ Service "${serviceName}" not found for checkTable`);
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
const checkResult = await exec(
|
|
196
|
+
`psql "${serviceUrl}" -tAc 'SELECT COUNT(*) FROM "${tableName}" LIMIT 1'`,
|
|
197
|
+
{ throwOnError: false },
|
|
198
|
+
);
|
|
199
|
+
const count = checkResult.stdout.trim();
|
|
200
|
+
const shouldSeed2 =
|
|
201
|
+
checkResult.exitCode !== 0 || count === "0" || count === "";
|
|
202
|
+
if (!shouldSeed2) {
|
|
203
|
+
console.log(
|
|
204
|
+
` \uD83D\uDCCA Table "${tableName}" has ${count} rows`,
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
return shouldSeed2;
|
|
208
|
+
};
|
|
209
|
+
const seedCheckContext = {
|
|
210
|
+
...getHookContext(),
|
|
211
|
+
checkTable,
|
|
212
|
+
};
|
|
213
|
+
shouldSeed = await config.seed.check(seedCheckContext);
|
|
214
|
+
}
|
|
215
|
+
if (shouldSeed) {
|
|
216
|
+
if (verbose) console.log("\uD83C\uDF31 Running seeders...");
|
|
217
|
+
const seedResult = await exec(config.seed.command, {
|
|
218
|
+
cwd: config.seed.cwd,
|
|
219
|
+
verbose,
|
|
220
|
+
throwOnError: false,
|
|
221
|
+
});
|
|
222
|
+
if (seedResult.exitCode !== 0) {
|
|
223
|
+
console.error("❌ Seeding failed");
|
|
224
|
+
console.error(seedResult.stderr);
|
|
225
|
+
} else {
|
|
226
|
+
if (verbose) console.log("✓ Seeding complete");
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
229
|
+
if (verbose)
|
|
230
|
+
console.log("✓ Database already has data, skipping seeders");
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (shouldStartServers && Object.keys(apps).length > 0) {
|
|
234
|
+
if (config.hooks?.beforeServers) {
|
|
235
|
+
await config.hooks.beforeServers(getHookContext());
|
|
236
|
+
}
|
|
237
|
+
if (productionBuild) {
|
|
238
|
+
buildApps(apps, root, envVars, { verbose });
|
|
239
|
+
}
|
|
240
|
+
const pids = await startDevServers(apps, root, envVars, ports, {
|
|
241
|
+
verbose,
|
|
242
|
+
productionBuild,
|
|
243
|
+
isCI: isCI2,
|
|
244
|
+
});
|
|
245
|
+
if (verbose) console.log("⏳ Waiting for servers to be ready...");
|
|
246
|
+
await waitForDevServers(apps, ports, {
|
|
247
|
+
timeout: isCI2 ? 120000 : 60000,
|
|
248
|
+
verbose,
|
|
249
|
+
productionBuild,
|
|
250
|
+
});
|
|
251
|
+
if (config.hooks?.afterServers) {
|
|
252
|
+
await config.hooks.afterServers(getHookContext());
|
|
253
|
+
}
|
|
254
|
+
if (verbose)
|
|
255
|
+
console.log(`✅ Environment ready
|
|
251
256
|
`);
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
257
|
+
return pids;
|
|
258
|
+
}
|
|
259
|
+
if (verbose)
|
|
260
|
+
console.log(`✅ Containers ready
|
|
256
261
|
`);
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
async function stop(stopOptions = {}) {
|
|
265
|
+
const { verbose = true, removeVolumes = false } = stopOptions;
|
|
266
|
+
if (config.hooks?.beforeStop) {
|
|
267
|
+
await config.hooks.beforeStop(getHookContext());
|
|
268
|
+
}
|
|
269
|
+
stopContainers(root, projectName, {
|
|
270
|
+
verbose,
|
|
271
|
+
removeVolumes,
|
|
272
|
+
composeFile: config.options?.composeFile,
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
async function restart() {
|
|
276
|
+
await stop();
|
|
277
|
+
await start({ startServers: false });
|
|
278
|
+
}
|
|
279
|
+
async function isRunning() {
|
|
280
|
+
const serviceCount = Object.keys(services).length;
|
|
281
|
+
return areContainersRunning(projectName, serviceCount);
|
|
282
|
+
}
|
|
283
|
+
async function startServersOnly(options2 = {}) {
|
|
284
|
+
const { productionBuild = false, verbose = true } = options2;
|
|
285
|
+
const envVars = buildEnvVars(productionBuild);
|
|
286
|
+
const isCI2 = process.env.CI === "true";
|
|
287
|
+
if (productionBuild) {
|
|
288
|
+
buildApps(apps, root, envVars, { verbose });
|
|
289
|
+
}
|
|
290
|
+
return startDevServers(apps, root, envVars, ports, {
|
|
291
|
+
verbose,
|
|
292
|
+
productionBuild,
|
|
293
|
+
isCI: isCI2,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
async function waitForServersReady(options2 = {}) {
|
|
297
|
+
const { timeout = 60000, productionBuild = false } = options2;
|
|
298
|
+
await waitForDevServers(apps, ports, { timeout, productionBuild });
|
|
299
|
+
}
|
|
300
|
+
function logInfo(label = "Docker Dev") {
|
|
301
|
+
const serviceNames = Object.keys(services);
|
|
302
|
+
const appNames = Object.keys(apps);
|
|
303
|
+
console.log("");
|
|
304
|
+
console.log(` ${pc.cyan(pc.bold(`\uD83D\uDC33 ${label}`))}`);
|
|
305
|
+
console.log(formatLabel("Project:", pc.white(projectName)));
|
|
306
|
+
if (serviceNames.length > 0) {
|
|
307
|
+
console.log("");
|
|
308
|
+
console.log(` ${pc.dim("─── Services ───")}`);
|
|
309
|
+
for (const name of serviceNames) {
|
|
310
|
+
const port = ports[name];
|
|
311
|
+
const url = `localhost:${port}`;
|
|
312
|
+
console.log(formatLabel(`${name}:`, formatUrl(`http://${url}`)));
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (appNames.length > 0) {
|
|
316
|
+
console.log("");
|
|
317
|
+
console.log(` ${pc.dim("─── Applications ───")}`);
|
|
318
|
+
for (const name of appNames) {
|
|
319
|
+
const port = ports[name];
|
|
320
|
+
const localUrl = `http://localhost:${port}`;
|
|
321
|
+
const networkUrl = `http://${localIp}:${port}`;
|
|
322
|
+
console.log(` ${pc.green("➜")} ${pc.bold(pc.cyan(name))}`);
|
|
323
|
+
console.log(` ${pc.dim("Local:")} ${formatUrl(localUrl)}`);
|
|
324
|
+
console.log(` ${pc.dim("Network:")} ${formatUrl(networkUrl)}`);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
console.log("");
|
|
328
|
+
console.log(` ${pc.dim("─── Environment ───")}`);
|
|
329
|
+
console.log(formatDimLabel("Worktree:", worktree ? "yes" : "no"));
|
|
330
|
+
console.log(
|
|
331
|
+
formatDimLabel(
|
|
332
|
+
"Port offset:",
|
|
333
|
+
portOffset > 0 ? `+${portOffset}` : "none",
|
|
334
|
+
),
|
|
335
|
+
);
|
|
336
|
+
if (suffix) {
|
|
337
|
+
console.log(formatDimLabel("Suffix:", suffix));
|
|
338
|
+
}
|
|
339
|
+
console.log(formatDimLabel("Local IP:", localIp));
|
|
340
|
+
console.log("");
|
|
341
|
+
}
|
|
342
|
+
async function waitForServerUrl(url, timeout) {
|
|
343
|
+
await waitForServer(url, { timeout });
|
|
344
|
+
}
|
|
345
|
+
function startHeartbeat2(intervalMs) {
|
|
346
|
+
startHeartbeat(projectName, intervalMs);
|
|
347
|
+
}
|
|
348
|
+
function stopHeartbeat2() {
|
|
349
|
+
stopHeartbeat();
|
|
350
|
+
}
|
|
351
|
+
async function spawnWatchdog2(timeoutMinutes) {
|
|
352
|
+
await spawnWatchdog(projectName, root, {
|
|
353
|
+
timeoutMinutes,
|
|
354
|
+
verbose: true,
|
|
355
|
+
composeFile: config.options?.composeFile,
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
function stopWatchdog2() {
|
|
359
|
+
stopWatchdog(projectName);
|
|
360
|
+
}
|
|
361
|
+
function getExpoApiUrl() {
|
|
362
|
+
const apiPort = ports.api;
|
|
363
|
+
const url = `http://${localIp}:${apiPort}`;
|
|
364
|
+
logExpoApiUrl(url);
|
|
365
|
+
return url;
|
|
366
|
+
}
|
|
367
|
+
function getFrontendPort() {
|
|
368
|
+
const port = ports.platform;
|
|
369
|
+
logFrontendPort(port);
|
|
370
|
+
return port;
|
|
371
|
+
}
|
|
372
|
+
function withSuffix(newSuffix) {
|
|
373
|
+
return createDevEnvironment(config, { suffix: newSuffix });
|
|
374
|
+
}
|
|
375
|
+
const env = {
|
|
376
|
+
projectName,
|
|
377
|
+
ports,
|
|
378
|
+
urls,
|
|
379
|
+
apps,
|
|
380
|
+
portOffset,
|
|
381
|
+
isWorktree: worktree,
|
|
382
|
+
localIp,
|
|
383
|
+
root,
|
|
384
|
+
start,
|
|
385
|
+
stop,
|
|
386
|
+
restart,
|
|
387
|
+
isRunning,
|
|
388
|
+
startServers: startServersOnly,
|
|
389
|
+
stopProcess,
|
|
390
|
+
waitForServers: waitForServersReady,
|
|
391
|
+
buildEnvVars,
|
|
392
|
+
exec,
|
|
393
|
+
waitForServer: waitForServerUrl,
|
|
394
|
+
logInfo,
|
|
395
|
+
getExpoApiUrl,
|
|
396
|
+
getFrontendPort,
|
|
397
|
+
startHeartbeat: startHeartbeat2,
|
|
398
|
+
stopHeartbeat: stopHeartbeat2,
|
|
399
|
+
spawnWatchdog: spawnWatchdog2,
|
|
400
|
+
stopWatchdog: stopWatchdog2,
|
|
401
|
+
prisma: undefined,
|
|
402
|
+
withSuffix,
|
|
403
|
+
};
|
|
404
|
+
if (config.prisma) {
|
|
405
|
+
env.prisma = createPrismaRunner(env, config.prisma);
|
|
406
|
+
}
|
|
407
|
+
return env;
|
|
398
408
|
}
|
|
399
409
|
|
|
400
410
|
export { createDevEnvironment };
|