vovk-cli 0.0.1-beta.23 → 0.0.1-beta.25
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 +1 -1
- package/dist/watcher/index.mjs +2 -2
- 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';
|
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,
|
|
@@ -183,7 +183,7 @@ export class VovkCLIWatcher {
|
|
|
183
183
|
workersByOriginalName[name]);
|
|
184
184
|
});
|
|
185
185
|
if (affectedSegments.length) {
|
|
186
|
-
log.debug(`A file with controller or worker ${namesOfClasses.join(', ')} have been modified at path "${filePath}". Segment(s) affected: ${JSON.stringify(affectedSegments)}`);
|
|
186
|
+
log.debug(`A file with controller or worker ${namesOfClasses.join(', ')} have been modified at path "${filePath}". Segment(s) affected: ${JSON.stringify(affectedSegments.map((s) => s.segmentName))}`);
|
|
187
187
|
for (const segment of affectedSegments) {
|
|
188
188
|
await this.#requestSchema(segment.segmentName);
|
|
189
189
|
}
|
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
|
-
}
|