@geekmidas/cli 0.13.0 → 0.15.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/{bundler-DskIqW2t.mjs → bundler-D7cM_FWw.mjs} +34 -10
- package/dist/bundler-D7cM_FWw.mjs.map +1 -0
- package/dist/{bundler-B1qy9b-j.cjs → bundler-Nuew7Xcn.cjs} +33 -9
- package/dist/bundler-Nuew7Xcn.cjs.map +1 -0
- package/dist/config.d.cts +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/dokploy-api-B7KxOQr3.cjs +3 -0
- package/dist/dokploy-api-C7F9VykY.cjs +317 -0
- package/dist/dokploy-api-C7F9VykY.cjs.map +1 -0
- package/dist/dokploy-api-CaETb2L6.mjs +305 -0
- package/dist/dokploy-api-CaETb2L6.mjs.map +1 -0
- package/dist/dokploy-api-DHvfmWbi.mjs +3 -0
- package/dist/{encryption-Dyf_r1h-.cjs → encryption-D7Efcdi9.cjs} +1 -1
- package/dist/{encryption-Dyf_r1h-.cjs.map → encryption-D7Efcdi9.cjs.map} +1 -1
- package/dist/{encryption-C8H-38Yy.mjs → encryption-h4Nb6W-M.mjs} +1 -1
- package/dist/{encryption-C8H-38Yy.mjs.map → encryption-h4Nb6W-M.mjs.map} +1 -1
- package/dist/index.cjs +1508 -1073
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1508 -1073
- package/dist/index.mjs.map +1 -1
- package/dist/{openapi-Bt_1FDpT.cjs → openapi-C89hhkZC.cjs} +3 -3
- package/dist/{openapi-Bt_1FDpT.cjs.map → openapi-C89hhkZC.cjs.map} +1 -1
- package/dist/{openapi-BfFlOBCG.mjs → openapi-CZVcfxk-.mjs} +3 -3
- package/dist/{openapi-BfFlOBCG.mjs.map → openapi-CZVcfxk-.mjs.map} +1 -1
- package/dist/{openapi-react-query-B6XTeGqS.mjs → openapi-react-query-CM2_qlW9.mjs} +1 -1
- package/dist/{openapi-react-query-B6XTeGqS.mjs.map → openapi-react-query-CM2_qlW9.mjs.map} +1 -1
- package/dist/{openapi-react-query-B-sNWHFU.cjs → openapi-react-query-iKjfLzff.cjs} +1 -1
- package/dist/{openapi-react-query-B-sNWHFU.cjs.map → openapi-react-query-iKjfLzff.cjs.map} +1 -1
- package/dist/openapi-react-query.cjs +1 -1
- package/dist/openapi-react-query.mjs +1 -1
- package/dist/openapi.cjs +1 -1
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +1 -1
- package/dist/{storage-kSxTjkNb.mjs → storage-BaOP55oq.mjs} +16 -2
- package/dist/storage-BaOP55oq.mjs.map +1 -0
- package/dist/{storage-Bj1E26lU.cjs → storage-Bn3K9Ccu.cjs} +21 -1
- package/dist/storage-Bn3K9Ccu.cjs.map +1 -0
- package/dist/storage-UfyTn7Zm.cjs +7 -0
- package/dist/storage-nkGIjeXt.mjs +3 -0
- package/dist/{types-BhkZc-vm.d.cts → types-BgaMXsUa.d.cts} +3 -1
- package/dist/{types-BR0M2v_c.d.mts.map → types-BgaMXsUa.d.cts.map} +1 -1
- package/dist/{types-BR0M2v_c.d.mts → types-iFk5ms7y.d.mts} +3 -1
- package/dist/{types-BhkZc-vm.d.cts.map → types-iFk5ms7y.d.mts.map} +1 -1
- package/package.json +4 -4
- package/src/auth/__tests__/credentials.spec.ts +127 -0
- package/src/auth/__tests__/index.spec.ts +69 -0
- package/src/auth/credentials.ts +33 -0
- package/src/auth/index.ts +57 -50
- package/src/build/__tests__/bundler.spec.ts +5 -4
- package/src/build/__tests__/endpoint-analyzer.spec.ts +623 -0
- package/src/build/__tests__/handler-templates.spec.ts +272 -0
- package/src/build/bundler.ts +61 -8
- package/src/build/index.ts +21 -0
- package/src/build/types.ts +6 -0
- package/src/deploy/__tests__/docker.spec.ts +44 -6
- package/src/deploy/__tests__/dokploy-api.spec.ts +698 -0
- package/src/deploy/__tests__/dokploy.spec.ts +196 -6
- package/src/deploy/__tests__/index.spec.ts +401 -0
- package/src/deploy/__tests__/init.spec.ts +147 -16
- package/src/deploy/docker.ts +109 -5
- package/src/deploy/dokploy-api.ts +581 -0
- package/src/deploy/dokploy.ts +66 -93
- package/src/deploy/index.ts +630 -32
- package/src/deploy/init.ts +192 -249
- package/src/deploy/types.ts +24 -2
- package/src/dev/__tests__/index.spec.ts +95 -0
- package/src/docker/__tests__/templates.spec.ts +144 -0
- package/src/docker/index.ts +96 -6
- package/src/docker/templates.ts +114 -27
- package/src/generators/EndpointGenerator.ts +2 -2
- package/src/index.ts +34 -13
- package/src/secrets/storage.ts +15 -0
- package/src/types.ts +2 -0
- package/dist/bundler-B1qy9b-j.cjs.map +0 -1
- package/dist/bundler-DskIqW2t.mjs.map +0 -1
- package/dist/storage-BOOpAF8N.cjs +0 -5
- package/dist/storage-Bj1E26lU.cjs.map +0 -1
- package/dist/storage-kSxTjkNb.mjs.map +0 -1
- package/dist/storage-tgZSUnKl.mjs +0 -3
package/src/auth/credentials.ts
CHANGED
|
@@ -12,6 +12,8 @@ export interface StoredCredentials {
|
|
|
12
12
|
token: string;
|
|
13
13
|
/** Dokploy endpoint URL */
|
|
14
14
|
endpoint: string;
|
|
15
|
+
/** Registry ID in Dokploy (for Docker image pulls) */
|
|
16
|
+
registryId?: string;
|
|
15
17
|
/** When the credentials were stored */
|
|
16
18
|
storedAt: string;
|
|
17
19
|
};
|
|
@@ -112,6 +114,7 @@ export async function getDokployCredentials(
|
|
|
112
114
|
): Promise<{
|
|
113
115
|
token: string;
|
|
114
116
|
endpoint: string;
|
|
117
|
+
registryId?: string;
|
|
115
118
|
} | null> {
|
|
116
119
|
const credentials = await readCredentials(options);
|
|
117
120
|
|
|
@@ -122,6 +125,7 @@ export async function getDokployCredentials(
|
|
|
122
125
|
return {
|
|
123
126
|
token: credentials.dokploy.token,
|
|
124
127
|
endpoint: credentials.dokploy.endpoint,
|
|
128
|
+
registryId: credentials.dokploy.registryId,
|
|
125
129
|
};
|
|
126
130
|
}
|
|
127
131
|
|
|
@@ -185,3 +189,32 @@ export async function getDokployEndpoint(
|
|
|
185
189
|
const stored = await getDokployCredentials(options);
|
|
186
190
|
return stored?.endpoint ?? null;
|
|
187
191
|
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Store Dokploy registry ID
|
|
195
|
+
*/
|
|
196
|
+
export async function storeDokployRegistryId(
|
|
197
|
+
registryId: string,
|
|
198
|
+
options?: CredentialOptions,
|
|
199
|
+
): Promise<void> {
|
|
200
|
+
const credentials = await readCredentials(options);
|
|
201
|
+
|
|
202
|
+
if (!credentials.dokploy) {
|
|
203
|
+
throw new Error(
|
|
204
|
+
'Dokploy credentials not found. Run "gkm login --service dokploy" first.',
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
credentials.dokploy.registryId = registryId;
|
|
209
|
+
await writeCredentials(credentials, options);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Get Dokploy registry ID from stored credentials
|
|
214
|
+
*/
|
|
215
|
+
export async function getDokployRegistryId(
|
|
216
|
+
options?: CredentialOptions,
|
|
217
|
+
): Promise<string | undefined> {
|
|
218
|
+
const stored = await getDokployCredentials(options);
|
|
219
|
+
return stored?.registryId ?? undefined;
|
|
220
|
+
}
|
package/src/auth/index.ts
CHANGED
|
@@ -30,19 +30,9 @@ export async function validateDokployToken(
|
|
|
30
30
|
endpoint: string,
|
|
31
31
|
token: string,
|
|
32
32
|
): Promise<boolean> {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
headers: {
|
|
37
|
-
'Content-Type': 'application/json',
|
|
38
|
-
Authorization: `Bearer ${token}`,
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
return response.ok;
|
|
43
|
-
} catch {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
33
|
+
const { DokployApi } = await import('../deploy/dokploy-api');
|
|
34
|
+
const api = new DokployApi({ baseUrl: endpoint, token });
|
|
35
|
+
return api.validateToken();
|
|
46
36
|
}
|
|
47
37
|
|
|
48
38
|
/**
|
|
@@ -55,46 +45,60 @@ async function prompt(message: string, hidden = false): Promise<string> {
|
|
|
55
45
|
);
|
|
56
46
|
}
|
|
57
47
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
48
|
+
if (hidden) {
|
|
49
|
+
// For hidden input, use raw mode directly without readline
|
|
50
|
+
process.stdout.write(message);
|
|
51
|
+
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
let value = '';
|
|
54
|
+
|
|
55
|
+
const cleanup = () => {
|
|
56
|
+
process.stdin.setRawMode(false);
|
|
57
|
+
process.stdin.pause();
|
|
58
|
+
process.stdin.removeListener('data', onData);
|
|
59
|
+
process.stdin.removeListener('error', onError);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const onError = (err: Error) => {
|
|
63
|
+
cleanup();
|
|
64
|
+
reject(err);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const onData = (char: Buffer) => {
|
|
68
|
+
const c = char.toString();
|
|
69
|
+
|
|
70
|
+
if (c === '\n' || c === '\r') {
|
|
71
|
+
cleanup();
|
|
72
|
+
process.stdout.write('\n');
|
|
73
|
+
resolve(value);
|
|
74
|
+
} else if (c === '\u0003') {
|
|
75
|
+
// Ctrl+C
|
|
76
|
+
cleanup();
|
|
77
|
+
process.stdout.write('\n');
|
|
78
|
+
process.exit(1);
|
|
79
|
+
} else if (c === '\u007F' || c === '\b') {
|
|
80
|
+
// Backspace
|
|
81
|
+
if (value.length > 0) {
|
|
82
|
+
value = value.slice(0, -1);
|
|
86
83
|
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
} else {
|
|
85
|
+
value += c;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
process.stdin.setRawMode(true);
|
|
90
|
+
process.stdin.resume();
|
|
91
|
+
process.stdin.on('data', onData);
|
|
92
|
+
process.stdin.on('error', onError);
|
|
93
|
+
});
|
|
94
|
+
} else {
|
|
95
|
+
// For visible input, use readline
|
|
96
|
+
const rl = readline.createInterface({ input, output });
|
|
97
|
+
try {
|
|
94
98
|
return await rl.question(message);
|
|
99
|
+
} finally {
|
|
100
|
+
rl.close();
|
|
95
101
|
}
|
|
96
|
-
} finally {
|
|
97
|
-
rl.close();
|
|
98
102
|
}
|
|
99
103
|
}
|
|
100
104
|
|
|
@@ -222,5 +226,8 @@ export function maskToken(token: string): string {
|
|
|
222
226
|
export {
|
|
223
227
|
getDokployCredentials,
|
|
224
228
|
getDokployEndpoint,
|
|
229
|
+
getDokployRegistryId,
|
|
225
230
|
getDokployToken,
|
|
231
|
+
storeDokployCredentials,
|
|
232
|
+
storeDokployRegistryId,
|
|
226
233
|
} from './credentials';
|
|
@@ -8,7 +8,7 @@ import { bundleServer } from '../bundler';
|
|
|
8
8
|
|
|
9
9
|
// Mock child_process to avoid actually running tsdown
|
|
10
10
|
vi.mock('node:child_process', () => ({
|
|
11
|
-
|
|
11
|
+
spawnSync: vi.fn().mockReturnValue({ status: 0, error: null }),
|
|
12
12
|
}));
|
|
13
13
|
|
|
14
14
|
// Mock construct that returns specific environment variables
|
|
@@ -371,10 +371,10 @@ describe('bundleServer environment validation', () => {
|
|
|
371
371
|
);
|
|
372
372
|
|
|
373
373
|
itWithDir(
|
|
374
|
-
'should
|
|
374
|
+
'should auto-initialize secrets and throw for missing env vars',
|
|
375
375
|
async ({ dir }) => {
|
|
376
376
|
const entryPoint = await createEntryPoint(dir);
|
|
377
|
-
// Don't create secrets file
|
|
377
|
+
// Don't create secrets file - it should be auto-initialized
|
|
378
378
|
|
|
379
379
|
const constructs = [createMockConstruct(['DATABASE_URL'])];
|
|
380
380
|
|
|
@@ -382,6 +382,7 @@ describe('bundleServer environment validation', () => {
|
|
|
382
382
|
process.chdir(dir);
|
|
383
383
|
|
|
384
384
|
try {
|
|
385
|
+
// Should auto-initialize secrets but then fail because DATABASE_URL is required
|
|
385
386
|
await expect(
|
|
386
387
|
bundleServer({
|
|
387
388
|
entryPoint,
|
|
@@ -392,7 +393,7 @@ describe('bundleServer environment validation', () => {
|
|
|
392
393
|
stage: 'production',
|
|
393
394
|
constructs,
|
|
394
395
|
}),
|
|
395
|
-
).rejects.toThrow('
|
|
396
|
+
).rejects.toThrow('Missing environment variables');
|
|
396
397
|
} finally {
|
|
397
398
|
process.chdir(originalCwd);
|
|
398
399
|
}
|