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.
Files changed (222) hide show
  1. package/dist/bin.d.ts +1 -12
  2. package/dist/bin.js +261 -252
  3. package/dist/cli/bin.d.ts +13 -0
  4. package/dist/cli/bin.js +315 -0
  5. package/dist/cli/commands/help.d.ts +1 -0
  6. package/dist/cli/commands/runtime.d.ts +5 -0
  7. package/dist/cli/commands/version.d.ts +1 -0
  8. package/dist/cli/index.d.ts +1 -0
  9. package/dist/cli/index.js +14 -0
  10. package/dist/cli/run-cli.d.ts +22 -0
  11. package/dist/cli.d.ts +1 -22
  12. package/dist/cli.js +5 -13
  13. package/dist/config/config.d.ts +1 -0
  14. package/dist/config/define-config.d.ts +13 -0
  15. package/dist/config/index.d.ts +3 -0
  16. package/dist/config/index.js +15 -0
  17. package/dist/config/merge-configs.d.ts +3 -0
  18. package/dist/config/validate-config.d.ts +3 -0
  19. package/dist/config.d.ts +1 -72
  20. package/dist/config.js +12 -12
  21. package/dist/core/docker.d.ts +1 -74
  22. package/dist/core/docker.js +35 -26
  23. package/dist/core/index.d.ts +1 -1
  24. package/dist/core/index.js +123 -108
  25. package/dist/core/network.js +2 -2
  26. package/dist/core/ports.d.ts +22 -0
  27. package/dist/core/ports.js +5 -1
  28. package/dist/core/process.js +1 -1
  29. package/dist/core/tunnel.d.ts +33 -0
  30. package/dist/core/utils.js +2 -2
  31. package/dist/core/watchdog-runner.js +45 -42
  32. package/dist/core/watchdog.d.ts +1 -0
  33. package/dist/core/watchdog.js +4 -2
  34. package/dist/docker/index.d.ts +1 -0
  35. package/dist/docker/index.js +38 -0
  36. package/dist/docker/runtime.d.ts +87 -0
  37. package/dist/docker/runtime.js +37 -0
  38. package/dist/docker-compose/compose.d.ts +1 -0
  39. package/dist/docker-compose/generated-file.d.ts +7 -0
  40. package/dist/docker-compose/index.d.ts +3 -0
  41. package/dist/docker-compose/index.js +15 -0
  42. package/dist/docker-compose/model.d.ts +6 -0
  43. package/dist/docker-compose/services/clickhouse.d.ts +16 -0
  44. package/dist/docker-compose/services/define-docker-service.d.ts +41 -0
  45. package/dist/docker-compose/services/index.d.ts +23 -0
  46. package/dist/docker-compose/services/index.js +17 -0
  47. package/dist/docker-compose/services/postgres.d.ts +12 -0
  48. package/dist/docker-compose/services/redis.d.ts +12 -0
  49. package/dist/docker-compose/services/shared.d.ts +7 -0
  50. package/dist/docker-compose/yaml.d.ts +2 -0
  51. package/dist/environment/create-dev-environment.d.ts +23 -0
  52. package/dist/environment/index.d.ts +1 -0
  53. package/dist/environment/index.js +15 -0
  54. package/dist/environment/logging.d.ts +17 -0
  55. package/dist/environment/seeding.d.ts +9 -0
  56. package/dist/environment.d.ts +1 -23
  57. package/dist/environment.js +12 -14
  58. package/dist/index-045jksh5.js +147 -0
  59. package/dist/index-08wa79cs.js +125 -117
  60. package/dist/index-0kxnae3z.js +335 -0
  61. package/dist/index-1mdrf7nz.js +66 -0
  62. package/dist/index-1yvbwj4k.js +262 -242
  63. package/dist/index-23ev345g.js +475 -0
  64. package/dist/index-2ckr49sf.js +228 -0
  65. package/dist/index-2f47khe5.js +376 -369
  66. package/dist/index-2fr3g85b.js +220 -183
  67. package/dist/index-38xnzpa6.js +450 -0
  68. package/dist/index-3h3dhtf2.js +51 -43
  69. package/dist/index-42x95209.js +51 -43
  70. package/dist/index-4gp0az1g.js +145 -0
  71. package/dist/index-4xrxh8yv.js +72 -0
  72. package/dist/index-5gmws6ah.js +181 -0
  73. package/dist/index-5hka0tff.js +78 -76
  74. package/dist/index-5rfqps4b.js +3 -0
  75. package/dist/index-5t9jxqm0.js +428 -0
  76. package/dist/index-6c1w1xk5.js +101 -0
  77. package/dist/index-6fm7mvwj.js +118 -97
  78. package/dist/index-6srpc523.js +127 -128
  79. package/dist/index-731rzzfp.js +187 -0
  80. package/dist/index-75y4cg2z.js +51 -43
  81. package/dist/index-7ja4ywyj.js +126 -127
  82. package/dist/index-8bw1cmz4.js +531 -0
  83. package/dist/index-8hbbj1mp.js +120 -121
  84. package/dist/index-8xj2p5n5.js +145 -0
  85. package/dist/index-bj79tw5w.js +0 -0
  86. package/dist/index-bnk6nr0g.js +73 -0
  87. package/dist/index-brbbzyks.js +72 -0
  88. package/dist/index-c0dr6mcv.js +123 -0
  89. package/dist/index-cty0bcry.js +235 -218
  90. package/dist/index-d8tyv5se.js +228 -0
  91. package/dist/index-d9efy0n4.js +176 -150
  92. package/dist/index-etfmqjjf.js +427 -0
  93. package/dist/index-fb29934k.js +172 -0
  94. package/dist/index-g50jw1yf.js +72 -0
  95. package/dist/index-g6eb5wdw.js +118 -117
  96. package/dist/index-ggq3yryx.js +99 -95
  97. package/dist/index-h70tce00.js +177 -0
  98. package/dist/index-hkxtfqtc.js +333 -0
  99. package/dist/index-kf3dhser.js +146 -143
  100. package/dist/index-ma6tgdb2.js +500 -0
  101. package/dist/index-mam0bcyz.js +123 -0
  102. package/dist/index-mm412dkp.js +274 -0
  103. package/dist/index-n8v18aeb.js +0 -0
  104. package/dist/index-ndnmnsej.js +378 -371
  105. package/dist/index-p8wty0e2.js +389 -379
  106. package/dist/index-qfphr2fd.js +100 -0
  107. package/dist/index-qqmms8rs.js +51 -43
  108. package/dist/index-qw4093g2.js +51 -43
  109. package/dist/index-qzwpzjbx.js +121 -122
  110. package/dist/index-segbnm0h.js +146 -143
  111. package/dist/index-t0fj6gg1.js +112 -0
  112. package/dist/index-thdkwnv7.js +122 -0
  113. package/dist/index-tjbx2r2t.js +270 -0
  114. package/dist/index-tjqw9vtj.js +62 -54
  115. package/dist/index-vbpb89jy.js +248 -0
  116. package/dist/index-vhs88xhe.js +99 -95
  117. package/dist/index-w8zxnjka.js +249 -0
  118. package/dist/index-wk2na3t9.js +404 -0
  119. package/dist/index-wz9x8g7z.js +383 -373
  120. package/dist/index-x249gyde.js +388 -378
  121. package/dist/index-xkvd0nsd.js +187 -0
  122. package/dist/index-yedqxm1z.js +80 -0
  123. package/dist/index-zfjzzjkf.js +266 -0
  124. package/dist/index.d.ts +12 -8
  125. package/dist/index.js +66 -35
  126. package/dist/lint.d.ts +1 -46
  127. package/dist/lint.js +3 -7
  128. package/dist/loader/cache.d.ts +4 -0
  129. package/dist/loader/find-config-file.d.ts +2 -0
  130. package/dist/loader/index.d.ts +5 -0
  131. package/dist/loader/index.js +24 -0
  132. package/dist/loader/load-dev-env.d.ts +5 -0
  133. package/dist/loader/loader.d.ts +1 -0
  134. package/dist/loader.d.ts +1 -45
  135. package/dist/loader.js +22 -20
  136. package/dist/prisma/index.d.ts +1 -0
  137. package/dist/prisma/prisma.d.ts +29 -0
  138. package/dist/prisma.d.ts +1 -29
  139. package/dist/prisma.js +6 -10
  140. package/dist/src/bin.js +309 -0
  141. package/dist/src/cli.js +5 -0
  142. package/dist/src/config.js +15 -0
  143. package/dist/src/core/docker.js +38 -0
  144. package/dist/src/core/index.js +130 -0
  145. package/dist/src/core/network.js +9 -0
  146. package/dist/src/core/ports.js +23 -0
  147. package/dist/src/core/process.js +31 -0
  148. package/dist/src/core/utils.js +11 -0
  149. package/dist/src/core/watchdog-runner.js +69 -0
  150. package/dist/src/core/watchdog.js +28 -0
  151. package/dist/src/docker/runtime.js +37 -0
  152. package/dist/src/docker-compose/index.js +16 -0
  153. package/dist/src/docker-compose/services/index.js +17 -0
  154. package/dist/src/environment.js +12 -0
  155. package/dist/src/index.js +122 -0
  156. package/dist/src/lint.js +3 -0
  157. package/dist/src/loader.js +25 -0
  158. package/dist/src/prisma.js +6 -0
  159. package/dist/src/types.js +0 -0
  160. package/dist/typecheck/index.d.ts +1 -0
  161. package/dist/typecheck/index.js +7 -0
  162. package/dist/typecheck/typecheck.d.ts +46 -0
  163. package/dist/types/all-types.d.ts +501 -0
  164. package/dist/types/cli.d.ts +1 -0
  165. package/dist/types/config.d.ts +6 -0
  166. package/dist/types/docker.d.ts +15 -0
  167. package/dist/types/environment.d.ts +8 -0
  168. package/dist/types/hooks.d.ts +9 -0
  169. package/dist/types/index.d.ts +1 -0
  170. package/dist/types/index.js +0 -0
  171. package/dist/types/prisma.d.ts +1 -0
  172. package/dist/types.d.ts +1 -393
  173. package/package.json +145 -140
  174. package/readme.md +358 -105
  175. package/src/cli/bin.ts +77 -0
  176. package/src/cli/commands/help.ts +39 -0
  177. package/src/cli/commands/runtime.ts +72 -0
  178. package/src/cli/commands/version.ts +4 -0
  179. package/src/cli/index.ts +1 -0
  180. package/{cli.ts → src/cli/run-cli.ts} +95 -6
  181. package/src/config/define-config.ts +30 -0
  182. package/src/config/index.ts +3 -0
  183. package/src/config/merge-configs.ts +33 -0
  184. package/src/config/validate-config.ts +136 -0
  185. package/{core → src/core}/index.ts +2 -2
  186. package/{core → src/core}/ports.ts +68 -1
  187. package/{core → src/core}/process.ts +6 -2
  188. package/src/core/tunnel.ts +151 -0
  189. package/{core → src/core}/utils.ts +1 -0
  190. package/{core → src/core}/watchdog.ts +5 -1
  191. package/src/docker/index.ts +1 -0
  192. package/{core/docker.ts → src/docker/runtime.ts} +40 -4
  193. package/src/docker-compose/generated-file.ts +45 -0
  194. package/src/docker-compose/index.ts +7 -0
  195. package/src/docker-compose/model.ts +197 -0
  196. package/src/docker-compose/services/clickhouse.ts +79 -0
  197. package/src/docker-compose/services/define-docker-service.ts +109 -0
  198. package/src/docker-compose/services/index.ts +67 -0
  199. package/src/docker-compose/services/postgres.ts +60 -0
  200. package/src/docker-compose/services/redis.ts +48 -0
  201. package/src/docker-compose/services/shared.ts +79 -0
  202. package/src/docker-compose/yaml.ts +88 -0
  203. package/{environment.ts → src/environment/create-dev-environment.ts} +101 -146
  204. package/src/environment/index.ts +1 -0
  205. package/src/environment/logging.ts +101 -0
  206. package/src/environment/seeding.ts +57 -0
  207. package/{index.ts → src/index.ts} +49 -15
  208. package/src/loader/cache.ts +23 -0
  209. package/src/loader/find-config-file.ts +29 -0
  210. package/src/loader/index.ts +17 -0
  211. package/src/loader/load-dev-env.ts +38 -0
  212. package/src/prisma/index.ts +1 -0
  213. package/{prisma.ts → src/prisma/prisma.ts} +4 -2
  214. package/src/typecheck/index.ts +1 -0
  215. package/{types.ts → src/types/all-types.ts} +137 -6
  216. package/src/types/index.ts +1 -0
  217. package/bin.ts +0 -191
  218. package/config.ts +0 -194
  219. package/loader.ts +0 -126
  220. /package/{core → src/core}/network.ts +0 -0
  221. /package/{core → src/core}/watchdog-runner.ts +0 -0
  222. /package/{lint.ts → src/typecheck/typecheck.ts} +0 -0
@@ -1,205 +1,242 @@
1
- import {
2
- sleep
3
- } from "./index-6fm7mvwj.js";
4
-
5
1
  // core/docker.ts
6
2
  import { execSync } from "node:child_process";
3
+ import { sleep } from "./index-6fm7mvwj.js";
4
+
7
5
  var POLL_INTERVAL = 250;
8
6
  var MAX_ATTEMPTS = 120;
9
7
  async function isContainerRunning(project, service) {
10
- try {
11
- const result = execSync(`docker ps --filter "label=com.docker.compose.project=${project}" --filter "label=com.docker.compose.service=${service}" --format "{{.State}}"`, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
12
- return result.trim() === "running";
13
- } catch {
14
- return false;
15
- }
8
+ try {
9
+ const result = execSync(
10
+ `docker ps --filter "label=com.docker.compose.project=${project}" --filter "label=com.docker.compose.service=${service}" --format "{{.State}}"`,
11
+ { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] },
12
+ );
13
+ return result.trim() === "running";
14
+ } catch {
15
+ return false;
16
+ }
16
17
  }
17
18
  async function areContainersRunning(project, minCount = 1) {
18
- try {
19
- const result = execSync(`docker ps --filter "label=com.docker.compose.project=${project}" --format "{{.State}}"`, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
20
- const states = result.trim().split(`
21
- `).filter(Boolean);
22
- if (states.length < minCount)
23
- return false;
24
- return states.every((state) => state === "running");
25
- } catch {
26
- return false;
27
- }
19
+ try {
20
+ const result = execSync(
21
+ `docker ps --filter "label=com.docker.compose.project=${project}" --format "{{.State}}"`,
22
+ { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] },
23
+ );
24
+ const states = result
25
+ .trim()
26
+ .split(`
27
+ `)
28
+ .filter(Boolean);
29
+ if (states.length < minCount) return false;
30
+ return states.every((state) => state === "running");
31
+ } catch {
32
+ return false;
33
+ }
28
34
  }
29
35
  function startContainers(root, projectName, envVars, options = {}) {
30
- const { verbose = true, wait = true, composeFile } = options;
31
- if (verbose)
32
- console.log("\uD83D\uDC33 Starting Docker containers...");
33
- const composeArg = composeFile ? `-f ${composeFile}` : "";
34
- const waitFlag = wait ? "--wait" : "";
35
- const cmd = `docker compose ${composeArg} up -d ${waitFlag}`.trim();
36
- execSync(cmd, {
37
- cwd: root,
38
- env: { ...process.env, ...envVars, COMPOSE_PROJECT_NAME: projectName },
39
- stdio: verbose ? "inherit" : "ignore"
40
- });
41
- if (verbose)
42
- console.log("✓ Containers started");
36
+ const { verbose = true, wait = true, composeFile } = options;
37
+ if (verbose) console.log("\uD83D\uDC33 Starting Docker containers...");
38
+ const composeArg = composeFile ? `-f ${composeFile}` : "";
39
+ const waitFlag = wait ? "--wait" : "";
40
+ const cmd = `docker compose ${composeArg} up -d ${waitFlag}`.trim();
41
+ execSync(cmd, {
42
+ cwd: root,
43
+ env: { ...process.env, ...envVars, COMPOSE_PROJECT_NAME: projectName },
44
+ stdio: verbose ? "inherit" : "ignore",
45
+ });
46
+ if (verbose) console.log("✓ Containers started");
43
47
  }
44
48
  function stopContainers(root, projectName, options = {}) {
45
- const { verbose = true, removeVolumes = false, composeFile } = options;
46
- if (verbose) {
47
- console.log(removeVolumes ? "\uD83D\uDDD1️ Stopping containers and removing volumes..." : "\uD83D\uDED1 Stopping containers...");
48
- }
49
- const composeArg = composeFile ? `-f ${composeFile}` : "";
50
- const volumeFlag = removeVolumes ? "-v" : "";
51
- const cmd = `docker compose ${composeArg} down ${volumeFlag}`.trim();
52
- execSync(cmd, {
53
- cwd: root,
54
- env: { ...process.env, COMPOSE_PROJECT_NAME: projectName },
55
- stdio: verbose ? "inherit" : "ignore"
56
- });
57
- if (verbose)
58
- console.log("✓ Containers stopped");
49
+ const { verbose = true, removeVolumes = false, composeFile } = options;
50
+ if (verbose) {
51
+ console.log(
52
+ removeVolumes
53
+ ? "\uD83D\uDDD1️ Stopping containers and removing volumes..."
54
+ : "\uD83D\uDED1 Stopping containers...",
55
+ );
56
+ }
57
+ const composeArg = composeFile ? `-f ${composeFile}` : "";
58
+ const volumeFlag = removeVolumes ? "-v" : "";
59
+ const cmd = `docker compose ${composeArg} down ${volumeFlag}`.trim();
60
+ execSync(cmd, {
61
+ cwd: root,
62
+ env: { ...process.env, COMPOSE_PROJECT_NAME: projectName },
63
+ stdio: verbose ? "inherit" : "ignore",
64
+ });
65
+ if (verbose) console.log("✓ Containers stopped");
59
66
  }
60
67
  function startService(root, projectName, serviceName, envVars, options = {}) {
61
- const { verbose = true, composeFile } = options;
62
- if (verbose)
63
- console.log(`\uD83D\uDC33 Starting ${serviceName}...`);
64
- const composeArg = composeFile ? `-f ${composeFile}` : "";
65
- const cmd = `docker compose ${composeArg} up -d ${serviceName}`.trim();
66
- execSync(cmd, {
67
- cwd: root,
68
- env: { ...process.env, ...envVars, COMPOSE_PROJECT_NAME: projectName },
69
- stdio: verbose ? "inherit" : "ignore"
70
- });
68
+ const { verbose = true, composeFile } = options;
69
+ if (verbose) console.log(`\uD83D\uDC33 Starting ${serviceName}...`);
70
+ const composeArg = composeFile ? `-f ${composeFile}` : "";
71
+ const cmd = `docker compose ${composeArg} up -d ${serviceName}`.trim();
72
+ execSync(cmd, {
73
+ cwd: root,
74
+ env: { ...process.env, ...envVars, COMPOSE_PROJECT_NAME: projectName },
75
+ stdio: verbose ? "inherit" : "ignore",
76
+ });
71
77
  }
72
78
  function createBuiltInHealthCheck(type, serviceName, context = {}) {
73
- const { projectName, root } = context;
74
- switch (type) {
75
- case "pg_isready":
76
- return async () => {
77
- try {
78
- const projectArg = projectName ? `-p ${projectName}` : "";
79
- execSync(`docker compose ${projectArg} exec -T ${serviceName} pg_isready -U postgres`, {
80
- cwd: root,
81
- stdio: ["pipe", "pipe", "pipe"]
82
- });
83
- return true;
84
- } catch {
85
- return false;
86
- }
87
- };
88
- case "redis-cli":
89
- return async () => {
90
- try {
91
- const projectArg = projectName ? `-p ${projectName}` : "";
92
- execSync(`docker compose ${projectArg} exec -T ${serviceName} redis-cli ping`, {
93
- cwd: root,
94
- stdio: ["pipe", "pipe", "pipe"]
95
- });
96
- return true;
97
- } catch {
98
- return false;
99
- }
100
- };
101
- case "http":
102
- return async (port) => {
103
- try {
104
- const controller = new AbortController;
105
- const timeoutId = setTimeout(() => controller.abort(), 2000);
106
- try {
107
- const response = await fetch(`http://localhost:${port}/`, {
108
- signal: controller.signal
109
- });
110
- clearTimeout(timeoutId);
111
- return response.ok || response.status === 404;
112
- } catch {
113
- clearTimeout(timeoutId);
114
- return false;
115
- }
116
- } catch {
117
- return false;
118
- }
119
- };
120
- case "tcp":
121
- return async (port) => {
122
- try {
123
- const controller = new AbortController;
124
- const timeoutId = setTimeout(() => controller.abort(), 1000);
125
- try {
126
- await fetch(`http://localhost:${port}/`, {
127
- signal: controller.signal
128
- });
129
- clearTimeout(timeoutId);
130
- return true;
131
- } catch (error) {
132
- clearTimeout(timeoutId);
133
- if (error instanceof Error && error.message.includes("ECONNREFUSED")) {
134
- return false;
135
- }
136
- return true;
137
- }
138
- } catch {
139
- return false;
140
- }
141
- };
142
- default:
143
- return async () => true;
144
- }
79
+ const { projectName, root } = context;
80
+ switch (type) {
81
+ case "pg_isready":
82
+ return async () => {
83
+ try {
84
+ const projectArg = projectName ? `-p ${projectName}` : "";
85
+ execSync(
86
+ `docker compose ${projectArg} exec -T ${serviceName} pg_isready -U postgres`,
87
+ {
88
+ cwd: root,
89
+ stdio: ["pipe", "pipe", "pipe"],
90
+ },
91
+ );
92
+ return true;
93
+ } catch {
94
+ return false;
95
+ }
96
+ };
97
+ case "redis-cli":
98
+ return async () => {
99
+ try {
100
+ const projectArg = projectName ? `-p ${projectName}` : "";
101
+ execSync(
102
+ `docker compose ${projectArg} exec -T ${serviceName} redis-cli ping`,
103
+ {
104
+ cwd: root,
105
+ stdio: ["pipe", "pipe", "pipe"],
106
+ },
107
+ );
108
+ return true;
109
+ } catch {
110
+ return false;
111
+ }
112
+ };
113
+ case "http":
114
+ return async (port) => {
115
+ try {
116
+ const controller = new AbortController();
117
+ const timeoutId = setTimeout(() => controller.abort(), 2000);
118
+ try {
119
+ const response = await fetch(`http://localhost:${port}/`, {
120
+ signal: controller.signal,
121
+ });
122
+ clearTimeout(timeoutId);
123
+ return response.ok || response.status === 404;
124
+ } catch {
125
+ clearTimeout(timeoutId);
126
+ return false;
127
+ }
128
+ } catch {
129
+ return false;
130
+ }
131
+ };
132
+ case "tcp":
133
+ return async (port) => {
134
+ try {
135
+ const controller = new AbortController();
136
+ const timeoutId = setTimeout(() => controller.abort(), 1000);
137
+ try {
138
+ await fetch(`http://localhost:${port}/`, {
139
+ signal: controller.signal,
140
+ });
141
+ clearTimeout(timeoutId);
142
+ return true;
143
+ } catch (error) {
144
+ clearTimeout(timeoutId);
145
+ if (
146
+ error instanceof Error &&
147
+ error.message.includes("ECONNREFUSED")
148
+ ) {
149
+ return false;
150
+ }
151
+ return true;
152
+ }
153
+ } catch {
154
+ return false;
155
+ }
156
+ };
157
+ default:
158
+ return async () => true;
159
+ }
145
160
  }
146
161
  async function waitForService(serviceName, config, port, options = {}) {
147
- const {
148
- maxAttempts = MAX_ATTEMPTS,
149
- pollInterval = POLL_INTERVAL,
150
- projectName,
151
- root
152
- } = options;
153
- if (config.healthCheck === false || config.healthCheck === undefined) {
154
- return;
155
- }
156
- const healthCheckFn = typeof config.healthCheck === "function" ? config.healthCheck : createBuiltInHealthCheck(config.healthCheck, config.serviceName ?? serviceName, { projectName, root });
157
- for (let i = 0;i < maxAttempts; i++) {
158
- const isHealthy = await healthCheckFn(port);
159
- if (isHealthy)
160
- return;
161
- await sleep(pollInterval);
162
- }
163
- throw new Error(`Service ${serviceName} did not become ready in time`);
162
+ const {
163
+ maxAttempts = MAX_ATTEMPTS,
164
+ pollInterval = POLL_INTERVAL,
165
+ projectName,
166
+ root,
167
+ } = options;
168
+ if (config.healthCheck === false || config.healthCheck === undefined) {
169
+ return;
170
+ }
171
+ const healthCheckFn =
172
+ typeof config.healthCheck === "function"
173
+ ? config.healthCheck
174
+ : createBuiltInHealthCheck(
175
+ config.healthCheck,
176
+ config.serviceName ?? serviceName,
177
+ { projectName, root },
178
+ );
179
+ for (let i = 0; i < maxAttempts; i++) {
180
+ const isHealthy = await healthCheckFn(port);
181
+ if (isHealthy) return;
182
+ await sleep(pollInterval);
183
+ }
184
+ throw new Error(`Service ${serviceName} did not become ready in time`);
164
185
  }
165
186
  async function waitForAllServices(services, ports, options = {}) {
166
- const { verbose = true, ...waitOptions } = options;
167
- if (verbose)
168
- console.log("⏳ Waiting for services to be healthy...");
169
- const promises = Object.entries(services).map(([name, config]) => {
170
- const port = ports[name];
171
- if (port === undefined) {
172
- console.warn(`⚠️ No port found for service ${name}, skipping health check`);
173
- return Promise.resolve();
174
- }
175
- return waitForService(name, config, port, waitOptions);
176
- });
177
- await Promise.all(promises);
178
- if (verbose)
179
- console.log("✓ All services healthy");
187
+ const { verbose = true, ...waitOptions } = options;
188
+ if (verbose) console.log("⏳ Waiting for services to be healthy...");
189
+ const promises = Object.entries(services).map(([name, config]) => {
190
+ const port = ports[name];
191
+ if (port === undefined) {
192
+ console.warn(
193
+ `⚠️ No port found for service ${name}, skipping health check`,
194
+ );
195
+ return Promise.resolve();
196
+ }
197
+ return waitForService(name, config, port, waitOptions);
198
+ });
199
+ await Promise.all(promises);
200
+ if (verbose) console.log("✓ All services healthy");
180
201
  }
181
- async function waitForServiceByType(serviceName, healthCheckType, port, options = {}) {
182
- const {
183
- maxAttempts = MAX_ATTEMPTS,
184
- pollInterval = POLL_INTERVAL,
185
- verbose = false,
186
- projectName,
187
- root
188
- } = options;
189
- const healthCheckFn = createBuiltInHealthCheck(healthCheckType, serviceName, {
190
- projectName,
191
- root
192
- });
193
- for (let i = 0;i < maxAttempts; i++) {
194
- const isHealthy = await healthCheckFn(port);
195
- if (isHealthy) {
196
- if (verbose)
197
- console.log(`✓ ${serviceName} is ready`);
198
- return;
199
- }
200
- await sleep(pollInterval);
201
- }
202
- throw new Error(`Service ${serviceName} did not become ready in time`);
202
+ async function waitForServiceByType(
203
+ serviceName,
204
+ healthCheckType,
205
+ port,
206
+ options = {},
207
+ ) {
208
+ const {
209
+ maxAttempts = MAX_ATTEMPTS,
210
+ pollInterval = POLL_INTERVAL,
211
+ verbose = false,
212
+ projectName,
213
+ root,
214
+ } = options;
215
+ const healthCheckFn = createBuiltInHealthCheck(healthCheckType, serviceName, {
216
+ projectName,
217
+ root,
218
+ });
219
+ for (let i = 0; i < maxAttempts; i++) {
220
+ const isHealthy = await healthCheckFn(port);
221
+ if (isHealthy) {
222
+ if (verbose) console.log(`✓ ${serviceName} is ready`);
223
+ return;
224
+ }
225
+ await sleep(pollInterval);
226
+ }
227
+ throw new Error(`Service ${serviceName} did not become ready in time`);
203
228
  }
204
229
 
205
- export { POLL_INTERVAL, MAX_ATTEMPTS, isContainerRunning, areContainersRunning, startContainers, stopContainers, startService, createBuiltInHealthCheck, waitForService, waitForAllServices, waitForServiceByType };
230
+ export {
231
+ POLL_INTERVAL,
232
+ MAX_ATTEMPTS,
233
+ isContainerRunning,
234
+ areContainersRunning,
235
+ startContainers,
236
+ stopContainers,
237
+ startService,
238
+ createBuiltInHealthCheck,
239
+ waitForService,
240
+ waitForAllServices,
241
+ waitForServiceByType,
242
+ };