vovk-cli 0.0.1-draft.181 → 0.0.1-draft.183
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/ts/index.ts.ejs +1 -1
- package/dist/generate/index.mjs +6 -0
- package/dist/generate/writeOneClientFile.d.mts +2 -1
- package/dist/generate/writeOneClientFile.mjs +2 -1
- package/dist/getProjectInfo/getConfig/index.mjs +1 -1
- package/dist/init/createConfig.mjs +1 -1
- package/dist/new/render.mjs +1 -1
- package/module-templates/{service.ts.ejs → Service.ts.ejs} +1 -1
- package/package.json +1 -1
- /package/module-templates/{controller.ts.ejs → Controller.ts.ejs} +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { VovkClientFetcher } from 'vovk';
|
|
3
3
|
import { fetcher } from '<%= t.imports.fetcher %>';
|
|
4
4
|
import { createRPC } from '<%= t.imports.createRPC %>';
|
|
5
|
-
import { schema } from './schema.
|
|
5
|
+
import { schema } from './schema<%= t.nodeNextResolutionTsExt %>';
|
|
6
6
|
<% Object.values(t.schema.segments).filter((segment) => segment.emitSchema).forEach((segment, i) => { %>
|
|
7
7
|
import type { Controllers as Controllers<%= i %> } from "<%= t.segmentMeta[segment.segmentName].segmentImportPath %>";
|
|
8
8
|
<% }) %>
|
package/dist/generate/index.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import getTemplateClientImports from './getTemplateClientImports.mjs';
|
|
|
10
10
|
import mergePackages from './mergePackages.mjs';
|
|
11
11
|
import writeOneClientFile from './writeOneClientFile.mjs';
|
|
12
12
|
import { ROOT_SEGMENT_SCHEMA_NAME } from '../dev/writeOneSegmentSchemaFile.mjs';
|
|
13
|
+
import { getTsconfig } from 'get-tsconfig';
|
|
13
14
|
const getIncludedSegmentNames = (config, fullSchema, configKey, cliGenerateOptions) => {
|
|
14
15
|
const segments = Object.values(fullSchema.segments);
|
|
15
16
|
const includeSegments = cliGenerateOptions?.[configKey === 'segmentedClient' ? 'segmentedIncludeSegments' : 'composedIncludeSegments'] ??
|
|
@@ -52,9 +53,12 @@ function logClientGenerationResults({ results, log, isEnsuringClient = false, fo
|
|
|
52
53
|
export default async function generate({ isEnsuringClient = false, projectInfo, forceNothingWrittenLog, fullSchema, locatedSegments, cliGenerateOptions, }) {
|
|
53
54
|
fullSchema = {
|
|
54
55
|
...fullSchema,
|
|
56
|
+
// sort segments by name to avoid unnecessary rendering
|
|
55
57
|
segments: Object.fromEntries(Object.entries(fullSchema.segments).sort(([a], [b]) => a.localeCompare(b))),
|
|
56
58
|
};
|
|
57
59
|
const { config, cwd, log } = projectInfo;
|
|
60
|
+
const tsConfigResult = await getTsconfig(cwd);
|
|
61
|
+
const isNodeNextResolution = ['node16', 'nodenext'].includes(tsConfigResult?.config?.compilerOptions?.moduleResolution?.toLowerCase() ?? '');
|
|
58
62
|
const isComposedEnabled = cliGenerateOptions?.composedOnly ||
|
|
59
63
|
!!cliGenerateOptions?.composedFrom ||
|
|
60
64
|
!!cliGenerateOptions?.composedOut ||
|
|
@@ -105,6 +109,7 @@ export default async function generate({ isEnsuringClient = false, projectInfo,
|
|
|
105
109
|
origin: config.origin ?? templateDef?.origin ?? null,
|
|
106
110
|
templateDef,
|
|
107
111
|
locatedSegments,
|
|
112
|
+
isNodeNextResolution,
|
|
108
113
|
});
|
|
109
114
|
const outAbsoluteDir = path.join(cwd, outCwdRelativeDir);
|
|
110
115
|
return {
|
|
@@ -174,6 +179,7 @@ export default async function generate({ isEnsuringClient = false, projectInfo,
|
|
|
174
179
|
origin: config.origin ?? templateDef?.origin ?? null,
|
|
175
180
|
templateDef,
|
|
176
181
|
locatedSegments,
|
|
182
|
+
isNodeNextResolution,
|
|
177
183
|
});
|
|
178
184
|
return {
|
|
179
185
|
written,
|
|
@@ -4,7 +4,7 @@ import type { ClientTemplateFile } from './getClientTemplateFiles.mjs';
|
|
|
4
4
|
import type { ClientImports } from './getTemplateClientImports.mjs';
|
|
5
5
|
import type { PackageJson } from 'type-fest';
|
|
6
6
|
import type { Segment } from '../locateSegments.mjs';
|
|
7
|
-
export default function writeOneClientFile({ cwd, projectInfo, clientTemplateFile, fullSchema, prettifyClient, segmentName, imports, templateContent, matterResult: { data, content }, package: packageJson, isEnsuringClient, outCwdRelativeDir, origin, templateDef, locatedSegments, }: {
|
|
7
|
+
export default function writeOneClientFile({ cwd, projectInfo, clientTemplateFile, fullSchema, prettifyClient, segmentName, imports, templateContent, matterResult: { data, content }, package: packageJson, isEnsuringClient, outCwdRelativeDir, origin, templateDef, locatedSegments, isNodeNextResolution, }: {
|
|
8
8
|
cwd: string;
|
|
9
9
|
projectInfo: ProjectInfo;
|
|
10
10
|
clientTemplateFile: ClientTemplateFile;
|
|
@@ -25,6 +25,7 @@ export default function writeOneClientFile({ cwd, projectInfo, clientTemplateFil
|
|
|
25
25
|
origin: string | null;
|
|
26
26
|
templateDef: VovkStrictConfig['clientTemplateDefs'][string];
|
|
27
27
|
locatedSegments: Segment[];
|
|
28
|
+
isNodeNextResolution: boolean;
|
|
28
29
|
}): Promise<{
|
|
29
30
|
written: boolean;
|
|
30
31
|
}>;
|
|
@@ -5,7 +5,7 @@ import _ from 'lodash';
|
|
|
5
5
|
import { VovkSchemaIdEnum } from 'vovk';
|
|
6
6
|
import prettify from '../utils/prettify.mjs';
|
|
7
7
|
import { ROOT_SEGMENT_SCHEMA_NAME, SEGMENTS_SCHEMA_DIR_NAME } from '../dev/writeOneSegmentSchemaFile.mjs';
|
|
8
|
-
export default async function writeOneClientFile({ cwd, projectInfo, clientTemplateFile, fullSchema, prettifyClient, segmentName, imports, templateContent, matterResult: { data, content }, package: packageJson, isEnsuringClient, outCwdRelativeDir, origin, templateDef, locatedSegments, }) {
|
|
8
|
+
export default async function writeOneClientFile({ cwd, projectInfo, clientTemplateFile, fullSchema, prettifyClient, segmentName, imports, templateContent, matterResult: { data, content }, package: packageJson, isEnsuringClient, outCwdRelativeDir, origin, templateDef, locatedSegments, isNodeNextResolution, }) {
|
|
9
9
|
const { config, apiRoot } = projectInfo;
|
|
10
10
|
const { templateFilePath, relativeDir } = clientTemplateFile;
|
|
11
11
|
const locatedSegmentsByName = _.keyBy(locatedSegments, 'segmentName');
|
|
@@ -24,6 +24,7 @@ export default async function writeOneClientFile({ cwd, projectInfo, clientTempl
|
|
|
24
24
|
imports,
|
|
25
25
|
schema: fullSchema,
|
|
26
26
|
VovkSchemaIdEnum,
|
|
27
|
+
nodeNextResolutionTsExt: isNodeNextResolution ? '.ts' : '',
|
|
27
28
|
schemaOutDir: typeof segmentName === 'string'
|
|
28
29
|
? path.relative(path.join(outCwdRelativeDir, segmentName || ROOT_SEGMENT_SCHEMA_NAME), config.schemaOutDir)
|
|
29
30
|
: path.relative(outCwdRelativeDir, config.schemaOutDir),
|
|
@@ -61,7 +61,7 @@ export default async function getConfig({ configPath, cwd }) {
|
|
|
61
61
|
devHttps: (env.VOVK_DEV_HTTPS ? !!env.VOVK_DEV_HTTPS : null) ?? conf.devHttps ?? false,
|
|
62
62
|
moduleTemplates: {
|
|
63
63
|
service: 'vovk-cli/module-templates/service.ts.ejs',
|
|
64
|
-
controller: 'vovk-cli/module-templates/
|
|
64
|
+
controller: 'vovk-cli/module-templates/Controller.ts.ejs',
|
|
65
65
|
...conf.moduleTemplates,
|
|
66
66
|
},
|
|
67
67
|
libs: conf.libs ?? {},
|
|
@@ -12,7 +12,7 @@ export default async function createConfig({ root, log, options: { validationLib
|
|
|
12
12
|
.then((content) => JSON.parse(content).type === 'module');
|
|
13
13
|
const configAbsolutePath = path.join(dir, isModule ? 'vovk.config.mjs' : 'vovk.config.js');
|
|
14
14
|
const moduleTemplates = {
|
|
15
|
-
controller: 'vovk-cli/module-templates/
|
|
15
|
+
controller: 'vovk-cli/module-templates/Controller.ts.ejs',
|
|
16
16
|
service: 'vovk-cli/module-templates/service.ts.ejs',
|
|
17
17
|
};
|
|
18
18
|
if (validationLibrary) {
|
package/dist/new/render.mjs
CHANGED
|
@@ -30,7 +30,7 @@ export default async function render(codeTemplate, { config, withService, segmen
|
|
|
30
30
|
config,
|
|
31
31
|
withService,
|
|
32
32
|
segmentName,
|
|
33
|
-
|
|
33
|
+
nodeNextResolutionTsExt: isNodeNextResolution ? '.ts' : '',
|
|
34
34
|
defaultDir: getModuleDirName(segmentName, theThing),
|
|
35
35
|
// libraries
|
|
36
36
|
_, // lodash
|
|
@@ -9,7 +9,7 @@ sourceName: <%= vars.ServiceName %>
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
import type { VovkBody, VovkQuery } from 'vovk';
|
|
12
|
-
import type <%= vars.rpcModuleName %> from './<%= vars.rpcModuleName %><%= t.
|
|
12
|
+
import type <%= vars.rpcModuleName %> from './<%= vars.rpcModuleName %><%= t.nodeNextResolutionTsExt %>';
|
|
13
13
|
|
|
14
14
|
export default class <%= vars.ServiceName %> {
|
|
15
15
|
static get<%= t.TheThings %> = (search: VovkQuery<typeof <%= vars.rpcModuleName %>.get<%= t.TheThings %>>['search']) => {
|
package/package.json
CHANGED
|
File without changes
|