vovk-cli 0.0.1-draft.41 → 0.0.1-draft.43
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/compiled/{client.d.ts.ejs → compiled.d.ts.ejs} +7 -6
- package/client-templates/compiled/{client.js.ejs → compiled.js.ejs} +7 -7
- package/client-templates/ts/index.ts.ejs +13 -14
- package/dist/dev/diffSchema.d.mts +2 -2
- package/dist/dev/ensureClient.d.mts +1 -1
- package/dist/dev/ensureClient.mjs +3 -4
- package/dist/dev/index.mjs +4 -4
- package/dist/generate/getClientTemplates.d.mts +11 -0
- package/dist/generate/getClientTemplates.mjs +25 -0
- package/dist/generate/index.d.mts +12 -0
- package/dist/{generateClient.mjs → generate/index.mjs} +10 -26
- package/dist/getProjectInfo/getConfig.mjs +1 -0
- package/dist/getProjectInfo/index.d.mts +1 -1
- package/dist/getProjectInfo/index.mjs +2 -2
- package/dist/index.mjs +4 -5
- package/dist/postinstall.mjs +3 -3
- package/dist/types.d.mts +1 -1
- package/package.json +2 -2
- package/dist/generateClient.d.mts +0 -12
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
|
|
1
2
|
<%- '// auto-generated\n/* eslint-disable */' %>
|
|
2
3
|
import type { clientizeController, VovkClientFetcher } from 'vovk/client';
|
|
3
4
|
import type { promisifyWorker } from 'vovk/worker';
|
|
4
5
|
import type fetcher from '<%= fetcherClientImportPath %>';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
<% segments.forEach((segment, i) => {
|
|
7
|
+
const hasWorkers = !!Object.keys(segmentsSchema[segment.segmentName].workers).length;
|
|
8
|
+
%>
|
|
9
|
+
import type { Controllers as Controllers<%= i %><% if(hasWorkers) { %>, Workers as Workers<%= i %> <% } %> } from "<%= segment.segmentImportPath %>";
|
|
8
10
|
<% }) %>
|
|
9
|
-
|
|
10
11
|
type Options = typeof fetcher extends VovkClientFetcher<infer U> ? U : never;
|
|
11
12
|
|
|
12
13
|
<% segments.forEach((segment, i) => {
|
|
@@ -16,9 +17,9 @@ type Options = typeof fetcher extends VovkClientFetcher<infer U> ? U : never;
|
|
|
16
17
|
const workers = Object.keys(segSchema.workers);
|
|
17
18
|
%>
|
|
18
19
|
<% controllers.forEach((key) => { %>
|
|
19
|
-
|
|
20
|
+
export const <%= key %>: ReturnType<typeof clientizeController<Controllers<%= i %>["<%= key %>"], Options>>;
|
|
20
21
|
<% }) %>
|
|
21
22
|
<% workers.forEach((key) => { %>
|
|
22
|
-
|
|
23
|
+
export const <%= key %>: ReturnType<typeof promisifyWorker<Workers<%= i %>["<%= key %>"]>>;
|
|
23
24
|
<% }) %>
|
|
24
25
|
<% }) %>
|
|
@@ -5,7 +5,7 @@ const { default: fetcher } = require('<%= fetcherClientImportPath %>');
|
|
|
5
5
|
const schema = require('<%= schemaOutImportPath %>');
|
|
6
6
|
|
|
7
7
|
const { default: validateOnClient = null } = <%- validateOnClientImportPath ? `require('${validateOnClientImportPath}')` : '{}'%>;
|
|
8
|
-
const apiRoot = '<%=
|
|
8
|
+
const apiRoot = '<%= apiRoot %>';
|
|
9
9
|
|
|
10
10
|
<% segments.forEach((segment) => {
|
|
11
11
|
const segSchema = segmentsSchema[segment.segmentName];
|
|
@@ -14,13 +14,13 @@ const apiRoot = '<%= apiEntryPoint %>';
|
|
|
14
14
|
const workers = Object.keys(segSchema.workers);
|
|
15
15
|
%>
|
|
16
16
|
<% controllers.forEach((key) => { %>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
exports.<%= key %> = clientizeController(
|
|
18
|
+
schema['<%= segment.segmentName %>'].controllers.<%= key %>,
|
|
19
|
+
'<%= segment.segmentName %>',
|
|
20
|
+
{ fetcher, validateOnClient, defaultOptions: { apiRoot } }
|
|
21
|
+
);
|
|
22
22
|
<% }) %>
|
|
23
23
|
<% workers.forEach((key) => { %>
|
|
24
|
-
|
|
24
|
+
exports.<%= key %> = promisifyWorker(null, schema['<%= segment.segmentName %>'].workers.<%= key %>);
|
|
25
25
|
<% }) %>
|
|
26
26
|
<% }) %>
|
|
@@ -1,36 +1,35 @@
|
|
|
1
1
|
<%- '// auto-generated\n/* eslint-disable */' %>
|
|
2
2
|
import { clientizeController, type VovkClientFetcher } from 'vovk/client';
|
|
3
|
-
import { promisifyWorker } from 'vovk/worker'
|
|
3
|
+
<% if(hasWorkers) { %>import { promisifyWorker } from 'vovk/worker';<% } %>
|
|
4
4
|
import fetcher from '<%= fetcherClientImportPath %>';
|
|
5
5
|
import schema from '<%= schemaOutImportPath %>';
|
|
6
|
-
|
|
7
6
|
<% if (validateOnClientImportPath) { %>
|
|
8
7
|
import validateOnClient from '<%= validateOnClientImportPath %>';
|
|
9
8
|
<% } else { %>
|
|
10
9
|
const validateOnClient = undefined;
|
|
11
10
|
<% } %>
|
|
12
|
-
|
|
13
11
|
type Options = typeof fetcher extends VovkClientFetcher<infer U> ? U : never;
|
|
14
|
-
const apiRoot = '<%=
|
|
12
|
+
const apiRoot = '<%= apiRoot %>';
|
|
15
13
|
|
|
16
14
|
<% segments.forEach((segment, i) => {
|
|
17
15
|
const segSchema = segmentsSchema[segment.segmentName];
|
|
18
16
|
if (!segSchema || !segSchema.emitSchema) return;
|
|
17
|
+
const hasWorkers = !!Object.keys(segmentsSchema[segment.segmentName].workers).length;
|
|
19
18
|
%>
|
|
20
|
-
|
|
19
|
+
import type { Controllers as Controllers<%= i %><% if(hasWorkers) { %>, Workers as Workers<%= i %> <% } %>} from "<%= segment.segmentImportPath %>";
|
|
21
20
|
|
|
22
21
|
<% Object.keys(segSchema.controllers).forEach((key) => { %>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
export const <%= key %> = clientizeController<Controllers<%= i %>["<%= key %>"], Options>(
|
|
23
|
+
schema['<%= segment.segmentName %>'].controllers.<%= key %>,
|
|
24
|
+
'<%= segment.segmentName %>',
|
|
25
|
+
{ fetcher, validateOnClient, defaultOptions: { apiRoot } }
|
|
26
|
+
);
|
|
28
27
|
<% }) %>
|
|
29
28
|
|
|
30
29
|
<% Object.keys(segSchema.workers).forEach((key) => { %>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
export const <%= key %> = promisifyWorker<Workers<%= i %>["<%= key %>"]>(
|
|
31
|
+
null,
|
|
32
|
+
schema['<%= segment.segmentName %>'].workers.<%= key %>
|
|
33
|
+
);
|
|
35
34
|
<% }) %>
|
|
36
35
|
<% }) %>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { VovkSchema } from 'vovk';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VovkControllerSchema, VovkWorkerSchema } from 'vovk/types';
|
|
3
3
|
interface HandlersDiff {
|
|
4
4
|
nameOfClass: string;
|
|
5
5
|
added: string[];
|
|
@@ -15,7 +15,7 @@ export interface DiffResult {
|
|
|
15
15
|
workers: WorkersOrControllersDiff;
|
|
16
16
|
controllers: WorkersOrControllersDiff;
|
|
17
17
|
}
|
|
18
|
-
export declare function diffHandlers<T extends
|
|
18
|
+
export declare function diffHandlers<T extends VovkWorkerSchema['handlers'] | VovkControllerSchema['handlers']>(oldHandlers: T, newHandlers: T, nameOfClass: string): HandlersDiff;
|
|
19
19
|
export declare function diffWorkersOrControllers<T extends VovkSchema['controllers'] | VovkSchema['workers']>(oldItems: T, newItems: T): WorkersOrControllersDiff;
|
|
20
20
|
/**
|
|
21
21
|
example output:
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
|
-
export default async function ensureClient(
|
|
4
|
-
const { config, cwd, log } = projectInfo;
|
|
3
|
+
export default async function ensureClient({ config, cwd, log }) {
|
|
5
4
|
const now = Date.now();
|
|
6
5
|
const clientoOutDirAbsolutePath = path.join(cwd, config.clientOutDir);
|
|
7
6
|
const dts = `// auto-generated
|
|
@@ -10,8 +9,8 @@ export default async function ensureClient(projectInfo) {
|
|
|
10
9
|
// Feel free to report an issue at https://github.com/finom/vovk/issues`;
|
|
11
10
|
const js = dts;
|
|
12
11
|
const ts = dts;
|
|
13
|
-
const localJsAbsolutePath = path.join(clientoOutDirAbsolutePath, '
|
|
14
|
-
const localDtsAbsolutePath = path.join(clientoOutDirAbsolutePath, '
|
|
12
|
+
const localJsAbsolutePath = path.join(clientoOutDirAbsolutePath, 'compiled.js');
|
|
13
|
+
const localDtsAbsolutePath = path.join(clientoOutDirAbsolutePath, 'compiled.d.ts');
|
|
15
14
|
const localTsAbsolutePath = path.join(clientoOutDirAbsolutePath, 'index.ts');
|
|
16
15
|
const existingJs = await fs.readFile(localJsAbsolutePath, 'utf-8').catch(() => null);
|
|
17
16
|
const existingDts = await fs.readFile(localDtsAbsolutePath, 'utf-8').catch(() => null);
|
package/dist/dev/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import writeOneSchemaFile from './writeOneSchemaFile.mjs';
|
|
|
11
11
|
import logDiffResult from './logDiffResult.mjs';
|
|
12
12
|
import ensureClient from './ensureClient.mjs';
|
|
13
13
|
import getProjectInfo from '../getProjectInfo/index.mjs';
|
|
14
|
-
import
|
|
14
|
+
import generate from '../generate/index.mjs';
|
|
15
15
|
import locateSegments from '../locateSegments.mjs';
|
|
16
16
|
import debounceWithArgs from '../utils/debounceWithArgs.mjs';
|
|
17
17
|
import formatLoggedSegmentName from '../utils/formatLoggedSegmentName.mjs';
|
|
@@ -215,9 +215,9 @@ export class VovkDev {
|
|
|
215
215
|
}
|
|
216
216
|
};
|
|
217
217
|
#requestSchema = debounceWithArgs(async (segmentName) => {
|
|
218
|
-
const {
|
|
218
|
+
const { apiRoot, log, port, config } = this.#projectInfo;
|
|
219
219
|
const { devHttps } = config;
|
|
220
|
-
const endpoint = `${
|
|
220
|
+
const endpoint = `${apiRoot.startsWith(`http${devHttps ? 's' : ''}://`) ? apiRoot : `http${devHttps ? 's' : ''}://localhost:${port}${apiRoot}`}/${segmentName ? `${segmentName}/` : ''}_schema_`;
|
|
221
221
|
log.debug(`Requesting schema for ${formatLoggedSegmentName(segmentName)} at ${endpoint}`);
|
|
222
222
|
try {
|
|
223
223
|
const resp = await fetch(endpoint);
|
|
@@ -275,7 +275,7 @@ export class VovkDev {
|
|
|
275
275
|
}
|
|
276
276
|
if (this.#segments.every((s) => this.#schemas[s.segmentName])) {
|
|
277
277
|
log.debug(`All segments with "emitSchema" have schema.`);
|
|
278
|
-
await
|
|
278
|
+
await generate({ projectInfo: this.#projectInfo, segments: this.#segments, segmentsSchema: this.#schemas });
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
async start() {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { VovkConfig } from "../types.mjs";
|
|
2
|
+
interface ClientTemplate {
|
|
3
|
+
templatePath: string;
|
|
4
|
+
outPath: string;
|
|
5
|
+
}
|
|
6
|
+
export default function getClientTemplates({ config, cwd, templateNames, }: {
|
|
7
|
+
config: Required<VovkConfig>;
|
|
8
|
+
cwd: string;
|
|
9
|
+
templateNames?: string[];
|
|
10
|
+
}): ClientTemplate[];
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
export default function getClientTemplates({ config, cwd, templateNames = [], }) {
|
|
3
|
+
const __dirname = path.dirname(new URL(import.meta.url).pathname);
|
|
4
|
+
const templatesDir = path.join(__dirname, '../..', 'client-templates');
|
|
5
|
+
const clientOutDirAbsolutePath = path.resolve(cwd, config.clientOutDir);
|
|
6
|
+
const mapper = (dir) => (name) => ({
|
|
7
|
+
templatePath: path.resolve(templatesDir, dir, name),
|
|
8
|
+
outPath: path.join(clientOutDirAbsolutePath, name.replace('.ejs', '')),
|
|
9
|
+
});
|
|
10
|
+
const builtInTemplatesMap = {
|
|
11
|
+
ts: ['index.ts.ejs'].map(mapper('ts')),
|
|
12
|
+
compiled: ['compiled.js.ejs', 'compiled.d.ts.ejs'].map(mapper('compiled')),
|
|
13
|
+
python: ['__init__.py'].map(mapper('python')),
|
|
14
|
+
};
|
|
15
|
+
const templateFiles = (templateNames ?? config.clientGenerateTemplateNames).reduce((acc, template) => {
|
|
16
|
+
if (template in builtInTemplatesMap) {
|
|
17
|
+
return [...acc, ...builtInTemplatesMap[template]];
|
|
18
|
+
}
|
|
19
|
+
return [...acc, {
|
|
20
|
+
templatePath: path.resolve(cwd, template),
|
|
21
|
+
outPath: path.join(clientOutDirAbsolutePath, path.basename(template).replace('.ejs', ''))
|
|
22
|
+
}];
|
|
23
|
+
}, []);
|
|
24
|
+
return templateFiles;
|
|
25
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { VovkSchema } from 'vovk';
|
|
2
|
+
import type { ProjectInfo } from '../getProjectInfo/index.mjs';
|
|
3
|
+
import type { Segment } from '../locateSegments.mjs';
|
|
4
|
+
import { GenerateOptions } from '../types.mjs';
|
|
5
|
+
export default function generate({ projectInfo, segments, segmentsSchema, templates, prettify: prettifyClient, fullSchema, }: {
|
|
6
|
+
projectInfo: ProjectInfo;
|
|
7
|
+
segments: Segment[];
|
|
8
|
+
segmentsSchema: Record<string, VovkSchema>;
|
|
9
|
+
} & Pick<GenerateOptions, 'templates' | 'prettify' | 'fullSchema'>): Promise<{
|
|
10
|
+
written: boolean;
|
|
11
|
+
path: string;
|
|
12
|
+
}>;
|
|
@@ -1,31 +1,15 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
3
|
import ejs from 'ejs';
|
|
4
|
-
import formatLoggedSegmentName from '
|
|
5
|
-
import prettify from '
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
4
|
+
import formatLoggedSegmentName from '../utils/formatLoggedSegmentName.mjs';
|
|
5
|
+
import prettify from '../utils/prettify.mjs';
|
|
6
|
+
import getClientTemplates from './getClientTemplates.mjs';
|
|
7
|
+
export default async function generate({ projectInfo, segments, segmentsSchema, templates, prettify: prettifyClient, fullSchema, }) {
|
|
8
|
+
templates = templates ?? projectInfo.config.clientGenerateTemplateNames;
|
|
9
|
+
const noClient = templates?.[0] === 'none';
|
|
10
|
+
const { config, cwd, log, validateOnClientImportPath, apiRoot, fetcherClientImportPath, schemaOutImportPath, } = projectInfo;
|
|
10
11
|
const clientOutDirAbsolutePath = path.resolve(cwd, config.clientOutDir);
|
|
11
|
-
const
|
|
12
|
-
templatePath: path.resolve(templatesDir, dir, name),
|
|
13
|
-
outPath: path.join(clientOutDirAbsolutePath, name.replace('.ejs', '')),
|
|
14
|
-
});
|
|
15
|
-
const builtInTemplatesMap = {
|
|
16
|
-
ts: ['index.ts.ejs'].map(mapper('ts')),
|
|
17
|
-
compiled: ['client.js.ejs', 'client.d.ts.ejs'].map(mapper('compiled')),
|
|
18
|
-
python: ['__init__.py'].map(mapper('python')),
|
|
19
|
-
};
|
|
20
|
-
const templateFiles = templates.reduce((acc, template) => {
|
|
21
|
-
if (template in builtInTemplatesMap) {
|
|
22
|
-
return [...acc, ...builtInTemplatesMap[template]];
|
|
23
|
-
}
|
|
24
|
-
return [...acc, {
|
|
25
|
-
templatePath: path.resolve(cwd, template),
|
|
26
|
-
outPath: path.join(clientOutDirAbsolutePath, path.basename(template).replace('.ejs', ''))
|
|
27
|
-
}];
|
|
28
|
-
}, []);
|
|
12
|
+
const templateFiles = getClientTemplates({ config, cwd, templateNames: templates });
|
|
29
13
|
// Ensure that each segment has a matching schema if it needs to be emitted:
|
|
30
14
|
for (let i = 0; i < segments.length; i++) {
|
|
31
15
|
const { segmentName } = segments[i];
|
|
@@ -39,7 +23,7 @@ export default async function generateClient({ projectInfo, segments, segmentsSc
|
|
|
39
23
|
const now = Date.now();
|
|
40
24
|
// Data for the EJS templates:
|
|
41
25
|
const ejsData = {
|
|
42
|
-
|
|
26
|
+
apiRoot,
|
|
43
27
|
fetcherClientImportPath,
|
|
44
28
|
schemaOutImportPath,
|
|
45
29
|
validateOnClientImportPath,
|
|
@@ -69,7 +53,7 @@ export default async function generateClient({ projectInfo, segments, segmentsSc
|
|
|
69
53
|
if (fullSchema) {
|
|
70
54
|
const fullSchemaOutAbsolutePath = path.resolve(clientOutDirAbsolutePath, typeof fullSchema === 'string' ? fullSchema : 'full-schema.json');
|
|
71
55
|
await fs.writeFile(fullSchemaOutAbsolutePath, JSON.stringify(segmentsSchema, null, 2));
|
|
72
|
-
log.info(`Full schema written to ${fullSchemaOutAbsolutePath}`);
|
|
56
|
+
log.info(`Full schema has ben written to ${fullSchemaOutAbsolutePath}`);
|
|
73
57
|
}
|
|
74
58
|
// 2. Check if any file needs rewriting
|
|
75
59
|
const anyNeedsWriting = processedTemplates.some(({ needsWriting }) => needsWriting);
|
|
@@ -18,6 +18,7 @@ export default async function getConfig({ clientOutDir, cwd }) {
|
|
|
18
18
|
logLevel: env.VOVK_LOG_LEVEL ?? conf.logLevel ?? 'info',
|
|
19
19
|
prettifyClient: (env.VOVK_PRETTIFY_CLIENT ? !!env.VOVK_PRETTIFY_CLIENT : null) ?? conf.prettifyClient ?? false,
|
|
20
20
|
devHttps: (env.VOVK_DEV_HTTPS ? !!env.VOVK_DEV_HTTPS : null) ?? conf.devHttps ?? false,
|
|
21
|
+
clientGenerateTemplateNames: conf.clientGenerateTemplateNames ?? ['compiled'],
|
|
21
22
|
templates: {
|
|
22
23
|
service: 'vovk-cli/templates/service.ejs',
|
|
23
24
|
controller: 'vovk-cli/templates/controller.ejs',
|
|
@@ -6,7 +6,7 @@ export default async function getProjectInfo({ port: givenPort, clientOutDir, cw
|
|
|
6
6
|
// Make PORT available to the config file at getConfig
|
|
7
7
|
process.env.PORT = port;
|
|
8
8
|
const { config, srcRoot, configAbsolutePaths, userConfig, error } = await getConfig({ clientOutDir, cwd });
|
|
9
|
-
const
|
|
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
12
|
const fetcherClientImportPath = config.fetcher.startsWith('.')
|
|
@@ -25,7 +25,7 @@ export default async function getProjectInfo({ port: givenPort, clientOutDir, cw
|
|
|
25
25
|
return {
|
|
26
26
|
cwd,
|
|
27
27
|
port,
|
|
28
|
-
|
|
28
|
+
apiRoot,
|
|
29
29
|
apiDir,
|
|
30
30
|
srcRoot,
|
|
31
31
|
schemaOutImportPath,
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { Command } from 'commander';
|
|
|
7
7
|
import concurrently from 'concurrently';
|
|
8
8
|
import getAvailablePort from './utils/getAvailablePort.mjs';
|
|
9
9
|
import getProjectInfo from './getProjectInfo/index.mjs';
|
|
10
|
-
import
|
|
10
|
+
import generate from './generate/index.mjs';
|
|
11
11
|
import locateSegments from './locateSegments.mjs';
|
|
12
12
|
import { VovkDev } from './dev/index.mjs';
|
|
13
13
|
import newComponents from './new/index.mjs';
|
|
@@ -66,19 +66,18 @@ program
|
|
|
66
66
|
.alias('g')
|
|
67
67
|
.description('Generate client')
|
|
68
68
|
.option('--out, --client-out-dir <path>', 'Path to output directory')
|
|
69
|
-
.option('--template, --templates <templates...>', 'Client code templates')
|
|
70
|
-
.option('--no-client', 'Do not generate client')
|
|
69
|
+
.option('--template, --templates <templates...>', 'Client code templates ("ts", "compiled", "python", "none", a custom path)')
|
|
71
70
|
.option('--full-schema [fileName]', 'Generate client with full schema')
|
|
72
71
|
.option('--prettify', 'Prettify output files')
|
|
73
72
|
.action(async (options) => {
|
|
74
|
-
const { clientOutDir, templates, prettify,
|
|
73
|
+
const { clientOutDir, templates, prettify, fullSchema } = options;
|
|
75
74
|
const projectInfo = await getProjectInfo({ clientOutDir });
|
|
76
75
|
const { cwd, config, apiDir } = projectInfo;
|
|
77
76
|
const segments = await locateSegments({ dir: apiDir, config });
|
|
78
77
|
const schemaOutAbsolutePath = path.join(cwd, config.schemaOutDir);
|
|
79
78
|
const schemaImportUrl = pathToFileURL(path.join(schemaOutAbsolutePath, 'index.js')).href;
|
|
80
79
|
const { default: segmentsSchema } = await import(schemaImportUrl);
|
|
81
|
-
await
|
|
80
|
+
await generate({ projectInfo, segments, segmentsSchema, templates, prettify, fullSchema });
|
|
82
81
|
});
|
|
83
82
|
program
|
|
84
83
|
.command('new [components...]')
|
package/dist/postinstall.mjs
CHANGED
|
@@ -7,9 +7,9 @@ import path from 'node:path';
|
|
|
7
7
|
*/
|
|
8
8
|
const getFileSystemEntryType = async (filePath) => !!(await fs.stat(filePath).catch(() => false));
|
|
9
9
|
async function postinstall() {
|
|
10
|
-
const vovk = path.join(import.meta.dirname, '../../.vovk');
|
|
11
|
-
const js = path.join(vovk, '
|
|
12
|
-
const ts = path.join(vovk, '
|
|
10
|
+
const vovk = path.join(import.meta.dirname, '../../.vovk-client');
|
|
11
|
+
const js = path.join(vovk, 'compiled.js');
|
|
12
|
+
const ts = path.join(vovk, 'compiled.d.ts');
|
|
13
13
|
const index = path.join(vovk, 'index.ts');
|
|
14
14
|
if ((await getFileSystemEntryType(js)) ||
|
|
15
15
|
(await getFileSystemEntryType(ts)) ||
|
package/dist/types.d.mts
CHANGED
|
@@ -30,6 +30,7 @@ export type VovkConfig = {
|
|
|
30
30
|
logLevel?: LogLevelNames;
|
|
31
31
|
prettifyClient?: boolean;
|
|
32
32
|
devHttps?: boolean;
|
|
33
|
+
clientGenerateTemplateNames?: string[];
|
|
33
34
|
templates?: {
|
|
34
35
|
service?: string;
|
|
35
36
|
controller?: string;
|
|
@@ -52,7 +53,6 @@ export interface GenerateOptions {
|
|
|
52
53
|
templates?: string[];
|
|
53
54
|
prettify?: boolean;
|
|
54
55
|
fullSchema?: string | boolean;
|
|
55
|
-
noClient?: boolean;
|
|
56
56
|
}
|
|
57
57
|
export interface InitOptions {
|
|
58
58
|
yes?: boolean;
|
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.43",
|
|
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.35"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@inquirer/prompts": "^7.1.0",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { VovkSchema } from 'vovk';
|
|
2
|
-
import type { ProjectInfo } from './getProjectInfo/index.mjs';
|
|
3
|
-
import type { Segment } from './locateSegments.mjs';
|
|
4
|
-
import { GenerateOptions } from './types.mjs';
|
|
5
|
-
export default function generateClient({ projectInfo, segments, segmentsSchema, templates, prettify: prettifyClient, fullSchema, noClient, }: {
|
|
6
|
-
projectInfo: ProjectInfo;
|
|
7
|
-
segments: Segment[];
|
|
8
|
-
segmentsSchema: Record<string, VovkSchema>;
|
|
9
|
-
} & Pick<GenerateOptions, 'templates' | 'prettify' | 'fullSchema' | 'noClient'>): Promise<{
|
|
10
|
-
written: boolean;
|
|
11
|
-
path: string;
|
|
12
|
-
}>;
|