vovk-cli 0.0.1-beta.20 → 0.0.1-beta.21

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.
@@ -85,7 +85,7 @@ const prefix = '${apiEntryPoint}';
85
85
  ts = await prettify(ts, localTsAbsolutePath);
86
86
  }
87
87
  if (existingJs === js && existingDts === dts && existingTs === ts) {
88
- log.info(`Client is up to date and doesn't need to be regenerated (${Date.now() - now}ms)`);
88
+ log.debug(`Client is up to date and doesn't need to be regenerated (${Date.now() - now}ms)`);
89
89
  return { written: false, path: clientoOutDirAbsolutePath };
90
90
  }
91
91
  await fs.mkdir(clientoOutDirAbsolutePath, { recursive: true });
@@ -2,6 +2,6 @@ import type { VovkConfig } from '../types.mjs';
2
2
  export default function getConfig({ clientOutDir }: {
3
3
  clientOutDir?: string;
4
4
  }): Promise<{
5
- config: Required<Omit<VovkConfig, "_devForceAppDir">>;
5
+ config: Required<VovkConfig>;
6
6
  srcRoot: string;
7
7
  }>;
@@ -17,12 +17,12 @@ export default async function getConfig({ clientOutDir }) {
17
17
  logLevel: env.VOVK_LOG_LEVEL ?? userConfig.logLevel ?? 'debug', // TODO: change to 'warn' when v3 is ready
18
18
  prettifyClient: userConfig.prettifyClient ?? false,
19
19
  templates: {
20
+ // TODO individual templates for each validation library
20
21
  service: 'vovk-cli/templates/service.ejs',
21
22
  controller: 'vovk-cli/templates/controller.ejs',
22
23
  worker: 'vovk-cli/templates/worker.ejs',
23
24
  ...userConfig.templates,
24
25
  },
25
26
  };
26
- // forceAppDir is used for testing purposes
27
27
  return { config, srcRoot };
28
28
  }
@@ -11,7 +11,7 @@ export default function getProjectInfo({ port: givenPort, clientOutDir, }?: {
11
11
  schemaOutImportPath: string;
12
12
  fetcherClientImportPath: string;
13
13
  validateOnClientImportPath: string | null;
14
- config: Required<Omit<import("../types.mjs").VovkConfig, "_devForceAppDir">>;
14
+ config: Required<import("../types.mjs").VovkConfig>;
15
15
  log: {
16
16
  info: (msg: string) => void;
17
17
  warn: (msg: string) => void;
@@ -48,7 +48,9 @@ export default async function newModule({ what, moduleNameWithOptionalSegment, d
48
48
  }
49
49
  for (const type of what) {
50
50
  const templatePath = templates[type];
51
- const templateAbsolutePath = path.join(cwd, '../..', templatePath); // TODO WRONG, use import.meta.resolve, also in other modules for fetcher, validateOnClient, etc.
51
+ const templateAbsolutePath = templatePath.startsWith('/') || templatePath.startsWith('.')
52
+ ? path.resolve(cwd, templatePath)
53
+ : path.resolve(cwd, './node_modules', templatePath);
52
54
  const templateCode = await fs.readFile(templateAbsolutePath, 'utf-8');
53
55
  const { fileName, className, rpcName, code } = await render(templateCode, {
54
56
  config,
@@ -56,8 +58,7 @@ export default async function newModule({ what, moduleNameWithOptionalSegment, d
56
58
  segmentName,
57
59
  moduleName,
58
60
  });
59
- console.log(config.modulesDir, fileName);
60
- const absoluteModulePath = path.join(config.modulesDir, fileName);
61
+ const absoluteModulePath = path.join(cwd, config.modulesDir, fileName);
61
62
  const dirName = path.dirname(absoluteModulePath);
62
63
  const prettiedCode = await prettify(code, absoluteModulePath);
63
64
  if (!dryRun) {
@@ -72,7 +73,7 @@ export default async function newModule({ what, moduleNameWithOptionalSegment, d
72
73
  if (type === 'controller' || type === 'worker') {
73
74
  const { routeFilePath } = segment;
74
75
  const segmentSourceCode = await fs.readFile(routeFilePath, 'utf-8');
75
- const importPath = path.relative(dirName, fileName); // TODO WRONG
76
+ const importPath = path.relative(dirName, absoluteModulePath).replace(/\.(ts|tsx)$/, '');
76
77
  const newSegmentCode = addClassToSegmentCode(segmentSourceCode, {
77
78
  className,
78
79
  rpcName,
@@ -194,7 +194,11 @@ export class VovkCLIWatcher {
194
194
  log.debug(`Requesting schema for ${formatLoggedSegmentName(segmentName)} at ${endpoint}`);
195
195
  const resp = await fetch(endpoint);
196
196
  if (resp.status !== 200) {
197
- log.warn(`Schema request to ${formatLoggedSegmentName(segmentName)} failed with status code ${resp.status}. Expected 200.`);
197
+ const probableCause = {
198
+ 404: 'The segment is not compiled.',
199
+ 500: 'Syntax error in one of controllers.',
200
+ }[resp.status];
201
+ log.warn(`Schema request to ${formatLoggedSegmentName(segmentName)} failed with status code ${resp.status} but expected 200.${probableCause ? ` Probable cause: ${probableCause}` : ''}`);
198
202
  return;
199
203
  }
200
204
  let schema = null;
@@ -25,7 +25,7 @@ export default function logDiffResult(segmentName, diffResult, projectInfo) {
25
25
  diffNormalized.push({ what: 'controllerHandler', type: 'changed', name: `${handler.nameOfClass}.${name}` });
26
26
  });
27
27
  });
28
- const LIMIT = 5;
28
+ const LIMIT = diffNormalized.length < 12 ? diffNormalized.length : 10;
29
29
  for (const diffNormalizedItem of diffNormalized.slice(0, LIMIT)) {
30
30
  switch (diffNormalizedItem.what) {
31
31
  case 'worker':
@@ -74,6 +74,6 @@ export default function logDiffResult(segmentName, diffResult, projectInfo) {
74
74
  }
75
75
  }
76
76
  if (diffNormalized.length > LIMIT) {
77
- projectInfo.log.info(`...and ${diffNormalized.length - LIMIT} more changes`);
77
+ projectInfo.log.info(`... and ${diffNormalized.length - LIMIT} more changes`);
78
78
  }
79
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk-cli",
3
- "version": "0.0.1-beta.20",
3
+ "version": "0.0.1-beta.21",
4
4
  "bin": {
5
5
  "vovk": "./dist/index.mjs"
6
6
  },