vovk-cli 0.0.1-draft.333 → 0.0.1-draft.335
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/readme/README.md.ejs +3 -2
- package/client-templates/schemaCjs/schema.cjs.ejs +1 -4
- package/client-templates/schemaTs/schema.ts.ejs +1 -5
- package/dist/bundle/index.mjs +10 -10
- package/dist/dev/ensureSchemaFiles.d.mts +1 -1
- package/dist/dev/index.d.mts +1 -1
- package/dist/dev/index.mjs +28 -19
- package/dist/dev/writeMetaJson.d.mts +1 -1
- package/dist/dev/writeMetaJson.mjs +5 -2
- package/dist/generate/generate.d.mts +2 -5
- package/dist/generate/generate.mjs +38 -40
- package/dist/generate/getClientTemplateFiles.mjs +1 -1
- package/dist/generate/getProjectFullSchema.d.mts +5 -2
- package/dist/generate/getProjectFullSchema.mjs +7 -7
- package/dist/generate/index.mjs +3 -1
- package/dist/generate/writeOneClientFile.d.mts +4 -3
- package/dist/generate/writeOneClientFile.mjs +11 -5
- package/dist/getProjectInfo/getConfig/getTemplateDefs.mjs +3 -3
- package/dist/getProjectInfo/getConfig/index.d.mts +9 -51
- package/dist/getProjectInfo/getConfig/index.mjs +18 -16
- package/dist/getProjectInfo/getMetaSchema.d.mts +10 -0
- package/dist/getProjectInfo/getMetaSchema.mjs +13 -0
- package/dist/getProjectInfo/index.d.mts +4 -2
- package/dist/getProjectInfo/index.mjs +5 -2
- package/dist/index.mjs +25 -6
- package/dist/init/createConfig.mjs +26 -4
- package/dist/init/createStandardSchemaValidatorFile.d.mts +4 -0
- package/dist/init/createStandardSchemaValidatorFile.mjs +38 -0
- package/dist/init/index.mjs +47 -21
- package/dist/init/updateNPMScripts.d.mts +0 -1
- package/dist/init/updateNPMScripts.mjs +1 -5
- package/dist/initProgram.mjs +1 -1
- package/dist/new/index.d.mts +2 -1
- package/dist/new/index.mjs +3 -2
- package/dist/new/newModule.d.mts +3 -1
- package/dist/new/newModule.mjs +2 -3
- package/dist/new/newSegment.d.mts +3 -1
- package/dist/new/newSegment.mjs +2 -3
- package/dist/types.d.mts +8 -3
- package/dist/utils/generateFnName.d.mts +23 -0
- package/dist/utils/generateFnName.mjs +76 -0
- package/dist/utils/normalizeOpenAPIMixin.d.mts +14 -0
- package/dist/utils/normalizeOpenAPIMixin.mjs +114 -0
- package/module-templates/arktype/controller.ts.ejs +68 -0
- package/module-templates/valibot/controller.ts.ejs +68 -0
- package/package.json +2 -2
- package/dist/generate/mergePackages.d.mts +0 -7
- package/dist/generate/mergePackages.mjs +0 -55
- package/dist/utils/normalizeOpenAPIMixins.d.mts +0 -7
- package/dist/utils/normalizeOpenAPIMixins.mjs +0 -67
- /package/module-templates/{controller.ts.ejs → type/controller.ts.ejs} +0 -0
- /package/module-templates/{service.ts.ejs → type/service.ts.ejs} +0 -0
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import * as YAML from 'yaml';
|
|
4
|
-
import chalkHighlightThing from './chalkHighlightThing.mjs';
|
|
5
|
-
async function getOpenApiSpecLocal(openApiSpecFilePath, cwd) {
|
|
6
|
-
const openApiSpecAbsolutePath = path.resolve(cwd, openApiSpecFilePath);
|
|
7
|
-
const fileName = path.basename(openApiSpecAbsolutePath);
|
|
8
|
-
if (!fileName.endsWith('.json') && !fileName.endsWith('.yaml') && !fileName.endsWith('.yml')) {
|
|
9
|
-
throw new Error(`Invalid OpenAPI spec file format: ${fileName}. Please provide a JSON or YAML file.`);
|
|
10
|
-
}
|
|
11
|
-
const openApiSpecContent = await fs.readFile(openApiSpecAbsolutePath, 'utf8');
|
|
12
|
-
return (fileName.endsWith('.json') ? JSON.parse(openApiSpecContent) : YAML.parse(openApiSpecContent));
|
|
13
|
-
}
|
|
14
|
-
async function getOpenApiSpecRemote({ cwd, url, fallback, log, }) {
|
|
15
|
-
const resp = await fetch(url);
|
|
16
|
-
const text = await resp.text();
|
|
17
|
-
if (!resp.ok) {
|
|
18
|
-
if (fallback) {
|
|
19
|
-
log.warn(`Failed to fetch OpenAPI spec from ${chalkHighlightThing(url)}: ${resp.status} ${resp.statusText}. Falling back to ${chalkHighlightThing(fallback)}`);
|
|
20
|
-
return getOpenApiSpecLocal(fallback, cwd);
|
|
21
|
-
}
|
|
22
|
-
throw new Error(`Failed to fetch OpenAPI spec from ${chalkHighlightThing(url)}: ${resp.status} ${resp.statusText}`);
|
|
23
|
-
}
|
|
24
|
-
if (fallback) {
|
|
25
|
-
const fallbackAbsolutePath = path.resolve(cwd, fallback);
|
|
26
|
-
const existingFallback = await fs.readFile(fallbackAbsolutePath, 'utf8').catch(() => null);
|
|
27
|
-
if (existingFallback !== text) {
|
|
28
|
-
await fs.mkdir(path.dirname(fallbackAbsolutePath), { recursive: true });
|
|
29
|
-
await fs.writeFile(fallbackAbsolutePath, text);
|
|
30
|
-
log.info(`Saved OpenAPI spec to fallback file ${chalkHighlightThing(fallbackAbsolutePath)}`);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
log.debug(`OpenAPI spec at ${chalkHighlightThing(url)} is unchanged. Skipping write to fallback file ${chalkHighlightThing(fallbackAbsolutePath)}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return (text.trim().startsWith('{') || text.trim().startsWith('[') ? JSON.parse(text) : YAML.parse(text));
|
|
37
|
-
}
|
|
38
|
-
export async function normalizeOpenAPIMixins({ mixinModules, log, cwd = process.cwd(), }) {
|
|
39
|
-
if (mixinModules) {
|
|
40
|
-
const modules = await Promise.all(Object.entries(mixinModules).map(async ([mixinName, { source, apiRoot, getModuleName, getMethodName, errorMessageKey, package: packageJson },]) => {
|
|
41
|
-
let openAPIObject;
|
|
42
|
-
if ('url' in source) {
|
|
43
|
-
openAPIObject = await getOpenApiSpecRemote({ url: source.url, fallback: source.fallback, log, cwd });
|
|
44
|
-
}
|
|
45
|
-
else if ('file' in source) {
|
|
46
|
-
openAPIObject = await getOpenApiSpecLocal(source.file, cwd);
|
|
47
|
-
}
|
|
48
|
-
else if ('object' in source) {
|
|
49
|
-
openAPIObject = source.object;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
throw new Error('Invalid source type for OpenAPI configuration');
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
source: { object: openAPIObject },
|
|
56
|
-
apiRoot,
|
|
57
|
-
getModuleName,
|
|
58
|
-
getMethodName,
|
|
59
|
-
errorMessageKey,
|
|
60
|
-
package: packageJson,
|
|
61
|
-
mixinName,
|
|
62
|
-
};
|
|
63
|
-
}));
|
|
64
|
-
return Object.fromEntries(modules.map((module) => [module.mixinName, module]));
|
|
65
|
-
}
|
|
66
|
-
return {};
|
|
67
|
-
}
|
|
File without changes
|
|
File without changes
|