vovk-cli 0.0.1-draft.4 → 0.0.1-draft.40

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 (78) hide show
  1. package/README.md +1 -1
  2. package/dist/{watcher → dev}/diffSchema.d.mts +2 -2
  3. package/dist/{watcher → dev}/diffSchema.mjs +1 -1
  4. package/dist/dev/ensureClient.d.mts +5 -0
  5. package/dist/dev/ensureClient.mjs +31 -0
  6. package/dist/{watcher → dev}/ensureSchemaFiles.mjs +20 -8
  7. package/dist/dev/index.d.mts +4 -0
  8. package/dist/{watcher → dev}/index.mjs +92 -55
  9. package/dist/{watcher → dev}/logDiffResult.d.mts +2 -2
  10. package/dist/{watcher → dev}/logDiffResult.mjs +13 -9
  11. package/dist/{watcher → dev}/writeOneSchemaFile.d.mts +1 -1
  12. package/dist/{watcher → dev}/writeOneSchemaFile.mjs +4 -3
  13. package/dist/generateClient.d.mts +1 -1
  14. package/dist/generateClient.mjs +6 -6
  15. package/dist/getProjectInfo/getConfig.mjs +1 -1
  16. package/dist/getProjectInfo/getConfigAbsolutePaths.mjs +2 -2
  17. package/dist/getProjectInfo/getRelativeSrcRoot.mjs +4 -4
  18. package/dist/getProjectInfo/getUserConfig.mjs +4 -2
  19. package/dist/getProjectInfo/importUncachedModule.mjs +0 -1
  20. package/dist/getProjectInfo/importUncachedModuleWorker.mjs +0 -1
  21. package/dist/getProjectInfo/index.mjs +2 -2
  22. package/dist/index.d.mts +1 -23
  23. package/dist/index.mjs +19 -43
  24. package/dist/init/checkTSConfigForExperimentalDecorators.mjs +2 -2
  25. package/dist/init/createConfig.d.mts +3 -4
  26. package/dist/init/createConfig.mjs +5 -5
  27. package/dist/init/getTemplateFilesFromPackage.d.mts +2 -1
  28. package/dist/init/getTemplateFilesFromPackage.mjs +4 -5
  29. package/dist/init/index.d.mts +1 -2
  30. package/dist/init/index.mjs +46 -93
  31. package/dist/init/installDependencies.d.mts +4 -1
  32. package/dist/init/installDependencies.mjs +2 -2
  33. package/dist/init/logUpdateDependenciesError.d.mts +11 -0
  34. package/dist/init/logUpdateDependenciesError.mjs +45 -0
  35. package/dist/init/updateDependenciesWithoutInstalling.d.mts +3 -2
  36. package/dist/init/updateDependenciesWithoutInstalling.mjs +12 -7
  37. package/dist/init/updateNPMScripts.d.mts +3 -1
  38. package/dist/init/updateNPMScripts.mjs +10 -6
  39. package/dist/init/updateTypeScriptConfig.mjs +2 -2
  40. package/dist/initProgram.d.mts +2 -0
  41. package/dist/initProgram.mjs +21 -0
  42. package/dist/locateSegments.mjs +3 -3
  43. package/dist/new/addClassToSegmentCode.mjs +6 -2
  44. package/dist/new/addCommonTerms.mjs +1 -0
  45. package/dist/new/index.d.mts +2 -2
  46. package/dist/new/index.mjs +13 -3
  47. package/dist/new/newModule.d.mts +6 -2
  48. package/dist/new/newModule.mjs +50 -26
  49. package/dist/new/newSegment.d.mts +3 -2
  50. package/dist/new/newSegment.mjs +5 -5
  51. package/dist/new/render.d.mts +3 -7
  52. package/dist/new/render.mjs +11 -7
  53. package/dist/postinstall.mjs +5 -3
  54. package/dist/types.d.mts +36 -1
  55. package/dist/utils/debounceWithArgs.d.mts +1 -1
  56. package/dist/utils/debounceWithArgs.mjs +24 -9
  57. package/dist/utils/formatLoggedSegmentName.mjs +1 -1
  58. package/dist/utils/getAvailablePort.mjs +3 -2
  59. package/dist/utils/getFileSystemEntryType.mjs +1 -1
  60. package/package.json +14 -11
  61. package/templates/controller.ejs +20 -18
  62. package/templates/service.ejs +24 -4
  63. package/templates/worker.ejs +24 -1
  64. package/dist/getProjectInfo/directoryExists.d.mts +0 -1
  65. package/dist/getProjectInfo/directoryExists.mjs +0 -10
  66. package/dist/watcher/index.d.mts +0 -6
  67. package/templates_old/MyThingController.c.only.template.ts +0 -32
  68. package/templates_old/MyThingController.c.template.ts +0 -34
  69. package/templates_old/MyThingService.s.template.ts +0 -18
  70. package/templates_old/controller.ejs +0 -85
  71. package/templates_old/service.ejs +0 -9
  72. package/templates_old/worker.ejs +0 -9
  73. package/templates_old/zod/MyThingController.c.only.template.ts +0 -32
  74. package/templates_old/zod/MyThingController.c.template.ts +0 -39
  75. package/templates_old/zod/MyThingService.s.template.ts +0 -18
  76. /package/dist/{watcher → dev}/ensureSchemaFiles.d.mts +0 -0
  77. /package/dist/{watcher → dev}/isMetadataEmpty.d.mts +0 -0
  78. /package/dist/{watcher → dev}/isMetadataEmpty.mjs +0 -0
@@ -1,7 +1,27 @@
1
- <% var ServiceName = _.upperFirst(_.camelCase(moduleName) + 'Service'; %>
2
-
1
+ <% var modulePascalName = _.upperFirst(_.camelCase(moduleName)); %>
2
+ <% var modulePascalNamePlural = pluralize(modulePascalName); %>
3
+ <% var serviceName = modulePascalName + 'Service'; %>
4
+ <% var controllerName = modulePascalName + 'Controller'; %>
3
5
  ---
4
- filePath: <%= getModulePath(segmentName, moduleName, ServiceName + '.ts') %> # Relative to "modules" dir
6
+ dir: <%= getModuleDirName(segmentName, moduleName) %>
7
+ fileName: <%= serviceName + '.ts' %>
5
8
  ---
6
9
 
7
- // TO DO: Implement <%= ServiceName %>
10
+ import type { VovkControllerBody, VovkControllerQuery } from 'vovk';
11
+ import type <%= controllerName %> from './<%= controllerName %>';
12
+
13
+ export default class <%= serviceName %> {
14
+ static get<%= modulePascalNamePlural %> = (search: VovkControllerQuery<typeof <%= controllerName %>.get<%= modulePascalNamePlural %>>['search']) => {
15
+ return { results: [], search };
16
+ };
17
+
18
+ static update<%= modulePascalName %> = (
19
+ id: string,
20
+ q: VovkControllerQuery<typeof <%= controllerName %>.update<%= modulePascalName %>>['q'],
21
+ body: VovkControllerBody<typeof <%= controllerName %>.update<%= modulePascalName %>>
22
+ ) => {
23
+ return { id, q, body };
24
+ };
25
+
26
+ // ...
27
+ }
@@ -1 +1,24 @@
1
- // TODO
1
+ <% var modulePascalName = _.upperFirst(_.camelCase(moduleName)); %>
2
+ <% var modulePascalNamePlural = pluralize(modulePascalName); %>
3
+ <% var workerName = modulePascalName + 'Worker'; %>
4
+ <% var compiledName = modulePascalName + 'WPC'; %>
5
+ ---
6
+ dir: <%= getModuleDirName(segmentName, moduleName) %>
7
+ fileName: <%= workerName + '.ts' %>
8
+ sourceName: <%= workerName %>
9
+ compiledName: <%= compiledName %>
10
+ ---
11
+ import { worker } from 'vovk';
12
+
13
+ @worker()
14
+ export default class <%= workerName %> {
15
+ static heavyComputation = () => {
16
+ return 'Hello, World';
17
+ };
18
+
19
+ static heavyComputationGenerator = function* () {
20
+ for(const str of ['Hello', 'World'] as const) {
21
+ yield str;
22
+ }
23
+ };
24
+ }
@@ -1 +0,0 @@
1
- export default function directoryExists(dir: string): Promise<boolean>;
@@ -1,10 +0,0 @@
1
- import fs from 'fs/promises';
2
- export default async function directoryExists(dir) {
3
- try {
4
- const stats = await fs.stat(dir);
5
- return stats.isDirectory();
6
- }
7
- catch (error) {
8
- return false;
9
- }
10
- }
@@ -1,6 +0,0 @@
1
- export declare class VovkCLIWatcher {
2
- #private;
3
- start({ clientOutDir }?: {
4
- clientOutDir?: string;
5
- }): Promise<void>;
6
- }
@@ -1,32 +0,0 @@
1
- import { prefix, get, put, post, del, type VovkRequest } from 'vovk';
2
-
3
- @prefix('my-things')
4
- export default class MyThingController {
5
- @get()
6
- static getMyThingsExample = (req: VovkRequest<null, { q: string }>) => {
7
- const q = req.nextUrl.searchParams.get('q');
8
- return { q };
9
- };
10
-
11
- @put(':id')
12
- static updateMyThingExample = async (
13
- req: VovkRequest<{ foo: 'bar' | 'baz' }, { q: string }>,
14
- params: { id: string }
15
- ) => {
16
- const { id } = params;
17
- const body = await req.json();
18
- const q = req.nextUrl.searchParams.get('q');
19
-
20
- return { id, q, body };
21
- };
22
-
23
- @post()
24
- static createMyThingExample = () => {
25
- // ...
26
- };
27
-
28
- @del(':id')
29
- static deleteMyThingExample = () => {
30
- // ...
31
- };
32
- }
@@ -1,34 +0,0 @@
1
- import { prefix, get, put, post, del, type VovkRequest } from 'vovk';
2
- import MyThingService from './MyThingService.s.template';
3
-
4
- @prefix('my-things')
5
- export default class MyThingController {
6
- @get()
7
- static getMyThingsExample(req: VovkRequest<null, { q: string }>) {
8
- const q = req.nextUrl.searchParams.get('q');
9
-
10
- return MyThingService.getMyThingsExample(q);
11
- }
12
-
13
- @put(':id')
14
- static updateMyThingExample = async (
15
- req: VovkRequest<{ foo: 'bar' | 'baz' }, { q: string }>,
16
- params: { id: string }
17
- ) => {
18
- const { id } = params;
19
- const body = await req.json();
20
- const q = req.nextUrl.searchParams.get('q');
21
-
22
- return MyThingService.updateMyThingExample(id, q, body);
23
- };
24
-
25
- @post()
26
- static createMyThingExample = () => {
27
- // ...
28
- };
29
-
30
- @del(':id')
31
- static deleteMyThingExample = () => {
32
- // ...
33
- };
34
- }
@@ -1,18 +0,0 @@
1
- import type { VovkControllerBody, VovkControllerQuery } from 'vovk';
2
- import type MyThingController from './MyThingController.c.template';
3
-
4
- export default class MyThingService {
5
- static getMyThingsExample = (q: VovkControllerQuery<typeof MyThingController.getMyThingsExample>['q']) => {
6
- return { q };
7
- };
8
-
9
- static updateMyThingExample = (
10
- id: string,
11
- q: VovkControllerQuery<typeof MyThingController.updateMyThingExample>['q'],
12
- body: VovkControllerBody<typeof MyThingController.updateMyThingExample>
13
- ) => {
14
- return { id, q, body };
15
- };
16
-
17
- // ...
18
- }
@@ -1,85 +0,0 @@
1
- <% var modulePascalName = _.upperFirst(_.camelCase(moduleName)); %>
2
- <% var modulePascalNamePlural = pluralize(modulePascalName); %>
3
- <% var ControllerName = modulePascalName + 'Controller'; %>
4
- <% var RPCName = modulePascalName + 'RPC'; %>
5
- <% var ServiceName = modulePascalName + 'Service'; %>
6
- ---
7
- # Relative to modules dir
8
- fileName: <%= getFileDir(segmentName, moduleName) + ControllerName + '.ts' %>
9
- className: <%= ControllerName %> # Used to define a controller in a segment
10
- rpcName: <%= RPCName %> # Used to define an exported RPC class in a segment
11
- ---
12
-
13
- import { prefix, get, put, post, del<%= !config.validationLibrary ? ', type VovkRequest' : '' %> } from 'vovk';
14
- <% if(withService) { %>
15
- import <%= ServiceName %> from './<%= ServiceName %>';
16
- <% } %>
17
- <% if(config.validationLibrary === 'vovk-zod') { %>
18
- import { withZod } from 'vovk-zod';
19
- import { z } from 'zod';
20
- <% } %>
21
-
22
- @prefix('<%= _.kebabCase(moduleName).toLowerCase() %>')
23
- export default class <%= ControllerName %> {
24
- @get()
25
- <% if(config.validationLibrary === 'vovk-zod') { %>
26
- async get<%= modulePascalNamePlural %> = withZod(null, z.object({ q: z.string() }), (req) => {
27
- const q = req.nextUrl.searchParams.get('q');
28
- <% if(withService) { %>
29
- return <%= ServiceName %>.getMyThingsExample(q);
30
- <% } else { %>
31
- return { q };
32
- <% } %>
33
- });
34
- <% } else { %>
35
- static get<%= modulePascalNamePlural %> = async (req: VovkRequest<null, { q: string }>) => {
36
- const q = req.nextUrl.searchParams.get('q');
37
- <% if(withService) { %>
38
- return <%= ServiceName %>.getMyThingsExample(q);
39
- <% } else { %>
40
- return { q };
41
- <% } %>
42
- }
43
- <% } %>
44
-
45
- @put(':id')
46
- <% if(config.validationLibrary === 'vovk-zod') { %>
47
- static update<%= modulePascalNamePlural %> = withZod(
48
- z.object({
49
- foo: z.union([z.literal('bar'), z.literal('baz')]),
50
- }),
51
- z.object({ q: z.string() }),
52
- async (req, params: { id: string }) => {
53
- const { id } = params;
54
- const body = await req.json();
55
- const q = req.nextUrl.searchParams.get('q');
56
- <% if(withService) { %>
57
- return MyThingService.updateMyThingExample(id, q, body);
58
- <% } else { %>
59
- return { id, body, q };
60
- <% } %>
61
- }
62
- );
63
- <% } else { %>
64
- static update<%= modulePascalNamePlural %> = async (req: VovkRequest<{ foo: 'bar' | 'baz' }, { q: string }>, params: { id: string }) => {
65
- const { id } = params;
66
- const body = await req.json();
67
- const q = req.nextUrl.searchParams.get('q');
68
- <% if(withService) { %>
69
- return MyThingService.updateMyThingExample(id, q, body);
70
- <% } else { %>
71
- return { id, body, q };
72
- <% } %>
73
- };
74
- <% } %>
75
-
76
- @post()
77
- static create<%= modulePascalNamePlural %> = () => {
78
- // ...
79
- };
80
-
81
- @del(':id')
82
- static delete<%= modulePascalNamePlural %> = () => {
83
- // ...
84
- };
85
- }
@@ -1,9 +0,0 @@
1
- <% var modulePascalName = _.upperFirst(_.camelCase(moduleName); %>
2
- <% var ServiceName = modulePascalName + 'Service'; %>
3
-
4
- ---
5
- # Relative to modules dir
6
- fileName: <%= getFileDir(segmentName, moduleName) + ServiceName + '.ts' %>
7
- ---
8
-
9
- // TO DO: Implement <%= ServiceName %>
@@ -1,9 +0,0 @@
1
- <% var modulePascalName = _.upperFirst(_.camelCase(moduleName); %>
2
- <% var WorkerName = modulePascalName + 'Worker'; %>
3
-
4
- ---
5
- # Relative to modules dir
6
- fileName: <%= getFileDir(segmentName, moduleName) + WorkerName + '.ts' %>
7
- ---
8
-
9
- // TO DO: Implement <%= WorkerName %>
@@ -1,32 +0,0 @@
1
- import { prefix, get, put, post, del, type VovkRequest } from 'vovk';
2
-
3
- @prefix('my-thing')
4
- export default class MyThingController {
5
- @get()
6
- static getMyThingsExample = (req: VovkRequest<null, { q: string }>) => {
7
- const q = req.nextUrl.searchParams.get('q');
8
- return { q };
9
- };
10
-
11
- @put(':id')
12
- static updateMyThingExample = async (
13
- req: VovkRequest<{ foo: 'bar' | 'baz' }, { q: string }>,
14
- params: { id: string }
15
- ) => {
16
- const { id } = params;
17
- const body = await req.json();
18
- const q = req.nextUrl.searchParams.get('q');
19
-
20
- return { id, q, body };
21
- };
22
-
23
- @post()
24
- static createMyThingExample = () => {
25
- // ...
26
- };
27
-
28
- @del(':id')
29
- static deleteMyThingExample = () => {
30
- // ...
31
- };
32
- }
@@ -1,39 +0,0 @@
1
- import { prefix, get, put, post, del } from 'vovk';
2
- import { z } from 'zod';
3
- import { withZod } from 'vovk-zod';
4
- import MyThingService from './MyThingService.s.template';
5
-
6
- @prefix('my-thing')
7
- export default class MyThingController {
8
- @get()
9
- static getMyThingsExample = withZod(null, z.object({ q: z.string() }), (req) => {
10
- const q = req.nextUrl.searchParams.get('q');
11
-
12
- return MyThingService.getMyThingsExample(q);
13
- });
14
-
15
- @put(':id')
16
- static updateMyThingExample = withZod(
17
- z.object({
18
- foo: z.union([z.literal('bar'), z.literal('baz')]),
19
- }),
20
- z.object({ q: z.string() }),
21
- async (req, params: { id: string }) => {
22
- const { id } = params;
23
- const body = await req.json();
24
- const q = req.nextUrl.searchParams.get('q');
25
-
26
- return MyThingService.updateMyThingExample(id, q, body);
27
- }
28
- );
29
-
30
- @post()
31
- static async createMyThingExample() {
32
- // ...
33
- }
34
-
35
- @del(':id')
36
- static deleteMyThingExample() {
37
- // ...
38
- }
39
- }
@@ -1,18 +0,0 @@
1
- import type { VovkControllerBody, VovkControllerQuery } from 'vovk';
2
- import type MyThingController from './MyThingController.c.template';
3
-
4
- export default class MyThingService {
5
- static getMyThingsExample = (q: VovkControllerQuery<typeof MyThingController.getMyThingsExample>['q']) => {
6
- return { q };
7
- };
8
-
9
- static updateMyThingExample = (
10
- id: string,
11
- q: VovkControllerQuery<typeof MyThingController.updateMyThingExample>['q'],
12
- body: VovkControllerBody<typeof MyThingController.updateMyThingExample>
13
- ) => {
14
- return { id, q, body };
15
- };
16
-
17
- // ...
18
- }
File without changes
File without changes
File without changes