vovk-cli 0.0.1-beta.16 → 0.0.1-beta.18
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/generateClient.mjs +1 -1
- package/dist/getProjectInfo/getConfig.mjs +1 -1
- package/dist/index.mjs +1 -2
- package/dist/utils/chalkHighlightThing.d.mts +1 -0
- package/dist/utils/chalkHighlightThing.mjs +4 -0
- package/dist/utils/formatLoggedSegmentName.mjs +2 -2
- package/dist/utils/getLogger.mjs +1 -1
- package/dist/watcher/index.mjs +4 -3
- package/dist/watcher/logDiffResult.mjs +10 -10
- package/package.json +2 -2
package/dist/generateClient.mjs
CHANGED
|
@@ -81,7 +81,7 @@ const prefix = '${projectInfo.apiEntryPoint}';
|
|
|
81
81
|
const existingDts = await fs.readFile(localDtsPath, 'utf-8').catch(() => '');
|
|
82
82
|
const existingTs = await fs.readFile(localTsPath, 'utf-8').catch(() => '');
|
|
83
83
|
if (existingJs === js && existingDts === dts && existingTs === ts) {
|
|
84
|
-
projectInfo.log.info(`Client is up to date and doesn't need to be regenerated (${Date.now() - now}ms)
|
|
84
|
+
projectInfo.log.info(`Client is up to date and doesn't need to be regenerated (${Date.now() - now}ms)`);
|
|
85
85
|
return { written: false, path: clientoOutDirFullPath };
|
|
86
86
|
}
|
|
87
87
|
await fs.mkdir(clientoOutDirFullPath, { recursive: true });
|
|
@@ -10,7 +10,7 @@ export default async function getConfig({ clientOutDir }) {
|
|
|
10
10
|
validationLibrary: env.VOVK_VALIDATION_LIBRARY ?? userConfig.validationLibrary ?? null,
|
|
11
11
|
fetcher: env.VOVK_FETCHER ?? userConfig.fetcher ?? 'vovk/client/defaultFetcher',
|
|
12
12
|
schemaOutDir: env.VOVK_SCHEMA_OUT_DIR ?? userConfig.schemaOutDir ?? './.vovk-schema',
|
|
13
|
-
clientOutDir: clientOutDir ?? env.VOVK_CLIENT_OUT_DIR ?? userConfig.clientOutDir ?? './node_modules/.vovk',
|
|
13
|
+
clientOutDir: clientOutDir ?? env.VOVK_CLIENT_OUT_DIR ?? userConfig.clientOutDir ?? './node_modules/.vovk-client',
|
|
14
14
|
origin: (env.VOVK_ORIGIN ?? userConfig.origin ?? '').replace(/\/$/, ''), // Remove trailing slash
|
|
15
15
|
rootEntry: env.VOVK_ROOT_ENTRY ?? userConfig.rootEntry ?? 'api',
|
|
16
16
|
rootSegmentModulesDirName: env.VOVK_ROOT_SEGMENT_MODULES_DIR_NAME ?? userConfig.rootSegmentModulesDirName ?? '',
|
package/dist/index.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function chalkHighlightThing(str: string): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import chalkHighlightThing from './chalkHighlightThing.mjs';
|
|
2
2
|
export default function formatLoggedSegmentName(segmentName, withChalk = false) {
|
|
3
3
|
const text = segmentName ? `segment "${segmentName}"` : 'the root segment';
|
|
4
|
-
return withChalk ?
|
|
4
|
+
return withChalk ? chalkHighlightThing(text) : text;
|
|
5
5
|
}
|
package/dist/utils/getLogger.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import chalk from 'chalk';
|
|
|
2
2
|
import loglevel from 'loglevel';
|
|
3
3
|
export default function getLogger(level) {
|
|
4
4
|
const log = {
|
|
5
|
-
info: (msg) => loglevel.info(chalk.
|
|
5
|
+
info: (msg) => loglevel.info(chalk.white(`🐺 ${msg}`)),
|
|
6
6
|
warn: (msg) => loglevel.warn(chalk.yellowBright(`🐺 ${msg}`)),
|
|
7
7
|
error: (msg) => loglevel.error(chalk.redBright(`🐺 ${msg}`)),
|
|
8
8
|
debug: (msg) => loglevel.debug(chalk.gray(`🐺 ${msg}`)),
|
package/dist/watcher/index.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import debounce from 'lodash/debounce.js';
|
|
|
12
12
|
import isEmpty from 'lodash/isEmpty.js';
|
|
13
13
|
import formatLoggedSegmentName from '../utils/formatLoggedSegmentName.mjs';
|
|
14
14
|
import keyBy from 'lodash/keyBy.js';
|
|
15
|
+
import capitalize from 'lodash/capitalize.js';
|
|
15
16
|
export class VovkCLIWatcher {
|
|
16
17
|
#projectInfo;
|
|
17
18
|
#segments = [];
|
|
@@ -38,7 +39,7 @@ export class VovkCLIWatcher {
|
|
|
38
39
|
this.#segments = this.#segments.find((s) => s.segmentName === segmentName)
|
|
39
40
|
? this.#segments
|
|
40
41
|
: [...this.#segments, { routeFilePath: filePath, segmentName }];
|
|
41
|
-
log.info(
|
|
42
|
+
log.info(`${capitalize(formatLoggedSegmentName(segmentName, true))} has been added`);
|
|
42
43
|
log.debug(`Full list of segments: ${this.#segments.map((s) => s.segmentName).join(', ')}`);
|
|
43
44
|
void debouncedEnsureSchemaFiles(schemaOutFullPath, this.#segments.map((s) => s.segmentName), this.#projectInfo // TODO refactor
|
|
44
45
|
);
|
|
@@ -71,7 +72,7 @@ export class VovkCLIWatcher {
|
|
|
71
72
|
if (segmentReg.test(filePath)) {
|
|
72
73
|
const segmentName = getSegmentName(filePath);
|
|
73
74
|
this.#segments = this.#segments.filter((s) => s.segmentName !== segmentName);
|
|
74
|
-
log.info(
|
|
75
|
+
log.info(`${capitalize(formatLoggedSegmentName(segmentName, true))} has been removed`);
|
|
75
76
|
log.debug(`Full list of segments: ${this.#segments.map((s) => s.segmentName).join(', ')}`);
|
|
76
77
|
void debouncedEnsureSchemaFiles(schemaOutFullPath, this.#segments.map((s) => s.segmentName), this.#projectInfo // TODO refactor
|
|
77
78
|
);
|
|
@@ -168,7 +169,7 @@ export class VovkCLIWatcher {
|
|
|
168
169
|
return;
|
|
169
170
|
const nameOfClasReg = /\bclass\s+([A-Za-z_]\w*)(?:\s*<[^>]*>)?\s*\{/g;
|
|
170
171
|
const namesOfClasses = [...code.matchAll(nameOfClasReg)].map((match) => match[1]);
|
|
171
|
-
const importRegex = /import\s*{[^}]*\b(
|
|
172
|
+
const importRegex = /import\s*{[^}]*\b(get|post|put|del|head|options|worker)\b[^}]*}\s*from\s*['"]vovk['"]/;
|
|
172
173
|
if (importRegex.test(code) && namesOfClasses.length) {
|
|
173
174
|
const affectedSegments = this.#segments.filter((s) => {
|
|
174
175
|
const schema = this.#schemas[s.segmentName];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
1
|
import formatLoggedSegmentName from '../utils/formatLoggedSegmentName.mjs';
|
|
2
|
+
import chalkHighlightThing from '../utils/chalkHighlightThing.mjs';
|
|
3
3
|
export default function logDiffResult(segmentName, diffResult, projectInfo) {
|
|
4
4
|
const diffNormalized = [];
|
|
5
5
|
diffResult.workers.added.forEach((name) => {
|
|
@@ -31,43 +31,43 @@ export default function logDiffResult(segmentName, diffResult, projectInfo) {
|
|
|
31
31
|
case 'worker':
|
|
32
32
|
switch (diffNormalizedItem.type) {
|
|
33
33
|
case 'added':
|
|
34
|
-
projectInfo.log.info(`Schema for worker ${
|
|
34
|
+
projectInfo.log.info(`Schema for worker ${chalkHighlightThing(diffNormalizedItem.name)} has been added at ${formatLoggedSegmentName(segmentName, true)}`);
|
|
35
35
|
break;
|
|
36
36
|
case 'removed':
|
|
37
|
-
projectInfo.log.info(`Schema for worker ${
|
|
37
|
+
projectInfo.log.info(`Schema for worker ${chalkHighlightThing(diffNormalizedItem.name)} has been removed from ${formatLoggedSegmentName(segmentName, true)}`);
|
|
38
38
|
break;
|
|
39
39
|
}
|
|
40
40
|
break;
|
|
41
41
|
case 'controller':
|
|
42
42
|
switch (diffNormalizedItem.type) {
|
|
43
43
|
case 'added':
|
|
44
|
-
projectInfo.log.info(`Schema for controller ${
|
|
44
|
+
projectInfo.log.info(`Schema for controller ${chalkHighlightThing(diffNormalizedItem.name)} has been added at ${formatLoggedSegmentName(segmentName, true)}`);
|
|
45
45
|
break;
|
|
46
46
|
case 'removed':
|
|
47
|
-
projectInfo.log.info(`Schema for controller ${
|
|
47
|
+
projectInfo.log.info(`Schema for controller ${chalkHighlightThing(diffNormalizedItem.name)} has been removed from ${formatLoggedSegmentName(segmentName, true)}`);
|
|
48
48
|
break;
|
|
49
49
|
}
|
|
50
50
|
break;
|
|
51
51
|
case 'workerHandler':
|
|
52
52
|
switch (diffNormalizedItem.type) {
|
|
53
53
|
case 'added':
|
|
54
|
-
projectInfo.log.info(`Schema for worker method ${
|
|
54
|
+
projectInfo.log.info(`Schema for worker method ${chalkHighlightThing(diffNormalizedItem.name)} has been added at ${formatLoggedSegmentName(segmentName, true)}`);
|
|
55
55
|
break;
|
|
56
56
|
case 'removed':
|
|
57
|
-
projectInfo.log.info(`Schema for worker method ${
|
|
57
|
+
projectInfo.log.info(`Schema for worker method ${chalkHighlightThing(diffNormalizedItem.name)} has been removed from ${formatLoggedSegmentName(segmentName, true)}`);
|
|
58
58
|
break;
|
|
59
59
|
}
|
|
60
60
|
break;
|
|
61
61
|
case 'controllerHandler':
|
|
62
62
|
switch (diffNormalizedItem.type) {
|
|
63
63
|
case 'added':
|
|
64
|
-
projectInfo.log.info(`Schema for controller method ${
|
|
64
|
+
projectInfo.log.info(`Schema for controller method ${chalkHighlightThing(diffNormalizedItem.name)} has been added at ${formatLoggedSegmentName(segmentName, true)}`);
|
|
65
65
|
break;
|
|
66
66
|
case 'removed':
|
|
67
|
-
projectInfo.log.info(`Schema for controller method ${
|
|
67
|
+
projectInfo.log.info(`Schema for controller method ${chalkHighlightThing(diffNormalizedItem.name)} has been removed from ${formatLoggedSegmentName(segmentName, true)}`);
|
|
68
68
|
break;
|
|
69
69
|
case 'changed':
|
|
70
|
-
projectInfo.log.info(`Schema for controller method ${
|
|
70
|
+
projectInfo.log.info(`Schema for controller method ${chalkHighlightThing(diffNormalizedItem.name)} has been changed at ${formatLoggedSegmentName(segmentName, true)}`);
|
|
71
71
|
break;
|
|
72
72
|
}
|
|
73
73
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vovk-cli",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.18",
|
|
4
4
|
"bin": {
|
|
5
5
|
"vovk": "./dist/index.mjs"
|
|
6
6
|
},
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://vovk.dev",
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"vovk": "^3.0.0-beta.
|
|
34
|
+
"vovk": "^3.0.0-beta.29"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@inquirer/prompts": "^5.5.0",
|