@geekmidas/cli 0.13.0 → 0.14.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 (79) hide show
  1. package/dist/{bundler-B1qy9b-j.cjs → bundler-BjholBlA.cjs} +26 -7
  2. package/dist/bundler-BjholBlA.cjs.map +1 -0
  3. package/dist/{bundler-DskIqW2t.mjs → bundler-DWctKN1z.mjs} +27 -8
  4. package/dist/bundler-DWctKN1z.mjs.map +1 -0
  5. package/dist/config.d.cts +1 -1
  6. package/dist/config.d.mts +1 -1
  7. package/dist/dokploy-api-B7KxOQr3.cjs +3 -0
  8. package/dist/dokploy-api-C7F9VykY.cjs +317 -0
  9. package/dist/dokploy-api-C7F9VykY.cjs.map +1 -0
  10. package/dist/dokploy-api-CaETb2L6.mjs +305 -0
  11. package/dist/dokploy-api-CaETb2L6.mjs.map +1 -0
  12. package/dist/dokploy-api-DHvfmWbi.mjs +3 -0
  13. package/dist/{encryption-Dyf_r1h-.cjs → encryption-D7Efcdi9.cjs} +1 -1
  14. package/dist/{encryption-Dyf_r1h-.cjs.map → encryption-D7Efcdi9.cjs.map} +1 -1
  15. package/dist/{encryption-C8H-38Yy.mjs → encryption-h4Nb6W-M.mjs} +1 -1
  16. package/dist/{encryption-C8H-38Yy.mjs.map → encryption-h4Nb6W-M.mjs.map} +1 -1
  17. package/dist/index.cjs +1513 -1136
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.mjs +1513 -1136
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/{openapi-Bt_1FDpT.cjs → openapi-C89hhkZC.cjs} +3 -3
  22. package/dist/{openapi-Bt_1FDpT.cjs.map → openapi-C89hhkZC.cjs.map} +1 -1
  23. package/dist/{openapi-BfFlOBCG.mjs → openapi-CZVcfxk-.mjs} +3 -3
  24. package/dist/{openapi-BfFlOBCG.mjs.map → openapi-CZVcfxk-.mjs.map} +1 -1
  25. package/dist/{openapi-react-query-B6XTeGqS.mjs → openapi-react-query-CM2_qlW9.mjs} +1 -1
  26. package/dist/{openapi-react-query-B6XTeGqS.mjs.map → openapi-react-query-CM2_qlW9.mjs.map} +1 -1
  27. package/dist/{openapi-react-query-B-sNWHFU.cjs → openapi-react-query-iKjfLzff.cjs} +1 -1
  28. package/dist/{openapi-react-query-B-sNWHFU.cjs.map → openapi-react-query-iKjfLzff.cjs.map} +1 -1
  29. package/dist/openapi-react-query.cjs +1 -1
  30. package/dist/openapi-react-query.mjs +1 -1
  31. package/dist/openapi.cjs +1 -1
  32. package/dist/openapi.d.cts +1 -1
  33. package/dist/openapi.d.mts +1 -1
  34. package/dist/openapi.mjs +1 -1
  35. package/dist/{storage-kSxTjkNb.mjs → storage-BaOP55oq.mjs} +16 -2
  36. package/dist/storage-BaOP55oq.mjs.map +1 -0
  37. package/dist/{storage-Bj1E26lU.cjs → storage-Bn3K9Ccu.cjs} +21 -1
  38. package/dist/storage-Bn3K9Ccu.cjs.map +1 -0
  39. package/dist/storage-UfyTn7Zm.cjs +7 -0
  40. package/dist/storage-nkGIjeXt.mjs +3 -0
  41. package/dist/{types-BhkZc-vm.d.cts → types-BgaMXsUa.d.cts} +3 -1
  42. package/dist/{types-BR0M2v_c.d.mts.map → types-BgaMXsUa.d.cts.map} +1 -1
  43. package/dist/{types-BR0M2v_c.d.mts → types-iFk5ms7y.d.mts} +3 -1
  44. package/dist/{types-BhkZc-vm.d.cts.map → types-iFk5ms7y.d.mts.map} +1 -1
  45. package/package.json +3 -3
  46. package/src/auth/__tests__/credentials.spec.ts +127 -0
  47. package/src/auth/__tests__/index.spec.ts +69 -0
  48. package/src/auth/credentials.ts +33 -0
  49. package/src/auth/index.ts +57 -50
  50. package/src/build/__tests__/bundler.spec.ts +1 -1
  51. package/src/build/__tests__/endpoint-analyzer.spec.ts +623 -0
  52. package/src/build/__tests__/handler-templates.spec.ts +272 -0
  53. package/src/build/bundler.ts +53 -4
  54. package/src/build/index.ts +21 -0
  55. package/src/build/types.ts +6 -0
  56. package/src/deploy/__tests__/dokploy-api.spec.ts +698 -0
  57. package/src/deploy/__tests__/dokploy.spec.ts +196 -6
  58. package/src/deploy/__tests__/index.spec.ts +339 -0
  59. package/src/deploy/__tests__/init.spec.ts +147 -16
  60. package/src/deploy/docker.ts +32 -3
  61. package/src/deploy/dokploy-api.ts +581 -0
  62. package/src/deploy/dokploy.ts +66 -93
  63. package/src/deploy/index.ts +587 -32
  64. package/src/deploy/init.ts +192 -249
  65. package/src/deploy/types.ts +19 -1
  66. package/src/dev/__tests__/index.spec.ts +95 -0
  67. package/src/docker/__tests__/templates.spec.ts +144 -0
  68. package/src/docker/index.ts +96 -6
  69. package/src/docker/templates.ts +114 -27
  70. package/src/generators/EndpointGenerator.ts +2 -2
  71. package/src/index.ts +34 -13
  72. package/src/secrets/storage.ts +15 -0
  73. package/src/types.ts +2 -0
  74. package/dist/bundler-B1qy9b-j.cjs.map +0 -1
  75. package/dist/bundler-DskIqW2t.mjs.map +0 -1
  76. package/dist/storage-BOOpAF8N.cjs +0 -5
  77. package/dist/storage-Bj1E26lU.cjs.map +0 -1
  78. package/dist/storage-kSxTjkNb.mjs.map +0 -1
  79. package/dist/storage-tgZSUnKl.mjs +0 -3
@@ -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
- try {
34
- const response = await fetch(`${endpoint}/api/project.all`, {
35
- method: 'GET',
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
- const rl = readline.createInterface({ input, output });
59
-
60
- try {
61
- if (hidden) {
62
- // For hidden input, we need to handle it differently
63
- process.stdout.write(message);
64
-
65
- return new Promise((resolve) => {
66
- let value = '';
67
-
68
- const onData = (char: Buffer) => {
69
- const c = char.toString();
70
-
71
- if (c === '\n' || c === '\r') {
72
- process.stdin.removeListener('data', onData);
73
- process.stdin.setRawMode(false);
74
- process.stdout.write('\n');
75
- resolve(value);
76
- } else if (c === '\u0003') {
77
- // Ctrl+C
78
- process.exit(1);
79
- } else if (c === '\u007F' || c === '\b') {
80
- // Backspace
81
- if (value.length > 0) {
82
- value = value.slice(0, -1);
83
- }
84
- } else {
85
- value += c;
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
- process.stdin.setRawMode(true);
90
- process.stdin.resume();
91
- process.stdin.on('data', onData);
92
- });
93
- } else {
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
- execSync: vi.fn(),
11
+ spawnSync: vi.fn().mockReturnValue({ status: 0, error: null }),
12
12
  }));
13
13
 
14
14
  // Mock construct that returns specific environment variables