@geekmidas/cli 0.10.0 → 0.13.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/README.md +525 -0
- package/dist/bundler-B1qy9b-j.cjs +112 -0
- package/dist/bundler-B1qy9b-j.cjs.map +1 -0
- package/dist/bundler-DskIqW2t.mjs +111 -0
- package/dist/bundler-DskIqW2t.mjs.map +1 -0
- package/dist/{config-C9aXOHBe.cjs → config-AmInkU7k.cjs} +8 -8
- package/dist/config-AmInkU7k.cjs.map +1 -0
- package/dist/{config-BrkUalUh.mjs → config-DYULeEv8.mjs} +3 -3
- package/dist/config-DYULeEv8.mjs.map +1 -0
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +1 -1
- package/dist/encryption-C8H-38Yy.mjs +42 -0
- package/dist/encryption-C8H-38Yy.mjs.map +1 -0
- package/dist/encryption-Dyf_r1h-.cjs +44 -0
- package/dist/encryption-Dyf_r1h-.cjs.map +1 -0
- package/dist/index.cjs +2123 -179
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +2141 -192
- package/dist/index.mjs.map +1 -1
- package/dist/{openapi-CZLI4QTr.mjs → openapi-BfFlOBCG.mjs} +801 -38
- package/dist/openapi-BfFlOBCG.mjs.map +1 -0
- package/dist/{openapi-BeHLKcwP.cjs → openapi-Bt_1FDpT.cjs} +794 -31
- package/dist/openapi-Bt_1FDpT.cjs.map +1 -0
- package/dist/{openapi-react-query-o5iMi8tz.cjs → openapi-react-query-B-sNWHFU.cjs} +5 -5
- package/dist/openapi-react-query-B-sNWHFU.cjs.map +1 -0
- package/dist/{openapi-react-query-CcciaVu5.mjs → openapi-react-query-B6XTeGqS.mjs} +5 -5
- package/dist/openapi-react-query-B6XTeGqS.mjs.map +1 -0
- package/dist/openapi-react-query.cjs +1 -1
- package/dist/openapi-react-query.d.cts.map +1 -1
- package/dist/openapi-react-query.d.mts.map +1 -1
- package/dist/openapi-react-query.mjs +1 -1
- package/dist/openapi.cjs +2 -2
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.cts.map +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.d.mts.map +1 -1
- package/dist/openapi.mjs +2 -2
- package/dist/storage-BOOpAF8N.cjs +5 -0
- package/dist/storage-Bj1E26lU.cjs +187 -0
- package/dist/storage-Bj1E26lU.cjs.map +1 -0
- package/dist/storage-kSxTjkNb.mjs +133 -0
- package/dist/storage-kSxTjkNb.mjs.map +1 -0
- package/dist/storage-tgZSUnKl.mjs +3 -0
- package/dist/{types-b-vwGpqc.d.cts → types-BR0M2v_c.d.mts} +100 -1
- package/dist/types-BR0M2v_c.d.mts.map +1 -0
- package/dist/{types-DXgiA1sF.d.mts → types-BhkZc-vm.d.cts} +100 -1
- package/dist/types-BhkZc-vm.d.cts.map +1 -0
- package/examples/cron-example.ts +27 -27
- package/examples/env.ts +27 -27
- package/examples/function-example.ts +31 -31
- package/examples/gkm.config.json +20 -20
- package/examples/gkm.config.ts +8 -8
- package/examples/gkm.minimal.config.json +5 -5
- package/examples/gkm.production.config.json +25 -25
- package/examples/logger.ts +2 -2
- package/package.json +6 -6
- package/src/__tests__/EndpointGenerator.hooks.spec.ts +191 -191
- package/src/__tests__/config.spec.ts +55 -55
- package/src/__tests__/loadEnvFiles.spec.ts +93 -93
- package/src/__tests__/normalizeHooksConfig.spec.ts +58 -58
- package/src/__tests__/openapi-react-query.spec.ts +497 -497
- package/src/__tests__/openapi.spec.ts +428 -428
- package/src/__tests__/test-helpers.ts +76 -76
- package/src/auth/__tests__/credentials.spec.ts +204 -0
- package/src/auth/__tests__/index.spec.ts +168 -0
- package/src/auth/credentials.ts +187 -0
- package/src/auth/index.ts +226 -0
- package/src/build/__tests__/bundler.spec.ts +444 -0
- package/src/build/__tests__/index-new.spec.ts +474 -474
- package/src/build/__tests__/manifests.spec.ts +333 -333
- package/src/build/bundler.ts +210 -0
- package/src/build/endpoint-analyzer.ts +236 -0
- package/src/build/handler-templates.ts +1253 -0
- package/src/build/index.ts +260 -179
- package/src/build/manifests.ts +52 -52
- package/src/build/providerResolver.ts +145 -145
- package/src/build/types.ts +64 -43
- package/src/config.ts +39 -39
- package/src/deploy/__tests__/docker.spec.ts +111 -0
- package/src/deploy/__tests__/dokploy.spec.ts +245 -0
- package/src/deploy/__tests__/init.spec.ts +662 -0
- package/src/deploy/docker.ts +128 -0
- package/src/deploy/dokploy.ts +204 -0
- package/src/deploy/index.ts +136 -0
- package/src/deploy/init.ts +484 -0
- package/src/deploy/types.ts +48 -0
- package/src/dev/__tests__/index.spec.ts +266 -266
- package/src/dev/index.ts +647 -601
- package/src/docker/__tests__/compose.spec.ts +531 -0
- package/src/docker/__tests__/templates.spec.ts +280 -0
- package/src/docker/compose.ts +273 -0
- package/src/docker/index.ts +230 -0
- package/src/docker/templates.ts +446 -0
- package/src/generators/CronGenerator.ts +72 -72
- package/src/generators/EndpointGenerator.ts +699 -398
- package/src/generators/FunctionGenerator.ts +84 -84
- package/src/generators/Generator.ts +72 -72
- package/src/generators/OpenApiTsGenerator.ts +577 -577
- package/src/generators/SubscriberGenerator.ts +124 -124
- package/src/generators/__tests__/CronGenerator.spec.ts +433 -433
- package/src/generators/__tests__/EndpointGenerator.spec.ts +532 -382
- package/src/generators/__tests__/FunctionGenerator.spec.ts +244 -244
- package/src/generators/__tests__/SubscriberGenerator.spec.ts +397 -382
- package/src/generators/index.ts +4 -4
- package/src/index.ts +623 -201
- package/src/init/__tests__/generators.spec.ts +334 -334
- package/src/init/__tests__/init.spec.ts +332 -332
- package/src/init/__tests__/utils.spec.ts +89 -89
- package/src/init/generators/config.ts +175 -175
- package/src/init/generators/docker.ts +41 -41
- package/src/init/generators/env.ts +72 -72
- package/src/init/generators/index.ts +1 -1
- package/src/init/generators/models.ts +64 -64
- package/src/init/generators/monorepo.ts +161 -161
- package/src/init/generators/package.ts +71 -71
- package/src/init/generators/source.ts +6 -6
- package/src/init/index.ts +203 -208
- package/src/init/templates/api.ts +115 -115
- package/src/init/templates/index.ts +75 -75
- package/src/init/templates/minimal.ts +98 -98
- package/src/init/templates/serverless.ts +89 -89
- package/src/init/templates/worker.ts +98 -98
- package/src/init/utils.ts +54 -56
- package/src/openapi-react-query.ts +194 -194
- package/src/openapi.ts +63 -63
- package/src/secrets/__tests__/encryption.spec.ts +226 -0
- package/src/secrets/__tests__/generator.spec.ts +319 -0
- package/src/secrets/__tests__/index.spec.ts +91 -0
- package/src/secrets/__tests__/storage.spec.ts +611 -0
- package/src/secrets/encryption.ts +91 -0
- package/src/secrets/generator.ts +164 -0
- package/src/secrets/index.ts +383 -0
- package/src/secrets/storage.ts +192 -0
- package/src/secrets/types.ts +53 -0
- package/src/types.ts +295 -176
- package/tsdown.config.ts +11 -8
- package/dist/config-BrkUalUh.mjs.map +0 -1
- package/dist/config-C9aXOHBe.cjs.map +0 -1
- package/dist/openapi-BeHLKcwP.cjs.map +0 -1
- package/dist/openapi-CZLI4QTr.mjs.map +0 -1
- package/dist/openapi-react-query-CcciaVu5.mjs.map +0 -1
- package/dist/openapi-react-query-o5iMi8tz.cjs.map +0 -1
- package/dist/types-DXgiA1sF.d.mts.map +0 -1
- package/dist/types-b-vwGpqc.d.cts.map +0 -1
|
@@ -6,336 +6,336 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
|
6
6
|
import { initCommand } from '../index.js';
|
|
7
7
|
|
|
8
8
|
describe('initCommand', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
9
|
+
let tempDir: string;
|
|
10
|
+
let originalCwd: string;
|
|
11
|
+
|
|
12
|
+
beforeEach(async () => {
|
|
13
|
+
tempDir = join(tmpdir(), `cli-init-test-${Date.now()}`);
|
|
14
|
+
await mkdir(tempDir, { recursive: true });
|
|
15
|
+
originalCwd = process.cwd();
|
|
16
|
+
process.chdir(tempDir);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(async () => {
|
|
20
|
+
process.chdir(originalCwd);
|
|
21
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('non-monorepo', () => {
|
|
25
|
+
it('should create project with minimal template', async () => {
|
|
26
|
+
await initCommand('my-api', {
|
|
27
|
+
template: 'minimal',
|
|
28
|
+
yes: true,
|
|
29
|
+
skipInstall: true,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const projectDir = join(tempDir, 'my-api');
|
|
33
|
+
expect(existsSync(projectDir)).toBe(true);
|
|
34
|
+
expect(existsSync(join(projectDir, 'package.json'))).toBe(true);
|
|
35
|
+
expect(existsSync(join(projectDir, 'gkm.config.ts'))).toBe(true);
|
|
36
|
+
expect(existsSync(join(projectDir, 'tsconfig.json'))).toBe(true);
|
|
37
|
+
expect(existsSync(join(projectDir, 'biome.json'))).toBe(true);
|
|
38
|
+
expect(existsSync(join(projectDir, 'turbo.json'))).toBe(true);
|
|
39
|
+
expect(existsSync(join(projectDir, 'docker-compose.yml'))).toBe(true);
|
|
40
|
+
expect(existsSync(join(projectDir, '.env'))).toBe(true);
|
|
41
|
+
expect(existsSync(join(projectDir, '.env.development'))).toBe(true);
|
|
42
|
+
expect(existsSync(join(projectDir, '.env.test'))).toBe(true);
|
|
43
|
+
expect(existsSync(join(projectDir, '.gitignore'))).toBe(true);
|
|
44
|
+
expect(existsSync(join(projectDir, 'src/config/env.ts'))).toBe(true);
|
|
45
|
+
expect(existsSync(join(projectDir, 'src/config/logger.ts'))).toBe(true);
|
|
46
|
+
expect(existsSync(join(projectDir, 'src/endpoints/health.ts'))).toBe(
|
|
47
|
+
true,
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should create package.json with correct content', async () => {
|
|
52
|
+
await initCommand('my-api', {
|
|
53
|
+
template: 'minimal',
|
|
54
|
+
yes: true,
|
|
55
|
+
skipInstall: true,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const pkgPath = join(tempDir, 'my-api', 'package.json');
|
|
59
|
+
const content = await readFile(pkgPath, 'utf-8');
|
|
60
|
+
const pkg = JSON.parse(content);
|
|
61
|
+
|
|
62
|
+
expect(pkg.name).toBe('my-api');
|
|
63
|
+
expect(pkg.type).toBe('module');
|
|
64
|
+
expect(pkg.dependencies['@geekmidas/constructs']).toBe('workspace:*');
|
|
65
|
+
expect(pkg.dependencies['@geekmidas/telescope']).toBe('workspace:*');
|
|
66
|
+
expect(pkg.dependencies.zod).toMatch(/^~/);
|
|
67
|
+
expect(pkg.devDependencies['@biomejs/biome']).toBeDefined();
|
|
68
|
+
expect(pkg.devDependencies.turbo).toBeDefined();
|
|
69
|
+
expect(pkg.scripts.dev).toBe('gkm dev');
|
|
70
|
+
expect(pkg.scripts.lint).toBe('biome lint .');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should create gkm.config.ts with telescope when enabled', async () => {
|
|
74
|
+
await initCommand('my-api', {
|
|
75
|
+
template: 'minimal',
|
|
76
|
+
yes: true,
|
|
77
|
+
skipInstall: true,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const configPath = join(tempDir, 'my-api', 'gkm.config.ts');
|
|
81
|
+
const content = await readFile(configPath, 'utf-8');
|
|
82
|
+
|
|
83
|
+
expect(content).toContain("routes: './src/endpoints/**/*.ts'");
|
|
84
|
+
expect(content).toContain('telescope');
|
|
85
|
+
expect(content).toContain('/__telescope');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('should create api template with user endpoints', async () => {
|
|
89
|
+
await initCommand('my-api', {
|
|
90
|
+
template: 'api',
|
|
91
|
+
yes: true,
|
|
92
|
+
skipInstall: true,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const projectDir = join(tempDir, 'my-api');
|
|
96
|
+
expect(existsSync(join(projectDir, 'src/endpoints/users/list.ts'))).toBe(
|
|
97
|
+
true,
|
|
98
|
+
);
|
|
99
|
+
expect(existsSync(join(projectDir, 'src/endpoints/users/get.ts'))).toBe(
|
|
100
|
+
true,
|
|
101
|
+
);
|
|
102
|
+
expect(existsSync(join(projectDir, 'src/services/database.ts'))).toBe(
|
|
103
|
+
true,
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should create serverless template with functions', async () => {
|
|
108
|
+
await initCommand('my-api', {
|
|
109
|
+
template: 'serverless',
|
|
110
|
+
yes: true,
|
|
111
|
+
skipInstall: true,
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const projectDir = join(tempDir, 'my-api');
|
|
115
|
+
expect(existsSync(join(projectDir, 'src/functions/hello.ts'))).toBe(true);
|
|
116
|
+
|
|
117
|
+
const configPath = join(projectDir, 'gkm.config.ts');
|
|
118
|
+
const content = await readFile(configPath, 'utf-8');
|
|
119
|
+
expect(content).toContain('functions');
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('should create worker template with crons and subscribers', async () => {
|
|
123
|
+
await initCommand('my-api', {
|
|
124
|
+
template: 'worker',
|
|
125
|
+
yes: true,
|
|
126
|
+
skipInstall: true,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const projectDir = join(tempDir, 'my-api');
|
|
130
|
+
expect(existsSync(join(projectDir, 'src/crons/cleanup.ts'))).toBe(true);
|
|
131
|
+
expect(
|
|
132
|
+
existsSync(join(projectDir, 'src/subscribers/user-events.ts')),
|
|
133
|
+
).toBe(true);
|
|
134
|
+
expect(existsSync(join(projectDir, 'src/events/types.ts'))).toBe(true);
|
|
135
|
+
|
|
136
|
+
const configPath = join(projectDir, 'gkm.config.ts');
|
|
137
|
+
const content = await readFile(configPath, 'utf-8');
|
|
138
|
+
expect(content).toContain('crons');
|
|
139
|
+
expect(content).toContain('subscribers');
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe('monorepo', () => {
|
|
144
|
+
it('should create monorepo structure', async () => {
|
|
145
|
+
await initCommand('my-monorepo', {
|
|
146
|
+
template: 'minimal',
|
|
147
|
+
yes: true,
|
|
148
|
+
skipInstall: true,
|
|
149
|
+
monorepo: true,
|
|
150
|
+
apiPath: 'apps/api',
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const projectDir = join(tempDir, 'my-monorepo');
|
|
154
|
+
|
|
155
|
+
// Root files
|
|
156
|
+
expect(existsSync(join(projectDir, 'package.json'))).toBe(true);
|
|
157
|
+
expect(existsSync(join(projectDir, 'pnpm-workspace.yaml'))).toBe(true);
|
|
158
|
+
expect(existsSync(join(projectDir, 'tsconfig.json'))).toBe(true);
|
|
159
|
+
expect(existsSync(join(projectDir, 'biome.json'))).toBe(true);
|
|
160
|
+
expect(existsSync(join(projectDir, 'turbo.json'))).toBe(true);
|
|
161
|
+
expect(existsSync(join(projectDir, '.gitignore'))).toBe(true);
|
|
162
|
+
|
|
163
|
+
// API app files
|
|
164
|
+
expect(existsSync(join(projectDir, 'apps/api/package.json'))).toBe(true);
|
|
165
|
+
expect(existsSync(join(projectDir, 'apps/api/gkm.config.ts'))).toBe(true);
|
|
166
|
+
expect(existsSync(join(projectDir, 'apps/api/tsconfig.json'))).toBe(true);
|
|
167
|
+
expect(
|
|
168
|
+
existsSync(join(projectDir, 'apps/api/src/endpoints/health.ts')),
|
|
169
|
+
).toBe(true);
|
|
170
|
+
|
|
171
|
+
// Models package
|
|
172
|
+
expect(existsSync(join(projectDir, 'packages/models/package.json'))).toBe(
|
|
173
|
+
true,
|
|
174
|
+
);
|
|
175
|
+
expect(
|
|
176
|
+
existsSync(join(projectDir, 'packages/models/tsconfig.json')),
|
|
177
|
+
).toBe(true);
|
|
178
|
+
expect(existsSync(join(projectDir, 'packages/models/src/index.ts'))).toBe(
|
|
179
|
+
true,
|
|
180
|
+
);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('should create root package.json with turbo scripts', async () => {
|
|
184
|
+
await initCommand('my-monorepo', {
|
|
185
|
+
template: 'minimal',
|
|
186
|
+
yes: true,
|
|
187
|
+
skipInstall: true,
|
|
188
|
+
monorepo: true,
|
|
189
|
+
apiPath: 'apps/api',
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const pkgPath = join(tempDir, 'my-monorepo', 'package.json');
|
|
193
|
+
const content = await readFile(pkgPath, 'utf-8');
|
|
194
|
+
const pkg = JSON.parse(content);
|
|
195
|
+
|
|
196
|
+
expect(pkg.name).toBe('my-monorepo');
|
|
197
|
+
expect(pkg.scripts.dev).toBe('turbo dev');
|
|
198
|
+
expect(pkg.scripts.build).toBe('turbo build');
|
|
199
|
+
expect(pkg.scripts.lint).toBe('biome lint .');
|
|
200
|
+
expect(pkg.devDependencies['@biomejs/biome']).toBeDefined();
|
|
201
|
+
expect(pkg.devDependencies.turbo).toBeDefined();
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('should create API package.json with models dependency', async () => {
|
|
205
|
+
await initCommand('my-monorepo', {
|
|
206
|
+
template: 'minimal',
|
|
207
|
+
yes: true,
|
|
208
|
+
skipInstall: true,
|
|
209
|
+
monorepo: true,
|
|
210
|
+
apiPath: 'apps/api',
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
const pkgPath = join(tempDir, 'my-monorepo', 'apps/api/package.json');
|
|
214
|
+
const content = await readFile(pkgPath, 'utf-8');
|
|
215
|
+
const pkg = JSON.parse(content);
|
|
216
|
+
|
|
217
|
+
expect(pkg.name).toBe('@my-monorepo/api');
|
|
218
|
+
expect(pkg.dependencies['@my-monorepo/models']).toBe('workspace:*');
|
|
219
|
+
expect(pkg.dependencies.zod).toBeUndefined(); // zod is in models
|
|
220
|
+
expect(pkg.devDependencies['@biomejs/biome']).toBeUndefined(); // at root
|
|
221
|
+
expect(pkg.devDependencies.turbo).toBeUndefined(); // at root
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('should create API tsconfig with paths', async () => {
|
|
225
|
+
await initCommand('my-monorepo', {
|
|
226
|
+
template: 'minimal',
|
|
227
|
+
yes: true,
|
|
228
|
+
skipInstall: true,
|
|
229
|
+
monorepo: true,
|
|
230
|
+
apiPath: 'apps/api',
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
const tsConfigPath = join(
|
|
234
|
+
tempDir,
|
|
235
|
+
'my-monorepo',
|
|
236
|
+
'apps/api/tsconfig.json',
|
|
237
|
+
);
|
|
238
|
+
const content = await readFile(tsConfigPath, 'utf-8');
|
|
239
|
+
const config = JSON.parse(content);
|
|
240
|
+
|
|
241
|
+
expect(config.extends).toBe('../../tsconfig.json');
|
|
242
|
+
expect(config.compilerOptions.paths['@my-monorepo/*']).toEqual([
|
|
243
|
+
'../../packages/*/src',
|
|
244
|
+
]);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('should create models package with zod schemas', async () => {
|
|
248
|
+
await initCommand('my-monorepo', {
|
|
249
|
+
template: 'minimal',
|
|
250
|
+
yes: true,
|
|
251
|
+
skipInstall: true,
|
|
252
|
+
monorepo: true,
|
|
253
|
+
apiPath: 'apps/api',
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
const pkgPath = join(
|
|
257
|
+
tempDir,
|
|
258
|
+
'my-monorepo',
|
|
259
|
+
'packages/models/package.json',
|
|
260
|
+
);
|
|
261
|
+
const content = await readFile(pkgPath, 'utf-8');
|
|
262
|
+
const pkg = JSON.parse(content);
|
|
263
|
+
|
|
264
|
+
expect(pkg.name).toBe('@my-monorepo/models');
|
|
265
|
+
expect(pkg.dependencies.zod).toBeDefined();
|
|
266
|
+
|
|
267
|
+
const indexPath = join(
|
|
268
|
+
tempDir,
|
|
269
|
+
'my-monorepo',
|
|
270
|
+
'packages/models/src/index.ts',
|
|
271
|
+
);
|
|
272
|
+
const indexContent = await readFile(indexPath, 'utf-8');
|
|
273
|
+
expect(indexContent).toContain('userSchema');
|
|
274
|
+
expect(indexContent).toContain('paginationSchema');
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('should support custom API path', async () => {
|
|
278
|
+
await initCommand('my-monorepo', {
|
|
279
|
+
template: 'minimal',
|
|
280
|
+
yes: true,
|
|
281
|
+
skipInstall: true,
|
|
282
|
+
monorepo: true,
|
|
283
|
+
apiPath: 'services/backend',
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
const projectDir = join(tempDir, 'my-monorepo');
|
|
287
|
+
expect(
|
|
288
|
+
existsSync(join(projectDir, 'services/backend/package.json')),
|
|
289
|
+
).toBe(true);
|
|
290
|
+
expect(
|
|
291
|
+
existsSync(join(projectDir, 'services/backend/gkm.config.ts')),
|
|
292
|
+
).toBe(true);
|
|
293
|
+
|
|
294
|
+
const pkgPath = join(projectDir, 'services/backend/package.json');
|
|
295
|
+
const content = await readFile(pkgPath, 'utf-8');
|
|
296
|
+
const pkg = JSON.parse(content);
|
|
297
|
+
expect(pkg.name).toBe('@my-monorepo/backend');
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
describe('docker-compose', () => {
|
|
302
|
+
it('should include postgres for database-enabled projects', async () => {
|
|
303
|
+
await initCommand('my-api', {
|
|
304
|
+
template: 'minimal',
|
|
305
|
+
yes: true,
|
|
306
|
+
skipInstall: true,
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
const dockerPath = join(tempDir, 'my-api', 'docker-compose.yml');
|
|
310
|
+
const content = await readFile(dockerPath, 'utf-8');
|
|
311
|
+
expect(content).toContain('postgres:16-alpine');
|
|
312
|
+
expect(content).toContain('5432:5432');
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('should include serverless-redis-http for serverless template', async () => {
|
|
316
|
+
await initCommand('my-api', {
|
|
317
|
+
template: 'serverless',
|
|
318
|
+
yes: true,
|
|
319
|
+
skipInstall: true,
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
const dockerPath = join(tempDir, 'my-api', 'docker-compose.yml');
|
|
323
|
+
const content = await readFile(dockerPath, 'utf-8');
|
|
324
|
+
expect(content).toContain('hiett/serverless-redis-http');
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('should include rabbitmq for worker template', async () => {
|
|
328
|
+
await initCommand('my-api', {
|
|
329
|
+
template: 'worker',
|
|
330
|
+
yes: true,
|
|
331
|
+
skipInstall: true,
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
const dockerPath = join(tempDir, 'my-api', 'docker-compose.yml');
|
|
335
|
+
const content = await readFile(dockerPath, 'utf-8');
|
|
336
|
+
expect(content).toContain('rabbitmq:3-management-alpine');
|
|
337
|
+
expect(content).toContain('5672:5672');
|
|
338
|
+
expect(content).toContain('15672:15672');
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
341
|
});
|