vovk 0.2.3-beta.120 → 0.2.3-beta.121
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/cli/generateClient.mjs +7 -13
- package/package.json +1 -1
package/cli/generateClient.mjs
CHANGED
|
@@ -4,18 +4,12 @@ import path from 'path';
|
|
|
4
4
|
import getReturnPath from './lib/getReturnPath.mjs';
|
|
5
5
|
|
|
6
6
|
/** @type {(moduleName: string) => Promise<boolean>} */
|
|
7
|
-
async function
|
|
7
|
+
async function fileExists(filePath) {
|
|
8
8
|
try {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// @ts-ignore Ignore dynamic imports errors
|
|
12
|
-
await import(moduleName, { assert: { type: 'json' } });
|
|
13
|
-
} else {
|
|
14
|
-
await import(moduleName);
|
|
15
|
-
}
|
|
16
|
-
return true; // The module exists and can be imported
|
|
9
|
+
await fs.stat(filePath);
|
|
10
|
+
return true; // The file exists
|
|
17
11
|
} catch (e) {
|
|
18
|
-
return false; // The
|
|
12
|
+
return false; // The file does not exist
|
|
19
13
|
}
|
|
20
14
|
}
|
|
21
15
|
|
|
@@ -32,7 +26,7 @@ export default async function generateClient({ ...env }) {
|
|
|
32
26
|
const fetcherPath = env.VOVK_FETCHER.startsWith('.') ? path.join(returnDir, env.VOVK_FETCHER) : env.VOVK_FETCHER;
|
|
33
27
|
|
|
34
28
|
if (!env.VOVK_VALIDATE_ON_CLIENT) {
|
|
35
|
-
env.VOVK_VALIDATE_ON_CLIENT = (await
|
|
29
|
+
env.VOVK_VALIDATE_ON_CLIENT = (await fileExists('vovk-zod/zodValidateOnClient'))
|
|
36
30
|
? 'vovk-zod/zodValidateOnClient'
|
|
37
31
|
: '';
|
|
38
32
|
}
|
|
@@ -41,13 +35,13 @@ export default async function generateClient({ ...env }) {
|
|
|
41
35
|
: env.VOVK_VALIDATE_ON_CLIENT;
|
|
42
36
|
const localValidatePath = env.VOVK_VALIDATE_ON_CLIENT.startsWith('.') ? path.join('..', validatePath) : validatePath;
|
|
43
37
|
|
|
44
|
-
if (env.VOVK_VALIDATE_ON_CLIENT && !(await
|
|
38
|
+
if (env.VOVK_VALIDATE_ON_CLIENT && !(await fileExists(localValidatePath))) {
|
|
45
39
|
throw new Error(
|
|
46
40
|
`Unble to generate Vovk Client: cannot find "validateOnClient" module '${env.VOVK_VALIDATE_ON_CLIENT}'. Check your vovk.config.js file`
|
|
47
41
|
);
|
|
48
42
|
}
|
|
49
43
|
|
|
50
|
-
if (!(await
|
|
44
|
+
if (!(await fileExists(localJsonPath))) {
|
|
51
45
|
throw new Error(
|
|
52
46
|
`Unble to generate Vovk Client: cannot find ".vovk.json" file '${localJsonPath}' (original value '${jsonPath}').`
|
|
53
47
|
);
|