vovk-cli 0.0.1-draft.64 → 0.0.1-draft.65
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/client-templates/module/module.mjs.ejs +4 -2
- package/dist/dev/ensureSchemaFiles.mjs +2 -2
- package/dist/generate/index.d.mts +2 -1
- package/dist/generate/index.mjs +3 -2
- package/dist/getProjectInfo/index.mjs +1 -1
- package/dist/index.mjs +10 -2
- package/dist/init/createConfig.mjs +1 -1
- package/package.json +2 -2
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
<%- '// auto-generated\n/* eslint-disable */' %>
|
|
2
2
|
import fetcherImport from '<%= fetcherClientImportPath %>';
|
|
3
|
-
import
|
|
3
|
+
import createRPCImport from '<%= createRPCImportPath %>';
|
|
4
4
|
import schema from '<%= schemaOutImportPath %>';
|
|
5
5
|
<% if (validateOnClientImportPath) { %>
|
|
6
|
-
import
|
|
6
|
+
import validateOnClientImport from '<%= validateOnClientImportPath %>';
|
|
7
|
+
const validateOnClient = validateOnClientImport.default || validateOnClientImport;
|
|
7
8
|
<% } else { %>
|
|
8
9
|
const validateOnClient = undefined;
|
|
9
10
|
<% } %>
|
|
10
11
|
const apiRoot = '<%= apiRoot %>';
|
|
11
12
|
const fetcher = fetcherImport.default || fetcherImport;
|
|
13
|
+
const createRPC = createRPCImport.default || createRPCImport;
|
|
12
14
|
<% segments.forEach((segment, i) => {
|
|
13
15
|
Object.keys(segmentsSchema[segment.segmentName].controllers).forEach((key) => { %>
|
|
14
16
|
export const <%= key %> = createRPC(
|
|
@@ -22,8 +22,8 @@ declare const segmentSchema: {
|
|
|
22
22
|
${segmentNames.map((segmentName) => ` '${segmentName}': VovkSchema;`).join('\n')}
|
|
23
23
|
};
|
|
24
24
|
export default segmentSchema;`;
|
|
25
|
-
const jsAbsolutePath = path.join(schemaOutAbsolutePath, 'index.
|
|
26
|
-
const dTsAbsolutePath = path.join(schemaOutAbsolutePath, 'index.d.
|
|
25
|
+
const jsAbsolutePath = path.join(schemaOutAbsolutePath, 'index.cjs');
|
|
26
|
+
const dTsAbsolutePath = path.join(schemaOutAbsolutePath, 'index.d.cts');
|
|
27
27
|
const existingJs = await fs.readFile(jsAbsolutePath, 'utf-8').catch(() => null);
|
|
28
28
|
const existingDTs = await fs.readFile(dTsAbsolutePath, 'utf-8').catch(() => null);
|
|
29
29
|
await fs.mkdir(schemaOutAbsolutePath, { recursive: true });
|
|
@@ -2,10 +2,11 @@ import type { VovkSchema } from 'vovk';
|
|
|
2
2
|
import type { ProjectInfo } from '../getProjectInfo/index.mjs';
|
|
3
3
|
import type { Segment } from '../locateSegments.mjs';
|
|
4
4
|
import { GenerateOptions } from '../types.mjs';
|
|
5
|
-
export default function generate({ projectInfo, segments, segmentsSchema, templates, prettify: prettifyClient, fullSchema, }: {
|
|
5
|
+
export default function generate({ projectInfo, segments, segmentsSchema, forceNothingWrittenLog, templates, prettify: prettifyClient, fullSchema, }: {
|
|
6
6
|
projectInfo: ProjectInfo;
|
|
7
7
|
segments: Segment[];
|
|
8
8
|
segmentsSchema: Record<string, VovkSchema>;
|
|
9
|
+
forceNothingWrittenLog?: boolean;
|
|
9
10
|
} & Pick<GenerateOptions, 'templates' | 'prettify' | 'fullSchema'>): Promise<{
|
|
10
11
|
written: boolean;
|
|
11
12
|
path: string;
|
package/dist/generate/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import ejs from 'ejs';
|
|
|
4
4
|
import formatLoggedSegmentName from '../utils/formatLoggedSegmentName.mjs';
|
|
5
5
|
import prettify from '../utils/prettify.mjs';
|
|
6
6
|
import getClientTemplates from './getClientTemplates.mjs';
|
|
7
|
-
export default async function generate({ projectInfo, segments, segmentsSchema, templates, prettify: prettifyClient, fullSchema, }) {
|
|
7
|
+
export default async function generate({ projectInfo, segments, segmentsSchema, forceNothingWrittenLog, templates, prettify: prettifyClient, fullSchema, }) {
|
|
8
8
|
templates = templates ?? projectInfo.config.experimental_clientGenerateTemplateNames;
|
|
9
9
|
const noClient = templates?.[0] === 'none';
|
|
10
10
|
const { config, cwd, log, validateOnClientImportPath, apiRoot, fetcherClientImportPath, createRPCImportPath, schemaOutImportPath, } = projectInfo;
|
|
@@ -63,7 +63,8 @@ export default async function generate({ projectInfo, segments, segmentsSchema,
|
|
|
63
63
|
log.info(`Full schema has ben written to ${fullSchemaOutAbsolutePath}`);
|
|
64
64
|
}
|
|
65
65
|
if (!anyNeedsWriting) {
|
|
66
|
-
|
|
66
|
+
const logOrDebug = forceNothingWrittenLog ? log.info : log.debug;
|
|
67
|
+
logOrDebug(`Client is up to date and doesn't need to be regenerated (${Date.now() - now}ms)`);
|
|
67
68
|
return { written: false, path: clientOutDirAbsolutePath };
|
|
68
69
|
}
|
|
69
70
|
// Write updated files where needed
|
|
@@ -9,7 +9,7 @@ export default async function getProjectInfo({ port: givenPort, clientOutDir, cw
|
|
|
9
9
|
const apiRoot = `${config.origin ?? ''}/${config.rootEntry}`;
|
|
10
10
|
const apiDir = path.join(srcRoot, 'app', config.rootEntry);
|
|
11
11
|
const schemaOutImportPath = path.relative(config.clientOutDir, config.schemaOutDir).replace(/\\/g, '/') + // windows fix
|
|
12
|
-
'/index.
|
|
12
|
+
'/index.cjs';
|
|
13
13
|
const fetcherClientImportPath = config.fetcherPath.startsWith('.')
|
|
14
14
|
? path.relative(config.clientOutDir, config.fetcherPath)
|
|
15
15
|
: config.fetcherPath;
|
package/dist/index.mjs
CHANGED
|
@@ -83,9 +83,17 @@ program
|
|
|
83
83
|
const { cwd, config, apiDir } = projectInfo;
|
|
84
84
|
const segments = await locateSegments({ dir: apiDir, config });
|
|
85
85
|
const schemaOutAbsolutePath = path.join(cwd, config.schemaOutDir);
|
|
86
|
-
const schemaImportUrl = pathToFileURL(path.join(schemaOutAbsolutePath, 'index.
|
|
86
|
+
const schemaImportUrl = pathToFileURL(path.join(schemaOutAbsolutePath, 'index.cjs')).href;
|
|
87
87
|
const { default: segmentsSchema } = (await import(schemaImportUrl));
|
|
88
|
-
await generate({
|
|
88
|
+
await generate({
|
|
89
|
+
projectInfo,
|
|
90
|
+
segments,
|
|
91
|
+
segmentsSchema,
|
|
92
|
+
templates,
|
|
93
|
+
prettify,
|
|
94
|
+
fullSchema,
|
|
95
|
+
forceNothingWrittenLog: true,
|
|
96
|
+
});
|
|
89
97
|
});
|
|
90
98
|
program
|
|
91
99
|
.command('new [components...]')
|
|
@@ -17,7 +17,7 @@ export default async function createConfig({ root, log, options: { validationLib
|
|
|
17
17
|
};
|
|
18
18
|
if (validationLibrary) {
|
|
19
19
|
if (validateOnClient) {
|
|
20
|
-
config.validateOnClientPath = `${validationLibrary}/validateOnClient`;
|
|
20
|
+
config.validateOnClientPath = `${validationLibrary}/validateOnClient/index.js`;
|
|
21
21
|
}
|
|
22
22
|
try {
|
|
23
23
|
const validationTemplates = await getTemplateFilesFromPackage(validationLibrary, channel);
|
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.65",
|
|
4
4
|
"bin": {
|
|
5
5
|
"vovk": "./dist/index.mjs"
|
|
6
6
|
},
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://vovk.dev",
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"vovk": "^3.0.0-draft.
|
|
39
|
+
"vovk": "^3.0.0-draft.65"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@inquirer/prompts": "^7.3.1",
|