@pikku/cli 0.6.6

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 (95) hide show
  1. package/CHANGELOG.md +445 -0
  2. package/README.md +3 -0
  3. package/bin/pikku-all.ts +110 -0
  4. package/bin/pikku-channels-map.ts +53 -0
  5. package/bin/pikku-channels.ts +57 -0
  6. package/bin/pikku-fetch.ts +54 -0
  7. package/bin/pikku-function-types.ts +76 -0
  8. package/bin/pikku-nextjs.test.ts +279 -0
  9. package/bin/pikku-nextjs.ts +113 -0
  10. package/bin/pikku-openapi.ts +71 -0
  11. package/bin/pikku-routes-map.ts +54 -0
  12. package/bin/pikku-routes.ts +55 -0
  13. package/bin/pikku-scheduler.ts +61 -0
  14. package/bin/pikku-schemas.ts +51 -0
  15. package/bin/pikku-websocket.ts +54 -0
  16. package/bin/pikku.ts +26 -0
  17. package/cli.schema.json +212 -0
  18. package/dist/bin/pikku-all.d.ts +4 -0
  19. package/dist/bin/pikku-all.js +71 -0
  20. package/dist/bin/pikku-channels-map.d.ts +5 -0
  21. package/dist/bin/pikku-channels-map.js +27 -0
  22. package/dist/bin/pikku-channels.d.ts +5 -0
  23. package/dist/bin/pikku-channels.js +32 -0
  24. package/dist/bin/pikku-fetch.d.ts +6 -0
  25. package/dist/bin/pikku-fetch.js +25 -0
  26. package/dist/bin/pikku-function-types.d.ts +6 -0
  27. package/dist/bin/pikku-function-types.js +32 -0
  28. package/dist/bin/pikku-nextjs.d.ts +7 -0
  29. package/dist/bin/pikku-nextjs.js +40 -0
  30. package/dist/bin/pikku-openapi.d.ts +5 -0
  31. package/dist/bin/pikku-openapi.js +41 -0
  32. package/dist/bin/pikku-routes-map.d.ts +5 -0
  33. package/dist/bin/pikku-routes-map.js +27 -0
  34. package/dist/bin/pikku-routes.d.ts +5 -0
  35. package/dist/bin/pikku-routes.js +33 -0
  36. package/dist/bin/pikku-scheduler.d.ts +5 -0
  37. package/dist/bin/pikku-scheduler.js +32 -0
  38. package/dist/bin/pikku-schemas.d.ts +5 -0
  39. package/dist/bin/pikku-schemas.js +27 -0
  40. package/dist/bin/pikku-websocket.d.ts +6 -0
  41. package/dist/bin/pikku-websocket.js +25 -0
  42. package/dist/bin/pikku.d.ts +2 -0
  43. package/dist/bin/pikku.js +23 -0
  44. package/dist/src/channels/serialize-channels.d.ts +3 -0
  45. package/dist/src/channels/serialize-channels.js +19 -0
  46. package/dist/src/channels/serialize-typed-channel-map.d.ts +3 -0
  47. package/dist/src/channels/serialize-typed-channel-map.js +87 -0
  48. package/dist/src/channels/serialize-websocket-wrapper.d.ts +1 -0
  49. package/dist/src/channels/serialize-websocket-wrapper.js +61 -0
  50. package/dist/src/core/serialize-import-map.d.ts +2 -0
  51. package/dist/src/core/serialize-import-map.js +23 -0
  52. package/dist/src/core/serialize-pikku-types.d.ts +4 -0
  53. package/dist/src/core/serialize-pikku-types.js +48 -0
  54. package/dist/src/http/serialize-fetch-wrapper.d.ts +1 -0
  55. package/dist/src/http/serialize-fetch-wrapper.js +57 -0
  56. package/dist/src/http/serialize-route-imports.d.ts +1 -0
  57. package/dist/src/http/serialize-route-imports.js +13 -0
  58. package/dist/src/http/serialize-route-meta.d.ts +2 -0
  59. package/dist/src/http/serialize-route-meta.js +6 -0
  60. package/dist/src/http/serialize-typed-route-map.d.ts +3 -0
  61. package/dist/src/http/serialize-typed-route-map.js +107 -0
  62. package/dist/src/inspector-glob.d.ts +2 -0
  63. package/dist/src/inspector-glob.js +12 -0
  64. package/dist/src/nextjs/serialize-nextjs-wrapper.d.ts +1 -0
  65. package/dist/src/nextjs/serialize-nextjs-wrapper.js +149 -0
  66. package/dist/src/openapi/openapi-spec-generator.d.ts +79 -0
  67. package/dist/src/openapi/openapi-spec-generator.js +135 -0
  68. package/dist/src/pikku-cli-config.d.ts +31 -0
  69. package/dist/src/pikku-cli-config.js +113 -0
  70. package/dist/src/scheduler/serialize-schedulers.d.ts +3 -0
  71. package/dist/src/scheduler/serialize-schedulers.js +22 -0
  72. package/dist/src/schema/schema-generator.d.ts +5 -0
  73. package/dist/src/schema/schema-generator.js +79 -0
  74. package/dist/src/utils.d.ts +34 -0
  75. package/dist/src/utils.js +109 -0
  76. package/dist/tsconfig.tsbuildinfo +1 -0
  77. package/package.json +42 -0
  78. package/run-tests.sh +53 -0
  79. package/src/channels/serialize-channels.ts +34 -0
  80. package/src/channels/serialize-typed-channel-map.ts +133 -0
  81. package/src/channels/serialize-websocket-wrapper.ts +61 -0
  82. package/src/core/serialize-import-map.ts +33 -0
  83. package/src/core/serialize-pikku-types.ts +53 -0
  84. package/src/http/serialize-fetch-wrapper.ts +57 -0
  85. package/src/http/serialize-route-imports.ts +24 -0
  86. package/src/http/serialize-route-meta.ts +10 -0
  87. package/src/http/serialize-typed-route-map.ts +147 -0
  88. package/src/inspector-glob.ts +27 -0
  89. package/src/nextjs/serialize-nextjs-wrapper.ts +156 -0
  90. package/src/openapi/openapi-spec-generator.ts +229 -0
  91. package/src/pikku-cli-config.ts +189 -0
  92. package/src/scheduler/serialize-schedulers.ts +43 -0
  93. package/src/schema/schema-generator.ts +117 -0
  94. package/src/utils.ts +219 -0
  95. package/tsconfig.json +21 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,445 @@
1
+ # @pikku/cli
2
+
3
+ ## 0.6.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 780d7c2: revert: using import for json
8
+ - Updated dependencies [0a92fa7]
9
+ - @pikku/core@0.6.7
10
+
11
+ ## 0.6.5
12
+
13
+ ### Patch Changes
14
+
15
+ - 4357bca: feat: fixing up nextjs apis
16
+ - Updated dependencies [4357bca]
17
+ - @pikku/core@0.6.6
18
+
19
+ ## 0.6.4
20
+
21
+ ### Patch Changes
22
+
23
+ - 2bc64fd: feat: adding methods to fetch wrapper (and small fixes)
24
+ - a40a508: fix: Fixing some generation bugs and other minors
25
+ - 4855e68: refactor: changing all generated files to have a .gen in the default name suffix
26
+ - Updated dependencies [a40a508]
27
+ - @pikku/inspector@0.6.2
28
+ - @pikku/core@0.6.5
29
+
30
+ ## 0.6.3
31
+
32
+ ### Patch Changes
33
+
34
+ - f26880f: feat: extracting inspector and adding unique type references
35
+ - Updated dependencies [f26880f]
36
+ - @pikku/inspector@0.6.1
37
+ - @pikku/core@0.6.4
38
+
39
+ ## 0.6.2
40
+
41
+ ### Patch Changes
42
+
43
+ - 09fc52c: feat: adding cloudflare and lambda websockets
44
+ breaking change: moved subscription from channel to services and renamed to event hub
45
+ - Updated dependencies [09fc52c]
46
+ - Updated dependencies [adecb52]
47
+ - @pikku/core@0.6.3
48
+
49
+ ## 0.6.1
50
+
51
+ ### Patch Changes
52
+
53
+ - adeb392: feat: more channel improvements, and adding bubble option to runners to avoid all the empty try catches
54
+ - Updated dependencies [ed45ca9]
55
+ - Updated dependencies [adeb392]
56
+ - @pikku/core@0.6.2
57
+
58
+ ## 0.6
59
+
60
+ Marking a major release to include channels and scheduled tasks
61
+
62
+ ## 0.5.43
63
+
64
+ ### Patch Changes
65
+
66
+ - 662a6cf: feat: adding scheduled tasks names
67
+ - c8578ea: fix: getting websocket auth to work on individual messages
68
+ - d2f8edf: feat: adding channelId to channels for serverless compatability
69
+ - Updated dependencies [662a6cf]
70
+ - Updated dependencies [c8578ea]
71
+ - Updated dependencies [d2f8edf]
72
+ - @pikku/core@0.5.29
73
+
74
+ ## 0.5.42
75
+
76
+ ### Patch Changes
77
+
78
+ - 886a2fb: refactor: moving singletons (like routes and channels) to global to avoid nodemodule overrides
79
+ - 886a2fb: fix: making core routes global to avoid state overrides
80
+ - Updated dependencies [a768bad]
81
+ - Updated dependencies [886a2fb]
82
+ - Updated dependencies [886a2fb]
83
+ - @pikku/core@0.5.28
84
+
85
+ ## 0.5.41
86
+
87
+ ### Patch Changes
88
+
89
+ - 3f2e365: fix: create custom types if one object thats not a valid alias
90
+
91
+ ## 0.5.40
92
+
93
+ ### Patch Changes
94
+
95
+ - 57731ed: fix: deleting a deadline in serializer
96
+
97
+ ## 0.5.39
98
+
99
+ ### Patch Changes
100
+
101
+ - 75a828d: feat: create schemas for custom types extracted from apis
102
+
103
+ ## 0.5.38
104
+
105
+ ### Patch Changes
106
+
107
+ - 6dc72d5: feat: add support for import attributes to cli options
108
+
109
+ ## 0.5.37
110
+
111
+ ### Patch Changes
112
+
113
+ - 5d03fac: refactor: removing some dead code
114
+
115
+ ## 0.5.36
116
+
117
+ ### Patch Changes
118
+
119
+ - aa8435c: fix: fixing up channel apis and implementations
120
+ - Updated dependencies [aa8435c]
121
+ - @pikku/core@0.5.27
122
+
123
+ ## 0.5.35
124
+
125
+ ### Patch Changes
126
+
127
+ - 2160039: fix: fixing alias issue with generated types
128
+ - ab42f18: chore: upgrading to next15 and dropping pages support
129
+ - Updated dependencies [ab42f18]
130
+ - @pikku/core@0.5.26
131
+
132
+ ## 0.5.34
133
+
134
+ ### Patch Changes
135
+
136
+ - 0f96787: refactor: dropping cjs support
137
+ - 64e4a1e: refactor: seperating core into cleaner sub-packages
138
+ - c23524a: refactor: bump to versions to ensure correct package usage
139
+ - Updated dependencies [0f96787]
140
+ - Updated dependencies [64e4a1e]
141
+ - Updated dependencies [c23524a]
142
+ - @pikku/core@0.5.25
143
+
144
+ ## 0.5.33
145
+
146
+ ### Patch Changes
147
+
148
+ - bba25cc: chore: updating all packages to reflect major changes
149
+ - 9deb482: refactor: finalizing stream api
150
+ - f37042d: fix: always print out core schema register file
151
+ - ee0c6ea: feat: adding ws server
152
+ - d97e952: refactor: removing requirement of config method outside of nextjs
153
+ - Updated dependencies [bba25cc]
154
+ - Updated dependencies [9deb482]
155
+ - Updated dependencies [ee0c6ea]
156
+ - @pikku/core@0.5.24
157
+
158
+ ## 0.5.32
159
+
160
+ ### Patch Changes
161
+
162
+ - e9a9968: refactor: completing rename of stream to channel
163
+ - Updated dependencies [7fa64a0]
164
+ - Updated dependencies [539937e]
165
+ - Updated dependencies [e9a9968]
166
+ - @pikku/core@0.5.23
167
+
168
+ ## 0.5.31
169
+
170
+ ### Patch Changes
171
+
172
+ - 73973ec: fix: data type for methods is optional
173
+ - Updated dependencies [73973ec]
174
+ - @pikku/core@0.5.22
175
+
176
+ ## 0.5.30
177
+
178
+ ### Patch Changes
179
+
180
+ - 179b9c2: fix: fixing stream types
181
+ - Updated dependencies [179b9c2]
182
+ - @pikku/core@0.5.21
183
+
184
+ ## 0.5.29
185
+
186
+ ### Patch Changes
187
+
188
+ - b20ef35: fix: generate stream types from message array
189
+
190
+ ## 0.5.28
191
+
192
+ ### Patch Changes
193
+
194
+ - 5be6da1: feat: adding streams to uws (and associated refactors)
195
+ - Updated dependencies [5be6da1]
196
+ - @pikku/core@0.5.20
197
+
198
+ ## 0.5.27
199
+
200
+ ### Patch Changes
201
+
202
+ - d58c440: refactor: making http requests explicit to support other types
203
+ - 11c50d4: feat: adding streams to cli
204
+ - Updated dependencies [cbcc75b]
205
+ - Updated dependencies [d58c440]
206
+ - Updated dependencies [11c50d4]
207
+ - @pikku/core@0.5.19
208
+
209
+ ## 0.5.26
210
+
211
+ ### Patch Changes
212
+
213
+ - b7b78bb: fix: add '& {}' to openapi interfaces as a workaround for not directly refering to a type since it confuses typescript
214
+
215
+ ## 0.5.25
216
+
217
+ ### Patch Changes
218
+
219
+ - 69d388d: refactor: switching to use config async creator
220
+
221
+ ## 0.5.24
222
+
223
+ ### Patch Changes
224
+
225
+ - 2307831: fix: removing unused import
226
+
227
+ ## 0.5.23
228
+
229
+ ### Patch Changes
230
+
231
+ - 30b46aa: fix: looks like using patch lowercase breaks the node fetch client sometimes
232
+ - Updated dependencies [30b46aa]
233
+ - @pikku/core@0.5.13
234
+
235
+ ## 0.5.22
236
+
237
+ ### Patch Changes
238
+
239
+ - f8aa99f: feat: export pikkuFetch instance to avoid needing a singleton class
240
+ - Updated dependencies [ff8a563]
241
+ - @pikku/core@0.5.12
242
+
243
+ ## 0.5.21
244
+
245
+ ### Patch Changes
246
+
247
+ - 5295380: refactor: changing config object a getConfig function
248
+ - f24a653: feat: coerce types in ajv for correct validation / usage later on
249
+ - Updated dependencies [be68efb]
250
+ - Updated dependencies [5295380]
251
+ - Updated dependencies [f24a653]
252
+ - @pikku/core@0.5.11
253
+
254
+ ## 0.5.20
255
+
256
+ ### Patch Changes
257
+
258
+ - effbb4c: doc: adding readme to all packages
259
+ - Updated dependencies [effbb4c]
260
+ - @pikku/core@0.5.10
261
+
262
+ ## 0.5.19
263
+
264
+ ### Patch Changes
265
+
266
+ - 3541ab7: refactor: rename nextDeclarationFile to nextJSFile
267
+ - 725723d: docs: adding typedocs
268
+ - Updated dependencies [3541ab7]
269
+ - Updated dependencies [725723d]
270
+ - @pikku/core@0.5.9
271
+
272
+ ## 0.5.18
273
+
274
+ ### Patch Changes
275
+
276
+ - b237ace: feat: adding core errors to openapi error specs
277
+ - 1876d7a: feat: add error return codes to doc generation
278
+ - fda3869: fix: dont ignore decleration files when looking for types
279
+ - Updated dependencies [1876d7a]
280
+ - Updated dependencies [8d85f7e]
281
+ - @pikku/core@0.5.8
282
+
283
+ ## 0.5.17
284
+
285
+ ### Patch Changes
286
+
287
+ - 25c6637: fix: fixing a type import for meta types
288
+
289
+ ## 0.5.16
290
+
291
+ ### Patch Changes
292
+
293
+ - 2654ef1: fix: testing relative files
294
+
295
+ ## 0.5.15
296
+
297
+ ### Patch Changes
298
+
299
+ - 707b26a: feat: save openapi as yml if needed
300
+
301
+ ## 0.5.14
302
+
303
+ ### Patch Changes
304
+
305
+ - 0883f00: fix: schema generation error
306
+ - Updated dependencies [0883f00]
307
+ - @pikku/core@0.5.6
308
+
309
+ ## 0.5.13
310
+
311
+ ### Patch Changes
312
+
313
+ - 93b80a3: feat: adding a beta openapi standard
314
+ - Updated dependencies [93b80a3]
315
+ - @pikku/core@0.5.5
316
+
317
+ ## 0.5.12
318
+
319
+ ### Patch Changes
320
+
321
+ - 473ac6a: fix: correcting name of schema root file
322
+ refactor: removing time change in generated files
323
+
324
+ ## 0.5.11
325
+
326
+ ### Patch Changes
327
+
328
+ - b3dcfc4: feat: adding a bootstrap file to simplify usage
329
+
330
+ ## 0.5.10
331
+
332
+ ### Patch Changes
333
+
334
+ - 2c0e940: fix: reinspecting after type file is created
335
+
336
+ ## 0.5.9
337
+
338
+ ### Patch Changes
339
+
340
+ - 0e1f01c: fix: inccorect string replacement
341
+
342
+ ## 0.5.8
343
+
344
+ ### Patch Changes
345
+
346
+ - 2841fce: fix: create empty schema directory
347
+
348
+ ## 0.5.7
349
+
350
+ ### Patch Changes
351
+
352
+ - 3724449: fix: fixing a cli path issue
353
+
354
+ ## 0.5.6
355
+
356
+ ### Patch Changes
357
+
358
+ - 58a510a: refactor: moving routes map into a declaration file
359
+
360
+ ## 0.5.5
361
+
362
+ ### Patch Changes
363
+
364
+ - 6cac8ab: feat: adding a do not edit to cli generated files
365
+ - Updated dependencies [6cac8ab]
366
+ - @pikku/core@0.5.4
367
+
368
+ ## 0.5.4
369
+
370
+ ### Patch Changes
371
+
372
+ - 8065e48: refactor: large cli refactor for a better dev experience
373
+ - Updated dependencies [8065e48]
374
+ - @pikku/core@0.5.3
375
+
376
+ ## 0.5.3
377
+
378
+ ### Patch Changes
379
+
380
+ - 5e0f033: feat: adding a routes map output file to support frontend sdks in the future
381
+ - Updated dependencies [5e0f033]
382
+ - @pikku/core@0.5.2
383
+
384
+ ## 0.5.2
385
+
386
+ ### Patch Changes
387
+
388
+ - 8712f25: fix: relative paths need to start with ./ for imports to work
389
+
390
+ ## 0.5.1
391
+
392
+ ### Patch Changes
393
+
394
+ - 45e07de: refactor: renaming packages and pikku structure
395
+ - Updated dependencies [97900d2]
396
+ - Updated dependencies [d939d46]
397
+ - Updated dependencies [45e07de]
398
+ - @pikku/core@0.5.1
399
+
400
+ ## 0.4.7
401
+
402
+ ### Patch Changes
403
+
404
+ - c382ed3: putting glob back to 10 again for node 18 support
405
+
406
+ ## 0.4.6
407
+
408
+ ### Patch Changes
409
+
410
+ - 2a2402b: republish since something went wrong
411
+ - Updated dependencies [2a2402b]
412
+ - @pikku/core@0.4.6
413
+
414
+ ## 0.4.5
415
+
416
+ ### Patch Changes
417
+
418
+ - 0650348: fix: export schemas using \*
419
+ - 1a708a7: refactor: renaming PikkuCLIConfig back to PikkuConfig
420
+ feat: adding .end() to pikku response for servers that need it
421
+ - 3019265: fix: ensuring node 18 compatability
422
+ - 642d370: fix: adding schema error logs on fail
423
+ - Updated dependencies [0650348]
424
+ - Updated dependencies [1a708a7]
425
+ - Updated dependencies [642d370]
426
+ - @pikku/core@0.4.4
427
+
428
+ ## 0.4.4
429
+
430
+ ### Patch Changes
431
+
432
+ - 94f8a74: fix: finalizing cjs and esm packages
433
+
434
+ ## 0.4.3
435
+
436
+ ### Patch Changes
437
+
438
+ - 28f62ea: refactor: using cjs and esm builds!
439
+ - 14783ee: fix: including all types as dependencies to avoid users needing to install them
440
+
441
+ ## 0.4.2
442
+
443
+ ### Patch Changes
444
+
445
+ - 5a012d9: Fixing typedoc generation
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Pikku CLI
2
+
3
+ This package is part of @pikku/mono and is responsible for all the intropsection and file generations.
@@ -0,0 +1,110 @@
1
+ import { Command } from 'commander'
2
+ import {
3
+ getFileImportRelativePath,
4
+ logPikkuLogo,
5
+ PikkuCLIOptions,
6
+ writeFileInDir,
7
+ } from '../src/utils.js'
8
+ import { getPikkuCLIConfig } from '../src/pikku-cli-config.js'
9
+ import { pikkuRoutes } from './pikku-routes.js'
10
+ import { pikkuFunctionTypes } from './pikku-function-types.js'
11
+ import { pikkuHTTPMap } from './pikku-routes-map.js'
12
+ import { existsSync } from 'fs'
13
+ import { pikkuFetch } from './pikku-fetch.js'
14
+ import { pikkuChannelsMap } from './pikku-channels-map.js'
15
+ import { pikkuChannels } from './pikku-channels.js'
16
+ import { pikkuNext } from './pikku-nextjs.js'
17
+ import { pikkuOpenAPI } from './pikku-openapi.js'
18
+ import { pikkuScheduler } from './pikku-scheduler.js'
19
+ import { pikkuSchemas } from './pikku-schemas.js'
20
+ import { pikkuWebSocket } from './pikku-websocket.js'
21
+ import { inspectorGlob } from '../src/inspector-glob.js'
22
+
23
+ export const action = async (options: PikkuCLIOptions): Promise<void> => {
24
+ logPikkuLogo()
25
+
26
+ const imports: string[] = []
27
+ const addImport = (from: string) => {
28
+ imports.push(
29
+ `import '${getFileImportRelativePath(cliConfig.bootstrapFile, from, cliConfig.packageMappings)}'`
30
+ )
31
+ }
32
+
33
+ const cliConfig = await getPikkuCLIConfig(options.config, [], true)
34
+
35
+ let typesDeclarationFileExists = true
36
+ let visitState = await inspectorGlob(
37
+ cliConfig.rootDir,
38
+ cliConfig.routeDirectories
39
+ )
40
+
41
+ if (!existsSync(cliConfig.typesDeclarationFile)) {
42
+ typesDeclarationFileExists = false
43
+ }
44
+ await pikkuFunctionTypes(cliConfig, options, visitState)
45
+
46
+ // This is needed since the addRoutes function will add the routes to the visitState
47
+ if (!typesDeclarationFileExists) {
48
+ console.log(`\x1b[34m• Type file first created, inspecting again...\x1b[0m`)
49
+ visitState = await inspectorGlob(
50
+ cliConfig.rootDir,
51
+ cliConfig.routeDirectories
52
+ )
53
+ }
54
+
55
+ const routes = await pikkuRoutes(cliConfig, visitState)
56
+ if (routes) {
57
+ await pikkuHTTPMap(cliConfig, visitState)
58
+ await pikkuFetch(cliConfig)
59
+ addImport(cliConfig.routesFile)
60
+ }
61
+
62
+ const scheduled = await pikkuScheduler(cliConfig, visitState)
63
+ if (scheduled) {
64
+ addImport(cliConfig.schedulersFile)
65
+ }
66
+
67
+ const channels = await pikkuChannels(cliConfig, visitState)
68
+ if (channels) {
69
+ await pikkuChannelsMap(cliConfig, visitState)
70
+ await pikkuWebSocket(cliConfig)
71
+ addImport(cliConfig.channelsFile)
72
+ }
73
+
74
+ const schemas = await pikkuSchemas(cliConfig, visitState)
75
+ if (schemas) {
76
+ addImport(`${cliConfig.schemaDirectory}/register.gen.ts`)
77
+ }
78
+
79
+ await pikkuNext(cliConfig, visitState, options)
80
+
81
+ if (cliConfig.openAPI) {
82
+ console.log(
83
+ `\x1b[34m• OpenAPI requires a reinspection to pickup new generated types..\x1b[0m`
84
+ )
85
+ visitState = await inspectorGlob(
86
+ cliConfig.rootDir,
87
+ cliConfig.routeDirectories
88
+ )
89
+ await pikkuOpenAPI(cliConfig, visitState)
90
+ }
91
+
92
+ await writeFileInDir(cliConfig.bootstrapFile, imports.join('\n'))
93
+ }
94
+
95
+ export const all = (program: Command): void => {
96
+ program
97
+ .command('all', { isDefault: true })
98
+ .description('Generate all the files used by pikku')
99
+ .option('-ct | --pikku-config-type', 'The type of your pikku config object')
100
+ .option(
101
+ '-ss | --singleton-services-factory-type',
102
+ 'The type of your singleton services factory'
103
+ )
104
+ .option(
105
+ '-se | --session-services-factory-type',
106
+ 'The type of your session services factory'
107
+ )
108
+ .option('-c | --config <string>', 'The path to pikku cli config file')
109
+ .action(action)
110
+ }
@@ -0,0 +1,53 @@
1
+ import { Command } from 'commander'
2
+ import { getPikkuCLIConfig, PikkuCLIConfig } from '../src/pikku-cli-config.js'
3
+ import { InspectorState } from '@pikku/inspector'
4
+ import {
5
+ logCommandInfoAndTime,
6
+ logPikkuLogo,
7
+ PikkuCLIOptions,
8
+ writeFileInDir,
9
+ } from '../src/utils.js'
10
+ import { serializeTypedChannelsMap } from '../src/channels/serialize-typed-channel-map.js'
11
+ import { inspectorGlob } from '../src/inspector-glob.js'
12
+
13
+ export const pikkuChannelsMap = async (
14
+ { channelsMapDeclarationFile, packageMappings }: PikkuCLIConfig,
15
+ state: InspectorState
16
+ ) => {
17
+ return await logCommandInfoAndTime(
18
+ 'Creating channels map',
19
+ 'Created channels map',
20
+ [state.channels.files.size === 0],
21
+ async () => {
22
+ const content = serializeTypedChannelsMap(
23
+ channelsMapDeclarationFile,
24
+ packageMappings,
25
+ state.channels.typesMap,
26
+ state.channels.meta
27
+ )
28
+ await writeFileInDir(channelsMapDeclarationFile, content)
29
+ }
30
+ )
31
+ }
32
+
33
+ async function action(cliOptions: PikkuCLIOptions): Promise<void> {
34
+ logPikkuLogo()
35
+ const cliConfig = await getPikkuCLIConfig(cliOptions.config, [
36
+ 'rootDir',
37
+ 'routeDirectories',
38
+ 'routesFile',
39
+ ])
40
+ const visitState = await inspectorGlob(
41
+ cliConfig.rootDir,
42
+ cliConfig.routeDirectories
43
+ )
44
+ await pikkuChannelsMap(cliConfig, visitState)
45
+ }
46
+
47
+ export const channelsMap = (program: Command): void => {
48
+ program
49
+ .command('channels-map')
50
+ .description('Generate a map of all channels to aid in type checking')
51
+ .option('-c | --config <string>', 'The path to pikku cli config file')
52
+ .action(action)
53
+ }
@@ -0,0 +1,57 @@
1
+ import { Command } from 'commander'
2
+ import { getPikkuCLIConfig, PikkuCLIConfig } from '../src/pikku-cli-config.js'
3
+ import { InspectorState } from '@pikku/inspector'
4
+ import {
5
+ logCommandInfoAndTime,
6
+ logPikkuLogo,
7
+ PikkuCLIOptions,
8
+ writeFileInDir,
9
+ } from '../src/utils.js'
10
+ import {
11
+ serializeChannels,
12
+ serializeChannelMeta,
13
+ } from '../src/channels/serialize-channels.js'
14
+ import { inspectorGlob } from '../src/inspector-glob.js'
15
+
16
+ export const pikkuChannels = async (
17
+ cliConfig: PikkuCLIConfig,
18
+ visitState: InspectorState
19
+ ) => {
20
+ return await logCommandInfoAndTime(
21
+ 'Finding Channels',
22
+ 'Found channels',
23
+ [visitState.channels.files.size === 0],
24
+ async () => {
25
+ const { channelsFile, packageMappings } = cliConfig
26
+ const { channels } = visitState
27
+ const content = [
28
+ serializeChannels(channelsFile, channels.files, packageMappings),
29
+ serializeChannelMeta(channels.meta),
30
+ ]
31
+ await writeFileInDir(channelsFile, content.join('\n\n'))
32
+ }
33
+ )
34
+ }
35
+
36
+ async function action(cliOptions: PikkuCLIOptions): Promise<void> {
37
+ logPikkuLogo()
38
+
39
+ const cliConfig = await getPikkuCLIConfig(cliOptions.config, [
40
+ 'rootDir',
41
+ 'routeDirectories',
42
+ 'routesFile',
43
+ ])
44
+ const visitState = await inspectorGlob(
45
+ cliConfig.rootDir,
46
+ cliConfig.routeDirectories
47
+ )
48
+ await pikkuChannels(cliConfig, visitState)
49
+ }
50
+
51
+ export const channels = (program: Command): void => {
52
+ program
53
+ .command('channels')
54
+ .description('Find all channels to import')
55
+ .option('-c | --config <string>', 'The path to pikku cli config file')
56
+ .action(action)
57
+ }
@@ -0,0 +1,54 @@
1
+ import { Command } from 'commander'
2
+ import {
3
+ getFileImportRelativePath,
4
+ logCommandInfoAndTime,
5
+ logPikkuLogo,
6
+ PikkuCLIOptions,
7
+ writeFileInDir,
8
+ } from '../src/utils.js'
9
+ import { getPikkuCLIConfig, PikkuCLIConfig } from '../src/pikku-cli-config.js'
10
+ import { serializeFetchWrapper } from '../src/http/serialize-fetch-wrapper.js'
11
+
12
+ export const pikkuFetch = async ({
13
+ fetchFile,
14
+ routesMapDeclarationFile,
15
+ packageMappings,
16
+ }: PikkuCLIConfig) => {
17
+ await logCommandInfoAndTime(
18
+ 'Generating fetch wrapper',
19
+ 'Generated fetch wrapper',
20
+ [fetchFile === undefined, 'fetchFile is required in pikku config'],
21
+ async () => {
22
+ if (!fetchFile) {
23
+ throw new Error('fetchFile is required in pikku config')
24
+ }
25
+
26
+ const routesMapDeclarationPath = getFileImportRelativePath(
27
+ fetchFile,
28
+ routesMapDeclarationFile,
29
+ packageMappings
30
+ )
31
+
32
+ const content = [serializeFetchWrapper(routesMapDeclarationPath)]
33
+ await writeFileInDir(fetchFile, content.join('\n'))
34
+ }
35
+ )
36
+ }
37
+
38
+ export const action = async (options: PikkuCLIOptions): Promise<void> => {
39
+ logPikkuLogo()
40
+ const cliConfig = await getPikkuCLIConfig(
41
+ options.config,
42
+ ['rootDir', 'schemaDirectory', 'configDir', 'fetchFile'],
43
+ true
44
+ )
45
+ await pikkuFetch(cliConfig)
46
+ }
47
+
48
+ export const fetch = (program: Command): void => {
49
+ program
50
+ .command('fetch')
51
+ .description('generate fetch wrapper')
52
+ .option('-c | --config <string>', 'The path to pikku cli config file')
53
+ .action(action)
54
+ }