@geekmidas/cli 0.48.0 → 0.50.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 (80) hide show
  1. package/dist/deploy/sniffer-envkit-patch.cjs +27 -0
  2. package/dist/deploy/sniffer-envkit-patch.cjs.map +1 -0
  3. package/dist/deploy/sniffer-envkit-patch.d.cts +46 -0
  4. package/dist/deploy/sniffer-envkit-patch.d.cts.map +1 -0
  5. package/dist/deploy/sniffer-envkit-patch.d.mts +46 -0
  6. package/dist/deploy/sniffer-envkit-patch.d.mts.map +1 -0
  7. package/dist/deploy/sniffer-envkit-patch.mjs +20 -0
  8. package/dist/deploy/sniffer-envkit-patch.mjs.map +1 -0
  9. package/dist/deploy/sniffer-hooks.cjs +25 -0
  10. package/dist/deploy/sniffer-hooks.cjs.map +1 -0
  11. package/dist/deploy/sniffer-hooks.d.cts +27 -0
  12. package/dist/deploy/sniffer-hooks.d.cts.map +1 -0
  13. package/dist/deploy/sniffer-hooks.d.mts +27 -0
  14. package/dist/deploy/sniffer-hooks.d.mts.map +1 -0
  15. package/dist/deploy/sniffer-hooks.mjs +24 -0
  16. package/dist/deploy/sniffer-hooks.mjs.map +1 -0
  17. package/dist/deploy/sniffer-loader.cjs +16 -0
  18. package/dist/deploy/sniffer-loader.cjs.map +1 -0
  19. package/dist/deploy/sniffer-loader.d.cts +1 -0
  20. package/dist/deploy/sniffer-loader.d.mts +1 -0
  21. package/dist/deploy/sniffer-loader.mjs +15 -0
  22. package/dist/deploy/sniffer-loader.mjs.map +1 -0
  23. package/dist/deploy/sniffer-worker.cjs +42 -0
  24. package/dist/deploy/sniffer-worker.cjs.map +1 -0
  25. package/dist/deploy/sniffer-worker.d.cts +9 -0
  26. package/dist/deploy/sniffer-worker.d.cts.map +1 -0
  27. package/dist/deploy/sniffer-worker.d.mts +9 -0
  28. package/dist/deploy/sniffer-worker.d.mts.map +1 -0
  29. package/dist/deploy/sniffer-worker.mjs +41 -0
  30. package/dist/deploy/sniffer-worker.mjs.map +1 -0
  31. package/dist/{dokploy-api-DvzIDxTj.mjs → dokploy-api-94KzmTVf.mjs} +4 -4
  32. package/dist/dokploy-api-94KzmTVf.mjs.map +1 -0
  33. package/dist/dokploy-api-CItuaWTq.mjs +3 -0
  34. package/dist/dokploy-api-DBNE8MDt.cjs +3 -0
  35. package/dist/{dokploy-api-BDLu0qWi.cjs → dokploy-api-YD8WCQfW.cjs} +4 -4
  36. package/dist/dokploy-api-YD8WCQfW.cjs.map +1 -0
  37. package/dist/index.cjs +2415 -1893
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.mjs +2411 -1889
  40. package/dist/index.mjs.map +1 -1
  41. package/package.json +8 -6
  42. package/src/build/__tests__/handler-templates.spec.ts +947 -0
  43. package/src/deploy/__tests__/__fixtures__/entry-apps/async-entry.ts +24 -0
  44. package/src/deploy/__tests__/__fixtures__/entry-apps/nested-config-entry.ts +24 -0
  45. package/src/deploy/__tests__/__fixtures__/entry-apps/no-env-entry.ts +12 -0
  46. package/src/deploy/__tests__/__fixtures__/entry-apps/simple-entry.ts +14 -0
  47. package/src/deploy/__tests__/__fixtures__/entry-apps/throwing-entry.ts +16 -0
  48. package/src/deploy/__tests__/__fixtures__/env-parsers/non-function-export.ts +10 -0
  49. package/src/deploy/__tests__/__fixtures__/env-parsers/parseable-env-parser.ts +18 -0
  50. package/src/deploy/__tests__/__fixtures__/env-parsers/throwing-env-parser.ts +18 -0
  51. package/src/deploy/__tests__/__fixtures__/env-parsers/valid-env-parser.ts +16 -0
  52. package/src/deploy/__tests__/dns-verification.spec.ts +229 -0
  53. package/src/deploy/__tests__/dokploy-api.spec.ts +2 -3
  54. package/src/deploy/__tests__/domain.spec.ts +7 -3
  55. package/src/deploy/__tests__/env-resolver.spec.ts +469 -0
  56. package/src/deploy/__tests__/index.spec.ts +12 -12
  57. package/src/deploy/__tests__/secrets.spec.ts +4 -1
  58. package/src/deploy/__tests__/sniffer.spec.ts +326 -1
  59. package/src/deploy/__tests__/state.spec.ts +844 -0
  60. package/src/deploy/dns/hostinger-api.ts +4 -1
  61. package/src/deploy/dns/index.ts +113 -1
  62. package/src/deploy/docker.ts +1 -2
  63. package/src/deploy/dokploy-api.ts +18 -9
  64. package/src/deploy/domain.ts +5 -4
  65. package/src/deploy/env-resolver.ts +278 -0
  66. package/src/deploy/index.ts +525 -119
  67. package/src/deploy/secrets.ts +7 -2
  68. package/src/deploy/sniffer-envkit-patch.ts +59 -0
  69. package/src/deploy/sniffer-hooks.ts +57 -0
  70. package/src/deploy/sniffer-loader.ts +28 -0
  71. package/src/deploy/sniffer-worker.ts +74 -0
  72. package/src/deploy/sniffer.ts +170 -14
  73. package/src/deploy/state.ts +162 -1
  74. package/src/init/versions.ts +3 -3
  75. package/tsconfig.tsbuildinfo +1 -1
  76. package/tsdown.config.ts +5 -0
  77. package/dist/dokploy-api-BDLu0qWi.cjs.map +0 -1
  78. package/dist/dokploy-api-BN3V57z1.mjs +0 -3
  79. package/dist/dokploy-api-BdCKjFDA.cjs +0 -3
  80. package/dist/dokploy-api-DvzIDxTj.mjs.map +0 -1
@@ -0,0 +1,469 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import type { NormalizedAppConfig } from '../../workspace/types';
3
+ import {
4
+ AUTO_SUPPORTED_VARS,
5
+ buildDatabaseUrl,
6
+ buildRedisUrl,
7
+ type EnvResolverContext,
8
+ formatMissingVarsError,
9
+ generateSecret,
10
+ getOrGenerateSecret,
11
+ isAutoSupportedVar,
12
+ resolveEnvVar,
13
+ resolveEnvVars,
14
+ validateEnvVars,
15
+ } from '../env-resolver';
16
+ import { createEmptyState, type DokployStageState } from '../state';
17
+
18
+ describe('isAutoSupportedVar', () => {
19
+ it('should return true for all AUTO_SUPPORTED_VARS', () => {
20
+ for (const varName of AUTO_SUPPORTED_VARS) {
21
+ expect(isAutoSupportedVar(varName)).toBe(true);
22
+ }
23
+ });
24
+
25
+ it('should return false for unknown variables', () => {
26
+ expect(isAutoSupportedVar('UNKNOWN_VAR')).toBe(false);
27
+ expect(isAutoSupportedVar('MY_CUSTOM_VAR')).toBe(false);
28
+ expect(isAutoSupportedVar('')).toBe(false);
29
+ });
30
+
31
+ it('should be case-sensitive', () => {
32
+ expect(isAutoSupportedVar('port')).toBe(false);
33
+ expect(isAutoSupportedVar('Port')).toBe(false);
34
+ expect(isAutoSupportedVar('PORT')).toBe(true);
35
+ });
36
+ });
37
+
38
+ describe('generateSecret', () => {
39
+ it('should generate a 64-character hex string', () => {
40
+ const secret = generateSecret();
41
+ expect(secret).toMatch(/^[a-f0-9]{64}$/);
42
+ });
43
+
44
+ it('should generate unique secrets each time', () => {
45
+ const secrets = new Set<string>();
46
+ for (let i = 0; i < 100; i++) {
47
+ secrets.add(generateSecret());
48
+ }
49
+ expect(secrets.size).toBe(100);
50
+ });
51
+ });
52
+
53
+ describe('getOrGenerateSecret', () => {
54
+ it('should return existing secret if already stored', () => {
55
+ const state: DokployStageState = {
56
+ ...createEmptyState('production', 'env-123'),
57
+ generatedSecrets: {
58
+ api: { BETTER_AUTH_SECRET: 'existing-secret-123' },
59
+ },
60
+ };
61
+
62
+ const result = getOrGenerateSecret(state, 'api', 'BETTER_AUTH_SECRET');
63
+ expect(result).toBe('existing-secret-123');
64
+ });
65
+
66
+ it('should generate and store new secret if not exists', () => {
67
+ const state = createEmptyState('production', 'env-123');
68
+
69
+ const result = getOrGenerateSecret(state, 'api', 'BETTER_AUTH_SECRET');
70
+
71
+ expect(result).toMatch(/^[a-f0-9]{64}$/);
72
+ expect(state.generatedSecrets?.api?.BETTER_AUTH_SECRET).toBe(result);
73
+ });
74
+
75
+ it('should generate different secrets for different apps', () => {
76
+ const state = createEmptyState('production', 'env-123');
77
+
78
+ const apiSecret = getOrGenerateSecret(state, 'api', 'BETTER_AUTH_SECRET');
79
+ const authSecret = getOrGenerateSecret(state, 'auth', 'BETTER_AUTH_SECRET');
80
+
81
+ expect(apiSecret).not.toBe(authSecret);
82
+ expect(state.generatedSecrets?.api?.BETTER_AUTH_SECRET).toBe(apiSecret);
83
+ expect(state.generatedSecrets?.auth?.BETTER_AUTH_SECRET).toBe(authSecret);
84
+ });
85
+
86
+ it('should generate different secrets for different secret names', () => {
87
+ const state = createEmptyState('production', 'env-123');
88
+
89
+ const secret1 = getOrGenerateSecret(state, 'api', 'SECRET_ONE');
90
+ const secret2 = getOrGenerateSecret(state, 'api', 'SECRET_TWO');
91
+
92
+ expect(secret1).not.toBe(secret2);
93
+ });
94
+
95
+ it('should return same secret on subsequent calls', () => {
96
+ const state = createEmptyState('production', 'env-123');
97
+
98
+ const first = getOrGenerateSecret(state, 'api', 'BETTER_AUTH_SECRET');
99
+ const second = getOrGenerateSecret(state, 'api', 'BETTER_AUTH_SECRET');
100
+
101
+ expect(first).toBe(second);
102
+ });
103
+ });
104
+
105
+ describe('buildDatabaseUrl', () => {
106
+ it('should build correct URL with credentials', () => {
107
+ const credentials = { dbUser: 'myuser', dbPassword: 'mypassword' };
108
+ const postgres = { host: 'localhost', port: 5432, database: 'mydb' };
109
+
110
+ const url = buildDatabaseUrl(credentials, postgres);
111
+
112
+ expect(url).toBe('postgresql://myuser:mypassword@localhost:5432/mydb');
113
+ });
114
+
115
+ it('should encode special characters in username and password', () => {
116
+ const credentials = { dbUser: 'user@test', dbPassword: 'pass#word!123' };
117
+ const postgres = { host: 'db.example.com', port: 5432, database: 'app' };
118
+
119
+ const url = buildDatabaseUrl(credentials, postgres);
120
+
121
+ expect(url).toBe(
122
+ 'postgresql://user%40test:pass%23word!123@db.example.com:5432/app',
123
+ );
124
+ });
125
+
126
+ it('should handle different port numbers', () => {
127
+ const credentials = { dbUser: 'user', dbPassword: 'pass' };
128
+ const postgres = { host: 'localhost', port: 5433, database: 'testdb' };
129
+
130
+ const url = buildDatabaseUrl(credentials, postgres);
131
+
132
+ expect(url).toBe('postgresql://user:pass@localhost:5433/testdb');
133
+ });
134
+ });
135
+
136
+ describe('buildRedisUrl', () => {
137
+ it('should build URL with password', () => {
138
+ const redis = { host: 'localhost', port: 6379, password: 'redispass' };
139
+
140
+ const url = buildRedisUrl(redis);
141
+
142
+ expect(url).toBe('redis://:redispass@localhost:6379');
143
+ });
144
+
145
+ it('should build URL without password', () => {
146
+ const redis = { host: 'localhost', port: 6379 };
147
+
148
+ const url = buildRedisUrl(redis);
149
+
150
+ expect(url).toBe('redis://localhost:6379');
151
+ });
152
+
153
+ it('should encode special characters in password', () => {
154
+ const redis = { host: 'redis.example.com', port: 6380, password: 'p@ss:word' };
155
+
156
+ const url = buildRedisUrl(redis);
157
+
158
+ expect(url).toBe('redis://:p%40ss%3Aword@redis.example.com:6380');
159
+ });
160
+ });
161
+
162
+ describe('resolveEnvVar', () => {
163
+ const createApp = (
164
+ overrides: Partial<NormalizedAppConfig> = {},
165
+ ): NormalizedAppConfig => ({
166
+ type: 'backend',
167
+ path: 'apps/api',
168
+ port: 3000,
169
+ dependencies: [],
170
+ resolvedDeployTarget: 'dokploy',
171
+ ...overrides,
172
+ });
173
+
174
+ const createContext = (
175
+ overrides: Partial<EnvResolverContext> = {},
176
+ ): EnvResolverContext => ({
177
+ app: createApp(),
178
+ appName: 'api',
179
+ stage: 'production',
180
+ state: createEmptyState('production', 'env-123'),
181
+ appHostname: 'api.example.com',
182
+ frontendUrls: [],
183
+ ...overrides,
184
+ });
185
+
186
+ it('should resolve PORT from app config', () => {
187
+ const context = createContext({
188
+ app: createApp({ port: 8080 }),
189
+ });
190
+
191
+ expect(resolveEnvVar('PORT', context)).toBe('8080');
192
+ });
193
+
194
+ it('should resolve NODE_ENV based on stage', () => {
195
+ expect(resolveEnvVar('NODE_ENV', createContext({ stage: 'production' }))).toBe(
196
+ 'production',
197
+ );
198
+ expect(resolveEnvVar('NODE_ENV', createContext({ stage: 'staging' }))).toBe(
199
+ 'development',
200
+ );
201
+ expect(resolveEnvVar('NODE_ENV', createContext({ stage: 'development' }))).toBe(
202
+ 'development',
203
+ );
204
+ });
205
+
206
+ it('should resolve DATABASE_URL when credentials and postgres are provided', () => {
207
+ const context = createContext({
208
+ appCredentials: { dbUser: 'api', dbPassword: 'secret123' },
209
+ postgres: { host: 'postgres', port: 5432, database: 'myproject' },
210
+ });
211
+
212
+ const url = resolveEnvVar('DATABASE_URL', context);
213
+
214
+ expect(url).toBe('postgresql://api:secret123@postgres:5432/myproject');
215
+ });
216
+
217
+ it('should return undefined for DATABASE_URL when credentials missing', () => {
218
+ const context = createContext({
219
+ postgres: { host: 'postgres', port: 5432, database: 'myproject' },
220
+ });
221
+
222
+ expect(resolveEnvVar('DATABASE_URL', context)).toBeUndefined();
223
+ });
224
+
225
+ it('should resolve REDIS_URL when redis is provided', () => {
226
+ const context = createContext({
227
+ redis: { host: 'redis', port: 6379, password: 'redispass' },
228
+ });
229
+
230
+ const url = resolveEnvVar('REDIS_URL', context);
231
+
232
+ expect(url).toBe('redis://:redispass@redis:6379');
233
+ });
234
+
235
+ it('should return undefined for REDIS_URL when redis missing', () => {
236
+ const context = createContext();
237
+
238
+ expect(resolveEnvVar('REDIS_URL', context)).toBeUndefined();
239
+ });
240
+
241
+ it('should resolve BETTER_AUTH_URL from app hostname', () => {
242
+ const context = createContext({ appHostname: 'auth.myapp.com' });
243
+
244
+ expect(resolveEnvVar('BETTER_AUTH_URL', context)).toBe('https://auth.myapp.com');
245
+ });
246
+
247
+ it('should resolve BETTER_AUTH_SECRET by generating and storing secret', () => {
248
+ const state = createEmptyState('production', 'env-123');
249
+ const context = createContext({ state, appName: 'auth' });
250
+
251
+ const secret = resolveEnvVar('BETTER_AUTH_SECRET', context);
252
+
253
+ expect(secret).toMatch(/^[a-f0-9]{64}$/);
254
+ expect(state.generatedSecrets?.auth?.BETTER_AUTH_SECRET).toBe(secret);
255
+ });
256
+
257
+ it('should resolve BETTER_AUTH_TRUSTED_ORIGINS from frontend URLs', () => {
258
+ const context = createContext({
259
+ frontendUrls: ['https://web.myapp.com', 'https://admin.myapp.com'],
260
+ });
261
+
262
+ const origins = resolveEnvVar('BETTER_AUTH_TRUSTED_ORIGINS', context);
263
+
264
+ expect(origins).toBe('https://web.myapp.com,https://admin.myapp.com');
265
+ });
266
+
267
+ it('should return undefined for BETTER_AUTH_TRUSTED_ORIGINS when no frontend URLs', () => {
268
+ const context = createContext({ frontendUrls: [] });
269
+
270
+ expect(resolveEnvVar('BETTER_AUTH_TRUSTED_ORIGINS', context)).toBeUndefined();
271
+ });
272
+
273
+ it('should resolve GKM_MASTER_KEY from context', () => {
274
+ const context = createContext({ masterKey: 'my-master-key-123' });
275
+
276
+ expect(resolveEnvVar('GKM_MASTER_KEY', context)).toBe('my-master-key-123');
277
+ });
278
+
279
+ it('should return undefined for GKM_MASTER_KEY when not provided', () => {
280
+ const context = createContext();
281
+
282
+ expect(resolveEnvVar('GKM_MASTER_KEY', context)).toBeUndefined();
283
+ });
284
+
285
+ it('should resolve custom variable from userSecrets.custom', () => {
286
+ const context = createContext({
287
+ userSecrets: {
288
+ custom: { MY_API_KEY: 'secret-api-key' },
289
+ urls: {},
290
+ services: {},
291
+ },
292
+ });
293
+
294
+ expect(resolveEnvVar('MY_API_KEY', context)).toBe('secret-api-key');
295
+ });
296
+
297
+ it('should resolve URL variables from userSecrets.urls', () => {
298
+ const context = createContext({
299
+ userSecrets: {
300
+ custom: {},
301
+ urls: { DATABASE_URL: 'postgresql://external:5432/db' },
302
+ services: {},
303
+ },
304
+ });
305
+
306
+ expect(resolveEnvVar('DATABASE_URL', context)).toBe(
307
+ 'postgresql://external:5432/db',
308
+ );
309
+ });
310
+
311
+ it('should resolve POSTGRES_PASSWORD from userSecrets.services', () => {
312
+ const context = createContext({
313
+ userSecrets: {
314
+ custom: {},
315
+ urls: {},
316
+ services: { postgres: { password: 'pg-password' } },
317
+ },
318
+ });
319
+
320
+ expect(resolveEnvVar('POSTGRES_PASSWORD', context)).toBe('pg-password');
321
+ });
322
+
323
+ it('should resolve REDIS_PASSWORD from userSecrets.services', () => {
324
+ const context = createContext({
325
+ userSecrets: {
326
+ custom: {},
327
+ urls: {},
328
+ services: { redis: { password: 'redis-password' } },
329
+ },
330
+ });
331
+
332
+ expect(resolveEnvVar('REDIS_PASSWORD', context)).toBe('redis-password');
333
+ });
334
+
335
+ it('should return undefined for unknown variable', () => {
336
+ const context = createContext();
337
+
338
+ expect(resolveEnvVar('UNKNOWN_VAR', context)).toBeUndefined();
339
+ });
340
+ });
341
+
342
+ describe('resolveEnvVars', () => {
343
+ const createContext = (
344
+ overrides: Partial<EnvResolverContext> = {},
345
+ ): EnvResolverContext => ({
346
+ app: {
347
+ type: 'backend',
348
+ path: 'apps/api',
349
+ port: 3000,
350
+ dependencies: [],
351
+ resolvedDeployTarget: 'dokploy',
352
+ },
353
+ appName: 'api',
354
+ stage: 'production',
355
+ state: createEmptyState('production', 'env-123'),
356
+ appHostname: 'api.example.com',
357
+ frontendUrls: ['https://web.example.com'],
358
+ ...overrides,
359
+ });
360
+
361
+ it('should resolve all provided variables', () => {
362
+ const context = createContext({
363
+ appCredentials: { dbUser: 'api', dbPassword: 'pass' },
364
+ postgres: { host: 'postgres', port: 5432, database: 'mydb' },
365
+ });
366
+
367
+ const result = resolveEnvVars(['PORT', 'NODE_ENV', 'DATABASE_URL'], context);
368
+
369
+ expect(result.resolved).toEqual({
370
+ PORT: '3000',
371
+ NODE_ENV: 'production',
372
+ DATABASE_URL: 'postgresql://api:pass@postgres:5432/mydb',
373
+ });
374
+ expect(result.missing).toEqual([]);
375
+ });
376
+
377
+ it('should collect missing variables', () => {
378
+ const context = createContext();
379
+
380
+ const result = resolveEnvVars(
381
+ ['PORT', 'DATABASE_URL', 'CUSTOM_VAR'],
382
+ context,
383
+ );
384
+
385
+ expect(result.resolved).toEqual({ PORT: '3000' });
386
+ expect(result.missing).toEqual(['DATABASE_URL', 'CUSTOM_VAR']);
387
+ });
388
+
389
+ it('should handle empty input', () => {
390
+ const context = createContext();
391
+
392
+ const result = resolveEnvVars([], context);
393
+
394
+ expect(result.resolved).toEqual({});
395
+ expect(result.missing).toEqual([]);
396
+ });
397
+ });
398
+
399
+ describe('formatMissingVarsError', () => {
400
+ it('should format error message with missing variables', () => {
401
+ const error = formatMissingVarsError('api', ['DATABASE_URL', 'REDIS_URL'], 'production');
402
+
403
+ expect(error).toContain('Deployment failed: api is missing required environment variables');
404
+ expect(error).toContain('- DATABASE_URL');
405
+ expect(error).toContain('- REDIS_URL');
406
+ expect(error).toContain('gkm secrets:set <VAR_NAME> <value> --stage production');
407
+ });
408
+
409
+ it('should handle single missing variable', () => {
410
+ const error = formatMissingVarsError('auth', ['MY_SECRET'], 'staging');
411
+
412
+ expect(error).toContain('auth is missing required environment variables');
413
+ expect(error).toContain('- MY_SECRET');
414
+ expect(error).toContain('--stage staging');
415
+ });
416
+ });
417
+
418
+ describe('validateEnvVars', () => {
419
+ const createContext = (
420
+ overrides: Partial<EnvResolverContext> = {},
421
+ ): EnvResolverContext => ({
422
+ app: {
423
+ type: 'backend',
424
+ path: 'apps/api',
425
+ port: 3000,
426
+ dependencies: [],
427
+ resolvedDeployTarget: 'dokploy',
428
+ },
429
+ appName: 'api',
430
+ stage: 'production',
431
+ state: createEmptyState('production', 'env-123'),
432
+ appHostname: 'api.example.com',
433
+ frontendUrls: [],
434
+ ...overrides,
435
+ });
436
+
437
+ it('should return valid=true when all vars resolved', () => {
438
+ const context = createContext();
439
+
440
+ const result = validateEnvVars(['PORT', 'NODE_ENV'], context);
441
+
442
+ expect(result.valid).toBe(true);
443
+ expect(result.missing).toEqual([]);
444
+ expect(result.resolved).toEqual({
445
+ PORT: '3000',
446
+ NODE_ENV: 'production',
447
+ });
448
+ });
449
+
450
+ it('should return valid=false when vars are missing', () => {
451
+ const context = createContext();
452
+
453
+ const result = validateEnvVars(['PORT', 'DATABASE_URL', 'CUSTOM_VAR'], context);
454
+
455
+ expect(result.valid).toBe(false);
456
+ expect(result.missing).toEqual(['DATABASE_URL', 'CUSTOM_VAR']);
457
+ expect(result.resolved).toEqual({ PORT: '3000' });
458
+ });
459
+
460
+ it('should return valid=true for empty input', () => {
461
+ const context = createContext();
462
+
463
+ const result = validateEnvVars([], context);
464
+
465
+ expect(result.valid).toBe(true);
466
+ expect(result.missing).toEqual([]);
467
+ expect(result.resolved).toEqual({});
468
+ });
469
+ });
@@ -134,7 +134,7 @@ describe('provisionServices', () => {
134
134
  });
135
135
 
136
136
  expect(result).toBeDefined();
137
- expect(result?.DATABASE_URL).toMatch(
137
+ expect(result?.serviceUrls?.DATABASE_URL).toMatch(
138
138
  /^postgresql:\/\/postgres:[a-f0-9]{32}@myapp-db:5432\/app$/,
139
139
  );
140
140
  });
@@ -165,11 +165,11 @@ describe('provisionServices', () => {
165
165
  });
166
166
 
167
167
  expect(result).toBeDefined();
168
- expect(result?.DATABASE_HOST).toBe('myapp-db');
169
- expect(result?.DATABASE_PORT).toBe('5432');
170
- expect(result?.DATABASE_NAME).toBe('mydb');
171
- expect(result?.DATABASE_USER).toBe('dbuser');
172
- expect(result?.DATABASE_PASSWORD).toMatch(/^[a-f0-9]{32}$/);
168
+ expect(result?.serviceUrls?.DATABASE_HOST).toBe('myapp-db');
169
+ expect(result?.serviceUrls?.DATABASE_PORT).toBe('5432');
170
+ expect(result?.serviceUrls?.DATABASE_NAME).toBe('mydb');
171
+ expect(result?.serviceUrls?.DATABASE_USER).toBe('dbuser');
172
+ expect(result?.serviceUrls?.DATABASE_PASSWORD).toMatch(/^[a-f0-9]{32}$/);
173
173
  });
174
174
 
175
175
  it('should provision redis and return REDIS_URL', async () => {
@@ -196,7 +196,7 @@ describe('provisionServices', () => {
196
196
  });
197
197
 
198
198
  expect(result).toBeDefined();
199
- expect(result?.REDIS_URL).toMatch(
199
+ expect(result?.serviceUrls?.REDIS_URL).toMatch(
200
200
  /^redis:\/\/:[a-f0-9]{32}@myapp-cache:6379$/,
201
201
  );
202
202
  });
@@ -225,9 +225,9 @@ describe('provisionServices', () => {
225
225
  });
226
226
 
227
227
  expect(result).toBeDefined();
228
- expect(result?.REDIS_HOST).toBe('myapp-cache');
229
- expect(result?.REDIS_PORT).toBe('6379');
230
- expect(result?.REDIS_PASSWORD).toMatch(/^[a-f0-9]{32}$/);
228
+ expect(result?.serviceUrls?.REDIS_HOST).toBe('myapp-cache');
229
+ expect(result?.serviceUrls?.REDIS_PORT).toBe('6379');
230
+ expect(result?.serviceUrls?.REDIS_PASSWORD).toMatch(/^[a-f0-9]{32}$/);
231
231
  });
232
232
 
233
233
  it('should provision both postgres and redis', async () => {
@@ -268,8 +268,8 @@ describe('provisionServices', () => {
268
268
  });
269
269
 
270
270
  expect(result).toBeDefined();
271
- expect(result?.DATABASE_URL).toBeDefined();
272
- expect(result?.REDIS_URL).toBeDefined();
271
+ expect(result?.serviceUrls?.DATABASE_URL).toBeDefined();
272
+ expect(result?.serviceUrls?.REDIS_URL).toBeDefined();
273
273
  });
274
274
 
275
275
  it('should handle postgres already exists error gracefully', async () => {
@@ -187,7 +187,10 @@ describe('prepareSecretsForAllApps', () => {
187
187
 
188
188
  it('should prepare secrets for multiple apps', () => {
189
189
  const sniffedApps = new Map<string, SniffedEnvironment>([
190
- ['api', { appName: 'api', requiredEnvVars: ['DATABASE_URL', 'REDIS_URL'] }],
190
+ [
191
+ 'api',
192
+ { appName: 'api', requiredEnvVars: ['DATABASE_URL', 'REDIS_URL'] },
193
+ ],
191
194
  [
192
195
  'auth',
193
196
  {