vovk-cli 0.0.1-draft.360 → 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 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 dirName in template file; relative to the root of the project')
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')
@@ -9,6 +9,7 @@ export default async function createConfig({ root, log, options: { validationLib
9
9
  const dir = (await getFileSystemEntryType(dotConfigPath)) === FileSystemEntryType.DIRECTORY ? dotConfigPath : root;
10
10
  const isModule = await fs
11
11
  .readFile(path.join(root, 'package.json'), 'utf-8')
12
+ .catch(() => '{}')
12
13
  .then((content) => JSON.parse(content).type === 'module');
13
14
  const configAbsolutePath = path.join(dir, isModule ? 'vovk.config.mjs' : 'vovk.config.js');
14
15
  const typeTemplates = {
@@ -173,10 +173,11 @@ export class Init {
173
173
  });
174
174
  }
175
175
  if (!(await getFileSystemEntryType(path.join(root, 'package.json')))) {
176
- log.warn(`package.json not found at ${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
- log.warn(`tsconfig.json not found at ${root}. Run "npx tsc --init" to create a new tsconfig.json file.`);
180
+ log.warn(`${chalkHighlightThing('tsconfig.json')} not found at ${chalkHighlightThing(root)}. Run "npx tsc --init" to create a new tsconfig.json file.`);
180
181
  }
181
182
  if (configPaths.length) {
182
183
  if (!(await confirm({
@@ -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, dir, templates, overwrite, noSegmentUpdate, empty, static: isStaticSegment }: NewOptions): Promise<void>;
3
+ export declare function newComponents(components: string[], projectInfo: ProjectInfo, { dryRun, outDir, templates, overwrite, noSegmentUpdate, empty, static: isStaticSegment }: NewOptions): Promise<void>;
@@ -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, dir, templates, overwrite, noSegmentUpdate, empty, static: isStaticSegment }) {
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
- dir,
30
+ outDir,
31
31
  templates,
32
32
  overwrite,
33
33
  noSegmentUpdate,
@@ -1,10 +1,10 @@
1
1
  import type { ProjectInfo } from '../getProjectInfo/index.mjs';
2
- export default function newModule({ projectInfo, what, moduleNameWithOptionalSegment, dryRun, dir: dirFlag, templates: templatesFlag, noSegmentUpdate, overwrite, empty, }: {
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
- dir?: string;
7
+ outDir?: string;
8
8
  templates?: string[];
9
9
  noSegmentUpdate?: boolean;
10
10
  overwrite?: boolean;
@@ -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, dir: dirFlag, templates: templatesFlag, noSegmentUpdate, overwrite, empty, }) {
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 { dir: renderedDir, fileName, sourceName, compiledName, code, } = await render(templateCode, {
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 dir = dirFlag || renderedDir;
72
- if (!dir) {
73
- throw new Error(`The template for "${type}" does not provide a dir`);
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, dir);
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) {
@@ -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 { dir, fileName, sourceName, compiledName } = parsed.data;
45
+ const { outDir, fileName, sourceName, compiledName } = parsed.data;
46
46
  const code = empty ? (sourceName ? `export default class ${sourceName} {}` : '') : parsed.content;
47
47
  return {
48
- dir,
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
- dir: string;
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
- dir?: string;
75
+ outDir?: string;
76
76
  overwrite?: boolean;
77
77
  noSegmentUpdate?: boolean;
78
78
  empty?: boolean;
@@ -3,7 +3,7 @@
3
3
  ServiceName: t.TheThing + 'Service',
4
4
  }; %>
5
5
  ---
6
- dir: <%= t.defaultDir %>
6
+ outDir: <%= t.defaultOutDir %>
7
7
  fileName: <%= vars.ModuleName + '.ts' %>
8
8
  sourceName: <%= vars.ModuleName %>
9
9
  compiledName: <%= t.TheThing + 'RPC' %>
@@ -3,7 +3,7 @@
3
3
  ServiceName: t.TheThing + 'Service',
4
4
  }; %>
5
5
  ---
6
- dir: <%= t.defaultDir %>
6
+ outDir: <%= t.defaultOutDir %>
7
7
  fileName: <%= vars.rpcModuleName + '.ts' %>
8
8
  sourceName: <%= vars.rpcModuleName %>
9
9
  compiledName: <%= t.TheThing + 'RPC' %>
@@ -3,7 +3,7 @@
3
3
  ServiceName: t.TheThing + 'Service',
4
4
  }; %>
5
5
  ---
6
- dir: <%= t.defaultDir %>
6
+ outDir: <%= t.defaultOutDir %>
7
7
  fileName: <%= vars.ServiceName + '.ts' %>
8
8
  sourceName: <%= vars.ServiceName %>
9
9
  ---
@@ -3,7 +3,7 @@
3
3
  ServiceName: t.TheThing + 'Service',
4
4
  }; %>
5
5
  ---
6
- dir: <%= t.defaultDir %>
6
+ outDir: <%= t.defaultOutDir %>
7
7
  fileName: <%= vars.ModuleName + '.ts' %>
8
8
  sourceName: <%= vars.ModuleName %>
9
9
  compiledName: <%= t.TheThing + 'RPC' %>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk-cli",
3
- "version": "0.0.1-draft.360",
3
+ "version": "0.0.1-draft.362",
4
4
  "bin": {
5
5
  "vovk": "./dist/index.mjs"
6
6
  },