@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.
- package/dist/{config-C0b0jdmU.mjs → config-C3LSBNSl.mjs} +2 -2
- package/dist/{config-C0b0jdmU.mjs.map → config-C3LSBNSl.mjs.map} +1 -1
- package/dist/{config-xVZsRjN7.cjs → config-HYiM3iQJ.cjs} +2 -2
- package/dist/{config-xVZsRjN7.cjs.map → config-HYiM3iQJ.cjs.map} +1 -1
- package/dist/config.cjs +2 -2
- package/dist/config.d.cts +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +2 -2
- package/dist/dokploy-api-C1JgU9Vr.mjs +3 -0
- package/dist/dokploy-api-Cpq_tLSz.cjs +3 -0
- package/dist/{dokploy-api-BdxOMH_V.cjs → dokploy-api-D8a0eQQB.cjs} +110 -1
- package/dist/dokploy-api-D8a0eQQB.cjs.map +1 -0
- package/dist/{dokploy-api-DWsqNjwP.mjs → dokploy-api-b6usLLKk.mjs} +110 -1
- package/dist/dokploy-api-b6usLLKk.mjs.map +1 -0
- package/dist/{index-CXa3odEw.d.mts → index-BtnjoghR.d.mts} +540 -46
- package/dist/index-BtnjoghR.d.mts.map +1 -0
- package/dist/{index-E8Nu2Rxl.d.cts → index-c89X2mi2.d.cts} +540 -46
- package/dist/index-c89X2mi2.d.cts.map +1 -0
- package/dist/index.cjs +254 -135
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +254 -135
- package/dist/index.mjs.map +1 -1
- package/dist/{openapi-D3pA6FfZ.mjs → openapi-C3C-BzIZ.mjs} +2 -2
- package/dist/{openapi-D3pA6FfZ.mjs.map → openapi-C3C-BzIZ.mjs.map} +1 -1
- package/dist/{openapi-DhcCtKzM.cjs → openapi-D7WwlpPF.cjs} +2 -2
- package/dist/{openapi-DhcCtKzM.cjs.map → openapi-D7WwlpPF.cjs.map} +1 -1
- package/dist/openapi.cjs +3 -3
- package/dist/openapi.mjs +3 -3
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.d.cts +1 -1
- package/dist/workspace/index.d.mts +1 -1
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-BDAhr6Kb.cjs → workspace-CaVW6j2q.cjs} +10 -1
- package/dist/{workspace-BDAhr6Kb.cjs.map → workspace-CaVW6j2q.cjs.map} +1 -1
- package/dist/{workspace-D_6ZCaR_.mjs → workspace-DLFRaDc-.mjs} +10 -1
- package/dist/{workspace-D_6ZCaR_.mjs.map → workspace-DLFRaDc-.mjs.map} +1 -1
- package/package.json +3 -3
- package/src/deploy/dokploy-api.ts +163 -0
- package/src/deploy/index.ts +313 -233
- package/src/deploy/state.ts +146 -0
- package/src/workspace/types.ts +566 -47
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/dokploy-api-Bdmk5ImW.cjs +0 -3
- package/dist/dokploy-api-BdxOMH_V.cjs.map +0 -1
- package/dist/dokploy-api-DWsqNjwP.mjs.map +0 -1
- package/dist/dokploy-api-tZSZaHd9.mjs +0 -3
- package/dist/index-CXa3odEw.d.mts.map +0 -1
- 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
|
+
}
|