buncargo 1.0.29 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.d.ts +1 -12
- package/dist/bin.js +261 -253
- package/dist/cli/bin.d.ts +13 -0
- package/dist/cli/bin.js +317 -0
- package/dist/cli/commands/help.d.ts +1 -0
- package/dist/cli/commands/runtime.d.ts +5 -0
- package/dist/cli/commands/version.d.ts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +14 -0
- package/dist/cli/run-cli.d.ts +30 -0
- package/dist/cli.d.ts +1 -22
- package/dist/cli.js +5 -13
- package/dist/config/config.d.ts +1 -0
- package/dist/config/define-config.d.ts +13 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +15 -0
- package/dist/config/merge-configs.d.ts +3 -0
- package/dist/config/validate-config.d.ts +3 -0
- package/dist/config.d.ts +1 -72
- package/dist/config.js +12 -12
- package/dist/core/docker.d.ts +1 -83
- package/dist/core/docker.js +35 -32
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +123 -118
- package/dist/core/network.js +2 -2
- package/dist/core/ports.js +1 -1
- package/dist/core/process.js +1 -1
- package/dist/core/quick-tunnel/cloudflared-process.d.ts +10 -0
- package/dist/core/quick-tunnel/constants.d.ts +9 -0
- package/dist/core/quick-tunnel/index.d.ts +17 -0
- package/dist/core/quick-tunnel/install.d.ts +1 -0
- package/dist/core/tunnel.d.ts +34 -0
- package/dist/core/utils.js +2 -2
- package/dist/core/watchdog-runner.js +45 -42
- package/dist/core/watchdog.d.ts +1 -0
- package/dist/core/watchdog.js +4 -2
- package/dist/docker/index.d.ts +1 -0
- package/dist/docker/index.js +38 -0
- package/dist/docker/runtime.d.ts +87 -0
- package/dist/docker/runtime.js +37 -0
- package/dist/docker-compose/compose.d.ts +1 -0
- package/dist/docker-compose/generated-file.d.ts +7 -0
- package/dist/docker-compose/index.d.ts +3 -0
- package/dist/docker-compose/index.js +15 -0
- package/dist/docker-compose/model.d.ts +6 -0
- package/dist/docker-compose/services/clickhouse.d.ts +16 -0
- package/dist/docker-compose/services/define-docker-service.d.ts +41 -0
- package/dist/docker-compose/services/index.d.ts +23 -0
- package/dist/docker-compose/services/index.js +17 -0
- package/dist/docker-compose/services/postgres.d.ts +12 -0
- package/dist/docker-compose/services/redis.d.ts +12 -0
- package/dist/docker-compose/services/shared.d.ts +7 -0
- package/dist/docker-compose/yaml.d.ts +2 -0
- package/dist/environment/create-dev-environment.d.ts +23 -0
- package/dist/environment/index.d.ts +1 -0
- package/dist/environment/index.js +15 -0
- package/dist/environment/logging.d.ts +17 -0
- package/dist/environment/only-apps.d.ts +10 -0
- package/dist/environment/seeding.d.ts +9 -0
- package/dist/environment.d.ts +1 -23
- package/dist/environment.js +12 -14
- package/dist/index-045jksh5.js +147 -0
- package/dist/index-08wa79cs.js +125 -117
- package/dist/index-0kxnae3z.js +335 -0
- package/dist/index-1mdrf7nz.js +51 -43
- package/dist/index-1yvbwj4k.js +262 -242
- package/dist/index-23ev345g.js +475 -0
- package/dist/index-2ckr49sf.js +228 -0
- package/dist/index-2f47khe5.js +376 -369
- package/dist/index-2fr3g85b.js +220 -183
- package/dist/index-38xnzpa6.js +450 -0
- package/dist/index-3eyrdxw9.js +577 -0
- package/dist/index-3h3dhtf2.js +51 -43
- package/dist/index-42x95209.js +51 -43
- package/dist/index-4gp0az1g.js +145 -0
- package/dist/index-4xrxh8yv.js +72 -0
- package/dist/index-5aq985p4.js +250 -0
- package/dist/index-5gmws6ah.js +181 -0
- package/dist/index-5hka0tff.js +78 -76
- package/dist/index-5rfqps4b.js +3 -0
- package/dist/index-5t9jxqm0.js +428 -0
- package/dist/index-6c1w1xk5.js +101 -0
- package/dist/index-6cmex7m5.js +72 -0
- package/dist/index-6d6x175r.js +572 -0
- package/dist/index-6fm7mvwj.js +118 -97
- package/dist/index-6srpc523.js +127 -128
- package/dist/index-731rzzfp.js +157 -142
- package/dist/index-75y4cg2z.js +51 -43
- package/dist/index-7ja4ywyj.js +126 -127
- package/dist/index-7v19es2e.js +666 -0
- package/dist/index-8bw1cmz4.js +531 -0
- package/dist/index-8hbbj1mp.js +120 -121
- package/dist/index-8xj2p5n5.js +118 -97
- package/dist/index-9wyhzw0h.js +574 -0
- package/dist/index-ag90ry8t.js +576 -0
- package/dist/index-bj79tw5w.js +0 -0
- package/dist/index-bnk6nr0g.js +73 -0
- package/dist/index-brbbzyks.js +72 -0
- package/dist/index-byeqyjrz.js +72 -0
- package/dist/index-c0dr6mcv.js +123 -0
- package/dist/index-cty0bcry.js +235 -218
- package/dist/index-d8tyv5se.js +228 -0
- package/dist/index-d9efy0n4.js +176 -150
- package/dist/index-enj4zdma.js +574 -0
- package/dist/index-etfmqjjf.js +427 -0
- package/dist/index-fb29934k.js +172 -0
- package/dist/index-g50jw1yf.js +72 -0
- package/dist/index-g6eb5wdw.js +118 -117
- package/dist/index-ggq3yryx.js +99 -95
- package/dist/index-h70tce00.js +177 -0
- package/dist/index-hkxtfqtc.js +333 -0
- package/dist/index-k370bech.js +72 -0
- package/dist/index-kf3dhser.js +146 -143
- package/dist/index-ma6tgdb2.js +500 -0
- package/dist/index-mam0bcyz.js +123 -0
- package/dist/index-mm412dkp.js +274 -0
- package/dist/index-n8v18aeb.js +0 -0
- package/dist/index-ndnmnsej.js +378 -371
- package/dist/index-p8wty0e2.js +389 -379
- package/dist/index-qa8akv6y.js +666 -0
- package/dist/index-qfphr2fd.js +78 -76
- package/dist/index-qqmms8rs.js +51 -43
- package/dist/index-qw4093g2.js +51 -43
- package/dist/index-qzwpzjbx.js +121 -122
- package/dist/index-segbnm0h.js +146 -143
- package/dist/index-t0fj6gg1.js +112 -0
- package/dist/index-thdkwnv7.js +122 -0
- package/dist/index-tjbx2r2t.js +270 -0
- package/dist/index-tjqw9vtj.js +62 -54
- package/dist/index-vbpb89jy.js +248 -0
- package/dist/index-vg55rq0y.js +250 -0
- package/dist/index-vhs88xhe.js +99 -95
- package/dist/index-vs81yaks.js +244 -0
- package/dist/index-w8zxnjka.js +249 -0
- package/dist/index-wk2na3t9.js +385 -375
- package/dist/index-wz9x8g7z.js +383 -373
- package/dist/index-x249gyde.js +388 -378
- package/dist/index-x54nbgs7.js +355 -0
- package/dist/index-xkvd0nsd.js +187 -0
- package/dist/index-yedqxm1z.js +80 -0
- package/dist/index-yz4jfz7z.js +338 -0
- package/dist/index-zfjzzjkf.js +240 -199
- package/dist/index.d.ts +12 -8
- package/dist/index.js +56 -34
- package/dist/lint.d.ts +1 -46
- package/dist/lint.js +3 -7
- package/dist/loader/cache.d.ts +4 -0
- package/dist/loader/find-config-file.d.ts +2 -0
- package/dist/loader/index.d.ts +5 -0
- package/dist/loader/index.js +24 -0
- package/dist/loader/load-dev-env.d.ts +5 -0
- package/dist/loader/loader.d.ts +1 -0
- package/dist/loader.d.ts +1 -45
- package/dist/loader.js +22 -20
- package/dist/prisma/index.d.ts +1 -0
- package/dist/prisma/prisma.d.ts +29 -0
- package/dist/prisma.d.ts +1 -29
- package/dist/prisma.js +6 -10
- package/dist/src/bin.js +309 -0
- package/dist/src/cli.js +5 -0
- package/dist/src/config.js +15 -0
- package/dist/src/core/docker.js +38 -0
- package/dist/src/core/index.js +130 -0
- package/dist/src/core/network.js +9 -0
- package/dist/src/core/ports.js +23 -0
- package/dist/src/core/process.js +31 -0
- package/dist/src/core/utils.js +11 -0
- package/dist/src/core/watchdog-runner.js +69 -0
- package/dist/src/core/watchdog.js +28 -0
- package/dist/src/docker/runtime.js +37 -0
- package/dist/src/docker-compose/index.js +16 -0
- package/dist/src/docker-compose/services/index.js +17 -0
- package/dist/src/environment.js +12 -0
- package/dist/src/index.js +122 -0
- package/dist/src/lint.js +3 -0
- package/dist/src/loader.js +25 -0
- package/dist/src/prisma.js +6 -0
- package/dist/src/types.js +0 -0
- package/dist/typecheck/index.d.ts +1 -0
- package/dist/typecheck/index.js +7 -0
- package/dist/typecheck/typecheck.d.ts +46 -0
- package/dist/types/all-types.d.ts +544 -0
- package/dist/types/cli.d.ts +1 -0
- package/dist/types/config.d.ts +6 -0
- package/dist/types/docker.d.ts +15 -0
- package/dist/types/environment.d.ts +8 -0
- package/dist/types/hooks.d.ts +9 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +0 -0
- package/dist/types/prisma.d.ts +1 -0
- package/dist/types.d.ts +1 -399
- package/package.json +55 -48
- package/readme.md +365 -109
- package/src/cli/bin.ts +77 -0
- package/src/cli/commands/help.ts +39 -0
- package/src/cli/commands/runtime.ts +72 -0
- package/src/cli/commands/version.ts +4 -0
- package/src/cli/index.ts +1 -0
- package/{cli.ts → src/cli/run-cli.ts} +114 -10
- package/src/config/define-config.ts +30 -0
- package/src/config/index.ts +3 -0
- package/src/config/merge-configs.ts +33 -0
- package/src/config/validate-config.ts +136 -0
- package/{core → src/core}/index.ts +2 -2
- package/{core → src/core}/ports.ts +5 -2
- package/{core → src/core}/process.ts +6 -2
- package/src/core/quick-tunnel/cloudflared-process.ts +83 -0
- package/src/core/quick-tunnel/constants.ts +31 -0
- package/src/core/quick-tunnel/index.ts +96 -0
- package/src/core/quick-tunnel/install.ts +160 -0
- package/src/core/tunnel.ts +165 -0
- package/{core → src/core}/utils.ts +1 -0
- package/{core → src/core}/watchdog.ts +5 -1
- package/src/docker/index.ts +1 -0
- package/{core/docker.ts → src/docker/runtime.ts} +11 -4
- package/src/docker-compose/generated-file.ts +45 -0
- package/src/docker-compose/index.ts +7 -0
- package/src/docker-compose/model.ts +197 -0
- package/src/docker-compose/services/clickhouse.ts +79 -0
- package/src/docker-compose/services/define-docker-service.ts +109 -0
- package/src/docker-compose/services/index.ts +67 -0
- package/src/docker-compose/services/postgres.ts +60 -0
- package/src/docker-compose/services/redis.ts +48 -0
- package/src/docker-compose/services/shared.ts +79 -0
- package/src/docker-compose/yaml.ts +88 -0
- package/{environment.ts → src/environment/create-dev-environment.ts} +214 -141
- package/src/environment/index.ts +1 -0
- package/src/environment/logging.ts +115 -0
- package/src/environment/only-apps.ts +34 -0
- package/src/environment/seeding.ts +57 -0
- package/{index.ts → src/index.ts} +52 -20
- package/src/loader/cache.ts +23 -0
- package/src/loader/find-config-file.ts +29 -0
- package/src/loader/index.ts +17 -0
- package/src/loader/load-dev-env.ts +38 -0
- package/src/prisma/index.ts +1 -0
- package/{prisma.ts → src/prisma/prisma.ts} +4 -2
- package/src/typecheck/index.ts +1 -0
- package/{types.ts → src/types/all-types.ts} +186 -8
- package/src/types/index.ts +1 -0
- package/bin.ts +0 -192
- package/config.ts +0 -194
- package/loader.ts +0 -126
- /package/{core → src/core}/network.ts +0 -0
- /package/{core → src/core}/watchdog-runner.ts +0 -0
- /package/{lint.ts → src/typecheck/typecheck.ts} +0 -0
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Health check function signature for custom health checks.
|
|
3
|
+
*/
|
|
4
|
+
export type HealthCheckFn = (port: number) => Promise<boolean>;
|
|
5
|
+
/**
|
|
6
|
+
* Built-in health check types that map to common patterns.
|
|
7
|
+
*/
|
|
8
|
+
export type BuiltInHealthCheck = "pg_isready" | "redis-cli" | "http" | "tcp";
|
|
9
|
+
/**
|
|
10
|
+
* URL builder context passed to urlTemplate function.
|
|
11
|
+
*/
|
|
12
|
+
export interface UrlBuilderContext {
|
|
13
|
+
port: number;
|
|
14
|
+
secondaryPort?: number;
|
|
15
|
+
host: string;
|
|
16
|
+
localIp: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* URL builder function receives port info and returns the connection URL.
|
|
20
|
+
*/
|
|
21
|
+
export type UrlBuilderFn = (ctx: UrlBuilderContext) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Recursive YAML-safe value used for Docker Compose objects.
|
|
24
|
+
*/
|
|
25
|
+
export type DockerComposeNode = string | number | boolean | null | DockerComposeNode[] | {
|
|
26
|
+
[key: string]: DockerComposeNode | undefined;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Built-in Docker service presets.
|
|
30
|
+
*/
|
|
31
|
+
export type DockerPresetName = "postgres" | "redis" | "clickhouse";
|
|
32
|
+
/**
|
|
33
|
+
* Docker Compose healthcheck object.
|
|
34
|
+
*/
|
|
35
|
+
export interface DockerComposeHealthcheckRaw {
|
|
36
|
+
test?: string[] | string;
|
|
37
|
+
interval?: string;
|
|
38
|
+
timeout?: string;
|
|
39
|
+
retries?: number;
|
|
40
|
+
start_period?: string;
|
|
41
|
+
disable?: boolean;
|
|
42
|
+
[composeKey: string]: DockerComposeNode | undefined;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Docker Compose service (raw escape hatch).
|
|
46
|
+
* Includes common fields plus index signature for advanced keys.
|
|
47
|
+
*/
|
|
48
|
+
export interface DockerComposeServiceRaw {
|
|
49
|
+
image?: string;
|
|
50
|
+
container_name?: string;
|
|
51
|
+
ports?: string[];
|
|
52
|
+
volumes?: string[];
|
|
53
|
+
environment?: Record<string, string | number | boolean>;
|
|
54
|
+
command?: string | string[];
|
|
55
|
+
entrypoint?: string | string[];
|
|
56
|
+
depends_on?: string[] | Record<string, DockerComposeNode>;
|
|
57
|
+
healthcheck?: DockerComposeHealthcheckRaw;
|
|
58
|
+
ulimits?: Record<string, number | {
|
|
59
|
+
soft: number;
|
|
60
|
+
hard: number;
|
|
61
|
+
}>;
|
|
62
|
+
restart?: string;
|
|
63
|
+
working_dir?: string;
|
|
64
|
+
[composeKey: string]: DockerComposeNode | undefined;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Docker Compose volume object.
|
|
68
|
+
*/
|
|
69
|
+
export interface DockerComposeVolumeRaw {
|
|
70
|
+
driver?: string;
|
|
71
|
+
driver_opts?: Record<string, string | number | boolean>;
|
|
72
|
+
[composeKey: string]: DockerComposeNode | undefined;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Helper-friendly preset service definition.
|
|
76
|
+
*/
|
|
77
|
+
export interface DockerPresetServiceDefinition {
|
|
78
|
+
kind: "preset";
|
|
79
|
+
preset: DockerPresetName;
|
|
80
|
+
service?: DockerComposeServiceRaw;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Docker service definition accepted by service config.
|
|
84
|
+
* - raw object is the manual escape hatch
|
|
85
|
+
* - helper mode returns `kind`-based definitions
|
|
86
|
+
*/
|
|
87
|
+
export type DockerServiceDefinition = DockerComposeServiceRaw | DockerPresetServiceDefinition;
|
|
88
|
+
/**
|
|
89
|
+
* Docker Compose generation configuration.
|
|
90
|
+
*/
|
|
91
|
+
export interface DockerComposeGenerationOptions {
|
|
92
|
+
/** Path to generated compose file relative to root. Default: '.buncargo/docker-compose.generated.yml' */
|
|
93
|
+
generatedFile?: string;
|
|
94
|
+
/** Write strategy for generated compose file. Default: 'always' */
|
|
95
|
+
writeStrategy?: "always" | "if-missing";
|
|
96
|
+
/** Extra top-level named volumes */
|
|
97
|
+
volumes?: Record<string, DockerComposeVolumeRaw>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Configuration for a Docker Compose service (e.g., postgres, redis).
|
|
101
|
+
*/
|
|
102
|
+
export interface ServiceConfig {
|
|
103
|
+
/** Base port for the service (before offset is applied) */
|
|
104
|
+
port: number;
|
|
105
|
+
/** Whether this service can be exposed publicly via tunnel */
|
|
106
|
+
expose?: boolean;
|
|
107
|
+
/** Optional secondary port (e.g., ClickHouse native protocol) */
|
|
108
|
+
secondaryPort?: number;
|
|
109
|
+
/** Health check: built-in name, custom function, or disabled (false) */
|
|
110
|
+
healthCheck?: BuiltInHealthCheck | HealthCheckFn | false;
|
|
111
|
+
/** URL builder function that returns the connection URL */
|
|
112
|
+
urlTemplate?: UrlBuilderFn;
|
|
113
|
+
/** Docker Compose service name (defaults to the key name) */
|
|
114
|
+
serviceName?: string;
|
|
115
|
+
/** Database name (for postgres, mysql, clickhouse). Enables built-in URL template. */
|
|
116
|
+
database?: string;
|
|
117
|
+
/** Username (default: 'postgres' for postgres, 'root' for mysql, 'default' for clickhouse) */
|
|
118
|
+
user?: string;
|
|
119
|
+
/** Password (default: 'postgres' for postgres, 'root' for mysql, 'clickhouse' for clickhouse) */
|
|
120
|
+
password?: string;
|
|
121
|
+
/** Docker Compose service definition (preset helper or raw escape hatch) */
|
|
122
|
+
docker?: DockerServiceDefinition;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Configuration for an application (e.g., api, web).
|
|
126
|
+
*/
|
|
127
|
+
export interface AppConfig {
|
|
128
|
+
/** Base port for the app (before offset is applied) */
|
|
129
|
+
port: number;
|
|
130
|
+
/** Whether this app can be exposed publicly via tunnel */
|
|
131
|
+
expose?: boolean;
|
|
132
|
+
/** Command to start the dev server */
|
|
133
|
+
devCommand: string;
|
|
134
|
+
/** Command to start production server (optional) */
|
|
135
|
+
prodCommand?: string;
|
|
136
|
+
/** Command to build for production (optional) */
|
|
137
|
+
buildCommand?: string;
|
|
138
|
+
/** Working directory relative to monorepo root */
|
|
139
|
+
cwd?: string;
|
|
140
|
+
/** Health check endpoint path (e.g., '/api/health') */
|
|
141
|
+
healthEndpoint?: string;
|
|
142
|
+
/** Timeout for health check in milliseconds */
|
|
143
|
+
healthTimeout?: number;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Execution options for the exec helper.
|
|
147
|
+
*/
|
|
148
|
+
export interface ExecOptions {
|
|
149
|
+
/** Working directory relative to monorepo root */
|
|
150
|
+
cwd?: string;
|
|
151
|
+
/** Print output to console */
|
|
152
|
+
verbose?: boolean;
|
|
153
|
+
/** Environment variables to add */
|
|
154
|
+
env?: Record<string, string>;
|
|
155
|
+
/** Throw on non-zero exit code (default: true) */
|
|
156
|
+
throwOnError?: boolean;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Context passed to hooks for executing commands and accessing environment.
|
|
160
|
+
*/
|
|
161
|
+
export interface HookContext<TServices extends Record<string, ServiceConfig>, TApps extends Record<string, AppConfig>> {
|
|
162
|
+
/** Project name (with suffix if applicable) */
|
|
163
|
+
projectName: string;
|
|
164
|
+
/** Computed ports for all services and apps */
|
|
165
|
+
ports: ComputedPorts<TServices, TApps>;
|
|
166
|
+
/** Computed URLs for all services and apps */
|
|
167
|
+
urls: ComputedUrls<TServices, TApps>;
|
|
168
|
+
/** Public tunnel URLs for exposed services/apps (when active) */
|
|
169
|
+
publicUrls: ComputedPublicUrls<TServices, TApps>;
|
|
170
|
+
/** Execute a shell command with environment variables set */
|
|
171
|
+
exec: (cmd: string, options?: ExecOptions) => Promise<{
|
|
172
|
+
exitCode: number;
|
|
173
|
+
stdout: string;
|
|
174
|
+
stderr: string;
|
|
175
|
+
}>;
|
|
176
|
+
/** Path to monorepo root */
|
|
177
|
+
root: string;
|
|
178
|
+
/** Whether running in CI environment */
|
|
179
|
+
isCI: boolean;
|
|
180
|
+
/** Port offset applied to all ports */
|
|
181
|
+
portOffset: number;
|
|
182
|
+
/** Local IP address for mobile connectivity */
|
|
183
|
+
localIp: string;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Lifecycle hooks for customizing the dev environment.
|
|
187
|
+
*/
|
|
188
|
+
export interface DevHooks<TServices extends Record<string, ServiceConfig>, TApps extends Record<string, AppConfig>> {
|
|
189
|
+
/** Called after all containers are healthy */
|
|
190
|
+
afterContainersReady?: (ctx: HookContext<TServices, TApps>) => Promise<void>;
|
|
191
|
+
/** Called before starting dev servers */
|
|
192
|
+
beforeServers?: (ctx: HookContext<TServices, TApps>) => Promise<void>;
|
|
193
|
+
/** Called after dev servers are ready */
|
|
194
|
+
afterServers?: (ctx: HookContext<TServices, TApps>) => Promise<void>;
|
|
195
|
+
/** Called before stopping the environment */
|
|
196
|
+
beforeStop?: (ctx: HookContext<TServices, TApps>) => Promise<void>;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Configuration for Prisma integration.
|
|
200
|
+
*/
|
|
201
|
+
export interface PrismaConfig {
|
|
202
|
+
/** Working directory where prisma schema lives (relative to monorepo root). Default: 'packages/prisma' */
|
|
203
|
+
cwd?: string;
|
|
204
|
+
/** Docker Compose service name for the database. Default: 'postgres' */
|
|
205
|
+
service?: string;
|
|
206
|
+
/** Environment variable name for the database URL. Default: 'DATABASE_URL' */
|
|
207
|
+
urlEnvVar?: string;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Prisma runner interface available on dev.prisma when prisma is configured.
|
|
211
|
+
*/
|
|
212
|
+
export interface PrismaRunner {
|
|
213
|
+
/** Run a prisma command with the correct environment. Returns exit code. */
|
|
214
|
+
run(args: string[]): Promise<number>;
|
|
215
|
+
/** Get the database URL from the dev environment */
|
|
216
|
+
getDatabaseUrl(): string;
|
|
217
|
+
/** Ensure the database container is running and healthy */
|
|
218
|
+
ensureDatabase(): Promise<void>;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Configuration for a migration command to run after containers are ready.
|
|
222
|
+
*/
|
|
223
|
+
export interface MigrationConfig {
|
|
224
|
+
/** Display name for the migration (e.g., 'prisma', 'clickhouse') */
|
|
225
|
+
name: string;
|
|
226
|
+
/** Command to run the migration */
|
|
227
|
+
command: string;
|
|
228
|
+
/** Working directory relative to monorepo root */
|
|
229
|
+
cwd?: string;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Helper functions available in the seed check function.
|
|
233
|
+
*/
|
|
234
|
+
export interface SeedCheckHelpers<TServices extends Record<string, ServiceConfig>> {
|
|
235
|
+
/**
|
|
236
|
+
* Check if a database table is empty.
|
|
237
|
+
* Returns true if the table has 0 rows (needs seeding), false otherwise.
|
|
238
|
+
*
|
|
239
|
+
* @param tableName - The table name to check (e.g., 'User')
|
|
240
|
+
* @param service - The database service name. Default: 'postgres'
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* seed: {
|
|
245
|
+
* command: 'bun run run:seeder',
|
|
246
|
+
* check: ({ checkTable }) => checkTable('User')
|
|
247
|
+
* }
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
checkTable: (tableName: string, service: keyof TServices) => Promise<boolean>;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Context passed to the seed check function.
|
|
254
|
+
*/
|
|
255
|
+
export type SeedCheckContext<TServices extends Record<string, ServiceConfig>, TApps extends Record<string, AppConfig>> = HookContext<TServices, TApps> & SeedCheckHelpers<TServices>;
|
|
256
|
+
/**
|
|
257
|
+
* Configuration for database seeding.
|
|
258
|
+
*/
|
|
259
|
+
export interface SeedConfig<TServices extends Record<string, ServiceConfig>, TApps extends Record<string, AppConfig>> {
|
|
260
|
+
/** Command to run the seeder */
|
|
261
|
+
command: string;
|
|
262
|
+
/** Working directory relative to monorepo root */
|
|
263
|
+
cwd?: string;
|
|
264
|
+
/**
|
|
265
|
+
* Check function to determine if seeding is needed.
|
|
266
|
+
* Return true to run the seed command, false to skip.
|
|
267
|
+
* If not provided, seeding always runs.
|
|
268
|
+
*
|
|
269
|
+
* Receives hook context plus helper functions like `checkTable`.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```typescript
|
|
273
|
+
* seed: {
|
|
274
|
+
* command: 'bun run run:seeder',
|
|
275
|
+
* check: ({ checkTable }) => checkTable('User')
|
|
276
|
+
* }
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
check?: (ctx: SeedCheckContext<TServices, TApps>) => Promise<boolean>;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Options for the dev environment.
|
|
283
|
+
*/
|
|
284
|
+
export interface DevOptions {
|
|
285
|
+
/**
|
|
286
|
+
* Enable worktree isolation. When true (default), each worktree gets:
|
|
287
|
+
* - unique ports (offset)
|
|
288
|
+
* - unique Docker Compose project name (separate containers/networks/volumes)
|
|
289
|
+
*
|
|
290
|
+
* Set to false to intentionally share Docker state across worktrees.
|
|
291
|
+
*/
|
|
292
|
+
worktreeIsolation?: boolean;
|
|
293
|
+
/** Auto-shutdown after idle time in ms. Set to false to disable. Default: false */
|
|
294
|
+
autoShutdown?: number | false;
|
|
295
|
+
/** Default verbose setting for all operations. Default: true */
|
|
296
|
+
verbose?: boolean;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Environment variable builder function.
|
|
300
|
+
*/
|
|
301
|
+
export type EnvVarsBuilder<TServices extends Record<string, ServiceConfig>, TApps extends Record<string, AppConfig>> = (ports: ComputedPorts<TServices, TApps>, urls: ComputedUrls<TServices, TApps>, ctx: {
|
|
302
|
+
projectName: string;
|
|
303
|
+
localIp: string;
|
|
304
|
+
portOffset: number;
|
|
305
|
+
publicUrls: ComputedPublicUrls<TServices, TApps>;
|
|
306
|
+
}) => Record<string, string | number>;
|
|
307
|
+
/**
|
|
308
|
+
* Main configuration for the dev environment.
|
|
309
|
+
*/
|
|
310
|
+
export interface DevConfig<TServices extends Record<string, ServiceConfig> = Record<string, ServiceConfig>, TApps extends Record<string, AppConfig> = Record<string, AppConfig>> {
|
|
311
|
+
/** Prefix for Docker project name (e.g., 'myapp' -> 'myapp-main') */
|
|
312
|
+
projectPrefix: string;
|
|
313
|
+
/** Docker Compose services to manage */
|
|
314
|
+
services: TServices;
|
|
315
|
+
/** Applications to start (optional) */
|
|
316
|
+
apps?: TApps;
|
|
317
|
+
/**
|
|
318
|
+
* Environment variables builder. Define all env vars here.
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* ```typescript
|
|
322
|
+
* envVars: (ports, urls, { localIp, publicUrls }) => ({
|
|
323
|
+
* DATABASE_URL: urls.postgres,
|
|
324
|
+
* BASE_URL: urls.api,
|
|
325
|
+
* VITE_PORT: ports.platform,
|
|
326
|
+
* EXPO_API_URL: `http://${localIp}:${ports.api}`,
|
|
327
|
+
* WEBHOOK_URL: publicUrls.api
|
|
328
|
+
* })
|
|
329
|
+
* ```
|
|
330
|
+
*/
|
|
331
|
+
envVars?: EnvVarsBuilder<TServices, TApps>;
|
|
332
|
+
/** Lifecycle hooks (optional) */
|
|
333
|
+
hooks?: DevHooks<TServices, TApps>;
|
|
334
|
+
/** Migrations to run after containers are ready (optional). Runs in parallel. */
|
|
335
|
+
migrations?: MigrationConfig[];
|
|
336
|
+
/** Seed configuration (optional). Runs after migrations, before servers. */
|
|
337
|
+
seed?: SeedConfig<TServices, TApps>;
|
|
338
|
+
/** Prisma configuration (optional). When set, dev.prisma is available. */
|
|
339
|
+
prisma?: PrismaConfig;
|
|
340
|
+
/** Additional options (optional) */
|
|
341
|
+
options?: DevOptions;
|
|
342
|
+
/** Docker Compose generation options (optional) */
|
|
343
|
+
docker?: DockerComposeGenerationOptions;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Computed ports object - maps service/app names to their port numbers.
|
|
347
|
+
*/
|
|
348
|
+
type ServicesWithSecondaryPort<TServices extends Record<string, ServiceConfig>> = {
|
|
349
|
+
[K in keyof TServices as TServices[K] extends {
|
|
350
|
+
secondaryPort: number;
|
|
351
|
+
} ? `${K & string}Secondary` : never]: number;
|
|
352
|
+
};
|
|
353
|
+
export type ComputedPorts<TServices extends Record<string, ServiceConfig>, TApps extends Record<string, AppConfig>> = {
|
|
354
|
+
[K in keyof TServices]: number;
|
|
355
|
+
} & {
|
|
356
|
+
[K in keyof TApps]: number;
|
|
357
|
+
} & ServicesWithSecondaryPort<TServices>;
|
|
358
|
+
/**
|
|
359
|
+
* Computed URLs object - maps service/app names to their URLs.
|
|
360
|
+
*/
|
|
361
|
+
export type ComputedUrls<TServices extends Record<string, ServiceConfig>, TApps extends Record<string, AppConfig>> = {
|
|
362
|
+
[K in keyof TServices]: string;
|
|
363
|
+
} & {
|
|
364
|
+
[K in keyof TApps]: string;
|
|
365
|
+
};
|
|
366
|
+
export type ComputedPublicUrls<TServices extends Record<string, ServiceConfig>, TApps extends Record<string, AppConfig>> = Partial<{
|
|
367
|
+
[K in keyof TServices | keyof TApps]: string;
|
|
368
|
+
}>;
|
|
369
|
+
/**
|
|
370
|
+
* Options for starting the dev environment.
|
|
371
|
+
*/
|
|
372
|
+
export interface StartOptions {
|
|
373
|
+
/** Print output to console. Default: true */
|
|
374
|
+
verbose?: boolean;
|
|
375
|
+
/** Wait for containers to be healthy. Default: true */
|
|
376
|
+
wait?: boolean;
|
|
377
|
+
/** Start dev servers after containers. Default: true */
|
|
378
|
+
startServers?: boolean;
|
|
379
|
+
/** Use production build for servers. Default: false (true in CI) */
|
|
380
|
+
productionBuild?: boolean;
|
|
381
|
+
/** Environment suffix for isolation (e.g., 'test'). Default: undefined */
|
|
382
|
+
suffix?: string;
|
|
383
|
+
/** Skip automatic seeding (useful when CLI handles seeding separately). Default: false */
|
|
384
|
+
skipSeed?: boolean;
|
|
385
|
+
/** Skip the initial `logInfo` banner (CLI uses this with `--expose`, then logs once with tunnel URLs). Default: false */
|
|
386
|
+
skipEnvironmentLog?: boolean;
|
|
387
|
+
/** If set, start and wait for only these app names (must exist in `apps`). */
|
|
388
|
+
onlyApps?: string[];
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Options for stopping the dev environment.
|
|
392
|
+
*/
|
|
393
|
+
export interface StopOptions {
|
|
394
|
+
/** Print output to console. Default: true */
|
|
395
|
+
verbose?: boolean;
|
|
396
|
+
/** Remove Docker volumes (destroys data). Default: false */
|
|
397
|
+
removeVolumes?: boolean;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Process IDs for running dev servers.
|
|
401
|
+
*/
|
|
402
|
+
export interface DevServerPids {
|
|
403
|
+
[appName: string]: number;
|
|
404
|
+
}
|
|
405
|
+
/** Tunnel rows passed to `logInfo` for public URL lines (matches `PublicTunnel` without `close`) */
|
|
406
|
+
export interface DevEnvironmentTunnelLog {
|
|
407
|
+
kind: "service" | "app";
|
|
408
|
+
name: string;
|
|
409
|
+
localUrl: string;
|
|
410
|
+
publicUrl: string;
|
|
411
|
+
}
|
|
412
|
+
/** Active tunnel with teardown — same shape as core `PublicTunnel`. */
|
|
413
|
+
export type PublicTunnelHandle = DevEnvironmentTunnelLog & {
|
|
414
|
+
close: () => Promise<void>;
|
|
415
|
+
};
|
|
416
|
+
/** Options for {@link DevEnvironment.openPublicTunnels}. */
|
|
417
|
+
export interface OpenPublicTunnelsOptions {
|
|
418
|
+
/** Subset of expose targets by name; omit for all `expose: true` services/apps. */
|
|
419
|
+
names?: string[];
|
|
420
|
+
/**
|
|
421
|
+
* Wait for these apps' HTTP health endpoints before opening tunnels.
|
|
422
|
+
* Servers must already be listening on their ports.
|
|
423
|
+
*/
|
|
424
|
+
waitForHealthy?: string[];
|
|
425
|
+
}
|
|
426
|
+
/** Result of {@link DevEnvironment.openPublicTunnels}. */
|
|
427
|
+
export interface OpenPublicTunnelsResult<TServices extends Record<string, ServiceConfig>, TApps extends Record<string, AppConfig>> {
|
|
428
|
+
publicUrls: ComputedPublicUrls<TServices, TApps>;
|
|
429
|
+
tunnels: PublicTunnelHandle[];
|
|
430
|
+
close: () => Promise<void>;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* The main dev environment interface returned by createDevEnvironment().
|
|
434
|
+
*/
|
|
435
|
+
export interface DevEnvironment<TServices extends Record<string, ServiceConfig>, TApps extends Record<string, AppConfig>> {
|
|
436
|
+
/** Docker project name (includes suffix if set) */
|
|
437
|
+
readonly projectName: string;
|
|
438
|
+
/** Computed ports for all services and apps */
|
|
439
|
+
readonly ports: ComputedPorts<TServices, TApps>;
|
|
440
|
+
/** Computed URLs for all services and apps */
|
|
441
|
+
readonly urls: ComputedUrls<TServices, TApps>;
|
|
442
|
+
/** Public tunnel URLs for exposed services/apps (when active) */
|
|
443
|
+
readonly publicUrls: ComputedPublicUrls<TServices, TApps>;
|
|
444
|
+
/** Services configuration */
|
|
445
|
+
readonly services: TServices;
|
|
446
|
+
/** Apps configuration (for CLI to build commands) */
|
|
447
|
+
readonly apps: TApps;
|
|
448
|
+
/** Port offset applied (0 for main, > 0 for worktrees) */
|
|
449
|
+
readonly portOffset: number;
|
|
450
|
+
/** Whether running in a git worktree */
|
|
451
|
+
readonly isWorktree: boolean;
|
|
452
|
+
/** Local IP address for mobile connectivity */
|
|
453
|
+
readonly localIp: string;
|
|
454
|
+
/** Path to monorepo root */
|
|
455
|
+
readonly root: string;
|
|
456
|
+
/** Path passed to docker compose -f */
|
|
457
|
+
readonly composeFile: string;
|
|
458
|
+
/** Start the dev environment (containers + optional servers) */
|
|
459
|
+
start(options?: StartOptions): Promise<DevServerPids | null>;
|
|
460
|
+
/** Stop the dev environment */
|
|
461
|
+
stop(options?: StopOptions): Promise<void>;
|
|
462
|
+
/** Restart containers only */
|
|
463
|
+
restart(): Promise<void>;
|
|
464
|
+
/** Check if containers are running */
|
|
465
|
+
isRunning(): Promise<boolean>;
|
|
466
|
+
/** Start dev servers only (assumes containers are running) */
|
|
467
|
+
startServers(options?: {
|
|
468
|
+
productionBuild?: boolean;
|
|
469
|
+
verbose?: boolean;
|
|
470
|
+
/** If set, start and wait for only these app names (must exist in `apps`). */
|
|
471
|
+
onlyApps?: string[];
|
|
472
|
+
}): Promise<DevServerPids>;
|
|
473
|
+
/** Stop a process by PID */
|
|
474
|
+
stopProcess(pid: number): void;
|
|
475
|
+
/** Wait for servers to be ready */
|
|
476
|
+
waitForServers(options?: {
|
|
477
|
+
timeout?: number;
|
|
478
|
+
productionBuild?: boolean;
|
|
479
|
+
/** If set, wait only for these app names (must exist in `apps`). */
|
|
480
|
+
onlyApps?: string[];
|
|
481
|
+
}): Promise<void>;
|
|
482
|
+
/**
|
|
483
|
+
* Build environment variables for shell commands.
|
|
484
|
+
* Call **after** {@link setPublicUrls} or {@link openPublicTunnels} so `envVars` and `*_PUBLIC_URL` reflect tunnel URLs.
|
|
485
|
+
*/
|
|
486
|
+
buildEnvVars(production?: boolean): Record<string, string>;
|
|
487
|
+
/** Set public tunnel URLs used by envVars and *_PUBLIC_URL injection */
|
|
488
|
+
setPublicUrls(urls: ComputedPublicUrls<TServices, TApps>): void;
|
|
489
|
+
/** Clear all public tunnel URLs */
|
|
490
|
+
clearPublicUrls(): void;
|
|
491
|
+
/** Ensure generated docker compose file exists and return path used with -f */
|
|
492
|
+
ensureComposeFile(): string;
|
|
493
|
+
/** Execute a command with environment variables set */
|
|
494
|
+
exec(cmd: string, options?: ExecOptions): Promise<{
|
|
495
|
+
exitCode: number;
|
|
496
|
+
stdout: string;
|
|
497
|
+
stderr: string;
|
|
498
|
+
}>;
|
|
499
|
+
/** Wait for an HTTP server to respond */
|
|
500
|
+
waitForServer(url: string, timeout?: number): Promise<void>;
|
|
501
|
+
/** Log environment info to console; pass `tunnels` to show public URLs next to services/apps */
|
|
502
|
+
logInfo(label?: string, tunnels?: DevEnvironmentTunnelLog[]): void;
|
|
503
|
+
/**
|
|
504
|
+
* Resolve expose targets, start public quick tunnels, and apply {@link setPublicUrls}.
|
|
505
|
+
* Call {@link buildEnvVars} after this resolves when spawning processes that need `EXPO_PUBLIC_*` / `*_PUBLIC_URL`.
|
|
506
|
+
*/
|
|
507
|
+
openPublicTunnels(options?: OpenPublicTunnelsOptions): Promise<OpenPublicTunnelsResult<TServices, TApps>>;
|
|
508
|
+
/**
|
|
509
|
+
* Get the Expo API URL (http://<local-ip>:<api-port>) and log it for detection.
|
|
510
|
+
* Used by tools like Vibe Kanban to find the API server for mobile testing.
|
|
511
|
+
*/
|
|
512
|
+
getExpoApiUrl(): string;
|
|
513
|
+
/**
|
|
514
|
+
* Get the frontend port and log it for detection.
|
|
515
|
+
* Used by tools like Vibe Kanban to find the dev server.
|
|
516
|
+
*/
|
|
517
|
+
getFrontendPort(): number | undefined;
|
|
518
|
+
/** Start writing heartbeat for watchdog */
|
|
519
|
+
startHeartbeat(intervalMs?: number): void;
|
|
520
|
+
/** Stop writing heartbeat */
|
|
521
|
+
stopHeartbeat(): void;
|
|
522
|
+
/** Spawn watchdog process for auto-shutdown */
|
|
523
|
+
spawnWatchdog(timeoutMinutes?: number): Promise<void>;
|
|
524
|
+
/** Stop the watchdog process */
|
|
525
|
+
stopWatchdog(): void;
|
|
526
|
+
/** Prisma runner (only available when prisma is configured) */
|
|
527
|
+
readonly prisma?: PrismaRunner;
|
|
528
|
+
/** Create a new environment with a different suffix (for test isolation) */
|
|
529
|
+
withSuffix(suffix: string): DevEnvironment<TServices, TApps>;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Options for the CLI runner.
|
|
533
|
+
*/
|
|
534
|
+
export interface CliOptions {
|
|
535
|
+
/** Custom args (defaults to process.argv.slice(2)) */
|
|
536
|
+
args?: string[];
|
|
537
|
+
/** Enable watchdog auto-shutdown (default: true) */
|
|
538
|
+
watchdog?: boolean;
|
|
539
|
+
/** Watchdog timeout in minutes (default: 10) */
|
|
540
|
+
watchdogTimeout?: number;
|
|
541
|
+
/** Command to run dev servers (e.g., 'bun concurrently ...') */
|
|
542
|
+
devServersCommand?: string;
|
|
543
|
+
}
|
|
544
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { CliOptions } from "./all-types";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
BuiltInHealthCheck,
|
|
3
|
+
DockerComposeGenerationOptions,
|
|
4
|
+
DockerComposeHealthcheckRaw,
|
|
5
|
+
DockerComposeNode,
|
|
6
|
+
DockerComposeServiceRaw,
|
|
7
|
+
DockerComposeVolumeRaw,
|
|
8
|
+
DockerPresetName,
|
|
9
|
+
DockerPresetServiceDefinition,
|
|
10
|
+
DockerServiceDefinition,
|
|
11
|
+
HealthCheckFn,
|
|
12
|
+
ServiceConfig,
|
|
13
|
+
UrlBuilderContext,
|
|
14
|
+
UrlBuilderFn,
|
|
15
|
+
} from "./all-types";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./all-types";
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { PrismaConfig, PrismaRunner } from "./all-types";
|