@geekmidas/cli 0.45.0 → 0.47.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 (51) 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-4a6h35VY.cjs +3 -0
  10. package/dist/{dokploy-api-BdxOMH_V.cjs → dokploy-api-BnX2OxyF.cjs} +121 -1
  11. package/dist/dokploy-api-BnX2OxyF.cjs.map +1 -0
  12. package/dist/{dokploy-api-DWsqNjwP.mjs → dokploy-api-CMWlWq7-.mjs} +121 -1
  13. package/dist/dokploy-api-CMWlWq7-.mjs.map +1 -0
  14. package/dist/dokploy-api-DQvi9iZa.mjs +3 -0
  15. package/dist/{index-CXa3odEw.d.mts → index-A70abJ1m.d.mts} +598 -46
  16. package/dist/index-A70abJ1m.d.mts.map +1 -0
  17. package/dist/{index-E8Nu2Rxl.d.cts → index-pOA56MWT.d.cts} +598 -46
  18. package/dist/index-pOA56MWT.d.cts.map +1 -0
  19. package/dist/index.cjs +916 -357
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.mjs +916 -357
  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/auth/credentials.ts +66 -0
  39. package/src/deploy/dns/hostinger-api.ts +258 -0
  40. package/src/deploy/dns/index.ts +399 -0
  41. package/src/deploy/dokploy-api.ts +175 -0
  42. package/src/deploy/index.ts +389 -240
  43. package/src/deploy/state.ts +146 -0
  44. package/src/workspace/types.ts +629 -47
  45. package/tsconfig.tsbuildinfo +1 -1
  46. package/dist/dokploy-api-Bdmk5ImW.cjs +0 -3
  47. package/dist/dokploy-api-BdxOMH_V.cjs.map +0 -1
  48. package/dist/dokploy-api-DWsqNjwP.mjs.map +0 -1
  49. package/dist/dokploy-api-tZSZaHd9.mjs +0 -3
  50. package/dist/index-CXa3odEw.d.mts.map +0 -1
  51. package/dist/index-E8Nu2Rxl.d.cts.map +0 -1
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Deploy state management for Dokploy deployments
3
+ *
4
+ * Stores resource IDs (applications, services) per stage to avoid
5
+ * re-creating resources on subsequent deploys.
6
+ */
7
+
8
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
9
+ import { join } from 'node:path';
10
+
11
+ /**
12
+ * State for a single stage deployment
13
+ */
14
+ export interface DokployStageState {
15
+ provider: 'dokploy';
16
+ stage: string;
17
+ environmentId: string;
18
+ applications: Record<string, string>; // appName -> applicationId
19
+ services: {
20
+ postgresId?: string;
21
+ redisId?: string;
22
+ };
23
+ lastDeployedAt: string;
24
+ }
25
+
26
+ /**
27
+ * Get the state file path for a stage
28
+ */
29
+ function getStateFilePath(workspaceRoot: string, stage: string): string {
30
+ return join(workspaceRoot, '.gkm', `deploy-${stage}.json`);
31
+ }
32
+
33
+ /**
34
+ * Read the deploy state for a stage
35
+ * Returns null if state file doesn't exist
36
+ */
37
+ export async function readStageState(
38
+ workspaceRoot: string,
39
+ stage: string,
40
+ ): Promise<DokployStageState | null> {
41
+ const filePath = getStateFilePath(workspaceRoot, stage);
42
+
43
+ try {
44
+ const content = await readFile(filePath, 'utf-8');
45
+ return JSON.parse(content) as DokployStageState;
46
+ } catch (error) {
47
+ // File doesn't exist or is invalid - return null
48
+ if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
49
+ return null;
50
+ }
51
+ // Log other errors but don't fail
52
+ console.warn(`Warning: Could not read deploy state: ${error}`);
53
+ return null;
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Write the deploy state for a stage
59
+ */
60
+ export async function writeStageState(
61
+ workspaceRoot: string,
62
+ stage: string,
63
+ state: DokployStageState,
64
+ ): Promise<void> {
65
+ const filePath = getStateFilePath(workspaceRoot, stage);
66
+ const dir = join(workspaceRoot, '.gkm');
67
+
68
+ // Ensure .gkm directory exists
69
+ await mkdir(dir, { recursive: true });
70
+
71
+ // Update last deployed timestamp
72
+ state.lastDeployedAt = new Date().toISOString();
73
+
74
+ await writeFile(filePath, JSON.stringify(state, null, 2));
75
+ }
76
+
77
+ /**
78
+ * Create a new empty state for a stage
79
+ */
80
+ export function createEmptyState(
81
+ stage: string,
82
+ environmentId: string,
83
+ ): DokployStageState {
84
+ return {
85
+ provider: 'dokploy',
86
+ stage,
87
+ environmentId,
88
+ applications: {},
89
+ services: {},
90
+ lastDeployedAt: new Date().toISOString(),
91
+ };
92
+ }
93
+
94
+ /**
95
+ * Get application ID from state
96
+ */
97
+ export function getApplicationId(
98
+ state: DokployStageState | null,
99
+ appName: string,
100
+ ): string | undefined {
101
+ return state?.applications[appName];
102
+ }
103
+
104
+ /**
105
+ * Set application ID in state (mutates state)
106
+ */
107
+ export function setApplicationId(
108
+ state: DokployStageState,
109
+ appName: string,
110
+ applicationId: string,
111
+ ): void {
112
+ state.applications[appName] = applicationId;
113
+ }
114
+
115
+ /**
116
+ * Get postgres ID from state
117
+ */
118
+ export function getPostgresId(
119
+ state: DokployStageState | null,
120
+ ): string | undefined {
121
+ return state?.services.postgresId;
122
+ }
123
+
124
+ /**
125
+ * Set postgres ID in state (mutates state)
126
+ */
127
+ export function setPostgresId(
128
+ state: DokployStageState,
129
+ postgresId: string,
130
+ ): void {
131
+ state.services.postgresId = postgresId;
132
+ }
133
+
134
+ /**
135
+ * Get redis ID from state
136
+ */
137
+ export function getRedisId(state: DokployStageState | null): string | undefined {
138
+ return state?.services.redisId;
139
+ }
140
+
141
+ /**
142
+ * Set redis ID in state (mutates state)
143
+ */
144
+ export function setRedisId(state: DokployStageState, redisId: string): void {
145
+ state.services.redisId = redisId;
146
+ }