vovk-cli 0.0.1-beta.24 → 0.0.1-beta.26
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/getProjectInfo/getConfig.d.mts +1 -0
- package/dist/getProjectInfo/getConfig.mjs +2 -2
- package/dist/getProjectInfo/getConfigPaths.d.mts +1 -0
- package/dist/getProjectInfo/getConfigPaths.mjs +22 -0
- package/dist/getProjectInfo/index.mjs +4 -1
- package/dist/getProjectInfo/readConfig.d.mts +4 -1
- package/dist/getProjectInfo/readConfig.mjs +8 -7
- package/dist/init/index.mjs +4 -3
- package/dist/watcher/index.mjs +2 -2
- package/dist/watcher/logDiffResult.mjs +11 -0
- package/package.json +1 -1
- package/dist/getProjectInfo/getConfigPath.d.mts +0 -1
- package/dist/getProjectInfo/getConfigPath.mjs +0 -18
|
@@ -2,7 +2,7 @@ import readConfig from './readConfig.mjs';
|
|
|
2
2
|
import getRelativeSrcRoot from './getRelativeSrcRoot.mjs';
|
|
3
3
|
export default async function getConfig({ clientOutDir }) {
|
|
4
4
|
const env = process.env;
|
|
5
|
-
const userConfig = await readConfig();
|
|
5
|
+
const { userConfig, configPaths } = await readConfig();
|
|
6
6
|
const srcRoot = await getRelativeSrcRoot();
|
|
7
7
|
const config = {
|
|
8
8
|
modulesDir: env.VOVK_MODULES_DIR ?? userConfig.modulesDir ?? './' + [srcRoot, 'modules'].filter(Boolean).join('/'),
|
|
@@ -24,5 +24,5 @@ export default async function getConfig({ clientOutDir }) {
|
|
|
24
24
|
...userConfig.templates,
|
|
25
25
|
},
|
|
26
26
|
};
|
|
27
|
-
return { config, srcRoot };
|
|
27
|
+
return { config, srcRoot, configPaths };
|
|
28
28
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getConfigPaths(relativePath?: string): Promise<string[]>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export default async function getConfigPaths(relativePath = '') {
|
|
4
|
+
const rootDir = path.resolve(process.cwd(), relativePath || '');
|
|
5
|
+
const baseName = 'vovk.config';
|
|
6
|
+
const extensions = ['cjs', 'mjs', 'js'];
|
|
7
|
+
const dirs = [path.join(rootDir, '.config'), rootDir];
|
|
8
|
+
const configs = [];
|
|
9
|
+
for (const ext of extensions) {
|
|
10
|
+
for (const dir of dirs) {
|
|
11
|
+
const filePath = path.join(dir, `${baseName}.${ext}`);
|
|
12
|
+
try {
|
|
13
|
+
await fs.stat(filePath);
|
|
14
|
+
configs.push(filePath); // Return the path if the file exists
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// Empty
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return configs;
|
|
22
|
+
}
|
|
@@ -6,7 +6,7 @@ export default async function getProjectInfo({ port: givenPort, clientOutDir, }
|
|
|
6
6
|
// Make PORT available to the config file at getConfig
|
|
7
7
|
process.env.PORT = port;
|
|
8
8
|
const cwd = process.cwd();
|
|
9
|
-
const { config, srcRoot } = await getConfig({ clientOutDir });
|
|
9
|
+
const { config, srcRoot, configPaths } = await getConfig({ clientOutDir });
|
|
10
10
|
const apiEntryPoint = `${config.origin ?? ''}/${config.rootEntry}`;
|
|
11
11
|
const apiDir = path.join(srcRoot, 'app', config.rootEntry);
|
|
12
12
|
const schemaOutImportPath = path.relative(config.clientOutDir, config.schemaOutDir);
|
|
@@ -17,6 +17,9 @@ export default async function getProjectInfo({ port: givenPort, clientOutDir, }
|
|
|
17
17
|
? path.relative(config.clientOutDir, config.validateOnClient)
|
|
18
18
|
: config.validateOnClient;
|
|
19
19
|
const log = getLogger(config.logLevel);
|
|
20
|
+
if (configPaths.length > 1) {
|
|
21
|
+
log.warn(`Multiple config files found. Using the first one: ${configPaths[0]}`);
|
|
22
|
+
}
|
|
20
23
|
return {
|
|
21
24
|
cwd,
|
|
22
25
|
port,
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import getConfigPath from './
|
|
1
|
+
import getConfigPath from './getConfigPaths.mjs';
|
|
2
2
|
async function readConfig() {
|
|
3
|
-
const
|
|
4
|
-
let
|
|
5
|
-
if (!
|
|
6
|
-
return
|
|
3
|
+
const configPaths = await getConfigPath();
|
|
4
|
+
let userConfig = {};
|
|
5
|
+
if (!configPaths.length) {
|
|
6
|
+
return { userConfig, configPaths };
|
|
7
7
|
}
|
|
8
|
+
const configPath = configPaths[0];
|
|
8
9
|
try {
|
|
9
10
|
const cacheBuster = Date.now();
|
|
10
|
-
({ default:
|
|
11
|
+
({ default: userConfig } = (await import(`${configPath}?cache=${cacheBuster}`)));
|
|
11
12
|
}
|
|
12
13
|
catch (e) {
|
|
13
14
|
// eslint-disable-next-line no-console
|
|
14
15
|
console.error('🐺 ❌ Error reading config file:', e.message);
|
|
15
16
|
}
|
|
16
|
-
return
|
|
17
|
+
return { userConfig, configPaths };
|
|
17
18
|
}
|
|
18
19
|
export default readConfig;
|
package/dist/init/index.mjs
CHANGED
|
@@ -61,7 +61,7 @@ import NPMCliPackageJson from '@npmcli/package-json';
|
|
|
61
61
|
import path from 'path';
|
|
62
62
|
import fs from 'fs/promises';
|
|
63
63
|
import * as jsonc from 'jsonc-parser';
|
|
64
|
-
import getConfigPath from '../getProjectInfo/
|
|
64
|
+
import getConfigPath from '../getProjectInfo/getConfigPaths.mjs';
|
|
65
65
|
import chalk from 'chalk';
|
|
66
66
|
import fileExists from '../utils/fileExists.mjs';
|
|
67
67
|
import installDependencies from './installDependencies.mjs';
|
|
@@ -166,9 +166,9 @@ class Context {
|
|
|
166
166
|
if (!(await fileExists(path.join(root, 'tsconfig.json')))) {
|
|
167
167
|
throw new Error(`tsconfig.json not found at ${root}. Run "npx tsc --init" to create a new tsconfig.json file.`);
|
|
168
168
|
}
|
|
169
|
-
if (configPath) {
|
|
169
|
+
if (configPath.length) {
|
|
170
170
|
if (!(await confirm({
|
|
171
|
-
message: `Found existing config file at ${configPath}. Do you want to reinitialize the project?`,
|
|
171
|
+
message: `Found existing config file at ${configPath[0]}. Do you want to reinitialize the project?`,
|
|
172
172
|
})))
|
|
173
173
|
return;
|
|
174
174
|
}
|
|
@@ -239,6 +239,7 @@ class Context {
|
|
|
239
239
|
context.actions.push(updateTsconfigAction);
|
|
240
240
|
}
|
|
241
241
|
await installDependencies(root, toBeInstalled, ['concurrently', 'vovk-cli']);
|
|
242
|
+
// TODO create config file, based on .config folder and "module" in package.json
|
|
242
243
|
}
|
|
243
244
|
}
|
|
244
245
|
export const Init = Context;
|
package/dist/watcher/index.mjs
CHANGED
|
@@ -136,7 +136,7 @@ export class VovkCLIWatcher {
|
|
|
136
136
|
this.#watchSegments();
|
|
137
137
|
}, 1000);
|
|
138
138
|
chokidar
|
|
139
|
-
.watch('vovk.config.{js,mjs,cjs}', {
|
|
139
|
+
.watch(['vovk.config.{js,mjs,cjs}', '.config/vovk.config.{js,mjs,cjs}'], {
|
|
140
140
|
persistent: true,
|
|
141
141
|
cwd,
|
|
142
142
|
ignoreInitial: false,
|
|
@@ -190,7 +190,7 @@ export class VovkCLIWatcher {
|
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
else {
|
|
193
|
-
log.debug(`
|
|
193
|
+
log.debug(`The file does not contain any controller or worker`);
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
196
|
#requestSchema = debounceWithArgs(async (segmentName) => {
|
|
@@ -8,6 +8,17 @@ export default function logDiffResult(segmentName, diffResult, projectInfo) {
|
|
|
8
8
|
diffResult.workers.removed.forEach((name) => {
|
|
9
9
|
diffNormalized.push({ what: 'worker', type: 'removed', name });
|
|
10
10
|
});
|
|
11
|
+
diffResult.workers.handlers.forEach((handler) => {
|
|
12
|
+
handler.added.forEach((name) => {
|
|
13
|
+
diffNormalized.push({ what: 'workerHandler', type: 'added', name: `${handler.nameOfClass}.${name}` });
|
|
14
|
+
});
|
|
15
|
+
handler.removed.forEach((name) => {
|
|
16
|
+
diffNormalized.push({ what: 'workerHandler', type: 'removed', name: `${handler.nameOfClass}.${name}` });
|
|
17
|
+
});
|
|
18
|
+
handler.changed.forEach((name) => {
|
|
19
|
+
diffNormalized.push({ what: 'workerHandler', type: 'changed', name: `${handler.nameOfClass}.${name}` });
|
|
20
|
+
});
|
|
21
|
+
});
|
|
11
22
|
diffResult.controllers.added.forEach((name) => {
|
|
12
23
|
diffNormalized.push({ what: 'controller', type: 'added', name });
|
|
13
24
|
});
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function getConfigPath(relativePath?: string): Promise<string | null>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
export default async function getConfigPath(relativePath = '') {
|
|
4
|
-
const rootDir = path.resolve(process.cwd(), relativePath || '');
|
|
5
|
-
const baseName = 'vovk.config';
|
|
6
|
-
const extensions = ['cjs', 'mjs', 'js'];
|
|
7
|
-
for (const ext of extensions) {
|
|
8
|
-
const filePath = path.join(rootDir, `${baseName}.${ext}`);
|
|
9
|
-
try {
|
|
10
|
-
await fs.stat(filePath);
|
|
11
|
-
return filePath; // Return the path if the file exists
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
// Empty
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return null; // Return null if no config file was found
|
|
18
|
-
}
|