@geekmidas/cli 0.45.0 → 0.46.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 (48) hide show
  1. package/dist/{config-C0b0jdmU.mjs → config-C3LSBNSl.mjs} +2 -2
  2. package/dist/{config-C0b0jdmU.mjs.map → config-C3LSBNSl.mjs.map} +1 -1
  3. package/dist/{config-xVZsRjN7.cjs → config-HYiM3iQJ.cjs} +2 -2
  4. package/dist/{config-xVZsRjN7.cjs.map → config-HYiM3iQJ.cjs.map} +1 -1
  5. package/dist/config.cjs +2 -2
  6. package/dist/config.d.cts +1 -1
  7. package/dist/config.d.mts +1 -1
  8. package/dist/config.mjs +2 -2
  9. package/dist/dokploy-api-C1JgU9Vr.mjs +3 -0
  10. package/dist/dokploy-api-Cpq_tLSz.cjs +3 -0
  11. package/dist/{dokploy-api-BdxOMH_V.cjs → dokploy-api-D8a0eQQB.cjs} +110 -1
  12. package/dist/dokploy-api-D8a0eQQB.cjs.map +1 -0
  13. package/dist/{dokploy-api-DWsqNjwP.mjs → dokploy-api-b6usLLKk.mjs} +110 -1
  14. package/dist/dokploy-api-b6usLLKk.mjs.map +1 -0
  15. package/dist/{index-CXa3odEw.d.mts → index-BtnjoghR.d.mts} +540 -46
  16. package/dist/index-BtnjoghR.d.mts.map +1 -0
  17. package/dist/{index-E8Nu2Rxl.d.cts → index-c89X2mi2.d.cts} +540 -46
  18. package/dist/index-c89X2mi2.d.cts.map +1 -0
  19. package/dist/index.cjs +254 -135
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.mjs +254 -135
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/{openapi-D3pA6FfZ.mjs → openapi-C3C-BzIZ.mjs} +2 -2
  24. package/dist/{openapi-D3pA6FfZ.mjs.map → openapi-C3C-BzIZ.mjs.map} +1 -1
  25. package/dist/{openapi-DhcCtKzM.cjs → openapi-D7WwlpPF.cjs} +2 -2
  26. package/dist/{openapi-DhcCtKzM.cjs.map → openapi-D7WwlpPF.cjs.map} +1 -1
  27. package/dist/openapi.cjs +3 -3
  28. package/dist/openapi.mjs +3 -3
  29. package/dist/workspace/index.cjs +1 -1
  30. package/dist/workspace/index.d.cts +1 -1
  31. package/dist/workspace/index.d.mts +1 -1
  32. package/dist/workspace/index.mjs +1 -1
  33. package/dist/{workspace-BDAhr6Kb.cjs → workspace-CaVW6j2q.cjs} +10 -1
  34. package/dist/{workspace-BDAhr6Kb.cjs.map → workspace-CaVW6j2q.cjs.map} +1 -1
  35. package/dist/{workspace-D_6ZCaR_.mjs → workspace-DLFRaDc-.mjs} +10 -1
  36. package/dist/{workspace-D_6ZCaR_.mjs.map → workspace-DLFRaDc-.mjs.map} +1 -1
  37. package/package.json +3 -3
  38. package/src/deploy/dokploy-api.ts +163 -0
  39. package/src/deploy/index.ts +313 -233
  40. package/src/deploy/state.ts +146 -0
  41. package/src/workspace/types.ts +566 -47
  42. package/tsconfig.tsbuildinfo +1 -1
  43. package/dist/dokploy-api-Bdmk5ImW.cjs +0 -3
  44. package/dist/dokploy-api-BdxOMH_V.cjs.map +0 -1
  45. package/dist/dokploy-api-DWsqNjwP.mjs.map +0 -1
  46. package/dist/dokploy-api-tZSZaHd9.mjs +0 -3
  47. package/dist/index-CXa3odEw.d.mts.map +0 -1
  48. package/dist/index-E8Nu2Rxl.d.cts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekmidas/cli",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "description": "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs",
5
5
  "private": false,
6
6
  "type": "module",
@@ -50,9 +50,9 @@
50
50
  "prompts": "~2.4.2",
51
51
  "@geekmidas/constructs": "~0.7.0",
52
52
  "@geekmidas/envkit": "~0.6.0",
53
+ "@geekmidas/schema": "~0.1.0",
53
54
  "@geekmidas/errors": "~0.1.0",
54
- "@geekmidas/logger": "~0.4.0",
55
- "@geekmidas/schema": "~0.1.0"
55
+ "@geekmidas/logger": "~0.4.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/lodash.kebabcase": "^4.1.9",
@@ -177,6 +177,34 @@ export class DokployApi {
177
177
  // Application endpoints
178
178
  // ============================================
179
179
 
180
+ /**
181
+ * List all applications in a project
182
+ */
183
+ async listApplications(projectId: string): Promise<DokployApplication[]> {
184
+ try {
185
+ return await this.get<DokployApplication[]>(
186
+ `application.all?projectId=${projectId}`,
187
+ );
188
+ } catch {
189
+ // Fallback: endpoint might not exist in older Dokploy versions
190
+ return [];
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Find an application by name in a project
196
+ */
197
+ async findApplicationByName(
198
+ projectId: string,
199
+ name: string,
200
+ ): Promise<DokployApplication | undefined> {
201
+ const applications = await this.listApplications(projectId);
202
+ const normalizedName = name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
203
+ return applications.find(
204
+ (app) => app.name === name || app.appName === normalizedName,
205
+ );
206
+ }
207
+
180
208
  /**
181
209
  * Create a new application
182
210
  */
@@ -193,6 +221,42 @@ export class DokployApi {
193
221
  });
194
222
  }
195
223
 
224
+ /**
225
+ * Find or create an application by name
226
+ */
227
+ async findOrCreateApplication(
228
+ name: string,
229
+ projectId: string,
230
+ environmentId: string,
231
+ ): Promise<{ application: DokployApplication; created: boolean }> {
232
+ const existing = await this.findApplicationByName(projectId, name);
233
+ if (existing) {
234
+ return { application: existing, created: false };
235
+ }
236
+ const application = await this.createApplication(
237
+ name,
238
+ projectId,
239
+ environmentId,
240
+ );
241
+ return { application, created: true };
242
+ }
243
+
244
+ /**
245
+ * Get an application by ID
246
+ */
247
+ async getApplication(
248
+ applicationId: string,
249
+ ): Promise<DokployApplication | null> {
250
+ try {
251
+ return await this.get<DokployApplication>(
252
+ `application.one?applicationId=${applicationId}`,
253
+ );
254
+ } catch {
255
+ // Application not found
256
+ return null;
257
+ }
258
+ }
259
+
196
260
  /**
197
261
  * Update an application
198
262
  */
@@ -317,6 +381,34 @@ export class DokployApi {
317
381
  // Postgres endpoints
318
382
  // ============================================
319
383
 
384
+ /**
385
+ * List all Postgres databases in a project
386
+ */
387
+ async listPostgres(projectId: string): Promise<DokployPostgres[]> {
388
+ try {
389
+ return await this.get<DokployPostgres[]>(
390
+ `postgres.all?projectId=${projectId}`,
391
+ );
392
+ } catch {
393
+ // Fallback: endpoint might not exist in older Dokploy versions
394
+ return [];
395
+ }
396
+ }
397
+
398
+ /**
399
+ * Find a Postgres database by name in a project
400
+ */
401
+ async findPostgresByName(
402
+ projectId: string,
403
+ name: string,
404
+ ): Promise<DokployPostgres | undefined> {
405
+ const databases = await this.listPostgres(projectId);
406
+ const normalizedName = name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
407
+ return databases.find(
408
+ (db) => db.name === name || db.appName === normalizedName,
409
+ );
410
+ }
411
+
320
412
  /**
321
413
  * Create a new Postgres database
322
414
  */
@@ -347,6 +439,30 @@ export class DokployApi {
347
439
  });
348
440
  }
349
441
 
442
+ /**
443
+ * Find or create a Postgres database by name
444
+ */
445
+ async findOrCreatePostgres(
446
+ name: string,
447
+ projectId: string,
448
+ environmentId: string,
449
+ options?: {
450
+ databasePassword?: string;
451
+ },
452
+ ): Promise<{ postgres: DokployPostgres; created: boolean }> {
453
+ const existing = await this.findPostgresByName(projectId, name);
454
+ if (existing) {
455
+ return { postgres: existing, created: false };
456
+ }
457
+ const postgres = await this.createPostgres(
458
+ name,
459
+ projectId,
460
+ environmentId,
461
+ options,
462
+ );
463
+ return { postgres, created: true };
464
+ }
465
+
350
466
  /**
351
467
  * Get a Postgres database by ID
352
468
  */
@@ -392,6 +508,34 @@ export class DokployApi {
392
508
  // Redis endpoints
393
509
  // ============================================
394
510
 
511
+ /**
512
+ * List all Redis instances in a project
513
+ */
514
+ async listRedis(projectId: string): Promise<DokployRedis[]> {
515
+ try {
516
+ return await this.get<DokployRedis[]>(
517
+ `redis.all?projectId=${projectId}`,
518
+ );
519
+ } catch {
520
+ // Fallback: endpoint might not exist in older Dokploy versions
521
+ return [];
522
+ }
523
+ }
524
+
525
+ /**
526
+ * Find a Redis instance by name in a project
527
+ */
528
+ async findRedisByName(
529
+ projectId: string,
530
+ name: string,
531
+ ): Promise<DokployRedis | undefined> {
532
+ const instances = await this.listRedis(projectId);
533
+ const normalizedName = name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
534
+ return instances.find(
535
+ (redis) => redis.name === name || redis.appName === normalizedName,
536
+ );
537
+ }
538
+
395
539
  /**
396
540
  * Create a new Redis instance
397
541
  */
@@ -418,6 +562,25 @@ export class DokployApi {
418
562
  });
419
563
  }
420
564
 
565
+ /**
566
+ * Find or create a Redis instance by name
567
+ */
568
+ async findOrCreateRedis(
569
+ name: string,
570
+ projectId: string,
571
+ environmentId: string,
572
+ options?: {
573
+ databasePassword?: string;
574
+ },
575
+ ): Promise<{ redis: DokployRedis; created: boolean }> {
576
+ const existing = await this.findRedisByName(projectId, name);
577
+ if (existing) {
578
+ return { redis: existing, created: false };
579
+ }
580
+ const redis = await this.createRedis(name, projectId, environmentId, options);
581
+ return { redis, created: true };
582
+ }
583
+
421
584
  /**
422
585
  * Get a Redis instance by ID
423
586
  */