buncargo 1.0.5
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/bin.ts +253 -0
- package/cli.ts +238 -0
- package/config.ts +194 -0
- package/core/docker.ts +384 -0
- package/core/index.ts +7 -0
- package/core/network.ts +152 -0
- package/core/ports.ts +253 -0
- package/core/process.ts +253 -0
- package/core/utils.ts +127 -0
- package/core/watchdog-runner.ts +111 -0
- package/core/watchdog.ts +196 -0
- package/dist/bin.d.ts +12 -0
- package/dist/cli.d.ts +22 -0
- package/dist/config.d.ts +72 -0
- package/dist/core/docker.d.ts +74 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/network.d.ts +30 -0
- package/dist/core/ports.d.ts +30 -0
- package/dist/core/process.d.ts +52 -0
- package/dist/core/utils.d.ts +60 -0
- package/dist/core/watchdog-runner.d.ts +14 -0
- package/dist/core/watchdog.d.ts +46 -0
- package/dist/environment.d.ts +23 -0
- package/dist/index.d.ts +12 -0
- package/dist/lint.d.ts +46 -0
- package/dist/loader.d.ts +39 -0
- package/dist/prisma.d.ts +29 -0
- package/dist/types.d.ts +391 -0
- package/environment.ts +604 -0
- package/index.ts +103 -0
- package/lint.ts +277 -0
- package/loader.ts +100 -0
- package/package.json +124 -0
- package/prisma.ts +138 -0
- package/readme.md +198 -0
- package/types.ts +538 -0
package/types.ts
ADDED
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
+
// Service Configuration
|
|
3
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Health check function signature for custom health checks.
|
|
7
|
+
*/
|
|
8
|
+
export type HealthCheckFn = (port: number) => Promise<boolean>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Built-in health check types that map to common patterns.
|
|
12
|
+
*/
|
|
13
|
+
export type BuiltInHealthCheck = "pg_isready" | "redis-cli" | "http" | "tcp";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* URL builder context passed to urlTemplate function.
|
|
17
|
+
*/
|
|
18
|
+
export interface UrlBuilderContext {
|
|
19
|
+
port: number;
|
|
20
|
+
secondaryPort?: number;
|
|
21
|
+
host: string;
|
|
22
|
+
localIp: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* URL builder function receives port info and returns the connection URL.
|
|
27
|
+
*/
|
|
28
|
+
export type UrlBuilderFn = (ctx: UrlBuilderContext) => string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Configuration for a Docker Compose service (e.g., postgres, redis).
|
|
32
|
+
*/
|
|
33
|
+
export interface ServiceConfig {
|
|
34
|
+
/** Base port for the service (before offset is applied) */
|
|
35
|
+
port: number;
|
|
36
|
+
/** Optional secondary port (e.g., ClickHouse native protocol) */
|
|
37
|
+
secondaryPort?: number;
|
|
38
|
+
/** Health check: built-in name, custom function, or disabled (false) */
|
|
39
|
+
healthCheck?: BuiltInHealthCheck | HealthCheckFn | false;
|
|
40
|
+
/** URL builder function that returns the connection URL */
|
|
41
|
+
urlTemplate?: UrlBuilderFn;
|
|
42
|
+
/** Docker Compose service name (defaults to the key name) */
|
|
43
|
+
serviceName?: string;
|
|
44
|
+
|
|
45
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
46
|
+
// Built-in URL template options (alternative to urlTemplate)
|
|
47
|
+
// When these are set, a built-in URL template is used based on the service name
|
|
48
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
49
|
+
|
|
50
|
+
/** Database name (for postgres, mysql, clickhouse). Enables built-in URL template. */
|
|
51
|
+
database?: string;
|
|
52
|
+
/** Username (default: 'postgres' for postgres, 'root' for mysql, 'default' for clickhouse) */
|
|
53
|
+
user?: string;
|
|
54
|
+
/** Password (default: 'postgres' for postgres, 'root' for mysql, 'clickhouse' for clickhouse) */
|
|
55
|
+
password?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
59
|
+
// App Configuration
|
|
60
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Configuration for an application (e.g., api, web).
|
|
64
|
+
*/
|
|
65
|
+
export interface AppConfig {
|
|
66
|
+
/** Base port for the app (before offset is applied) */
|
|
67
|
+
port: number;
|
|
68
|
+
/** Command to start the dev server */
|
|
69
|
+
devCommand: string;
|
|
70
|
+
/** Command to start production server (optional) */
|
|
71
|
+
prodCommand?: string;
|
|
72
|
+
/** Command to build for production (optional) */
|
|
73
|
+
buildCommand?: string;
|
|
74
|
+
/** Working directory relative to monorepo root */
|
|
75
|
+
cwd?: string;
|
|
76
|
+
/** Health check endpoint path (e.g., '/api/health') */
|
|
77
|
+
healthEndpoint?: string;
|
|
78
|
+
/** Timeout for health check in milliseconds */
|
|
79
|
+
healthTimeout?: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
83
|
+
// Hooks
|
|
84
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Execution options for the exec helper.
|
|
88
|
+
*/
|
|
89
|
+
export interface ExecOptions {
|
|
90
|
+
/** Working directory relative to monorepo root */
|
|
91
|
+
cwd?: string;
|
|
92
|
+
/** Print output to console */
|
|
93
|
+
verbose?: boolean;
|
|
94
|
+
/** Environment variables to add */
|
|
95
|
+
env?: Record<string, string>;
|
|
96
|
+
/** Throw on non-zero exit code (default: true) */
|
|
97
|
+
throwOnError?: boolean;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Context passed to hooks for executing commands and accessing environment.
|
|
102
|
+
*/
|
|
103
|
+
export interface HookContext<
|
|
104
|
+
TServices extends Record<string, ServiceConfig>,
|
|
105
|
+
TApps extends Record<string, AppConfig>,
|
|
106
|
+
> {
|
|
107
|
+
/** Project name (with suffix if applicable) */
|
|
108
|
+
projectName: string;
|
|
109
|
+
/** Computed ports for all services and apps */
|
|
110
|
+
ports: ComputedPorts<TServices, TApps>;
|
|
111
|
+
/** Computed URLs for all services and apps */
|
|
112
|
+
urls: ComputedUrls<TServices, TApps>;
|
|
113
|
+
/** Execute a shell command with environment variables set */
|
|
114
|
+
exec: (
|
|
115
|
+
cmd: string,
|
|
116
|
+
options?: ExecOptions,
|
|
117
|
+
) => Promise<{ exitCode: number; stdout: string; stderr: string }>;
|
|
118
|
+
/** Path to monorepo root */
|
|
119
|
+
root: string;
|
|
120
|
+
/** Whether running in CI environment */
|
|
121
|
+
isCI: boolean;
|
|
122
|
+
/** Port offset applied to all ports */
|
|
123
|
+
portOffset: number;
|
|
124
|
+
/** Local IP address for mobile connectivity */
|
|
125
|
+
localIp: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Lifecycle hooks for customizing the dev environment.
|
|
130
|
+
*/
|
|
131
|
+
export interface DevHooks<
|
|
132
|
+
TServices extends Record<string, ServiceConfig>,
|
|
133
|
+
TApps extends Record<string, AppConfig>,
|
|
134
|
+
> {
|
|
135
|
+
/** Called after all containers are healthy */
|
|
136
|
+
afterContainersReady?: (ctx: HookContext<TServices, TApps>) => Promise<void>;
|
|
137
|
+
/** Called before starting dev servers */
|
|
138
|
+
beforeServers?: (ctx: HookContext<TServices, TApps>) => Promise<void>;
|
|
139
|
+
/** Called after dev servers are ready */
|
|
140
|
+
afterServers?: (ctx: HookContext<TServices, TApps>) => Promise<void>;
|
|
141
|
+
/** Called before stopping the environment */
|
|
142
|
+
beforeStop?: (ctx: HookContext<TServices, TApps>) => Promise<void>;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
146
|
+
// Prisma Configuration
|
|
147
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Configuration for Prisma integration.
|
|
151
|
+
*/
|
|
152
|
+
export interface PrismaConfig {
|
|
153
|
+
/** Working directory where prisma schema lives (relative to monorepo root). Default: 'packages/prisma' */
|
|
154
|
+
cwd?: string;
|
|
155
|
+
/** Docker Compose service name for the database. Default: 'postgres' */
|
|
156
|
+
service?: string;
|
|
157
|
+
/** Environment variable name for the database URL. Default: 'DATABASE_URL' */
|
|
158
|
+
urlEnvVar?: string;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Prisma runner interface available on dev.prisma when prisma is configured.
|
|
163
|
+
*/
|
|
164
|
+
export interface PrismaRunner {
|
|
165
|
+
/** Run a prisma command with the correct environment. Returns exit code. */
|
|
166
|
+
run(args: string[]): Promise<number>;
|
|
167
|
+
/** Get the database URL from the dev environment */
|
|
168
|
+
getDatabaseUrl(): string;
|
|
169
|
+
/** Ensure the database container is running and healthy */
|
|
170
|
+
ensureDatabase(): Promise<void>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
174
|
+
// Migrations Configuration
|
|
175
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Configuration for a migration command to run after containers are ready.
|
|
179
|
+
*/
|
|
180
|
+
export interface MigrationConfig {
|
|
181
|
+
/** Display name for the migration (e.g., 'prisma', 'clickhouse') */
|
|
182
|
+
name: string;
|
|
183
|
+
/** Command to run the migration */
|
|
184
|
+
command: string;
|
|
185
|
+
/** Working directory relative to monorepo root */
|
|
186
|
+
cwd?: string;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
190
|
+
// Seed Configuration
|
|
191
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Helper functions available in the seed check function.
|
|
195
|
+
*/
|
|
196
|
+
export interface SeedCheckHelpers<
|
|
197
|
+
TServices extends Record<string, ServiceConfig>,
|
|
198
|
+
> {
|
|
199
|
+
/**
|
|
200
|
+
* Check if a database table is empty.
|
|
201
|
+
* Returns true if the table has 0 rows (needs seeding), false otherwise.
|
|
202
|
+
*
|
|
203
|
+
* @param tableName - The table name to check (e.g., 'User')
|
|
204
|
+
* @param service - The database service name. Default: 'postgres'
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* seed: {
|
|
209
|
+
* command: 'bun run run:seeder',
|
|
210
|
+
* check: ({ checkTable }) => checkTable('User')
|
|
211
|
+
* }
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
checkTable: (tableName: string, service: keyof TServices) => Promise<boolean>;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Context passed to the seed check function.
|
|
219
|
+
*/
|
|
220
|
+
export type SeedCheckContext<
|
|
221
|
+
TServices extends Record<string, ServiceConfig>,
|
|
222
|
+
TApps extends Record<string, AppConfig>,
|
|
223
|
+
> = HookContext<TServices, TApps> & SeedCheckHelpers<TServices>;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Configuration for database seeding.
|
|
227
|
+
*/
|
|
228
|
+
export interface SeedConfig<
|
|
229
|
+
TServices extends Record<string, ServiceConfig>,
|
|
230
|
+
TApps extends Record<string, AppConfig>,
|
|
231
|
+
> {
|
|
232
|
+
/** Command to run the seeder */
|
|
233
|
+
command: string;
|
|
234
|
+
/** Working directory relative to monorepo root */
|
|
235
|
+
cwd?: string;
|
|
236
|
+
/**
|
|
237
|
+
* Check function to determine if seeding is needed.
|
|
238
|
+
* Return true to run the seed command, false to skip.
|
|
239
|
+
* If not provided, seeding always runs.
|
|
240
|
+
*
|
|
241
|
+
* Receives hook context plus helper functions like `checkTable`.
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* seed: {
|
|
246
|
+
* command: 'bun run run:seeder',
|
|
247
|
+
* check: ({ checkTable }) => checkTable('User')
|
|
248
|
+
* }
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
check?: (ctx: SeedCheckContext<TServices, TApps>) => Promise<boolean>;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
255
|
+
// Dev Config
|
|
256
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Options for the dev environment.
|
|
260
|
+
*/
|
|
261
|
+
export interface DevOptions {
|
|
262
|
+
/** Enable worktree isolation (unique ports per worktree). Default: true */
|
|
263
|
+
worktreeIsolation?: boolean;
|
|
264
|
+
/** Auto-shutdown after idle time in ms. Set to false to disable. Default: false */
|
|
265
|
+
autoShutdown?: number | false;
|
|
266
|
+
/** Path to docker-compose.yml relative to root. Default: 'docker-compose.yml' */
|
|
267
|
+
composeFile?: string;
|
|
268
|
+
/** Default verbose setting for all operations. Default: true */
|
|
269
|
+
verbose?: boolean;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Environment variable builder function.
|
|
274
|
+
*/
|
|
275
|
+
export type EnvVarsBuilder<
|
|
276
|
+
TServices extends Record<string, ServiceConfig>,
|
|
277
|
+
TApps extends Record<string, AppConfig>,
|
|
278
|
+
> = (
|
|
279
|
+
ports: ComputedPorts<TServices, TApps>,
|
|
280
|
+
urls: ComputedUrls<TServices, TApps>,
|
|
281
|
+
ctx: { projectName: string; localIp: string; portOffset: number },
|
|
282
|
+
) => Record<string, string | number>;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Main configuration for the dev environment.
|
|
286
|
+
*/
|
|
287
|
+
export interface DevConfig<
|
|
288
|
+
TServices extends Record<string, ServiceConfig> = Record<
|
|
289
|
+
string,
|
|
290
|
+
ServiceConfig
|
|
291
|
+
>,
|
|
292
|
+
TApps extends Record<string, AppConfig> = Record<string, AppConfig>,
|
|
293
|
+
> {
|
|
294
|
+
/** Prefix for Docker project name (e.g., 'myapp' -> 'myapp-main') */
|
|
295
|
+
projectPrefix: string;
|
|
296
|
+
/** Docker Compose services to manage */
|
|
297
|
+
services: TServices;
|
|
298
|
+
/** Applications to start (optional) */
|
|
299
|
+
apps?: TApps;
|
|
300
|
+
/**
|
|
301
|
+
* Environment variables builder. Define all env vars here.
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```typescript
|
|
305
|
+
* envVars: (ports, urls, { localIp }) => ({
|
|
306
|
+
* DATABASE_URL: urls.postgres,
|
|
307
|
+
* BASE_URL: urls.api,
|
|
308
|
+
* VITE_PORT: ports.platform,
|
|
309
|
+
* EXPO_API_URL: `http://${localIp}:${ports.api}`
|
|
310
|
+
* })
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
|
+
envVars?: EnvVarsBuilder<TServices, TApps>;
|
|
314
|
+
/** Lifecycle hooks (optional) */
|
|
315
|
+
hooks?: DevHooks<TServices, TApps>;
|
|
316
|
+
/** Migrations to run after containers are ready (optional). Runs in parallel. */
|
|
317
|
+
migrations?: MigrationConfig[];
|
|
318
|
+
/** Seed configuration (optional). Runs after migrations, before servers. */
|
|
319
|
+
seed?: SeedConfig<TServices, TApps>;
|
|
320
|
+
/** Prisma configuration (optional). When set, dev.prisma is available. */
|
|
321
|
+
prisma?: PrismaConfig;
|
|
322
|
+
/** Additional options (optional) */
|
|
323
|
+
options?: DevOptions;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
327
|
+
// Computed Types (Type-Level Utilities)
|
|
328
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Computed ports object - maps service/app names to their port numbers.
|
|
332
|
+
*/
|
|
333
|
+
// Helper to extract services that have secondaryPort defined
|
|
334
|
+
type ServicesWithSecondaryPort<
|
|
335
|
+
TServices extends Record<string, ServiceConfig>,
|
|
336
|
+
> = {
|
|
337
|
+
[K in keyof TServices as TServices[K] extends { secondaryPort: number }
|
|
338
|
+
? `${K & string}Secondary`
|
|
339
|
+
: never]: number;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
export type ComputedPorts<
|
|
343
|
+
TServices extends Record<string, ServiceConfig>,
|
|
344
|
+
TApps extends Record<string, AppConfig>,
|
|
345
|
+
> = {
|
|
346
|
+
[K in keyof TServices]: number;
|
|
347
|
+
} & {
|
|
348
|
+
[K in keyof TApps]: number;
|
|
349
|
+
} & ServicesWithSecondaryPort<TServices>;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Computed URLs object - maps service/app names to their URLs.
|
|
353
|
+
*/
|
|
354
|
+
export type ComputedUrls<
|
|
355
|
+
TServices extends Record<string, ServiceConfig>,
|
|
356
|
+
TApps extends Record<string, AppConfig>,
|
|
357
|
+
> = {
|
|
358
|
+
[K in keyof TServices]: string;
|
|
359
|
+
} & {
|
|
360
|
+
[K in keyof TApps]: string;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
364
|
+
// Start/Stop Options
|
|
365
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Options for starting the dev environment.
|
|
369
|
+
*/
|
|
370
|
+
export interface StartOptions {
|
|
371
|
+
/** Print output to console. Default: true */
|
|
372
|
+
verbose?: boolean;
|
|
373
|
+
/** Wait for containers to be healthy. Default: true */
|
|
374
|
+
wait?: boolean;
|
|
375
|
+
/** Start dev servers after containers. Default: true */
|
|
376
|
+
startServers?: boolean;
|
|
377
|
+
/** Use production build for servers. Default: false (true in CI) */
|
|
378
|
+
productionBuild?: boolean;
|
|
379
|
+
/** Environment suffix for isolation (e.g., 'test'). Default: undefined */
|
|
380
|
+
suffix?: string;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Options for stopping the dev environment.
|
|
385
|
+
*/
|
|
386
|
+
export interface StopOptions {
|
|
387
|
+
/** Print output to console. Default: true */
|
|
388
|
+
verbose?: boolean;
|
|
389
|
+
/** Remove Docker volumes (destroys data). Default: false */
|
|
390
|
+
removeVolumes?: boolean;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
394
|
+
// Dev Environment Interface
|
|
395
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Process IDs for running dev servers.
|
|
399
|
+
*/
|
|
400
|
+
export interface DevServerPids {
|
|
401
|
+
[appName: string]: number;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* The main dev environment interface returned by createDevEnvironment().
|
|
406
|
+
*/
|
|
407
|
+
export interface DevEnvironment<
|
|
408
|
+
TServices extends Record<string, ServiceConfig>,
|
|
409
|
+
TApps extends Record<string, AppConfig>,
|
|
410
|
+
> {
|
|
411
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
412
|
+
// Configuration Access
|
|
413
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
414
|
+
|
|
415
|
+
/** Docker project name (includes suffix if set) */
|
|
416
|
+
readonly projectName: string;
|
|
417
|
+
/** Computed ports for all services and apps */
|
|
418
|
+
readonly ports: ComputedPorts<TServices, TApps>;
|
|
419
|
+
/** Computed URLs for all services and apps */
|
|
420
|
+
readonly urls: ComputedUrls<TServices, TApps>;
|
|
421
|
+
/** Apps configuration (for CLI to build commands) */
|
|
422
|
+
readonly apps: TApps;
|
|
423
|
+
/** Port offset applied (0 for main, > 0 for worktrees) */
|
|
424
|
+
readonly portOffset: number;
|
|
425
|
+
/** Whether running in a git worktree */
|
|
426
|
+
readonly isWorktree: boolean;
|
|
427
|
+
/** Local IP address for mobile connectivity */
|
|
428
|
+
readonly localIp: string;
|
|
429
|
+
/** Path to monorepo root */
|
|
430
|
+
readonly root: string;
|
|
431
|
+
|
|
432
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
433
|
+
// Container Management
|
|
434
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
435
|
+
|
|
436
|
+
/** Start the dev environment (containers + optional servers) */
|
|
437
|
+
start(options?: StartOptions): Promise<DevServerPids | null>;
|
|
438
|
+
/** Stop the dev environment */
|
|
439
|
+
stop(options?: StopOptions): Promise<void>;
|
|
440
|
+
/** Restart containers only */
|
|
441
|
+
restart(): Promise<void>;
|
|
442
|
+
/** Check if containers are running */
|
|
443
|
+
isRunning(): Promise<boolean>;
|
|
444
|
+
|
|
445
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
446
|
+
// Server Management
|
|
447
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
448
|
+
|
|
449
|
+
/** Start dev servers only (assumes containers are running) */
|
|
450
|
+
startServers(options?: {
|
|
451
|
+
productionBuild?: boolean;
|
|
452
|
+
verbose?: boolean;
|
|
453
|
+
}): Promise<DevServerPids>;
|
|
454
|
+
/** Stop a process by PID */
|
|
455
|
+
stopProcess(pid: number): void;
|
|
456
|
+
/** Wait for servers to be ready */
|
|
457
|
+
waitForServers(options?: {
|
|
458
|
+
timeout?: number;
|
|
459
|
+
productionBuild?: boolean;
|
|
460
|
+
}): Promise<void>;
|
|
461
|
+
|
|
462
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
463
|
+
// Utilities
|
|
464
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
465
|
+
|
|
466
|
+
/** Build environment variables for shell commands */
|
|
467
|
+
buildEnvVars(production?: boolean): Record<string, string>;
|
|
468
|
+
/** Execute a command with environment variables set */
|
|
469
|
+
exec(
|
|
470
|
+
cmd: string,
|
|
471
|
+
options?: ExecOptions,
|
|
472
|
+
): Promise<{ exitCode: number; stdout: string; stderr: string }>;
|
|
473
|
+
/** Wait for an HTTP server to respond */
|
|
474
|
+
waitForServer(url: string, timeout?: number): Promise<void>;
|
|
475
|
+
/** Log environment info to console */
|
|
476
|
+
logInfo(label?: string): void;
|
|
477
|
+
|
|
478
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
479
|
+
// Vibe Kanban Integration
|
|
480
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Get the Expo API URL (http://<local-ip>:<api-port>) and log it for detection.
|
|
484
|
+
* Used by tools like Vibe Kanban to find the API server for mobile testing.
|
|
485
|
+
*/
|
|
486
|
+
getExpoApiUrl(): string;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Get the frontend port and log it for detection.
|
|
490
|
+
* Used by tools like Vibe Kanban to find the dev server.
|
|
491
|
+
*/
|
|
492
|
+
getFrontendPort(): number | undefined;
|
|
493
|
+
|
|
494
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
495
|
+
// Watchdog / Heartbeat
|
|
496
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
497
|
+
|
|
498
|
+
/** Start writing heartbeat for watchdog */
|
|
499
|
+
startHeartbeat(intervalMs?: number): void;
|
|
500
|
+
/** Stop writing heartbeat */
|
|
501
|
+
stopHeartbeat(): void;
|
|
502
|
+
/** Spawn watchdog process for auto-shutdown */
|
|
503
|
+
spawnWatchdog(timeoutMinutes?: number): Promise<void>;
|
|
504
|
+
/** Stop the watchdog process */
|
|
505
|
+
stopWatchdog(): void;
|
|
506
|
+
|
|
507
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
508
|
+
// Prisma Integration
|
|
509
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
510
|
+
|
|
511
|
+
/** Prisma runner (only available when prisma is configured) */
|
|
512
|
+
readonly prisma?: PrismaRunner;
|
|
513
|
+
|
|
514
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
515
|
+
// Advanced
|
|
516
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
517
|
+
|
|
518
|
+
/** Create a new environment with a different suffix (for test isolation) */
|
|
519
|
+
withSuffix(suffix: string): DevEnvironment<TServices, TApps>;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
523
|
+
// CLI Options
|
|
524
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Options for the CLI runner.
|
|
528
|
+
*/
|
|
529
|
+
export interface CliOptions {
|
|
530
|
+
/** Custom args (defaults to process.argv.slice(2)) */
|
|
531
|
+
args?: string[];
|
|
532
|
+
/** Enable watchdog auto-shutdown (default: true) */
|
|
533
|
+
watchdog?: boolean;
|
|
534
|
+
/** Watchdog timeout in minutes (default: 10) */
|
|
535
|
+
watchdogTimeout?: number;
|
|
536
|
+
/** Command to run dev servers (e.g., 'bun concurrently ...') */
|
|
537
|
+
devServersCommand?: string;
|
|
538
|
+
}
|