vovk-cli 0.0.1-draft.390 → 0.0.1-draft.393
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.
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
3
|
import matter from 'gray-matter';
|
|
4
4
|
import _ from 'lodash';
|
|
5
|
-
import {
|
|
5
|
+
import { openAPIToVovkSchema, vovkSchemaToOpenAPI, } from 'vovk';
|
|
6
6
|
import getClientTemplateFiles from './getClientTemplateFiles.mjs';
|
|
7
7
|
import chalkHighlightThing from '../utils/chalkHighlightThing.mjs';
|
|
8
8
|
import pickSegmentFullSchema from '../utils/pickSegmentFullSchema.mjs';
|
|
@@ -142,18 +142,15 @@ export async function generate({ isEnsuringClient = false, isBundle = false, pro
|
|
|
142
142
|
const matterResult = templateFilePath.endsWith('.ejs')
|
|
143
143
|
? matter(templateContent)
|
|
144
144
|
: { data: { imports: [] }, content: templateContent };
|
|
145
|
-
const { package: packageJson, readme, origin, samples, reExports, } =
|
|
145
|
+
const { package: packageJson, readme, origin, samples, reExports, openAPIObject, } = vovkSchemaToOpenAPI({
|
|
146
146
|
config: projectInfo.config,
|
|
147
|
+
rootEntry: config.rootEntry,
|
|
147
148
|
schema: fullSchema,
|
|
148
149
|
outputConfigs: [templateDef.outputConfig ?? {}, { origin: cliGenerateOptions?.origin }],
|
|
149
150
|
projectPackageJson,
|
|
150
151
|
isBundle,
|
|
151
152
|
segmentName: null,
|
|
152
153
|
});
|
|
153
|
-
const openapi = vovkSchemaToOpenAPI({
|
|
154
|
-
schema: fullSchema,
|
|
155
|
-
rootEntry: config.rootEntry,
|
|
156
|
-
});
|
|
157
154
|
const composedFullSchema = pickSegmentFullSchema(fullSchema, segmentNames);
|
|
158
155
|
const hasMixins = Object.values(composedFullSchema.segments).some((segment) => segment.segmentType === 'mixin');
|
|
159
156
|
if (templateName === BuiltInTemplateName.mixins && !hasMixins) {
|
|
@@ -168,7 +165,7 @@ export async function generate({ isEnsuringClient = false, isBundle = false, pro
|
|
|
168
165
|
segmentName: null,
|
|
169
166
|
templateContent,
|
|
170
167
|
matterResult,
|
|
171
|
-
|
|
168
|
+
openAPIObject,
|
|
172
169
|
package: packageJson,
|
|
173
170
|
readme,
|
|
174
171
|
samples,
|
|
@@ -227,23 +224,19 @@ export async function generate({ isEnsuringClient = false, isBundle = false, pro
|
|
|
227
224
|
? matter(templateContent)
|
|
228
225
|
: { data: { imports: [] }, content: templateContent };
|
|
229
226
|
const results = await Promise.all(segmentNames.map(async (segmentName) => {
|
|
230
|
-
const { package: packageJson, readme, origin, samples, reExports, } = resolveGeneratorConfigValues({
|
|
231
|
-
config: projectInfo.config,
|
|
232
|
-
schema: fullSchema,
|
|
233
|
-
outputConfigs: [templateDef.outputConfig ?? {}, { origin: cliGenerateOptions?.origin }],
|
|
234
|
-
projectPackageJson,
|
|
235
|
-
segmentName,
|
|
236
|
-
isBundle,
|
|
237
|
-
});
|
|
238
227
|
const segmentedFullSchema = pickSegmentFullSchema(fullSchema, [segmentName]);
|
|
239
228
|
const hasMixins = Object.values(segmentedFullSchema.segments).some((segment) => segment.segmentType === 'mixin');
|
|
240
229
|
if (templateName === BuiltInTemplateName.mixins && !hasMixins) {
|
|
241
230
|
return null;
|
|
242
231
|
}
|
|
243
|
-
const
|
|
232
|
+
const { package: packageJson, readme, origin, samples, reExports, openAPIObject, } = vovkSchemaToOpenAPI({
|
|
233
|
+
config: projectInfo.config,
|
|
244
234
|
schema: fullSchema,
|
|
245
235
|
rootEntry: config.rootEntry,
|
|
246
236
|
segmentName,
|
|
237
|
+
outputConfigs: [templateDef.outputConfig ?? {}, { origin: cliGenerateOptions?.origin }],
|
|
238
|
+
isBundle,
|
|
239
|
+
projectPackageJson,
|
|
247
240
|
});
|
|
248
241
|
const { written } = await writeOneClientFile({
|
|
249
242
|
cwd,
|
|
@@ -254,7 +247,7 @@ export async function generate({ isEnsuringClient = false, isBundle = false, pro
|
|
|
254
247
|
segmentName,
|
|
255
248
|
templateContent,
|
|
256
249
|
matterResult,
|
|
257
|
-
|
|
250
|
+
openAPIObject,
|
|
258
251
|
package: packageJson,
|
|
259
252
|
readme,
|
|
260
253
|
samples,
|
|
@@ -4,12 +4,13 @@ export type ClientImports = {
|
|
|
4
4
|
validateOnClient: string | null;
|
|
5
5
|
createRPC: string;
|
|
6
6
|
};
|
|
7
|
-
export default function getTemplateClientImports({ config, fullSchema, outCwdRelativeDir, segmentName, isBundle, }: {
|
|
7
|
+
export default function getTemplateClientImports({ config, fullSchema, outCwdRelativeDir, segmentName, isBundle, outputConfigs, }: {
|
|
8
8
|
config: VovkStrictConfig;
|
|
9
9
|
fullSchema: VovkSchema;
|
|
10
10
|
outCwdRelativeDir: string;
|
|
11
11
|
segmentName: string | null;
|
|
12
12
|
isBundle: boolean;
|
|
13
|
+
outputConfigs: VovkStrictConfig['outputConfig'][];
|
|
13
14
|
}): {
|
|
14
15
|
composedClient: ClientImports & {
|
|
15
16
|
module: ClientImports;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { resolveGeneratorConfigValues } from 'vovk';
|
|
3
3
|
import { ROOT_SEGMENT_FILE_NAME } from '../dev/writeOneSegmentSchemaFile.mjs';
|
|
4
|
-
export default function getTemplateClientImports({ config, fullSchema, outCwdRelativeDir, segmentName, isBundle, }) {
|
|
4
|
+
export default function getTemplateClientImports({ config, fullSchema, outCwdRelativeDir, segmentName, isBundle, outputConfigs, }) {
|
|
5
5
|
const { imports: configImports } = resolveGeneratorConfigValues({
|
|
6
6
|
config,
|
|
7
7
|
schema: fullSchema,
|
|
8
8
|
segmentName,
|
|
9
9
|
isBundle,
|
|
10
|
+
projectPackageJson: undefined,
|
|
11
|
+
outputConfigs,
|
|
10
12
|
});
|
|
11
13
|
const validateOnClientImport = configImports?.validateOnClient ?? null;
|
|
12
14
|
const fetcherImport = configImports?.fetcher ?? 'vovk';
|
|
@@ -5,7 +5,7 @@ import type { ClientTemplateFile } from './getClientTemplateFiles.mjs';
|
|
|
5
5
|
import type { Segment } from '../locateSegments.mjs';
|
|
6
6
|
import { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
7
7
|
export declare function normalizeOutTemplatePath(out: string, packageJson: PackageJson): string;
|
|
8
|
-
export default function writeOneClientFile({ cwd, projectInfo, clientTemplateFile, fullSchema, prettifyClient, segmentName, templateContent, matterResult: { data, content },
|
|
8
|
+
export default function writeOneClientFile({ cwd, projectInfo, clientTemplateFile, fullSchema, prettifyClient, segmentName, templateContent, matterResult: { data, content }, openAPIObject, package: packageJson, readme, samples, reExports, isEnsuringClient, outCwdRelativeDir, templateDef, locatedSegments, isNodeNextResolution, hasMixins, isVovkProject, vovkCliPackage, isBundle, origin, configKey, cliSchemaPath, projectConfig, }: {
|
|
9
9
|
cwd: string;
|
|
10
10
|
projectInfo: ProjectInfo;
|
|
11
11
|
clientTemplateFile: ClientTemplateFile;
|
|
@@ -19,7 +19,7 @@ export default function writeOneClientFile({ cwd, projectInfo, clientTemplateFil
|
|
|
19
19
|
};
|
|
20
20
|
content: string;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
openAPIObject: OpenAPIObject;
|
|
23
23
|
package: PackageJson;
|
|
24
24
|
readme: VovkReadmeConfig;
|
|
25
25
|
samples: VovkSamplesConfig;
|
|
@@ -15,9 +15,7 @@ export function normalizeOutTemplatePath(out, packageJson) {
|
|
|
15
15
|
}
|
|
16
16
|
export default async function writeOneClientFile({ cwd, projectInfo, clientTemplateFile, fullSchema, prettifyClient, segmentName,
|
|
17
17
|
// imports,
|
|
18
|
-
templateContent, matterResult: { data, content },
|
|
19
|
-
// templateDef,
|
|
20
|
-
locatedSegments, isNodeNextResolution, hasMixins, isVovkProject, vovkCliPackage, isBundle, origin, configKey, cliSchemaPath, projectConfig, }) {
|
|
18
|
+
templateContent, matterResult: { data, content }, openAPIObject, package: packageJson, readme, samples, reExports, isEnsuringClient, outCwdRelativeDir, templateDef, locatedSegments, isNodeNextResolution, hasMixins, isVovkProject, vovkCliPackage, isBundle, origin, configKey, cliSchemaPath, projectConfig, }) {
|
|
21
19
|
const { config } = projectInfo;
|
|
22
20
|
const { templateFilePath, relativeDir } = clientTemplateFile;
|
|
23
21
|
const locatedSegmentsByName = _.keyBy(locatedSegments, 'segmentName');
|
|
@@ -51,7 +49,7 @@ locatedSegments, isNodeNextResolution, hasMixins, isVovkProject, vovkCliPackage,
|
|
|
51
49
|
readme,
|
|
52
50
|
samples,
|
|
53
51
|
reExports,
|
|
54
|
-
openapi,
|
|
52
|
+
openapi: openAPIObject,
|
|
55
53
|
ROOT_SEGMENT_FILE_NAME,
|
|
56
54
|
apiRoot: origin ? `${origin}/${config.rootEntry}` : undefined,
|
|
57
55
|
imports: {},
|
|
@@ -79,6 +77,7 @@ locatedSegments, isNodeNextResolution, hasMixins, isVovkProject, vovkCliPackage,
|
|
|
79
77
|
isBundle,
|
|
80
78
|
outCwdRelativeDir,
|
|
81
79
|
segmentName,
|
|
80
|
+
outputConfigs: [templateDef.outputConfig ?? {}],
|
|
82
81
|
})['composedClient'],
|
|
83
82
|
segmentImports: Object.fromEntries(Object.values(fullSchema.segments).map(({ segmentName: sName }) => {
|
|
84
83
|
const clientImports = getTemplateClientImports({
|
|
@@ -87,6 +86,7 @@ locatedSegments, isNodeNextResolution, hasMixins, isVovkProject, vovkCliPackage,
|
|
|
87
86
|
segmentName: sName,
|
|
88
87
|
isBundle,
|
|
89
88
|
outCwdRelativeDir,
|
|
89
|
+
outputConfigs: [templateDef.outputConfig ?? {}],
|
|
90
90
|
});
|
|
91
91
|
const imports = configKey === 'composedClient' ? clientImports['composedClient'] : clientImports['segmentedClient'][sName];
|
|
92
92
|
return [sName, imports];
|
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.393",
|
|
4
4
|
"bin": {
|
|
5
5
|
"vovk": "./dist/index.mjs"
|
|
6
6
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://vovk.dev",
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"vovk": "^3.0.0-draft.
|
|
38
|
+
"vovk": "^3.0.0-draft.469",
|
|
39
39
|
"vovk-ajv": "^0.0.0-draft.112",
|
|
40
40
|
"vovk-client": "^0.0.4-draft.139",
|
|
41
41
|
"vovk-python": "^0.0.1-draft.81",
|