vovk-cli 0.0.1-draft.310 → 0.0.1-draft.313
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/dist/bundle/index.mjs +1 -0
- package/dist/dev/index.mjs +3 -2
- package/dist/generate/generate.d.mts +2 -1
- package/dist/generate/generate.mjs +3 -1
- package/dist/generate/writeOneClientFile.d.mts +2 -1
- package/dist/generate/writeOneClientFile.mjs +4 -2
- package/dist/getProjectInfo/getConfig/index.d.mts +2 -1
- package/dist/getProjectInfo/getConfig/index.mjs +1 -0
- package/package.json +2 -2
package/dist/bundle/index.mjs
CHANGED
package/dist/dev/index.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import { locateSegments } from '../locateSegments.mjs';
|
|
|
18
18
|
import debounceWithArgs from '../utils/debounceWithArgs.mjs';
|
|
19
19
|
import formatLoggedSegmentName from '../utils/formatLoggedSegmentName.mjs';
|
|
20
20
|
import writeMetaJson from './writeMetaJson.mjs';
|
|
21
|
+
import chalkHighlightThing from '../utils/chalkHighlightThing.mjs';
|
|
21
22
|
export class VovkDev {
|
|
22
23
|
#projectInfo;
|
|
23
24
|
#segments = [];
|
|
@@ -265,7 +266,7 @@ export class VovkDev {
|
|
|
265
266
|
const probableCause = {
|
|
266
267
|
404: 'The segment did not compile or config.origin is wrong.',
|
|
267
268
|
}[resp.status];
|
|
268
|
-
log.warn(`Schema request to ${endpoint} for ${formatLoggedSegmentName(segmentName)} failed with status code ${resp.status} but expected 200.${probableCause ? ` Probable cause: ${probableCause}` : ''}. Response text will be logged below on "debug" level.`);
|
|
269
|
+
log.warn(`Schema request to ${chalkHighlightThing(endpoint)} for ${formatLoggedSegmentName(segmentName)} failed with status code ${resp.status} but expected 200.${probableCause ? ` Probable cause: ${probableCause}` : ''}. Response text will be logged below on "debug" level.`);
|
|
269
270
|
log.debug(`Response from ${formatLoggedSegmentName(segmentName)}: ${text}`);
|
|
270
271
|
return { isError: true };
|
|
271
272
|
}
|
|
@@ -288,7 +289,7 @@ export class VovkDev {
|
|
|
288
289
|
async #handleSegmentSchema(segmentName, segmentSchema) {
|
|
289
290
|
const { log, config, cwd } = this.#projectInfo;
|
|
290
291
|
if (!segmentSchema) {
|
|
291
|
-
log.warn(`${formatLoggedSegmentName(segmentName)} schema is null`);
|
|
292
|
+
log.warn(`${formatLoggedSegmentName(segmentName, { upperFirst: true })} schema is null`);
|
|
292
293
|
return;
|
|
293
294
|
}
|
|
294
295
|
log.debug(`Handling received schema from ${formatLoggedSegmentName(segmentName)}`);
|
|
@@ -3,8 +3,9 @@ import type { PackageJson } from 'type-fest';
|
|
|
3
3
|
import type { ProjectInfo } from '../getProjectInfo/index.mjs';
|
|
4
4
|
import type { GenerateOptions } from '../types.mjs';
|
|
5
5
|
import type { Segment } from '../locateSegments.mjs';
|
|
6
|
-
export declare function generate({ isEnsuringClient, projectInfo, forceNothingWrittenLog, fullSchema, locatedSegments, cliGenerateOptions, package: argPackageJson, readme: argReadme, }: {
|
|
6
|
+
export declare function generate({ isEnsuringClient, isBundle, projectInfo, forceNothingWrittenLog, fullSchema, locatedSegments, cliGenerateOptions, package: argPackageJson, readme: argReadme, }: {
|
|
7
7
|
isEnsuringClient?: boolean;
|
|
8
|
+
isBundle?: boolean;
|
|
8
9
|
projectInfo: ProjectInfo;
|
|
9
10
|
forceNothingWrittenLog?: boolean;
|
|
10
11
|
fullSchema: VovkSchema;
|
|
@@ -86,7 +86,7 @@ const cliOptionsToOpenAPIMixins = ({ openapiGetMethodName, openapiGetModuleName,
|
|
|
86
86
|
},
|
|
87
87
|
]));
|
|
88
88
|
};
|
|
89
|
-
export async function generate({ isEnsuringClient = false, projectInfo, forceNothingWrittenLog, fullSchema, locatedSegments, cliGenerateOptions, package: argPackageJson, readme: argReadme, }) {
|
|
89
|
+
export async function generate({ isEnsuringClient = false, isBundle = false, projectInfo, forceNothingWrittenLog, fullSchema, locatedSegments, cliGenerateOptions, package: argPackageJson, readme: argReadme, }) {
|
|
90
90
|
fullSchema = {
|
|
91
91
|
...fullSchema,
|
|
92
92
|
// sort segments by name to avoid unnecessary rendering
|
|
@@ -173,6 +173,7 @@ export async function generate({ isEnsuringClient = false, projectInfo, forceNot
|
|
|
173
173
|
hasMixins,
|
|
174
174
|
isVovkProject,
|
|
175
175
|
vovkCliPackage,
|
|
176
|
+
isBundle,
|
|
176
177
|
});
|
|
177
178
|
const outAbsoluteDir = path.resolve(cwd, outCwdRelativeDir);
|
|
178
179
|
return {
|
|
@@ -258,6 +259,7 @@ export async function generate({ isEnsuringClient = false, projectInfo, forceNot
|
|
|
258
259
|
hasMixins,
|
|
259
260
|
isVovkProject,
|
|
260
261
|
vovkCliPackage,
|
|
262
|
+
isBundle,
|
|
261
263
|
});
|
|
262
264
|
return {
|
|
263
265
|
written,
|
|
@@ -5,7 +5,7 @@ import type { ClientTemplateFile } from './getClientTemplateFiles.mjs';
|
|
|
5
5
|
import type { ClientImports } from './getTemplateClientImports.mjs';
|
|
6
6
|
import type { Segment } from '../locateSegments.mjs';
|
|
7
7
|
export declare function normalizeOutTemplatePath(out: string, packageJson: PackageJson): string;
|
|
8
|
-
export default function writeOneClientFile({ cwd, projectInfo, clientTemplateFile, fullSchema, prettifyClient, segmentName, imports, templateContent, matterResult: { data, content }, package: packageJson, readme, isEnsuringClient, outCwdRelativeDir, origin, templateDef, locatedSegments, isNodeNextResolution, hasMixins, isVovkProject, vovkCliPackage, }: {
|
|
8
|
+
export default function writeOneClientFile({ cwd, projectInfo, clientTemplateFile, fullSchema, prettifyClient, segmentName, imports, templateContent, matterResult: { data, content }, package: packageJson, readme, isEnsuringClient, outCwdRelativeDir, origin, templateDef, locatedSegments, isNodeNextResolution, hasMixins, isVovkProject, vovkCliPackage, isBundle, }: {
|
|
9
9
|
cwd: string;
|
|
10
10
|
projectInfo: ProjectInfo;
|
|
11
11
|
clientTemplateFile: ClientTemplateFile;
|
|
@@ -31,6 +31,7 @@ export default function writeOneClientFile({ cwd, projectInfo, clientTemplateFil
|
|
|
31
31
|
hasMixins: boolean;
|
|
32
32
|
isVovkProject: boolean;
|
|
33
33
|
vovkCliPackage: PackageJson;
|
|
34
|
+
isBundle: boolean;
|
|
34
35
|
}): Promise<{
|
|
35
36
|
written: boolean;
|
|
36
37
|
}>;
|
|
@@ -11,7 +11,7 @@ import { compileJSONSchemaToTypeScriptType } from '../utils/compileJSONSchemaToT
|
|
|
11
11
|
export function normalizeOutTemplatePath(out, packageJson) {
|
|
12
12
|
return out.replace('[package_name]', packageJson.name?.replace(/-/g, '_') ?? 'my_package_name');
|
|
13
13
|
}
|
|
14
|
-
export default async function writeOneClientFile({ cwd, projectInfo, clientTemplateFile, fullSchema, prettifyClient, segmentName, imports, templateContent, matterResult: { data, content }, package: packageJson, readme, isEnsuringClient, outCwdRelativeDir, origin, templateDef, locatedSegments, isNodeNextResolution, hasMixins, isVovkProject, vovkCliPackage, }) {
|
|
14
|
+
export default async function writeOneClientFile({ cwd, projectInfo, clientTemplateFile, fullSchema, prettifyClient, segmentName, imports, templateContent, matterResult: { data, content }, package: packageJson, readme, isEnsuringClient, outCwdRelativeDir, origin, templateDef, locatedSegments, isNodeNextResolution, hasMixins, isVovkProject, vovkCliPackage, isBundle, }) {
|
|
15
15
|
const { config, apiRoot } = projectInfo;
|
|
16
16
|
const { templateFilePath, relativeDir } = clientTemplateFile;
|
|
17
17
|
const locatedSegmentsByName = _.keyBy(locatedSegments, 'segmentName');
|
|
@@ -62,10 +62,12 @@ export default async function writeOneClientFile({ cwd, projectInfo, clientTempl
|
|
|
62
62
|
const segmentImportPath = routeFilePath
|
|
63
63
|
? path.relative(path.resolve(cwd, outCwdRelativeDir, typeof segmentName === 'string' ? segmentName || ROOT_SEGMENT_FILE_NAME : '.'), path.resolve(cwd, routeFilePath))
|
|
64
64
|
: null;
|
|
65
|
-
const
|
|
65
|
+
const segmentConfig = {
|
|
66
66
|
...(config.segmentConfig ? config.segmentConfig[sName] : {}),
|
|
67
67
|
...(templateDef.segmentConfig ? templateDef.segmentConfig[sName] : {}),
|
|
68
68
|
};
|
|
69
|
+
const { origin: segmentConfigOrigin, rootEntry: segmentConfigRootEntry, segmentNameOverride } = segmentConfig;
|
|
70
|
+
const reExports = { ...segmentConfig.reExports, ...(isBundle ? projectInfo.config.bundle.reExports : {}) };
|
|
69
71
|
return [
|
|
70
72
|
sName,
|
|
71
73
|
{
|
|
@@ -13,7 +13,7 @@ export default function getConfig({ configPath, cwd }: {
|
|
|
13
13
|
modulesDir?: string;
|
|
14
14
|
rootEntry?: string;
|
|
15
15
|
origin?: string;
|
|
16
|
-
logLevel?: "error" | "trace" | "debug" | "info" | "warn";
|
|
16
|
+
logLevel?: "error" | "trace" | "debug" | "info" | "warn" | (string & {});
|
|
17
17
|
prettifyClient?: boolean;
|
|
18
18
|
libs?: {
|
|
19
19
|
ajv: import("vovk").KnownAny;
|
|
@@ -60,6 +60,7 @@ export default function getConfig({ configPath, cwd }: {
|
|
|
60
60
|
readme?: {
|
|
61
61
|
banner?: string;
|
|
62
62
|
};
|
|
63
|
+
reExports?: Record<string, string>;
|
|
63
64
|
tsdownBuildOptions?: Parameters<typeof import("tsdown/config-9hj-APNF.mjs").build>[0];
|
|
64
65
|
} & ({
|
|
65
66
|
excludeSegments?: never;
|
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.313",
|
|
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.355"
|
|
39
39
|
},
|
|
40
40
|
"optionalDependencies": {
|
|
41
41
|
"vovk-python": "^0.0.1-draft.58"
|