vovk-cli 0.0.1-draft.361 → 0.0.1-draft.362
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/index.mjs +1 -1
- package/dist/init/index.mjs +2 -1
- package/dist/new/index.d.mts +1 -1
- package/dist/new/index.mjs +2 -2
- package/dist/new/newModule.d.mts +2 -2
- package/dist/new/newModule.mjs +6 -6
- package/dist/new/render.mjs +2 -2
- package/dist/types.d.mts +2 -2
- package/module-templates/arktype/controller.ts.ejs +1 -1
- package/module-templates/type/controller.ts.ejs +1 -1
- package/module-templates/type/service.ts.ejs +1 -1
- package/module-templates/valibot/controller.ts.ejs +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -157,7 +157,7 @@ program
|
|
|
157
157
|
.description('Create new components. "vovk new [...components] [segmentName/]moduleName" to create a new module or "vovk new segment [segmentName]" to create a new segment')
|
|
158
158
|
.option('-o, --overwrite', 'overwrite existing files')
|
|
159
159
|
.option('--template, --templates <templates...>', 'override config template; accepts an array of strings that correspond the order of the components')
|
|
160
|
-
.option('--dir <dirname>', 'override
|
|
160
|
+
.option('--out, --out-dir <dirname>', 'override outDir in template file; relative to the root of the project')
|
|
161
161
|
.option('--empty', 'create an empty module')
|
|
162
162
|
.option('--no-segment-update', 'do not update segment files when creating a new module')
|
|
163
163
|
.option('--dry-run', 'do not write files to disk')
|
package/dist/init/index.mjs
CHANGED
|
@@ -173,7 +173,8 @@ export class Init {
|
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
if (!(await getFileSystemEntryType(path.join(root, 'package.json')))) {
|
|
176
|
-
log.warn(`${chalkHighlightThing('package.json')} not found at ${chalkHighlightThing(root)}. Run "npx create-next-app" to create a new Next.js project
|
|
176
|
+
log.warn(`${chalkHighlightThing('package.json')} not found at ${chalkHighlightThing(root)}. Run "npx create-next-app" to create a new Next.js project
|
|
177
|
+
.`);
|
|
177
178
|
}
|
|
178
179
|
else if (pkgJson && !(await getFileSystemEntryType(path.join(root, 'tsconfig.json')))) {
|
|
179
180
|
log.warn(`${chalkHighlightThing('tsconfig.json')} not found at ${chalkHighlightThing(root)}. Run "npx tsc --init" to create a new tsconfig.json file.`);
|
package/dist/new/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { NewOptions } from '../types.mjs';
|
|
2
2
|
import type { ProjectInfo } from '../getProjectInfo/index.mts';
|
|
3
|
-
export declare function newComponents(components: string[], projectInfo: ProjectInfo, { dryRun,
|
|
3
|
+
export declare function newComponents(components: string[], projectInfo: ProjectInfo, { dryRun, outDir, templates, overwrite, noSegmentUpdate, empty, static: isStaticSegment }: NewOptions): Promise<void>;
|
package/dist/new/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import newModule from './newModule.mjs';
|
|
2
2
|
import newSegment from './newSegment.mjs';
|
|
3
|
-
export async function newComponents(components, projectInfo, { dryRun,
|
|
3
|
+
export async function newComponents(components, projectInfo, { dryRun, outDir, templates, overwrite, noSegmentUpdate, empty, static: isStaticSegment }) {
|
|
4
4
|
if (components[0] === 'segment' || components[0] === 'segments') {
|
|
5
5
|
// vovk new segment [segmentName]
|
|
6
6
|
let segmentNames = components
|
|
@@ -27,7 +27,7 @@ export async function newComponents(components, projectInfo, { dryRun, dir, temp
|
|
|
27
27
|
projectInfo,
|
|
28
28
|
what,
|
|
29
29
|
moduleNameWithOptionalSegment,
|
|
30
|
-
|
|
30
|
+
outDir,
|
|
31
31
|
templates,
|
|
32
32
|
overwrite,
|
|
33
33
|
noSegmentUpdate,
|
package/dist/new/newModule.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ProjectInfo } from '../getProjectInfo/index.mjs';
|
|
2
|
-
export default function newModule({ projectInfo, what, moduleNameWithOptionalSegment, dryRun,
|
|
2
|
+
export default function newModule({ projectInfo, what, moduleNameWithOptionalSegment, dryRun, outDir: outDirFlag, templates: templatesFlag, noSegmentUpdate, overwrite, empty, }: {
|
|
3
3
|
projectInfo: ProjectInfo;
|
|
4
4
|
what: string[];
|
|
5
5
|
moduleNameWithOptionalSegment: string;
|
|
6
6
|
dryRun?: boolean;
|
|
7
|
-
|
|
7
|
+
outDir?: string;
|
|
8
8
|
templates?: string[];
|
|
9
9
|
noSegmentUpdate?: boolean;
|
|
10
10
|
overwrite?: boolean;
|
package/dist/new/newModule.mjs
CHANGED
|
@@ -19,7 +19,7 @@ function splitByLast(str, delimiter = '/') {
|
|
|
19
19
|
const after = str.substring(index + delimiter.length);
|
|
20
20
|
return [before, after];
|
|
21
21
|
}
|
|
22
|
-
export default async function newModule({ projectInfo, what, moduleNameWithOptionalSegment, dryRun,
|
|
22
|
+
export default async function newModule({ projectInfo, what, moduleNameWithOptionalSegment, dryRun, outDir: outDirFlag, templates: templatesFlag, noSegmentUpdate, overwrite, empty, }) {
|
|
23
23
|
const { config, log, cwd, apiDirAbsolutePath } = projectInfo;
|
|
24
24
|
const segments = await locateSegments({ dir: apiDirAbsolutePath, config, log });
|
|
25
25
|
const isNodeNextResolution = ['node16', 'nodenext'].includes((await getTsconfig(cwd)?.config?.compilerOptions?.moduleResolution?.toLowerCase()) ?? '');
|
|
@@ -58,7 +58,7 @@ export default async function newModule({ projectInfo, what, moduleNameWithOptio
|
|
|
58
58
|
const templatePath = templates[type];
|
|
59
59
|
const templateAbsolutePath = resolveAbsoluteModulePath(templatePath, cwd);
|
|
60
60
|
const templateCode = await fs.readFile(templateAbsolutePath, 'utf-8');
|
|
61
|
-
const {
|
|
61
|
+
const { outDir: renderedOutDir, fileName, sourceName, compiledName, code, } = await render(templateCode, {
|
|
62
62
|
cwd,
|
|
63
63
|
config,
|
|
64
64
|
withService: what.includes('service'),
|
|
@@ -68,14 +68,14 @@ export default async function newModule({ projectInfo, what, moduleNameWithOptio
|
|
|
68
68
|
templateFileName: templateAbsolutePath,
|
|
69
69
|
isNodeNextResolution,
|
|
70
70
|
});
|
|
71
|
-
const
|
|
72
|
-
if (!
|
|
73
|
-
throw new Error(`The template for "${type}" does not provide a
|
|
71
|
+
const outDir = outDirFlag || renderedOutDir;
|
|
72
|
+
if (!outDir) {
|
|
73
|
+
throw new Error(`The template for "${type}" does not provide a outDir`);
|
|
74
74
|
}
|
|
75
75
|
if (!fileName) {
|
|
76
76
|
throw new Error(`The template for "${type}" does not provide a fileName`);
|
|
77
77
|
}
|
|
78
|
-
const absoluteModuleDir = path.join(cwd,
|
|
78
|
+
const absoluteModuleDir = path.join(cwd, outDir);
|
|
79
79
|
const absoluteModulePath = path.join(absoluteModuleDir, fileName);
|
|
80
80
|
const prettiedCode = await prettify(code, absoluteModulePath);
|
|
81
81
|
if (!dryRun) {
|
package/dist/new/render.mjs
CHANGED
|
@@ -42,10 +42,10 @@ export default async function render(codeTemplate, { config, withService, segmen
|
|
|
42
42
|
pluralize,
|
|
43
43
|
};
|
|
44
44
|
const parsed = matter((await ejs.render(codeTemplate, { t }, { async: true, filename: templateFileName })).trim());
|
|
45
|
-
const {
|
|
45
|
+
const { outDir, fileName, sourceName, compiledName } = parsed.data;
|
|
46
46
|
const code = empty ? (sourceName ? `export default class ${sourceName} {}` : '') : parsed.content;
|
|
47
47
|
return {
|
|
48
|
-
|
|
48
|
+
outDir,
|
|
49
49
|
fileName,
|
|
50
50
|
sourceName,
|
|
51
51
|
compiledName,
|
package/dist/types.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import type { build } from 'tsdown';
|
|
|
3
3
|
import type { VovkStrictConfig } from 'vovk';
|
|
4
4
|
export type VovkModuleRenderResult = {
|
|
5
5
|
fileName: string;
|
|
6
|
-
|
|
6
|
+
outDir: string;
|
|
7
7
|
sourceName?: string;
|
|
8
8
|
compiledName?: string;
|
|
9
9
|
code: string;
|
|
@@ -72,7 +72,7 @@ export interface InitOptions {
|
|
|
72
72
|
export interface NewOptions {
|
|
73
73
|
dryRun?: boolean;
|
|
74
74
|
templates?: string[];
|
|
75
|
-
|
|
75
|
+
outDir?: string;
|
|
76
76
|
overwrite?: boolean;
|
|
77
77
|
noSegmentUpdate?: boolean;
|
|
78
78
|
empty?: boolean;
|