@geekmidas/cli 0.9.0 → 0.12.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 (146) hide show
  1. package/README.md +525 -0
  2. package/dist/bundler-DRXCw_YR.mjs +70 -0
  3. package/dist/bundler-DRXCw_YR.mjs.map +1 -0
  4. package/dist/bundler-WsEvH_b2.cjs +71 -0
  5. package/dist/bundler-WsEvH_b2.cjs.map +1 -0
  6. package/dist/{config-CFls09Ey.cjs → config-AmInkU7k.cjs} +10 -8
  7. package/dist/config-AmInkU7k.cjs.map +1 -0
  8. package/dist/{config-Bq72aj8e.mjs → config-DYULeEv8.mjs} +6 -4
  9. package/dist/config-DYULeEv8.mjs.map +1 -0
  10. package/dist/config.cjs +1 -1
  11. package/dist/config.d.cts +2 -1
  12. package/dist/config.d.cts.map +1 -0
  13. package/dist/config.d.mts +2 -1
  14. package/dist/config.d.mts.map +1 -0
  15. package/dist/config.mjs +1 -1
  16. package/dist/encryption-C8H-38Yy.mjs +42 -0
  17. package/dist/encryption-C8H-38Yy.mjs.map +1 -0
  18. package/dist/encryption-Dyf_r1h-.cjs +44 -0
  19. package/dist/encryption-Dyf_r1h-.cjs.map +1 -0
  20. package/dist/index.cjs +2125 -184
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.mjs +2143 -197
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/{openapi--vOy9mo4.mjs → openapi-BfFlOBCG.mjs} +812 -49
  25. package/dist/openapi-BfFlOBCG.mjs.map +1 -0
  26. package/dist/{openapi-CHhTPief.cjs → openapi-Bt_1FDpT.cjs} +805 -42
  27. package/dist/openapi-Bt_1FDpT.cjs.map +1 -0
  28. package/dist/{openapi-react-query-o5iMi8tz.cjs → openapi-react-query-B-sNWHFU.cjs} +5 -5
  29. package/dist/openapi-react-query-B-sNWHFU.cjs.map +1 -0
  30. package/dist/{openapi-react-query-CcciaVu5.mjs → openapi-react-query-B6XTeGqS.mjs} +5 -5
  31. package/dist/openapi-react-query-B6XTeGqS.mjs.map +1 -0
  32. package/dist/openapi-react-query.cjs +1 -1
  33. package/dist/openapi-react-query.d.cts.map +1 -0
  34. package/dist/openapi-react-query.d.mts.map +1 -0
  35. package/dist/openapi-react-query.mjs +1 -1
  36. package/dist/openapi.cjs +2 -2
  37. package/dist/openapi.d.cts +1 -1
  38. package/dist/openapi.d.cts.map +1 -0
  39. package/dist/openapi.d.mts +1 -1
  40. package/dist/openapi.d.mts.map +1 -0
  41. package/dist/openapi.mjs +2 -2
  42. package/dist/storage-BUYQJgz7.cjs +4 -0
  43. package/dist/storage-BXoJvmv2.cjs +149 -0
  44. package/dist/storage-BXoJvmv2.cjs.map +1 -0
  45. package/dist/storage-C9PU_30f.mjs +101 -0
  46. package/dist/storage-C9PU_30f.mjs.map +1 -0
  47. package/dist/storage-DLJAYxzJ.mjs +3 -0
  48. package/dist/{types-b-vwGpqc.d.cts → types-BR0M2v_c.d.mts} +100 -1
  49. package/dist/types-BR0M2v_c.d.mts.map +1 -0
  50. package/dist/{types-DXgiA1sF.d.mts → types-BhkZc-vm.d.cts} +100 -1
  51. package/dist/types-BhkZc-vm.d.cts.map +1 -0
  52. package/examples/cron-example.ts +27 -27
  53. package/examples/env.ts +27 -27
  54. package/examples/function-example.ts +31 -31
  55. package/examples/gkm.config.json +20 -20
  56. package/examples/gkm.config.ts +8 -8
  57. package/examples/gkm.minimal.config.json +5 -5
  58. package/examples/gkm.production.config.json +25 -25
  59. package/examples/logger.ts +2 -2
  60. package/package.json +6 -6
  61. package/src/__tests__/EndpointGenerator.hooks.spec.ts +191 -191
  62. package/src/__tests__/config.spec.ts +55 -55
  63. package/src/__tests__/loadEnvFiles.spec.ts +93 -93
  64. package/src/__tests__/normalizeHooksConfig.spec.ts +58 -58
  65. package/src/__tests__/openapi-react-query.spec.ts +497 -497
  66. package/src/__tests__/openapi.spec.ts +428 -428
  67. package/src/__tests__/test-helpers.ts +77 -76
  68. package/src/auth/__tests__/credentials.spec.ts +204 -0
  69. package/src/auth/__tests__/index.spec.ts +168 -0
  70. package/src/auth/credentials.ts +187 -0
  71. package/src/auth/index.ts +226 -0
  72. package/src/build/__tests__/index-new.spec.ts +474 -474
  73. package/src/build/__tests__/manifests.spec.ts +333 -333
  74. package/src/build/bundler.ts +141 -0
  75. package/src/build/endpoint-analyzer.ts +236 -0
  76. package/src/build/handler-templates.ts +1253 -0
  77. package/src/build/index.ts +250 -179
  78. package/src/build/manifests.ts +52 -52
  79. package/src/build/providerResolver.ts +145 -145
  80. package/src/build/types.ts +64 -43
  81. package/src/config.ts +39 -37
  82. package/src/deploy/__tests__/docker.spec.ts +111 -0
  83. package/src/deploy/__tests__/dokploy.spec.ts +245 -0
  84. package/src/deploy/__tests__/init.spec.ts +662 -0
  85. package/src/deploy/docker.ts +128 -0
  86. package/src/deploy/dokploy.ts +204 -0
  87. package/src/deploy/index.ts +136 -0
  88. package/src/deploy/init.ts +484 -0
  89. package/src/deploy/types.ts +48 -0
  90. package/src/dev/__tests__/index.spec.ts +266 -266
  91. package/src/dev/index.ts +647 -593
  92. package/src/docker/__tests__/compose.spec.ts +531 -0
  93. package/src/docker/__tests__/templates.spec.ts +280 -0
  94. package/src/docker/compose.ts +273 -0
  95. package/src/docker/index.ts +230 -0
  96. package/src/docker/templates.ts +446 -0
  97. package/src/generators/CronGenerator.ts +72 -72
  98. package/src/generators/EndpointGenerator.ts +699 -398
  99. package/src/generators/FunctionGenerator.ts +84 -84
  100. package/src/generators/Generator.ts +72 -72
  101. package/src/generators/OpenApiTsGenerator.ts +589 -589
  102. package/src/generators/SubscriberGenerator.ts +124 -124
  103. package/src/generators/__tests__/CronGenerator.spec.ts +433 -433
  104. package/src/generators/__tests__/EndpointGenerator.spec.ts +532 -382
  105. package/src/generators/__tests__/FunctionGenerator.spec.ts +244 -244
  106. package/src/generators/__tests__/SubscriberGenerator.spec.ts +397 -382
  107. package/src/generators/index.ts +4 -4
  108. package/src/index.ts +628 -206
  109. package/src/init/__tests__/generators.spec.ts +334 -334
  110. package/src/init/__tests__/init.spec.ts +332 -332
  111. package/src/init/__tests__/utils.spec.ts +89 -89
  112. package/src/init/generators/config.ts +175 -175
  113. package/src/init/generators/docker.ts +41 -41
  114. package/src/init/generators/env.ts +72 -72
  115. package/src/init/generators/index.ts +1 -1
  116. package/src/init/generators/models.ts +64 -64
  117. package/src/init/generators/monorepo.ts +161 -161
  118. package/src/init/generators/package.ts +71 -71
  119. package/src/init/generators/source.ts +6 -6
  120. package/src/init/index.ts +203 -208
  121. package/src/init/templates/api.ts +115 -115
  122. package/src/init/templates/index.ts +75 -75
  123. package/src/init/templates/minimal.ts +98 -98
  124. package/src/init/templates/serverless.ts +89 -89
  125. package/src/init/templates/worker.ts +98 -98
  126. package/src/init/utils.ts +54 -56
  127. package/src/openapi-react-query.ts +194 -194
  128. package/src/openapi.ts +63 -63
  129. package/src/secrets/__tests__/encryption.spec.ts +226 -0
  130. package/src/secrets/__tests__/generator.spec.ts +319 -0
  131. package/src/secrets/__tests__/index.spec.ts +91 -0
  132. package/src/secrets/__tests__/storage.spec.ts +403 -0
  133. package/src/secrets/encryption.ts +91 -0
  134. package/src/secrets/generator.ts +164 -0
  135. package/src/secrets/index.ts +383 -0
  136. package/src/secrets/storage.ts +134 -0
  137. package/src/secrets/types.ts +53 -0
  138. package/src/types.ts +295 -176
  139. package/tsconfig.json +9 -0
  140. package/tsdown.config.ts +11 -8
  141. package/dist/config-Bq72aj8e.mjs.map +0 -1
  142. package/dist/config-CFls09Ey.cjs.map +0 -1
  143. package/dist/openapi--vOy9mo4.mjs.map +0 -1
  144. package/dist/openapi-CHhTPief.cjs.map +0 -1
  145. package/dist/openapi-react-query-CcciaVu5.mjs.map +0 -1
  146. package/dist/openapi-react-query-o5iMi8tz.cjs.map +0 -1
package/src/init/index.ts CHANGED
@@ -10,224 +10,219 @@ import { generateMonorepoFiles } from './generators/monorepo.js';
10
10
  import { generatePackageJson } from './generators/package.js';
11
11
  import { generateSourceFiles } from './generators/source.js';
12
12
  import {
13
- type TemplateName,
14
- type TemplateOptions,
15
- getTemplate,
16
- loggerTypeChoices,
17
- routesStructureChoices,
18
- templateChoices,
13
+ getTemplate,
14
+ loggerTypeChoices,
15
+ routesStructureChoices,
16
+ type TemplateName,
17
+ type TemplateOptions,
18
+ templateChoices,
19
19
  } from './templates/index.js';
20
20
  import {
21
- checkDirectoryExists,
22
- detectPackageManager,
23
- getInstallCommand,
24
- getRunCommand,
25
- validateProjectName,
21
+ checkDirectoryExists,
22
+ detectPackageManager,
23
+ getInstallCommand,
24
+ getRunCommand,
25
+ validateProjectName,
26
26
  } from './utils.js';
27
27
 
28
28
  export interface InitOptions {
29
- template?: TemplateName;
30
- skipInstall?: boolean;
31
- yes?: boolean;
32
- monorepo?: boolean;
33
- apiPath?: string;
29
+ template?: TemplateName;
30
+ skipInstall?: boolean;
31
+ yes?: boolean;
32
+ monorepo?: boolean;
33
+ apiPath?: string;
34
34
  }
35
35
 
36
36
  /**
37
37
  * Main init command - scaffolds a new project
38
38
  */
39
39
  export async function initCommand(
40
- projectName?: string,
41
- options: InitOptions = {},
40
+ projectName?: string,
41
+ options: InitOptions = {},
42
42
  ): Promise<void> {
43
- const cwd = process.cwd();
44
- const pkgManager = detectPackageManager(cwd);
45
-
46
- // Handle Ctrl+C gracefully
47
- prompts.override({});
48
- const onCancel = () => {
49
- process.exit(0);
50
- };
51
-
52
- // Gather answers via prompts
53
- const answers = await prompts(
54
- [
55
- {
56
- type: projectName ? null : 'text',
57
- name: 'name',
58
- message: 'Project name:',
59
- initial: 'my-api',
60
- validate: (value: string) => {
61
- const nameValid = validateProjectName(value);
62
- if (nameValid !== true) return nameValid;
63
- const dirValid = checkDirectoryExists(value, cwd);
64
- if (dirValid !== true) return dirValid;
65
- return true;
66
- },
67
- },
68
- {
69
- type: options.template || options.yes ? null : 'select',
70
- name: 'template',
71
- message: 'Template:',
72
- choices: templateChoices,
73
- initial: 0,
74
- },
75
- {
76
- type: options.yes ? null : 'confirm',
77
- name: 'telescope',
78
- message: 'Include Telescope (debugging dashboard)?',
79
- initial: true,
80
- },
81
- {
82
- type: options.yes ? null : 'confirm',
83
- name: 'database',
84
- message: 'Include database support (Kysely)?',
85
- initial: true,
86
- },
87
- {
88
- type: (prev) => (options.yes ? null : prev ? 'confirm' : null),
89
- name: 'studio',
90
- message: 'Include Studio (database browser)?',
91
- initial: true,
92
- },
93
- {
94
- type: options.yes ? null : 'select',
95
- name: 'loggerType',
96
- message: 'Logger:',
97
- choices: loggerTypeChoices,
98
- initial: 0,
99
- },
100
- {
101
- type: options.yes ? null : 'select',
102
- name: 'routesStructure',
103
- message: 'Routes structure:',
104
- choices: routesStructureChoices,
105
- initial: 0,
106
- },
107
- {
108
- type: options.yes || options.monorepo !== undefined ? null : 'confirm',
109
- name: 'monorepo',
110
- message: 'Setup as monorepo?',
111
- initial: false,
112
- },
113
- {
114
- type: (prev) =>
115
- (prev === true || options.monorepo) && !options.apiPath
116
- ? 'text'
117
- : null,
118
- name: 'apiPath',
119
- message: 'API app path:',
120
- initial: 'apps/api',
121
- },
122
- ],
123
- { onCancel },
124
- );
125
-
126
- // Build final options
127
- const name = projectName || answers.name;
128
- if (!name) {
129
- console.error(' Error: Project name is required\n');
130
- process.exit(1);
131
- }
132
-
133
- // Validate name if provided via argument
134
- if (projectName) {
135
- const nameValid = validateProjectName(projectName);
136
- if (nameValid !== true) {
137
- console.error(` Error: ${nameValid}\n`);
138
- process.exit(1);
139
- }
140
- const dirValid = checkDirectoryExists(projectName, cwd);
141
- if (dirValid !== true) {
142
- console.error(` Error: ${dirValid}\n`);
143
- process.exit(1);
144
- }
145
- }
146
-
147
- const monorepo =
148
- options.monorepo ?? (options.yes ? false : (answers.monorepo ?? false));
149
- const database = options.yes ? true : (answers.database ?? true);
150
- const templateOptions: TemplateOptions = {
151
- name,
152
- template: options.template || answers.template || 'minimal',
153
- telescope: options.yes ? true : (answers.telescope ?? true),
154
- database,
155
- studio: database && (options.yes ? true : (answers.studio ?? true)),
156
- loggerType: options.yes ? 'pino' : (answers.loggerType ?? 'pino'),
157
- routesStructure: options.yes
158
- ? 'centralized-endpoints'
159
- : (answers.routesStructure ?? 'centralized-endpoints'),
160
- monorepo,
161
- apiPath: monorepo ? (options.apiPath ?? answers.apiPath ?? 'apps/api') : '',
162
- };
163
-
164
- const targetDir = join(cwd, name);
165
- const template = getTemplate(templateOptions.template);
166
-
167
- const isMonorepo = templateOptions.monorepo;
168
- const apiPath = templateOptions.apiPath;
169
-
170
- // Create project directory
171
- await mkdir(targetDir, { recursive: true });
172
-
173
- // For monorepo, app files go in the specified apiPath (e.g., apps/api)
174
- const appDir = isMonorepo ? join(targetDir, apiPath) : targetDir;
175
- if (isMonorepo) {
176
- await mkdir(appDir, { recursive: true });
177
- }
178
-
179
- // Collect app files
180
- const appFiles = [
181
- ...generatePackageJson(templateOptions, template),
182
- ...generateConfigFiles(templateOptions, template),
183
- ...generateEnvFiles(templateOptions, template),
184
- ...generateSourceFiles(templateOptions, template),
185
- ...generateDockerFiles(templateOptions, template),
186
- ];
187
-
188
- // Collect root monorepo files (includes packages/models)
189
- const rootFiles = [
190
- ...generateMonorepoFiles(templateOptions, template),
191
- ...generateModelsPackage(templateOptions),
192
- ];
193
-
194
- // Write root files (for monorepo)
195
- for (const { path, content } of rootFiles) {
196
- const fullPath = join(targetDir, path);
197
- await mkdir(dirname(fullPath), { recursive: true });
198
- await writeFile(fullPath, content);
199
- }
200
-
201
- // Write app files
202
- for (const { path, content } of appFiles) {
203
- const fullPath = join(appDir, path);
204
- const displayPath = isMonorepo ? `${apiPath}/${path}` : path;
205
- await mkdir(dirname(fullPath), { recursive: true });
206
- await writeFile(fullPath, content);
207
- }
208
-
209
- // Install dependencies
210
- if (!options.skipInstall) {
211
- try {
212
- execSync(getInstallCommand(pkgManager), {
213
- cwd: targetDir,
214
- stdio: 'inherit',
215
- });
216
- } catch {
217
- console.error('\n Warning: Failed to install dependencies.');
218
- }
219
-
220
- // Format generated files with biome
221
- try {
222
- execSync('npx @biomejs/biome format --write --unsafe .', {
223
- cwd: targetDir,
224
- stdio: 'inherit',
225
- });
226
- } catch {
227
- // Silently ignore format errors
228
- }
229
- }
230
-
231
- // Print next steps
232
- const devCommand = getRunCommand(pkgManager, 'dev');
43
+ const cwd = process.cwd();
44
+ const pkgManager = detectPackageManager(cwd);
45
+
46
+ // Handle Ctrl+C gracefully
47
+ prompts.override({});
48
+ const onCancel = () => {
49
+ process.exit(0);
50
+ };
51
+
52
+ // Gather answers via prompts
53
+ const answers = await prompts(
54
+ [
55
+ {
56
+ type: projectName ? null : 'text',
57
+ name: 'name',
58
+ message: 'Project name:',
59
+ initial: 'my-api',
60
+ validate: (value: string) => {
61
+ const nameValid = validateProjectName(value);
62
+ if (nameValid !== true) return nameValid;
63
+ const dirValid = checkDirectoryExists(value, cwd);
64
+ if (dirValid !== true) return dirValid;
65
+ return true;
66
+ },
67
+ },
68
+ {
69
+ type: options.template || options.yes ? null : 'select',
70
+ name: 'template',
71
+ message: 'Template:',
72
+ choices: templateChoices,
73
+ initial: 0,
74
+ },
75
+ {
76
+ type: options.yes ? null : 'confirm',
77
+ name: 'telescope',
78
+ message: 'Include Telescope (debugging dashboard)?',
79
+ initial: true,
80
+ },
81
+ {
82
+ type: options.yes ? null : 'confirm',
83
+ name: 'database',
84
+ message: 'Include database support (Kysely)?',
85
+ initial: true,
86
+ },
87
+ {
88
+ type: (prev) => (options.yes ? null : prev ? 'confirm' : null),
89
+ name: 'studio',
90
+ message: 'Include Studio (database browser)?',
91
+ initial: true,
92
+ },
93
+ {
94
+ type: options.yes ? null : 'select',
95
+ name: 'loggerType',
96
+ message: 'Logger:',
97
+ choices: loggerTypeChoices,
98
+ initial: 0,
99
+ },
100
+ {
101
+ type: options.yes ? null : 'select',
102
+ name: 'routesStructure',
103
+ message: 'Routes structure:',
104
+ choices: routesStructureChoices,
105
+ initial: 0,
106
+ },
107
+ {
108
+ type: options.yes || options.monorepo !== undefined ? null : 'confirm',
109
+ name: 'monorepo',
110
+ message: 'Setup as monorepo?',
111
+ initial: false,
112
+ },
113
+ {
114
+ type: (prev) =>
115
+ (prev === true || options.monorepo) && !options.apiPath
116
+ ? 'text'
117
+ : null,
118
+ name: 'apiPath',
119
+ message: 'API app path:',
120
+ initial: 'apps/api',
121
+ },
122
+ ],
123
+ { onCancel },
124
+ );
125
+
126
+ // Build final options
127
+ const name = projectName || answers.name;
128
+ if (!name) {
129
+ process.exit(1);
130
+ }
131
+
132
+ // Validate name if provided via argument
133
+ if (projectName) {
134
+ const nameValid = validateProjectName(projectName);
135
+ if (nameValid !== true) {
136
+ process.exit(1);
137
+ }
138
+ const dirValid = checkDirectoryExists(projectName, cwd);
139
+ if (dirValid !== true) {
140
+ process.exit(1);
141
+ }
142
+ }
143
+
144
+ const monorepo =
145
+ options.monorepo ?? (options.yes ? false : (answers.monorepo ?? false));
146
+ const database = options.yes ? true : (answers.database ?? true);
147
+ const templateOptions: TemplateOptions = {
148
+ name,
149
+ template: options.template || answers.template || 'minimal',
150
+ telescope: options.yes ? true : (answers.telescope ?? true),
151
+ database,
152
+ studio: database && (options.yes ? true : (answers.studio ?? true)),
153
+ loggerType: options.yes ? 'pino' : (answers.loggerType ?? 'pino'),
154
+ routesStructure: options.yes
155
+ ? 'centralized-endpoints'
156
+ : (answers.routesStructure ?? 'centralized-endpoints'),
157
+ monorepo,
158
+ apiPath: monorepo ? (options.apiPath ?? answers.apiPath ?? 'apps/api') : '',
159
+ };
160
+
161
+ const targetDir = join(cwd, name);
162
+ const template = getTemplate(templateOptions.template);
163
+
164
+ const isMonorepo = templateOptions.monorepo;
165
+ const apiPath = templateOptions.apiPath;
166
+
167
+ // Create project directory
168
+ await mkdir(targetDir, { recursive: true });
169
+
170
+ // For monorepo, app files go in the specified apiPath (e.g., apps/api)
171
+ const appDir = isMonorepo ? join(targetDir, apiPath) : targetDir;
172
+ if (isMonorepo) {
173
+ await mkdir(appDir, { recursive: true });
174
+ }
175
+
176
+ // Collect app files
177
+ const appFiles = [
178
+ ...generatePackageJson(templateOptions, template),
179
+ ...generateConfigFiles(templateOptions, template),
180
+ ...generateEnvFiles(templateOptions, template),
181
+ ...generateSourceFiles(templateOptions, template),
182
+ ...generateDockerFiles(templateOptions, template),
183
+ ];
184
+
185
+ // Collect root monorepo files (includes packages/models)
186
+ const rootFiles = [
187
+ ...generateMonorepoFiles(templateOptions, template),
188
+ ...generateModelsPackage(templateOptions),
189
+ ];
190
+
191
+ // Write root files (for monorepo)
192
+ for (const { path, content } of rootFiles) {
193
+ const fullPath = join(targetDir, path);
194
+ await mkdir(dirname(fullPath), { recursive: true });
195
+ await writeFile(fullPath, content);
196
+ }
197
+
198
+ // Write app files
199
+ for (const { path, content } of appFiles) {
200
+ const fullPath = join(appDir, path);
201
+ const _displayPath = isMonorepo ? `${apiPath}/${path}` : path;
202
+ await mkdir(dirname(fullPath), { recursive: true });
203
+ await writeFile(fullPath, content);
204
+ }
205
+
206
+ // Install dependencies
207
+ if (!options.skipInstall) {
208
+ try {
209
+ execSync(getInstallCommand(pkgManager), {
210
+ cwd: targetDir,
211
+ stdio: 'inherit',
212
+ });
213
+ } catch {}
214
+
215
+ // Format generated files with biome
216
+ try {
217
+ execSync('npx @biomejs/biome format --write --unsafe .', {
218
+ cwd: targetDir,
219
+ stdio: 'inherit',
220
+ });
221
+ } catch {
222
+ // Silently ignore format errors
223
+ }
224
+ }
225
+
226
+ // Print next steps
227
+ const _devCommand = getRunCommand(pkgManager, 'dev');
233
228
  }