vovk-cli 0.0.1-draft.3 → 0.0.1-draft.30
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 +1 -1
- package/dist/{watcher → dev}/diffSchema.d.mts +2 -2
- package/dist/{watcher → dev}/diffSchema.mjs +1 -1
- package/dist/dev/ensureClient.d.mts +5 -0
- package/dist/dev/ensureClient.mjs +31 -0
- package/dist/{watcher → dev}/ensureSchemaFiles.mjs +20 -8
- package/dist/dev/index.d.mts +4 -0
- package/dist/{watcher → dev}/index.mjs +30 -30
- package/dist/{watcher → dev}/logDiffResult.d.mts +2 -2
- package/dist/{watcher → dev}/logDiffResult.mjs +13 -9
- package/dist/{watcher → dev}/writeOneSchemaFile.d.mts +1 -1
- package/dist/{watcher → dev}/writeOneSchemaFile.mjs +4 -3
- package/dist/generateClient.d.mts +1 -1
- package/dist/generateClient.mjs +6 -6
- package/dist/getProjectInfo/getConfigAbsolutePaths.mjs +2 -2
- package/dist/getProjectInfo/getRelativeSrcRoot.mjs +4 -4
- package/dist/getProjectInfo/getUserConfig.mjs +1 -1
- package/dist/getProjectInfo/index.mjs +1 -1
- package/dist/index.d.mts +2 -24
- package/dist/index.mjs +15 -41
- package/dist/init/checkTSConfigForExperimentalDecorators.mjs +2 -2
- package/dist/init/createConfig.d.mts +3 -4
- package/dist/init/createConfig.mjs +5 -5
- package/dist/init/getTemplateFilesFromPackage.d.mts +2 -1
- package/dist/init/getTemplateFilesFromPackage.mjs +3 -4
- package/dist/init/index.d.mts +1 -2
- package/dist/init/index.mjs +36 -85
- package/dist/init/installDependencies.d.mts +4 -1
- package/dist/init/installDependencies.mjs +2 -2
- package/dist/init/logUpdateDependenciesError.d.mts +11 -0
- package/dist/init/logUpdateDependenciesError.mjs +45 -0
- package/dist/init/updateDependenciesWithoutInstalling.d.mts +3 -2
- package/dist/init/updateDependenciesWithoutInstalling.mjs +12 -7
- package/dist/init/updateNPMScripts.mjs +2 -1
- package/dist/init/updateTypeScriptConfig.mjs +2 -2
- package/dist/initProgram.d.mts +2 -0
- package/dist/initProgram.mjs +21 -0
- package/dist/locateSegments.mjs +2 -2
- package/dist/new/addClassToSegmentCode.mjs +6 -2
- package/dist/new/index.d.mts +2 -2
- package/dist/new/index.mjs +13 -3
- package/dist/new/newModule.d.mts +6 -2
- package/dist/new/newModule.mjs +50 -26
- package/dist/new/newSegment.d.mts +3 -2
- package/dist/new/newSegment.mjs +5 -5
- package/dist/new/render.d.mts +3 -7
- package/dist/new/render.mjs +11 -7
- package/dist/postinstall.mjs +5 -3
- package/dist/types.d.mts +37 -2
- package/dist/utils/debounceWithArgs.mjs +1 -4
- package/dist/utils/formatLoggedSegmentName.mjs +1 -1
- package/dist/utils/getAvailablePort.mjs +3 -2
- package/dist/utils/getFileSystemEntryType.mjs +1 -1
- package/package.json +8 -6
- package/templates/controller.ejs +18 -17
- package/templates/service.ejs +24 -4
- package/templates/worker.ejs +24 -1
- package/dist/getProjectInfo/directoryExists.d.mts +0 -1
- package/dist/getProjectInfo/directoryExists.mjs +0 -10
- package/dist/watcher/index.d.mts +0 -6
- package/templates_old/MyThingController.c.only.template.ts +0 -32
- package/templates_old/MyThingController.c.template.ts +0 -34
- package/templates_old/MyThingService.s.template.ts +0 -18
- package/templates_old/controller.ejs +0 -85
- package/templates_old/service.ejs +0 -9
- package/templates_old/worker.ejs +0 -9
- package/templates_old/zod/MyThingController.c.only.template.ts +0 -32
- package/templates_old/zod/MyThingController.c.template.ts +0 -39
- package/templates_old/zod/MyThingService.s.template.ts +0 -18
- /package/dist/{watcher → dev}/ensureSchemaFiles.d.mts +0 -0
- /package/dist/{watcher → dev}/isMetadataEmpty.d.mts +0 -0
- /package/dist/{watcher → dev}/isMetadataEmpty.mjs +0 -0
package/dist/new/newSegment.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import fs from 'fs/promises';
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
3
|
import getProjectInfo from '../getProjectInfo/index.mjs';
|
|
4
4
|
import getFileSystemEntryType from '../utils/getFileSystemEntryType.mjs';
|
|
5
5
|
import chalkHighlightThing from '../utils/chalkHighlightThing.mjs';
|
|
6
6
|
import formatLoggedSegmentName from '../utils/formatLoggedSegmentName.mjs';
|
|
7
7
|
import prettify from '../utils/prettify.mjs';
|
|
8
|
-
export default async function newSegment({ segmentName, dryRun }) {
|
|
8
|
+
export default async function newSegment({ segmentName, overwrite, dryRun, }) {
|
|
9
9
|
const { apiDir, cwd, log } = await getProjectInfo();
|
|
10
10
|
const absoluteSegmentRoutePath = path.join(cwd, apiDir, segmentName, '[[...vovk]]/route.ts');
|
|
11
|
-
if (await getFileSystemEntryType(absoluteSegmentRoutePath)) {
|
|
11
|
+
if (!overwrite && (await getFileSystemEntryType(absoluteSegmentRoutePath))) {
|
|
12
12
|
throw new Error(`Unable to create new segment. ${formatLoggedSegmentName(segmentName, { upperFirst: true })} already exists.`);
|
|
13
13
|
}
|
|
14
14
|
const code = await prettify(`import { initVovk } from 'vovk';
|
|
@@ -29,5 +29,5 @@ ${segmentName ? ` segmentName: '${segmentName}',\n` : ''} emitSchema: true,
|
|
|
29
29
|
await fs.mkdir(path.dirname(absoluteSegmentRoutePath), { recursive: true });
|
|
30
30
|
await fs.writeFile(absoluteSegmentRoutePath, code);
|
|
31
31
|
}
|
|
32
|
-
log.info(`${formatLoggedSegmentName(segmentName, { upperFirst: true })} created at ${absoluteSegmentRoutePath}. Run ${chalkHighlightThing(`vovk new controller ${segmentName}
|
|
32
|
+
log.info(`${formatLoggedSegmentName(segmentName, { upperFirst: true })} created at ${absoluteSegmentRoutePath}. Run ${chalkHighlightThing(`vovk new controller ${[segmentName, 'someName'].filter(Boolean).join('/')}`)} to create a new controller`);
|
|
33
33
|
}
|
package/dist/new/render.d.mts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import type { VovkConfig } from '../types.mjs';
|
|
1
|
+
import type { VovkConfig, VovkModuleRenderResult } from '../types.mjs';
|
|
2
2
|
export default function render(codeTemplate: string, { config, withService, segmentName, moduleName, }: {
|
|
3
|
+
cwd: string;
|
|
3
4
|
config: VovkConfig;
|
|
4
5
|
withService: boolean;
|
|
5
6
|
segmentName: string;
|
|
6
7
|
moduleName: string;
|
|
7
|
-
}): Promise<
|
|
8
|
-
filePath: string;
|
|
9
|
-
sourceName: string;
|
|
10
|
-
compiledName: string;
|
|
11
|
-
code: string;
|
|
12
|
-
}>;
|
|
8
|
+
}): Promise<VovkModuleRenderResult>;
|
package/dist/new/render.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import pluralize from 'pluralize';
|
|
|
5
5
|
import addCommonTerms from './addCommonTerms.mjs';
|
|
6
6
|
addCommonTerms();
|
|
7
7
|
export default async function render(codeTemplate, { config, withService, segmentName, moduleName, }) {
|
|
8
|
-
const
|
|
8
|
+
const getModuleDirName = (givenSegmentName, givenModuleName) => [config.modulesDir, givenSegmentName || config.rootSegmentModulesDirName, _.camelCase(givenModuleName)]
|
|
9
9
|
.filter(Boolean)
|
|
10
10
|
.join('/');
|
|
11
11
|
const templateVars = {
|
|
@@ -15,15 +15,19 @@ export default async function render(codeTemplate, { config, withService, segmen
|
|
|
15
15
|
segmentName,
|
|
16
16
|
moduleName,
|
|
17
17
|
// utils
|
|
18
|
-
|
|
18
|
+
getModuleDirName,
|
|
19
19
|
// libraries
|
|
20
20
|
_, // lodash
|
|
21
21
|
pluralize,
|
|
22
22
|
};
|
|
23
|
-
// first, render the front matter because it can use ejs variables
|
|
24
23
|
const parsed = matter((await ejs.render(codeTemplate, templateVars, { async: true })).trim());
|
|
25
|
-
const {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const { dir, fileName, sourceName, compiledName } = parsed.data;
|
|
25
|
+
const code = parsed.content;
|
|
26
|
+
return {
|
|
27
|
+
dir,
|
|
28
|
+
fileName,
|
|
29
|
+
sourceName,
|
|
30
|
+
compiledName,
|
|
31
|
+
code,
|
|
32
|
+
};
|
|
29
33
|
}
|
package/dist/postinstall.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import path from 'path';
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
3
|
/**
|
|
4
4
|
* Checks if a file exists at the given path.
|
|
5
5
|
* @param {string} filePath - The path to the file.
|
|
@@ -11,7 +11,9 @@ async function postinstall() {
|
|
|
11
11
|
const js = path.join(vovk, 'client.js');
|
|
12
12
|
const ts = path.join(vovk, 'client.d.ts');
|
|
13
13
|
const index = path.join(vovk, 'index.ts');
|
|
14
|
-
if ((await getFileSystemEntryType(js)) ||
|
|
14
|
+
if ((await getFileSystemEntryType(js)) ||
|
|
15
|
+
(await getFileSystemEntryType(ts)) ||
|
|
16
|
+
(await getFileSystemEntryType(index))) {
|
|
15
17
|
return;
|
|
16
18
|
}
|
|
17
19
|
await fs.mkdir(vovk, { recursive: true });
|
package/dist/types.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LogLevelNames } from 'loglevel';
|
|
1
|
+
import type { LogLevelNames } from 'loglevel';
|
|
2
2
|
export type KnownAny = any;
|
|
3
|
-
export type
|
|
3
|
+
export type VovkDevEnv = {
|
|
4
4
|
PORT?: string;
|
|
5
5
|
VOVK_CLIENT_OUT_DIR?: string;
|
|
6
6
|
VOVK_SCHEMA_OUT_DIR?: string;
|
|
@@ -37,3 +37,38 @@ export type VovkConfig = {
|
|
|
37
37
|
[key: string]: string | undefined;
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
|
+
export type VovkModuleRenderResult = {
|
|
41
|
+
fileName: string;
|
|
42
|
+
dir: string;
|
|
43
|
+
sourceName?: string;
|
|
44
|
+
compiledName?: string;
|
|
45
|
+
code: string;
|
|
46
|
+
};
|
|
47
|
+
export interface DevOptions {
|
|
48
|
+
nextDev?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface GenerateOptions {
|
|
51
|
+
clientOut?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface InitOptions {
|
|
54
|
+
yes?: boolean;
|
|
55
|
+
logLevel: LogLevelNames;
|
|
56
|
+
useNpm?: boolean;
|
|
57
|
+
useYarn?: boolean;
|
|
58
|
+
usePnpm?: boolean;
|
|
59
|
+
useBun?: boolean;
|
|
60
|
+
skipInstall?: boolean;
|
|
61
|
+
updateTsConfig?: boolean;
|
|
62
|
+
updateScripts?: 'implicit' | 'explicit';
|
|
63
|
+
validationLibrary?: string | null;
|
|
64
|
+
validateOnClient?: boolean;
|
|
65
|
+
dryRun?: boolean;
|
|
66
|
+
channel?: 'latest' | 'beta' | 'draft';
|
|
67
|
+
}
|
|
68
|
+
export interface NewOptions {
|
|
69
|
+
dryRun?: boolean;
|
|
70
|
+
templates?: string[];
|
|
71
|
+
dir?: string;
|
|
72
|
+
overwrite?: boolean;
|
|
73
|
+
noSegmentUpdate?: boolean;
|
|
74
|
+
}
|
|
@@ -6,9 +6,6 @@ export default function debounceWithArgs(fn, wait) {
|
|
|
6
6
|
if (!debouncedFunctions.has(key)) {
|
|
7
7
|
debouncedFunctions.set(key, debounce(fn, wait));
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
if (debouncedFn) {
|
|
11
|
-
debouncedFn(...args);
|
|
12
|
-
}
|
|
9
|
+
return debouncedFunctions.get(key)(...args);
|
|
13
10
|
};
|
|
14
11
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import chalkHighlightThing from './chalkHighlightThing.mjs';
|
|
2
1
|
import upperFirstLodash from 'lodash/upperFirst.js';
|
|
2
|
+
import chalkHighlightThing from './chalkHighlightThing.mjs';
|
|
3
3
|
export default function formatLoggedSegmentName(segmentName, { withChalk = true, upperFirst = false } = {}) {
|
|
4
4
|
let text = segmentName ? `segment "${segmentName}"` : 'the root segment';
|
|
5
5
|
text = upperFirst ? upperFirstLodash(text) : text;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import net from 'net';
|
|
1
|
+
import net from 'node:net';
|
|
2
|
+
// TODO check comments
|
|
2
3
|
/**
|
|
3
4
|
* Checks if a port is available.
|
|
4
5
|
* @param {number} port - The port to check.
|
|
@@ -34,7 +35,7 @@ function getAvailablePort(startPort, maxAttempts, attempt, onWarning) {
|
|
|
34
35
|
getAvailablePort(startPort + 1, maxAttempts, attempt + 1, onWarning).then(resolve, reject);
|
|
35
36
|
}
|
|
36
37
|
else {
|
|
37
|
-
reject('No available ports found');
|
|
38
|
+
reject(new Error('No available ports found'));
|
|
38
39
|
}
|
|
39
40
|
});
|
|
40
41
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vovk-cli",
|
|
3
|
-
"version": "0.0.1-draft.
|
|
3
|
+
"version": "0.0.1-draft.30",
|
|
4
4
|
"bin": {
|
|
5
5
|
"vovk": "./dist/index.mjs"
|
|
6
6
|
},
|
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "rm -rf dist tsconfig.build.tsbuildinfo && tsc -P tsconfig.build.json",
|
|
13
13
|
"build-test": "rm -rf test_dist && tsc -P tsconfig.test.json",
|
|
14
|
-
"test": "npm run build && chmod +x ./dist/index.mjs && npm run build-test
|
|
15
|
-
"
|
|
14
|
+
"pre-test": "npm run build && chmod +x ./dist/index.mjs && npm run build-test",
|
|
15
|
+
"test-only": "npm run pre-test && node --test --test-only test_dist/test/**/*.mjs",
|
|
16
|
+
"test": "npm run pre-test && node --test --test-concurrency=1 test_dist/test/**/*.mjs",
|
|
17
|
+
"tsc": "tsc --noEmit",
|
|
16
18
|
"ncu": "npm-check-updates -u",
|
|
17
19
|
"npm-publish": "npm publish"
|
|
18
20
|
},
|
|
@@ -33,10 +35,10 @@
|
|
|
33
35
|
},
|
|
34
36
|
"homepage": "https://vovk.dev",
|
|
35
37
|
"peerDependencies": {
|
|
36
|
-
"vovk": "^3.0.0-draft.
|
|
38
|
+
"vovk": "^3.0.0-draft.21"
|
|
37
39
|
},
|
|
38
40
|
"dependencies": {
|
|
39
|
-
"@inquirer/prompts": "^7.0.
|
|
41
|
+
"@inquirer/prompts": "^7.0.1",
|
|
40
42
|
"@npmcli/package-json": "^6.0.1",
|
|
41
43
|
"chalk": "^5.3.0",
|
|
42
44
|
"chokidar": "^4.0.1",
|
|
@@ -62,7 +64,7 @@
|
|
|
62
64
|
"@types/pluralize": "^0.0.33",
|
|
63
65
|
"@types/tar-stream": "^3.1.3",
|
|
64
66
|
"concat-stream": "^2.0.0",
|
|
65
|
-
"create-next-app": "^15.0.
|
|
67
|
+
"create-next-app": "^15.0.2",
|
|
66
68
|
"node-pty": "^1.0.0",
|
|
67
69
|
"type-fest": "^4.26.1"
|
|
68
70
|
}
|
package/templates/controller.ejs
CHANGED
|
@@ -1,50 +1,51 @@
|
|
|
1
1
|
<% var modulePascalName = _.upperFirst(_.camelCase(moduleName)); %>
|
|
2
2
|
<% var modulePascalNamePlural = pluralize(modulePascalName); %>
|
|
3
|
-
<% var
|
|
4
|
-
<% var
|
|
5
|
-
<% var
|
|
3
|
+
<% var controllerName = modulePascalName + 'Controller'; %>
|
|
4
|
+
<% var compiledName = modulePascalName + 'RPC'; %>
|
|
5
|
+
<% var serviceName = modulePascalName + 'Service'; %>
|
|
6
6
|
---
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
dir: <%= getModuleDirName(segmentName, moduleName) %>
|
|
8
|
+
fileName: <%= controllerName + '.ts' %>
|
|
9
|
+
sourceName: <%= controllerName %>
|
|
10
|
+
compiledName: <%= compiledName %>
|
|
10
11
|
---
|
|
11
12
|
|
|
12
|
-
import { prefix, get, put, post, del
|
|
13
|
+
import { prefix, get, put, post, del, type VovkRequest } from 'vovk';
|
|
13
14
|
<% if(withService) { %>
|
|
14
|
-
import <%=
|
|
15
|
+
import <%= serviceName %> from './<%= serviceName %>';
|
|
15
16
|
<% } %>
|
|
16
17
|
|
|
17
18
|
@prefix('<%= _.kebabCase(moduleName).toLowerCase() %>')
|
|
18
|
-
export default class <%=
|
|
19
|
+
export default class <%= controllerName %> {
|
|
19
20
|
@get()
|
|
20
|
-
static get<%= modulePascalNamePlural %> = async (req: VovkRequest<null, {
|
|
21
|
-
const
|
|
21
|
+
static get<%= modulePascalNamePlural %> = async (req: VovkRequest<null, { search: string }>) => {
|
|
22
|
+
const search = req.nextUrl.searchParams.get('search');
|
|
22
23
|
<% if(withService) { %>
|
|
23
|
-
return <%=
|
|
24
|
+
return <%= serviceName %>.get<%= modulePascalNamePlural %>(search);
|
|
24
25
|
<% } else { %>
|
|
25
|
-
return {
|
|
26
|
+
return { results: [], search };
|
|
26
27
|
<% } %>
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
@put(':id')
|
|
30
|
-
static update<%=
|
|
31
|
+
static update<%= modulePascalName %> = async (req: VovkRequest<{ foo: 'bar' | 'baz' }, { q: string }>, params: { id: string }) => {
|
|
31
32
|
const { id } = params;
|
|
32
33
|
const body = await req.json();
|
|
33
34
|
const q = req.nextUrl.searchParams.get('q');
|
|
34
35
|
<% if(withService) { %>
|
|
35
|
-
return
|
|
36
|
+
return <%= serviceName %>.update<%= modulePascalName %>(id, q, body);
|
|
36
37
|
<% } else { %>
|
|
37
38
|
return { id, body, q };
|
|
38
39
|
<% } %>
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
@post()
|
|
42
|
-
static create<%=
|
|
43
|
+
static create<%= modulePascalName %> = () => {
|
|
43
44
|
// ...
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
@del(':id')
|
|
47
|
-
static delete<%=
|
|
48
|
+
static delete<%= modulePascalName %> = () => {
|
|
48
49
|
// ...
|
|
49
50
|
};
|
|
50
51
|
}
|
package/templates/service.ejs
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
<% var
|
|
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
|
-
|
|
6
|
+
dir: <%= getModuleDirName(segmentName, moduleName) %>
|
|
7
|
+
fileName: <%= serviceName + '.ts' %>
|
|
5
8
|
---
|
|
6
9
|
|
|
7
|
-
|
|
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
|
+
}
|
package/templates/worker.ejs
CHANGED
|
@@ -1 +1,24 @@
|
|
|
1
|
-
|
|
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>;
|
package/dist/watcher/index.d.mts
DELETED
|
@@ -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 %>
|
package/templates_old/worker.ejs
DELETED
|
@@ -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
|
-
}
|