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,120 +1,124 @@
1
- import {
2
- isProcessAlive
3
- } from "./index-cty0bcry.js";
4
-
5
1
  // core/watchdog.ts
6
2
  import { spawn } from "node:child_process";
7
3
  import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
4
+ import { isProcessAlive } from "./index-cty0bcry.js";
5
+
8
6
  function getHeartbeatFile(projectName) {
9
- return `/tmp/${projectName}-heartbeat`;
7
+ return `/tmp/${projectName}-heartbeat`;
10
8
  }
11
9
  function getWatchdogPidFile(projectName) {
12
- return `/tmp/${projectName}-watchdog.pid`;
10
+ return `/tmp/${projectName}-watchdog.pid`;
13
11
  }
14
12
  var heartbeatInterval = null;
15
13
  function startHeartbeat(projectName, intervalMs = 30000) {
16
- const heartbeatFile = getHeartbeatFile(projectName);
17
- writeFileSync(heartbeatFile, Date.now().toString());
18
- heartbeatInterval = setInterval(() => {
19
- writeFileSync(heartbeatFile, Date.now().toString());
20
- }, intervalMs);
14
+ const heartbeatFile = getHeartbeatFile(projectName);
15
+ writeFileSync(heartbeatFile, Date.now().toString());
16
+ heartbeatInterval = setInterval(() => {
17
+ writeFileSync(heartbeatFile, Date.now().toString());
18
+ }, intervalMs);
21
19
  }
22
20
  function stopHeartbeat() {
23
- if (heartbeatInterval) {
24
- clearInterval(heartbeatInterval);
25
- heartbeatInterval = null;
26
- }
21
+ if (heartbeatInterval) {
22
+ clearInterval(heartbeatInterval);
23
+ heartbeatInterval = null;
24
+ }
27
25
  }
28
26
  function readHeartbeat(projectName) {
29
- const heartbeatFile = getHeartbeatFile(projectName);
30
- try {
31
- if (!existsSync(heartbeatFile))
32
- return null;
33
- const content = readFileSync(heartbeatFile, "utf-8");
34
- const timestamp = parseInt(content, 10);
35
- return Number.isNaN(timestamp) ? null : timestamp;
36
- } catch {
37
- return null;
38
- }
27
+ const heartbeatFile = getHeartbeatFile(projectName);
28
+ try {
29
+ if (!existsSync(heartbeatFile)) return null;
30
+ const content = readFileSync(heartbeatFile, "utf-8");
31
+ const timestamp = parseInt(content, 10);
32
+ return Number.isNaN(timestamp) ? null : timestamp;
33
+ } catch {
34
+ return null;
35
+ }
39
36
  }
40
37
  function removeHeartbeatFile(projectName) {
41
- const heartbeatFile = getHeartbeatFile(projectName);
42
- try {
43
- unlinkSync(heartbeatFile);
44
- } catch {}
38
+ const heartbeatFile = getHeartbeatFile(projectName);
39
+ try {
40
+ unlinkSync(heartbeatFile);
41
+ } catch {}
45
42
  }
46
43
  function isWatchdogRunning(projectName) {
47
- const pidFile = getWatchdogPidFile(projectName);
48
- try {
49
- if (!existsSync(pidFile))
50
- return false;
51
- const content = readFileSync(pidFile, "utf-8");
52
- const pid = parseInt(content, 10);
53
- if (Number.isNaN(pid))
54
- return false;
55
- return isProcessAlive(pid);
56
- } catch {
57
- return false;
58
- }
44
+ const pidFile = getWatchdogPidFile(projectName);
45
+ try {
46
+ if (!existsSync(pidFile)) return false;
47
+ const content = readFileSync(pidFile, "utf-8");
48
+ const pid = parseInt(content, 10);
49
+ if (Number.isNaN(pid)) return false;
50
+ return isProcessAlive(pid);
51
+ } catch {
52
+ return false;
53
+ }
59
54
  }
60
55
  function getWatchdogPid(projectName) {
61
- const pidFile = getWatchdogPidFile(projectName);
62
- try {
63
- if (!existsSync(pidFile))
64
- return null;
65
- const content = readFileSync(pidFile, "utf-8");
66
- const pid = parseInt(content, 10);
67
- if (Number.isNaN(pid))
68
- return null;
69
- if (!isProcessAlive(pid))
70
- return null;
71
- return pid;
72
- } catch {
73
- return null;
74
- }
56
+ const pidFile = getWatchdogPidFile(projectName);
57
+ try {
58
+ if (!existsSync(pidFile)) return null;
59
+ const content = readFileSync(pidFile, "utf-8");
60
+ const pid = parseInt(content, 10);
61
+ if (Number.isNaN(pid)) return null;
62
+ if (!isProcessAlive(pid)) return null;
63
+ return pid;
64
+ } catch {
65
+ return null;
66
+ }
75
67
  }
76
68
  async function spawnWatchdog(projectName, root, options = {}) {
77
- const { timeoutMinutes = 10, verbose = true, composeFile } = options;
78
- const existingPid = getWatchdogPid(projectName);
79
- if (existingPid) {
80
- if (verbose)
81
- console.log(`✓ Watchdog already running (PID: ${existingPid})`);
82
- return;
83
- }
84
- const pidFile = getWatchdogPidFile(projectName);
85
- try {
86
- unlinkSync(pidFile);
87
- } catch {}
88
- const watchdogScript = new URL("./watchdog-runner.ts", import.meta.url).pathname;
89
- const proc = spawn("bun", ["run", watchdogScript], {
90
- cwd: root,
91
- detached: true,
92
- stdio: "ignore",
93
- env: {
94
- ...process.env,
95
- WATCHDOG_PROJECT_NAME: projectName,
96
- WATCHDOG_HEARTBEAT_FILE: getHeartbeatFile(projectName),
97
- WATCHDOG_PID_FILE: pidFile,
98
- WATCHDOG_TIMEOUT_MS: String(timeoutMinutes * 60 * 1000),
99
- WATCHDOG_COMPOSE_ARG: composeFile ? `-f ${composeFile}` : ""
100
- }
101
- });
102
- proc.unref();
103
- if (verbose && proc.pid) {
104
- console.log(`✓ Watchdog started (PID: ${proc.pid})`);
105
- }
69
+ const { timeoutMinutes = 10, verbose = true, composeFile } = options;
70
+ const existingPid = getWatchdogPid(projectName);
71
+ if (existingPid) {
72
+ if (verbose)
73
+ console.log(`✓ Watchdog already running (PID: ${existingPid})`);
74
+ return;
75
+ }
76
+ const pidFile = getWatchdogPidFile(projectName);
77
+ try {
78
+ unlinkSync(pidFile);
79
+ } catch {}
80
+ const watchdogScript = new URL("./watchdog-runner.ts", import.meta.url)
81
+ .pathname;
82
+ const proc = spawn("bun", ["run", watchdogScript], {
83
+ cwd: root,
84
+ detached: true,
85
+ stdio: "ignore",
86
+ env: {
87
+ ...process.env,
88
+ WATCHDOG_PROJECT_NAME: projectName,
89
+ WATCHDOG_HEARTBEAT_FILE: getHeartbeatFile(projectName),
90
+ WATCHDOG_PID_FILE: pidFile,
91
+ WATCHDOG_TIMEOUT_MS: String(timeoutMinutes * 60 * 1000),
92
+ WATCHDOG_COMPOSE_ARG: composeFile ? `-f ${composeFile}` : "",
93
+ },
94
+ });
95
+ proc.unref();
96
+ if (verbose && proc.pid) {
97
+ console.log(`✓ Watchdog started (PID: ${proc.pid})`);
98
+ }
106
99
  }
107
100
  function stopWatchdog(projectName) {
108
- const pid = getWatchdogPid(projectName);
109
- if (pid) {
110
- try {
111
- process.kill(pid, "SIGTERM");
112
- } catch {}
113
- }
114
- const pidFile = getWatchdogPidFile(projectName);
115
- try {
116
- unlinkSync(pidFile);
117
- } catch {}
101
+ const pid = getWatchdogPid(projectName);
102
+ if (pid) {
103
+ try {
104
+ process.kill(pid, "SIGTERM");
105
+ } catch {}
106
+ }
107
+ const pidFile = getWatchdogPidFile(projectName);
108
+ try {
109
+ unlinkSync(pidFile);
110
+ } catch {}
118
111
  }
119
112
 
120
- export { getHeartbeatFile, getWatchdogPidFile, startHeartbeat, stopHeartbeat, readHeartbeat, removeHeartbeatFile, isWatchdogRunning, getWatchdogPid, spawnWatchdog, stopWatchdog };
113
+ export {
114
+ getHeartbeatFile,
115
+ getWatchdogPidFile,
116
+ startHeartbeat,
117
+ stopHeartbeat,
118
+ readHeartbeat,
119
+ removeHeartbeatFile,
120
+ isWatchdogRunning,
121
+ getWatchdogPid,
122
+ spawnWatchdog,
123
+ stopWatchdog,
124
+ };
@@ -0,0 +1,249 @@
1
+ // src/docker-compose/services/define-docker-service.ts
2
+ function defineDockerService(input) {
3
+ function createPresetDefinition(service) {
4
+ return {
5
+ kind: "preset",
6
+ preset: input.preset,
7
+ service,
8
+ };
9
+ }
10
+ function toServiceConfig(options = {}) {
11
+ const base = {
12
+ port: options.port ?? input.defaults.port,
13
+ healthCheck: options.healthCheck ?? input.defaults.healthCheck,
14
+ database: options.database,
15
+ user: options.user,
16
+ password: options.password,
17
+ serviceName: options.serviceName,
18
+ docker: createPresetDefinition(options.docker),
19
+ };
20
+ return input.enhanceServiceConfig
21
+ ? input.enhanceServiceConfig(base, options)
22
+ : base;
23
+ }
24
+ return {
25
+ preset: input.preset,
26
+ defaults: input.defaults,
27
+ build: input.build,
28
+ createPresetDefinition,
29
+ toServiceConfig,
30
+ };
31
+ }
32
+
33
+ // src/docker-compose/services/shared.ts
34
+ var DEFAULT_HEALTHCHECK_SETTINGS = {
35
+ interval: "250ms",
36
+ timeout: "5s",
37
+ retries: 20,
38
+ };
39
+ function getPortEnvName(portKey) {
40
+ return `${portKey.toUpperCase()}_PORT`;
41
+ }
42
+ function getDefaultPortBindings(serviceKey, config, preset) {
43
+ const envName = getPortEnvName(serviceKey);
44
+ const bindings = [];
45
+ const defaultInternalPort =
46
+ preset === "postgres"
47
+ ? 5432
48
+ : preset === "redis"
49
+ ? 6379
50
+ : preset === "clickhouse"
51
+ ? 8123
52
+ : config.port;
53
+ bindings.push(`\${${envName}:-${config.port}}:${defaultInternalPort}`);
54
+ if (config.secondaryPort !== undefined) {
55
+ const secondaryEnv = getPortEnvName(`${serviceKey}Secondary`);
56
+ const secondaryInternal =
57
+ preset === "clickhouse" ? 9000 : config.secondaryPort;
58
+ bindings.push(
59
+ `\${${secondaryEnv}:-${config.secondaryPort}}:${secondaryInternal}`,
60
+ );
61
+ }
62
+ return bindings;
63
+ }
64
+ function resolveHealthcheck(healthCheck, fallback, options) {
65
+ if (healthCheck === false) return;
66
+ if (typeof healthCheck === "function") return fallback;
67
+ if (!healthCheck) return fallback;
68
+ switch (healthCheck) {
69
+ case "pg_isready":
70
+ return {
71
+ test: ["CMD-SHELL", `pg_isready -U ${options.user ?? "postgres"}`],
72
+ ...DEFAULT_HEALTHCHECK_SETTINGS,
73
+ };
74
+ case "redis-cli":
75
+ return {
76
+ test: ["CMD", "redis-cli", "ping"],
77
+ ...DEFAULT_HEALTHCHECK_SETTINGS,
78
+ };
79
+ case "http":
80
+ return {
81
+ test: [
82
+ "CMD-SHELL",
83
+ `wget -qO- http://127.0.0.1:${options.internalPort}/ping || exit 1`,
84
+ ],
85
+ ...DEFAULT_HEALTHCHECK_SETTINGS,
86
+ };
87
+ case "tcp":
88
+ default:
89
+ return fallback;
90
+ }
91
+ }
92
+
93
+ // src/docker-compose/services/clickhouse.ts
94
+ var clickhouseDockerService = defineDockerService({
95
+ preset: "clickhouse",
96
+ defaults: {
97
+ port: 8123,
98
+ secondaryPort: 9000,
99
+ healthCheck: "http",
100
+ },
101
+ enhanceServiceConfig: (base, options) => ({
102
+ ...base,
103
+ secondaryPort: options.secondaryPort ?? 9000,
104
+ }),
105
+ build: ({ serviceKey, config }) => {
106
+ const user = config.user ?? "default";
107
+ const password = config.password ?? "clickhouse";
108
+ const database = config.database ?? "default";
109
+ const defaultHealthcheck = {
110
+ test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:8123/ping || exit 1"],
111
+ interval: "250ms",
112
+ timeout: "5s",
113
+ retries: 20,
114
+ };
115
+ return {
116
+ service: {
117
+ image: "clickhouse/clickhouse-server:24-alpine",
118
+ ports: getDefaultPortBindings(serviceKey, config, "clickhouse"),
119
+ volumes: [`${serviceKey}_data:/var/lib/clickhouse`],
120
+ environment: {
121
+ CLICKHOUSE_USER: user,
122
+ CLICKHOUSE_PASSWORD: password,
123
+ CLICKHOUSE_DB: database,
124
+ },
125
+ ulimits: {
126
+ nofile: {
127
+ soft: 262144,
128
+ hard: 262144,
129
+ },
130
+ },
131
+ healthcheck: resolveHealthcheck(
132
+ config.healthCheck,
133
+ defaultHealthcheck,
134
+ {
135
+ internalPort: 8123,
136
+ user,
137
+ },
138
+ ),
139
+ },
140
+ volume: `${serviceKey}_data`,
141
+ };
142
+ },
143
+ });
144
+
145
+ // src/docker-compose/services/postgres.ts
146
+ var postgresDockerService = defineDockerService({
147
+ preset: "postgres",
148
+ defaults: {
149
+ port: 5432,
150
+ healthCheck: "pg_isready",
151
+ },
152
+ build: ({ serviceKey, config }) => {
153
+ const user = config.user ?? "postgres";
154
+ const password = config.password ?? "postgres";
155
+ const database = config.database ?? "postgres";
156
+ const defaultHealthcheck = {
157
+ test: ["CMD-SHELL", `pg_isready -U ${user}`],
158
+ interval: "250ms",
159
+ timeout: "5s",
160
+ retries: 20,
161
+ };
162
+ return {
163
+ service: {
164
+ image: "pgvector/pgvector:pg16",
165
+ ports: getDefaultPortBindings(serviceKey, config, "postgres"),
166
+ volumes: [`${serviceKey}_data:/var/lib/postgresql/data`],
167
+ environment: {
168
+ POSTGRES_USER: user,
169
+ POSTGRES_PASSWORD: password,
170
+ POSTGRES_DB: database,
171
+ },
172
+ healthcheck: resolveHealthcheck(
173
+ config.healthCheck,
174
+ defaultHealthcheck,
175
+ {
176
+ internalPort: 5432,
177
+ user,
178
+ },
179
+ ),
180
+ },
181
+ volume: `${serviceKey}_data`,
182
+ };
183
+ },
184
+ });
185
+
186
+ // src/docker-compose/services/redis.ts
187
+ var redisDockerService = defineDockerService({
188
+ preset: "redis",
189
+ defaults: {
190
+ port: 6379,
191
+ healthCheck: "redis-cli",
192
+ },
193
+ build: ({ serviceKey, config }) => {
194
+ const defaultHealthcheck = {
195
+ test: ["CMD", "redis-cli", "ping"],
196
+ interval: "250ms",
197
+ timeout: "5s",
198
+ retries: 20,
199
+ };
200
+ return {
201
+ service: {
202
+ image: "redis:7-alpine",
203
+ ports: getDefaultPortBindings(serviceKey, config, "redis"),
204
+ healthcheck: resolveHealthcheck(
205
+ config.healthCheck,
206
+ defaultHealthcheck,
207
+ {
208
+ internalPort: 6379,
209
+ },
210
+ ),
211
+ },
212
+ };
213
+ },
214
+ });
215
+
216
+ // src/docker-compose/services/index.ts
217
+ var PRESET_SERVICES = {
218
+ postgres: postgresDockerService,
219
+ redis: redisDockerService,
220
+ clickhouse: clickhouseDockerService,
221
+ };
222
+ var service = {
223
+ postgres: postgresDockerService.toServiceConfig,
224
+ redis: redisDockerService.toServiceConfig,
225
+ clickhouse: clickhouseDockerService.toServiceConfig,
226
+ custom(options) {
227
+ return options;
228
+ },
229
+ };
230
+ function inferDockerPreset(serviceKey) {
231
+ const normalized = serviceKey.toLowerCase();
232
+ if (Object.hasOwn(PRESET_SERVICES, normalized)) {
233
+ return normalized;
234
+ }
235
+ return;
236
+ }
237
+ function buildPresetDockerService(preset, input) {
238
+ return PRESET_SERVICES[preset].build(input);
239
+ }
240
+
241
+ export {
242
+ getDefaultPortBindings,
243
+ clickhouseDockerService,
244
+ postgresDockerService,
245
+ redisDockerService,
246
+ service,
247
+ inferDockerPreset,
248
+ buildPresetDockerService,
249
+ };