vovk-cli 0.0.1-draft.64 → 0.0.1-draft.66

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.
@@ -1,14 +1,16 @@
1
1
  <%- '// auto-generated\n/* eslint-disable */' %>
2
2
  import fetcherImport from '<%= fetcherClientImportPath %>';
3
- import createRPC from '<%= createRPCImportPath %>';
3
+ import createRPCImport from '<%= createRPCImportPath %>';
4
4
  import schema from '<%= schemaOutImportPath %>';
5
5
  <% if (validateOnClientImportPath) { %>
6
- import validateOnClient from '<%= validateOnClientImportPath %>';
6
+ import validateOnClientImport from '<%= validateOnClientImportPath %>';
7
+ const validateOnClient = validateOnClientImport.default || validateOnClientImport;
7
8
  <% } else { %>
8
9
  const validateOnClient = undefined;
9
10
  <% } %>
10
11
  const apiRoot = '<%= apiRoot %>';
11
12
  const fetcher = fetcherImport.default || fetcherImport;
13
+ const createRPC = createRPCImport.default || createRPCImport;
12
14
  <% segments.forEach((segment, i) => {
13
15
  Object.keys(segmentsSchema[segment.segmentName].controllers).forEach((key) => { %>
14
16
  export const <%= key %> = createRPC(
@@ -2,10 +2,11 @@ import type { VovkSchema } from 'vovk';
2
2
  import type { ProjectInfo } from '../getProjectInfo/index.mjs';
3
3
  import type { Segment } from '../locateSegments.mjs';
4
4
  import { GenerateOptions } from '../types.mjs';
5
- export default function generate({ projectInfo, segments, segmentsSchema, templates, prettify: prettifyClient, fullSchema, }: {
5
+ export default function generate({ projectInfo, segments, segmentsSchema, forceNothingWrittenLog, templates, prettify: prettifyClient, fullSchema, }: {
6
6
  projectInfo: ProjectInfo;
7
7
  segments: Segment[];
8
8
  segmentsSchema: Record<string, VovkSchema>;
9
+ forceNothingWrittenLog?: boolean;
9
10
  } & Pick<GenerateOptions, 'templates' | 'prettify' | 'fullSchema'>): Promise<{
10
11
  written: boolean;
11
12
  path: string;
@@ -4,7 +4,7 @@ import ejs from 'ejs';
4
4
  import formatLoggedSegmentName from '../utils/formatLoggedSegmentName.mjs';
5
5
  import prettify from '../utils/prettify.mjs';
6
6
  import getClientTemplates from './getClientTemplates.mjs';
7
- export default async function generate({ projectInfo, segments, segmentsSchema, templates, prettify: prettifyClient, fullSchema, }) {
7
+ export default async function generate({ projectInfo, segments, segmentsSchema, forceNothingWrittenLog, templates, prettify: prettifyClient, fullSchema, }) {
8
8
  templates = templates ?? projectInfo.config.experimental_clientGenerateTemplateNames;
9
9
  const noClient = templates?.[0] === 'none';
10
10
  const { config, cwd, log, validateOnClientImportPath, apiRoot, fetcherClientImportPath, createRPCImportPath, schemaOutImportPath, } = projectInfo;
@@ -63,7 +63,8 @@ export default async function generate({ projectInfo, segments, segmentsSchema,
63
63
  log.info(`Full schema has ben written to ${fullSchemaOutAbsolutePath}`);
64
64
  }
65
65
  if (!anyNeedsWriting) {
66
- log.debug(`Client is up to date and doesn't need to be regenerated (${Date.now() - now}ms)`);
66
+ const logOrDebug = forceNothingWrittenLog ? log.info : log.debug;
67
+ logOrDebug(`Client is up to date and doesn't need to be regenerated (${Date.now() - now}ms)`);
67
68
  return { written: false, path: clientOutDirAbsolutePath };
68
69
  }
69
70
  // Write updated files where needed
package/dist/index.mjs CHANGED
@@ -85,7 +85,15 @@ program
85
85
  const schemaOutAbsolutePath = path.join(cwd, config.schemaOutDir);
86
86
  const schemaImportUrl = pathToFileURL(path.join(schemaOutAbsolutePath, 'index.js')).href;
87
87
  const { default: segmentsSchema } = (await import(schemaImportUrl));
88
- await generate({ projectInfo, segments, segmentsSchema, templates, prettify, fullSchema });
88
+ await generate({
89
+ projectInfo,
90
+ segments,
91
+ segmentsSchema,
92
+ templates,
93
+ prettify,
94
+ fullSchema,
95
+ forceNothingWrittenLog: true,
96
+ });
89
97
  });
90
98
  program
91
99
  .command('new [components...]')
@@ -17,7 +17,7 @@ export default async function createConfig({ root, log, options: { validationLib
17
17
  };
18
18
  if (validationLibrary) {
19
19
  if (validateOnClient) {
20
- config.validateOnClientPath = `${validationLibrary}/validateOnClient`;
20
+ config.validateOnClientPath = `${validationLibrary}/validateOnClient/index.js`;
21
21
  }
22
22
  try {
23
23
  const validationTemplates = await getTemplateFilesFromPackage(validationLibrary, channel);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk-cli",
3
- "version": "0.0.1-draft.64",
3
+ "version": "0.0.1-draft.66",
4
4
  "bin": {
5
5
  "vovk": "./dist/index.mjs"
6
6
  },
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "homepage": "https://vovk.dev",
38
38
  "peerDependencies": {
39
- "vovk": "^3.0.0-draft.58"
39
+ "vovk": "^3.0.0-draft.65"
40
40
  },
41
41
  "dependencies": {
42
42
  "@inquirer/prompts": "^7.3.1",