vike 0.4.160 → 0.4.161-commit-0e9c635
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/cjs/node/cli/bin.js +5 -0
- package/dist/cjs/node/client/router.js +4 -2
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +2 -2
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +148 -0
- package/dist/cjs/node/plugin/plugins/buildConfig.js +61 -35
- package/dist/cjs/node/plugin/plugins/commonConfig.js +5 -13
- package/dist/cjs/node/plugin/plugins/config/stemUtils.js +1 -1
- package/dist/cjs/node/plugin/plugins/distFileNames.js +9 -1
- package/dist/cjs/node/plugin/plugins/envVars.js +6 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +16 -4
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/cjs/node/plugin/plugins/importBuild/getVikeManifest.js +1 -21
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +5 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +11 -91
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +28 -46
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{loadFileConfigEnv.js → loadFileAtConfigTime.js} +5 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +33 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformImports.js → transformFileImports.js} +7 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +21 -27
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +157 -111
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -1
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +0 -14
- package/dist/cjs/node/plugin/shared/rollupSourceMap.js +20 -0
- package/dist/cjs/node/plugin/utils.js +3 -2
- package/dist/cjs/node/prerender/runPrerender.js +13 -5
- package/dist/cjs/node/runtime/globalContext.js +15 -23
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
- package/dist/cjs/node/runtime/html/renderHtml.js +1 -1
- package/dist/cjs/node/runtime/html/stream.js +2 -2
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +39 -39
- package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -5
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -7
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +23 -28
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/cjs/node/runtime/renderPage/{logHintForCjsEsmError.js → logErrorHint.js} +81 -43
- package/dist/cjs/node/runtime/renderPage/loggerProd.js +3 -3
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -23
- package/dist/cjs/node/runtime/utils.js +1 -1
- package/dist/cjs/node/shared/assertPluginManifest.js +1 -4
- package/dist/cjs/node/shared/assertV1Design.js +26 -0
- package/dist/cjs/node/shared/{getClientEntryFilePath.js → getClientEntry.js} +3 -3
- package/dist/cjs/node/shared/prependEntriesDir.js +13 -0
- package/dist/cjs/node/shared/utils.js +2 -0
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +53 -26
- package/dist/cjs/shared/route/executeGuardHook.js +3 -2
- package/dist/cjs/shared/utils.js +0 -1
- package/dist/cjs/utils/assertNodeVersion.js +2 -2
- package/dist/cjs/utils/{findUserPackageJsonPath.js → findFile.js} +11 -8
- package/dist/cjs/utils/isVersionOrAbove.js +29 -0
- package/dist/cjs/utils/nodeEnv.js +23 -1
- package/dist/cjs/utils/objectKeys.js +19 -3
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/cjs/utils/sorter.js +62 -1
- package/dist/esm/client/client-routing-runtime/index.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/index.js +1 -1
- package/dist/esm/node/cli/bin.js +3 -1
- package/dist/esm/node/client/router.d.ts +2 -0
- package/dist/esm/node/client/router.js +3 -1
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +2 -2
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.d.ts +13 -0
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +142 -0
- package/dist/esm/node/plugin/plugins/buildConfig.d.ts +2 -0
- package/dist/esm/node/plugin/plugins/buildConfig.js +60 -34
- package/dist/esm/node/plugin/plugins/commonConfig.js +6 -14
- package/dist/esm/node/plugin/plugins/config/stemUtils.js +2 -2
- package/dist/esm/node/plugin/plugins/distFileNames.js +9 -1
- package/dist/esm/node/plugin/plugins/envVars.js +6 -2
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +17 -5
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.js +2 -19
- package/dist/esm/node/plugin/plugins/importBuild/index.d.ts +6 -1
- package/dist/esm/node/plugin/plugins/importBuild/index.js +5 -8
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +13 -93
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +39 -12
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +29 -47
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{loadFileConfigEnv.js → loadFileAtConfigTime.js} +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.d.ts +5 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +27 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformImports.d.ts → transformFileImports.d.ts} +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformImports.js → transformFileImports.js} +6 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +20 -26
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +5 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +155 -109
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -1
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +1 -15
- package/dist/esm/node/plugin/shared/rollupSourceMap.d.ts +14 -0
- package/dist/esm/node/plugin/shared/rollupSourceMap.js +17 -0
- package/dist/esm/node/plugin/utils.d.ts +3 -2
- package/dist/esm/node/plugin/utils.js +3 -2
- package/dist/esm/node/prerender/runPrerender.js +15 -7
- package/dist/esm/node/runtime/globalContext.d.ts +3 -10
- package/dist/esm/node/runtime/globalContext.js +15 -23
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
- package/dist/esm/node/runtime/html/renderHtml.js +1 -1
- package/dist/esm/node/runtime/html/stream.js +2 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -2
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.d.ts +6 -5
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +39 -39
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -5
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -7
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +24 -29
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/esm/node/runtime/renderPage/logErrorHint.d.ts +8 -0
- package/dist/esm/node/runtime/renderPage/{logHintForCjsEsmError.js → logErrorHint.js} +80 -42
- package/dist/esm/node/runtime/renderPage/loggerProd.js +3 -3
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -24
- package/dist/esm/node/runtime/utils.d.ts +1 -1
- package/dist/esm/node/runtime/utils.js +1 -1
- package/dist/esm/node/shared/ViteManifest.d.ts +1 -0
- package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -1
- package/dist/esm/node/shared/assertPluginManifest.js +2 -5
- package/dist/esm/node/shared/assertV1Design.d.ts +4 -0
- package/dist/esm/node/shared/assertV1Design.js +23 -0
- package/dist/esm/node/shared/getClientEntry.d.ts +3 -0
- package/dist/esm/node/shared/{getClientEntryFilePath.js → getClientEntry.js} +2 -2
- package/dist/esm/node/shared/prependEntriesDir.d.ts +2 -0
- package/dist/esm/node/shared/prependEntriesDir.js +10 -0
- package/dist/esm/node/shared/utils.d.ts +2 -0
- package/dist/esm/node/shared/utils.js +2 -0
- package/dist/esm/shared/page-configs/Config.d.ts +1 -1
- package/dist/esm/shared/page-configs/PageConfig.d.ts +3 -3
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +53 -26
- package/dist/esm/shared/route/executeGuardHook.js +3 -2
- package/dist/esm/shared/utils.d.ts +0 -1
- package/dist/esm/shared/utils.js +0 -1
- package/dist/esm/utils/assertNodeVersion.js +2 -2
- package/dist/esm/utils/findFile.d.ts +3 -0
- package/dist/esm/utils/findFile.js +21 -0
- package/dist/esm/utils/getOutDirs.d.ts +1 -0
- package/dist/esm/utils/isVersionOrAbove.d.ts +2 -0
- package/dist/esm/utils/isVersionOrAbove.js +26 -0
- package/dist/esm/utils/nodeEnv.d.ts +4 -0
- package/dist/esm/utils/nodeEnv.js +19 -0
- package/dist/esm/utils/objectKeys.d.ts +10 -1
- package/dist/esm/utils/objectKeys.js +20 -3
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/dist/esm/utils/sorter.d.ts +59 -0
- package/dist/esm/utils/sorter.js +61 -0
- package/package.json +2 -2
- package/dist/cjs/node/plugin/shared/removeSourceMap.js +0 -12
- package/dist/cjs/utils/objectEntries.js +0 -8
- package/dist/esm/node/plugin/shared/removeSourceMap.d.ts +0 -7
- package/dist/esm/node/plugin/shared/removeSourceMap.js +0 -9
- package/dist/esm/node/runtime/renderPage/logHintForCjsEsmError.d.ts +0 -13
- package/dist/esm/node/shared/getClientEntryFilePath.d.ts +0 -3
- package/dist/esm/utils/findUserPackageJsonPath.d.ts +0 -2
- package/dist/esm/utils/findUserPackageJsonPath.js +0 -18
- package/dist/esm/utils/objectEntries.d.ts +0 -4
- package/dist/esm/utils/objectEntries.js +0 -5
- /package/dist/cjs/node/runtime/renderPage/{logHintForCjsEsmError → logErrorHint}/errors.js +0 -0
- /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{loadFileConfigEnv.d.ts → loadFileAtConfigTime.d.ts} +0 -0
- /package/dist/esm/node/runtime/renderPage/{logHintForCjsEsmError → logErrorHint}/errors.d.ts +0 -0
- /package/dist/esm/node/runtime/renderPage/{logHintForCjsEsmError → logErrorHint}/errors.js +0 -0
|
@@ -3,22 +3,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getHint = exports.
|
|
6
|
+
exports.getHint = exports.isKnownError = exports.isCjsEsmError = exports.logErrorHint = void 0;
|
|
7
7
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
8
8
|
const utils_js_1 = require("../utils.js");
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const knownErrors = [
|
|
10
|
+
{
|
|
11
|
+
errMsg: 'jsxDEV is not a function',
|
|
12
|
+
link: 'https://github.com/vikejs/vike/issues/1469#issuecomment-1919518096'
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
errMsg: 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components)',
|
|
16
|
+
link: 'https://vike.dev/broken-npm-package#react-invalid-component'
|
|
17
|
+
}
|
|
18
|
+
];
|
|
19
|
+
function logErrorHint(error) {
|
|
20
|
+
/* Collect errors for ./logErrorHint.spec.ts
|
|
11
21
|
collectError(error)
|
|
12
22
|
//*/
|
|
13
23
|
const hint = getHint(error);
|
|
14
24
|
if (hint)
|
|
15
25
|
logHint(hint);
|
|
16
26
|
}
|
|
17
|
-
exports.
|
|
27
|
+
exports.logErrorHint = logErrorHint;
|
|
18
28
|
function getHint(error) {
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
29
|
+
{
|
|
30
|
+
const link = isKnownError(error);
|
|
31
|
+
if (link)
|
|
32
|
+
return `To fix this error, see ${link}`;
|
|
22
33
|
}
|
|
23
34
|
const res = isCjsEsmError(error);
|
|
24
35
|
if (res) {
|
|
@@ -40,44 +51,73 @@ function logHint(hint) {
|
|
|
40
51
|
hint = (0, utils_js_1.formatHintLog)(hint);
|
|
41
52
|
console.error(hint);
|
|
42
53
|
}
|
|
43
|
-
function
|
|
54
|
+
function isKnownError(error) {
|
|
44
55
|
const anywhere = getAnywhere(error);
|
|
45
|
-
|
|
56
|
+
const knownErr = knownErrors.find((knownErorr) => {
|
|
57
|
+
return includes(anywhere, knownErorr.errMsg);
|
|
58
|
+
});
|
|
59
|
+
if (!knownErr)
|
|
60
|
+
return false;
|
|
61
|
+
return knownErr.link;
|
|
46
62
|
}
|
|
47
|
-
exports.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
* `'some-npm-package'` -> add some-npm-package to `ssr.noExternal`
|
|
52
|
-
*/
|
|
63
|
+
exports.isKnownError = isKnownError;
|
|
64
|
+
// `false` -> noop
|
|
65
|
+
// `true` -> generic message
|
|
66
|
+
// `'some-npm-package'` -> add some-npm-package to `ssr.noExternal`
|
|
53
67
|
function isCjsEsmError(error) {
|
|
68
|
+
const res = check(error);
|
|
69
|
+
if (res === true || res === false)
|
|
70
|
+
return res;
|
|
71
|
+
const packageNames = normalizeRes(res);
|
|
72
|
+
if (packageNames === false)
|
|
73
|
+
return packageNames;
|
|
74
|
+
packageNames.forEach((packageName) => {
|
|
75
|
+
(0, utils_js_1.assert)(!['vite', 'vike'].includes(packageName));
|
|
76
|
+
});
|
|
77
|
+
return packageNames;
|
|
78
|
+
}
|
|
79
|
+
exports.isCjsEsmError = isCjsEsmError;
|
|
80
|
+
function normalizeRes(res) {
|
|
81
|
+
let packageNames = Array.isArray(res) ? res : [res];
|
|
82
|
+
packageNames = (0, utils_js_1.unique)(packageNames.filter(utils_js_1.isNotNullish).filter((packageName) => packageName !== '@brillout/import'));
|
|
83
|
+
if (packageNames.length === 0)
|
|
84
|
+
return false;
|
|
85
|
+
return packageNames;
|
|
86
|
+
}
|
|
87
|
+
function check(error) {
|
|
54
88
|
const message = getErrMessage(error);
|
|
55
89
|
const anywhere = getAnywhere(error);
|
|
56
90
|
const packageName_stack1 = getPackageName_stack1(error);
|
|
57
91
|
const packageName_stack2 = getPackageName_stack2(error);
|
|
58
92
|
const isRelatedToNodeModules = !!packageName_stack1 || !!packageName_stack2 || includesNodeModules(message);
|
|
59
|
-
|
|
93
|
+
/*
|
|
94
|
+
const relatedNpmPackages = normalizeArray([
|
|
95
|
+
packageName_stack1 || null,
|
|
96
|
+
packageName_stack2 || null,
|
|
97
|
+
(message && extractFromNodeModulesPath(message)) || null
|
|
98
|
+
])
|
|
99
|
+
*/
|
|
60
100
|
// ERR_UNSUPPORTED_DIR_IMPORT
|
|
61
101
|
{
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
64
|
-
return
|
|
102
|
+
const packageName = parseNodeModulesPathMessage('ERR_UNSUPPORTED_DIR_IMPORT', anywhere);
|
|
103
|
+
if (packageName)
|
|
104
|
+
return packageName;
|
|
65
105
|
}
|
|
66
106
|
// ERR_UNKNOWN_FILE_EXTENSION
|
|
67
107
|
{
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
70
|
-
return
|
|
108
|
+
const packageName = parseUnkownFileExtensionMessage(anywhere);
|
|
109
|
+
if (packageName)
|
|
110
|
+
return packageName;
|
|
71
111
|
}
|
|
72
112
|
{
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
return
|
|
113
|
+
const packageName = parseNodeModulesPathMessage('ERR_UNKNOWN_FILE_EXTENSION', anywhere);
|
|
114
|
+
if (packageName)
|
|
115
|
+
return packageName;
|
|
76
116
|
}
|
|
77
117
|
{
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
return
|
|
118
|
+
const packageName = parseNodeModulesPathMessage('is not exported', anywhere);
|
|
119
|
+
if (packageName)
|
|
120
|
+
return packageName;
|
|
81
121
|
}
|
|
82
122
|
// Using CJS inside ESM modules.
|
|
83
123
|
if (includes(anywhere, 'require is not a function') ||
|
|
@@ -98,7 +138,7 @@ function isCjsEsmError(error) {
|
|
|
98
138
|
if (includes(anywhere, 'ERR_REQUIRE_ESM')) {
|
|
99
139
|
/* The issue is the importer, not the importee.
|
|
100
140
|
if (relatedNpmPackages) return relatedNpmPackages
|
|
101
|
-
|
|
141
|
+
*/
|
|
102
142
|
{
|
|
103
143
|
if (packageName_stack1)
|
|
104
144
|
return packageName_stack1;
|
|
@@ -118,9 +158,9 @@ function isCjsEsmError(error) {
|
|
|
118
158
|
*/
|
|
119
159
|
// `SyntaxError: Named export '${exportName}' not found. The requested module '${packageName}' is a CommonJS module, which may not support all module.exports as named exports.`
|
|
120
160
|
{
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
123
|
-
return
|
|
161
|
+
const packageName = parseImportFrom(anywhere);
|
|
162
|
+
if (packageName)
|
|
163
|
+
return packageName;
|
|
124
164
|
}
|
|
125
165
|
if (includes(anywhere, 'Cannot read properties of undefined')) {
|
|
126
166
|
if (isRelatedToNodeModules) {
|
|
@@ -150,14 +190,13 @@ function isCjsEsmError(error) {
|
|
|
150
190
|
}
|
|
151
191
|
return false;
|
|
152
192
|
}
|
|
153
|
-
exports.isCjsEsmError = isCjsEsmError;
|
|
154
193
|
function parseCannotFindMessage(str) {
|
|
155
194
|
const match = /Cannot find \S+ '(\S+)' imported from (\S+)/.exec(str);
|
|
156
195
|
if (!match)
|
|
157
196
|
return false;
|
|
158
197
|
// const packageNameCannotFind = extractFromPath(match[1]!)
|
|
159
198
|
const packageNameFrom = extractFromPath(match[2]);
|
|
160
|
-
return
|
|
199
|
+
return normalizeArray([
|
|
161
200
|
// packageNameCannotFind,
|
|
162
201
|
packageNameFrom
|
|
163
202
|
]);
|
|
@@ -168,7 +207,7 @@ function parseUnkownFileExtensionMessage(str) {
|
|
|
168
207
|
return false;
|
|
169
208
|
const filePath = match[1];
|
|
170
209
|
const packageName = extractFromPath(filePath);
|
|
171
|
-
return
|
|
210
|
+
return packageName;
|
|
172
211
|
}
|
|
173
212
|
function parseImportFrom(str) {
|
|
174
213
|
const match = /\bimport\b.*?\bfrom\b\s*?"(.+?)"/.exec(str);
|
|
@@ -176,7 +215,7 @@ function parseImportFrom(str) {
|
|
|
176
215
|
return false;
|
|
177
216
|
const importPath = match[1];
|
|
178
217
|
const packageName = extractFromPath(importPath);
|
|
179
|
-
return
|
|
218
|
+
return packageName;
|
|
180
219
|
}
|
|
181
220
|
function parseNodeModulesPathMessage(begin, str) {
|
|
182
221
|
str = str.replaceAll('\\', '/');
|
|
@@ -230,7 +269,6 @@ function extractFromPath(filePath) {
|
|
|
230
269
|
packageName = packageName.split('/')[0];
|
|
231
270
|
}
|
|
232
271
|
packageName = clean(packageName);
|
|
233
|
-
(0, utils_js_1.assert)(!['vite', 'vike'].includes(packageName));
|
|
234
272
|
return packageName;
|
|
235
273
|
}
|
|
236
274
|
function clean(packageName) {
|
|
@@ -248,7 +286,7 @@ function extractFromNodeModulesPath(str) {
|
|
|
248
286
|
return false;
|
|
249
287
|
const packageName = extractFromPath(str);
|
|
250
288
|
(0, utils_js_1.assert)(packageName);
|
|
251
|
-
return
|
|
289
|
+
return packageName;
|
|
252
290
|
}
|
|
253
291
|
function includes(str1, str2) {
|
|
254
292
|
return !!str1 && str1.toLowerCase().includes(str2.toLowerCase());
|
|
@@ -263,11 +301,11 @@ function includesNodeModules(str) {
|
|
|
263
301
|
return false;
|
|
264
302
|
return true;
|
|
265
303
|
}
|
|
266
|
-
function
|
|
267
|
-
const
|
|
268
|
-
if (
|
|
269
|
-
return
|
|
270
|
-
return
|
|
304
|
+
function normalizeArray(arr) {
|
|
305
|
+
const arrNormalized = arr.filter(utils_js_1.isNotNullish);
|
|
306
|
+
if (arrNormalized.length === 0)
|
|
307
|
+
return null;
|
|
308
|
+
return arrNormalized;
|
|
271
309
|
}
|
|
272
310
|
function getErrMessage(err) {
|
|
273
311
|
if (!(0, utils_js_1.isObject)(err))
|
|
@@ -10,7 +10,7 @@ const abort_js_1 = require("../../../shared/route/abort.js");
|
|
|
10
10
|
const isNewError_js_1 = require("./isNewError.js");
|
|
11
11
|
const utils_js_1 = require("../utils.js");
|
|
12
12
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
|
-
const
|
|
13
|
+
const logErrorHint_js_1 = require("./logErrorHint.js");
|
|
14
14
|
function logErrorProd(err, _httpRquestId) {
|
|
15
15
|
(0, utils_js_1.warnIfErrorIsNotObject)(err);
|
|
16
16
|
(0, isNewError_js_1.setAlreadyLogged)(err);
|
|
@@ -25,7 +25,7 @@ function logErrorProd(err, _httpRquestId) {
|
|
|
25
25
|
exports.logErrorProd = logErrorProd;
|
|
26
26
|
// Every server-side runtime error is expected to go through onRuntimeError(). (In principle, any runtime error is (or at least should) be catched by Vike, otherwise Vike couldn't render the error page.)
|
|
27
27
|
function onRuntimeError(err) {
|
|
28
|
-
// The more runtime errors we pass to
|
|
29
|
-
(0,
|
|
28
|
+
// The more runtime errors we pass to logErrorHint() the better.
|
|
29
|
+
(0, logErrorHint_js_1.logErrorHint)(err);
|
|
30
30
|
}
|
|
31
31
|
exports.onRuntimeError = onRuntimeError;
|
|
@@ -21,8 +21,8 @@ const preparePageContextForUserConsumptionServerSide_js_1 = require("./preparePa
|
|
|
21
21
|
const executeGuardHook_js_1 = require("../../../shared/route/executeGuardHook.js");
|
|
22
22
|
const loadPageRoutes_js_1 = require("../../../shared/route/loadPageRoutes.js");
|
|
23
23
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
24
|
-
const helpers_js_1 = require("../../../shared/page-configs/helpers.js");
|
|
25
24
|
const isServerSideError_js_1 = require("../../../shared/misc/isServerSideError.js");
|
|
25
|
+
const assertV1Design_js_1 = require("../../shared/assertV1Design.js");
|
|
26
26
|
async function renderPageAlreadyRouted(pageContext) {
|
|
27
27
|
// pageContext._pageId can either be the:
|
|
28
28
|
// - ID of the page matching the routing, or the
|
|
@@ -156,7 +156,7 @@ async function getRenderContext() {
|
|
|
156
156
|
const globalContext = (0, globalContext_js_1.getGlobalContext)();
|
|
157
157
|
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal } = await (0, getPageFiles_js_1.getPageFilesAll)(false, globalContext.isProduction);
|
|
158
158
|
const { pageRoutes, onBeforeRouteHook } = await (0, loadPageRoutes_js_1.loadPageRoutes)(pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds);
|
|
159
|
-
assertV1Design(pageFilesAll, pageConfigs);
|
|
159
|
+
(0, assertV1Design_js_1.assertV1Design)(pageFilesAll.length > 0, pageConfigs, pageFilesAll);
|
|
160
160
|
const renderContext = {
|
|
161
161
|
pageFilesAll: pageFilesAll,
|
|
162
162
|
pageConfigs,
|
|
@@ -168,24 +168,3 @@ async function getRenderContext() {
|
|
|
168
168
|
return renderContext;
|
|
169
169
|
}
|
|
170
170
|
exports.getRenderContext = getRenderContext;
|
|
171
|
-
function assertV1Design(pageFilesAll, pageConfigs) {
|
|
172
|
-
const isV1Design = pageConfigs.length !== 0;
|
|
173
|
-
const isDesignOld = pageFilesAll.length !== 0;
|
|
174
|
-
if (isV1Design && isDesignOld) {
|
|
175
|
-
const indent = '- ';
|
|
176
|
-
const v1Files = (0, utils_js_1.unique)(pageConfigs
|
|
177
|
-
.map((p) => Object.values(p.configValues)
|
|
178
|
-
.map(helpers_js_1.getConfigValueFilePathToShowToUser)
|
|
179
|
-
.filter(utils_js_1.isNotNullish)
|
|
180
|
-
.map((filePathToShowToUser) => indent + filePathToShowToUser))
|
|
181
|
-
.flat(2));
|
|
182
|
-
(0, utils_js_1.assertUsage)(false, [
|
|
183
|
-
'Mixing the new V1 design with the old V0.4 design is forbidden.',
|
|
184
|
-
'V1 files:',
|
|
185
|
-
...v1Files,
|
|
186
|
-
'V0.4 files:',
|
|
187
|
-
...pageFilesAll.map((p) => indent + p.filePath)
|
|
188
|
-
].join('\n'));
|
|
189
|
-
}
|
|
190
|
-
(0, utils_js_1.assertWarning)(!isDesignOld, "You are using Vike's deprecated design. Update to the new V1 design, see https://vike.dev/migration/v1-design for how to migrate.", { onlyOnce: true });
|
|
191
|
-
}
|
|
@@ -55,7 +55,7 @@ __exportStar(require("../../utils/isNpmPackage.js"), exports);
|
|
|
55
55
|
__exportStar(require("../../utils/isNotNullish.js"), exports);
|
|
56
56
|
__exportStar(require("../../utils/isScriptFile.js"), exports);
|
|
57
57
|
__exportStar(require("../../utils/removeFileExtention.js"), exports);
|
|
58
|
-
__exportStar(require("../../utils/
|
|
58
|
+
__exportStar(require("../../utils/objectKeys.js"), exports);
|
|
59
59
|
__exportStar(require("../../utils/isStringRecord.js"), exports);
|
|
60
60
|
__exportStar(require("../../utils/getFileExtension.js"), exports);
|
|
61
61
|
__exportStar(require("../../utils/assertIsNotProductionRuntime.js"), exports);
|
|
@@ -9,16 +9,13 @@ function assertPluginManifest(pluginManifest) {
|
|
|
9
9
|
(0, assertRuntimeManifest_js_1.assertRuntimeManifest)(pluginManifest);
|
|
10
10
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pluginManifest, 'usesClientRouter', 'boolean'));
|
|
11
11
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pluginManifest, 'version', 'string'));
|
|
12
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pluginManifest, 'manifestKeyMap', 'object'));
|
|
13
|
-
const { manifestKeyMap } = pluginManifest;
|
|
14
|
-
(0, utils_js_1.assert)((0, utils_js_1.isStringRecord)(manifestKeyMap));
|
|
15
12
|
// Avoid:
|
|
16
13
|
// ```
|
|
17
14
|
// Uncaught (in promise) TypeError: Cannot set property manifestKeyMap of #<Object> which has only a getter
|
|
18
15
|
// ```
|
|
16
|
+
// We removed manifestKeyMap, maybe this isn't needed anymore.
|
|
19
17
|
// See https://github.com/vikejs/vike/issues/596
|
|
20
18
|
const pluginManifestClone = { ...pluginManifest };
|
|
21
|
-
(0, utils_js_1.objectAssign)(pluginManifestClone, { manifestKeyMap });
|
|
22
19
|
(0, utils_js_1.checkType)(pluginManifestClone);
|
|
23
20
|
}
|
|
24
21
|
exports.assertPluginManifest = assertPluginManifest;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertV1Design = void 0;
|
|
4
|
+
const helpers_js_1 = require("../../shared/page-configs/helpers.js");
|
|
5
|
+
const utils_js_1 = require("./utils.js");
|
|
6
|
+
function assertV1Design(isOldDesign, pageConfigs, pageFilesAll) {
|
|
7
|
+
const isV1Design = pageConfigs.length > 0;
|
|
8
|
+
if (isV1Design && isOldDesign) {
|
|
9
|
+
const lines = ['Mixing the new V1 design with the old V0.4 design is forbidden.'];
|
|
10
|
+
if (pageFilesAll) {
|
|
11
|
+
(0, utils_js_1.assert)(pageFilesAll.length > 0);
|
|
12
|
+
const indent = '- ';
|
|
13
|
+
const filesV1 = (0, utils_js_1.unique)(pageConfigs
|
|
14
|
+
.map((p) => Object.values(p.configValues)
|
|
15
|
+
.map(helpers_js_1.getConfigValueFilePathToShowToUser)
|
|
16
|
+
.filter(utils_js_1.isNotNullish)
|
|
17
|
+
.map((filePathToShowToUser) => indent + filePathToShowToUser))
|
|
18
|
+
.flat(2));
|
|
19
|
+
const filesOld = pageFilesAll.map((p) => indent + p.filePath);
|
|
20
|
+
lines.push(...['V1 design files:', ...filesV1, 'Old design files:', ...filesOld]);
|
|
21
|
+
}
|
|
22
|
+
(0, utils_js_1.assertUsage)(false, lines.join('\n'));
|
|
23
|
+
}
|
|
24
|
+
(0, utils_js_1.assertWarning)(!isOldDesign, "You are using Vike's deprecated design. Update to the new V1 design, see https://vike.dev/migration/v1-design for how to migrate.", { onlyOnce: true });
|
|
25
|
+
}
|
|
26
|
+
exports.assertV1Design = assertV1Design;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getClientEntry = void 0;
|
|
4
4
|
const helpers_js_1 = require("../../shared/page-configs/helpers.js");
|
|
5
|
-
function
|
|
5
|
+
function getClientEntry(pageConfig) {
|
|
6
6
|
const configName = 'client';
|
|
7
7
|
const configValue = (0, helpers_js_1.getConfigValue)(pageConfig, configName, 'string');
|
|
8
8
|
if (!configValue)
|
|
9
9
|
return null;
|
|
10
10
|
return configValue.value;
|
|
11
11
|
}
|
|
12
|
-
exports.
|
|
12
|
+
exports.getClientEntry = getClientEntry;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prependEntriesDir = void 0;
|
|
4
|
+
const utils_js_1 = require("./utils.js");
|
|
5
|
+
function prependEntriesDir(entryName) {
|
|
6
|
+
if (entryName.startsWith('/')) {
|
|
7
|
+
entryName = entryName.slice(1);
|
|
8
|
+
}
|
|
9
|
+
(0, utils_js_1.assert)(!entryName.startsWith('/'));
|
|
10
|
+
entryName = `entries/${entryName}`;
|
|
11
|
+
return entryName;
|
|
12
|
+
}
|
|
13
|
+
exports.prependEntriesDir = prependEntriesDir;
|
|
@@ -31,3 +31,5 @@ __exportStar(require("../../utils/parseUrl-extras.js"), exports);
|
|
|
31
31
|
__exportStar(require("../../utils/isObject.js"), exports);
|
|
32
32
|
__exportStar(require("../../utils/virtual-files.js"), exports);
|
|
33
33
|
__exportStar(require("../../utils/assertIsNotBrowser.js"), exports);
|
|
34
|
+
__exportStar(require("../../utils/isNotNullish.js"), exports);
|
|
35
|
+
__exportStar(require("../../utils/unique.js"), exports);
|
|
@@ -4,41 +4,68 @@ exports.parseConfigValuesImported = void 0;
|
|
|
4
4
|
const utils_js_1 = require("../../utils.js");
|
|
5
5
|
const assertPlusFileExport_js_1 = require("../assertPlusFileExport.js");
|
|
6
6
|
function parseConfigValuesImported(configValuesImported) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
definedAt: {
|
|
12
|
-
// importPath cannot be relative to the current file, since the current file is a virtual file
|
|
13
|
-
filePathToShowToUser: importPath,
|
|
14
|
-
fileExportPathToShowToUser: [configName, 'default'].includes(exportName)
|
|
15
|
-
? []
|
|
16
|
-
: // Side-effect config
|
|
17
|
-
[exportName]
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
assertIsNotNull(value, configName, importPath);
|
|
21
|
-
};
|
|
22
|
-
configValuesImported.forEach((configValueLoaded) => {
|
|
7
|
+
const configValuesUnmerged = {};
|
|
8
|
+
configValuesImported
|
|
9
|
+
.filter((c) => c.configName !== 'client')
|
|
10
|
+
.forEach((configValueLoaded) => {
|
|
23
11
|
if (configValueLoaded.isValueFile) {
|
|
24
12
|
const { exportValues, importPath, configName } = configValueLoaded;
|
|
25
|
-
|
|
26
|
-
(0, assertPlusFileExport_js_1.assertPlusFileExport)(exportValues, importPath, configName);
|
|
27
|
-
}
|
|
13
|
+
(0, assertPlusFileExport_js_1.assertPlusFileExport)(exportValues, importPath, configName);
|
|
28
14
|
Object.entries(exportValues).forEach(([exportName, exportValue]) => {
|
|
29
15
|
const isSideExport = exportName !== 'default'; // .md files may have "side-exports" such as `export { frontmatter }`
|
|
30
16
|
const configName = isSideExport ? exportName : configValueLoaded.configName;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
configValuesUnmerged[configName] ?? (configValuesUnmerged[configName] = []);
|
|
18
|
+
configValuesUnmerged[configName].push({
|
|
19
|
+
value: exportValue,
|
|
20
|
+
importPath,
|
|
21
|
+
exportName,
|
|
22
|
+
isSideExport
|
|
23
|
+
});
|
|
37
24
|
});
|
|
38
25
|
}
|
|
39
26
|
else {
|
|
40
27
|
const { configName, importPath, exportValue, exportName } = configValueLoaded;
|
|
41
|
-
|
|
28
|
+
configValuesUnmerged[configName] ?? (configValuesUnmerged[configName] = []);
|
|
29
|
+
configValuesUnmerged[configName].push({
|
|
30
|
+
value: exportValue,
|
|
31
|
+
importPath,
|
|
32
|
+
exportName,
|
|
33
|
+
isSideExport: false
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const configValues = {};
|
|
38
|
+
Object.entries(configValuesUnmerged).forEach(([configName, values]) => {
|
|
39
|
+
const valuesWithoutSideExports = values.filter((v) => !v.isSideExport);
|
|
40
|
+
const isCumulative = valuesWithoutSideExports.length > 1;
|
|
41
|
+
const noSideExports = valuesWithoutSideExports.length === values.length;
|
|
42
|
+
if (isCumulative) {
|
|
43
|
+
// Vike currently doesn't support side exports for cumulative configs
|
|
44
|
+
(0, utils_js_1.assert)(noSideExports);
|
|
45
|
+
// TODO: implement
|
|
46
|
+
(0, utils_js_1.assert)(false);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
const val = valuesWithoutSideExports[0] ??
|
|
50
|
+
// We can't avoid side-export conflicts upstream. (We cannot know about side-exports at build-time.)
|
|
51
|
+
// Side-exports have lower precedence.
|
|
52
|
+
values[0];
|
|
53
|
+
(0, utils_js_1.assert)(val);
|
|
54
|
+
const { value, importPath, exportName } = val;
|
|
55
|
+
configValues[configName] = {
|
|
56
|
+
value,
|
|
57
|
+
definedAt: {
|
|
58
|
+
// importPath cannot be relative to the current file, since the current file is a virtual file
|
|
59
|
+
filePathToShowToUser: importPath,
|
|
60
|
+
fileExportPathToShowToUser: [configName, 'default'].includes(exportName)
|
|
61
|
+
? []
|
|
62
|
+
: [
|
|
63
|
+
// Side-export
|
|
64
|
+
exportName
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
assertIsNotNull(value, configName, importPath);
|
|
42
69
|
}
|
|
43
70
|
});
|
|
44
71
|
return configValues;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.executeGuardHook = void 0;
|
|
4
4
|
const getHook_js_1 = require("../hooks/getHook.js");
|
|
5
5
|
const utils_js_1 = require("./utils.js");
|
|
6
|
+
const errIntro = 'The guard() hook defined by';
|
|
6
7
|
async function executeGuardHook(pageContext, prepareForUserConsumption) {
|
|
7
8
|
let hook;
|
|
8
9
|
if (pageContext._pageFilesAll.length > 0) {
|
|
@@ -22,7 +23,7 @@ async function executeGuardHook(pageContext, prepareForUserConsumption) {
|
|
|
22
23
|
if (res)
|
|
23
24
|
pageContextForUserConsumption = res;
|
|
24
25
|
const hookResult = await (0, utils_js_1.executeHook)(() => guard(pageContextForUserConsumption), hook);
|
|
25
|
-
(0, utils_js_1.assertUsage)(hookResult === undefined,
|
|
26
|
+
(0, utils_js_1.assertUsage)(hookResult === undefined, `${errIntro} ${hook.hookFilePath} returns a value, but guard() shouldn't return any value`);
|
|
26
27
|
}
|
|
27
28
|
exports.executeGuardHook = executeGuardHook;
|
|
28
29
|
function findPageGuard(pageId, pageFilesAll) {
|
|
@@ -36,6 +37,6 @@ function findPageGuard(pageId, pageFilesAll) {
|
|
|
36
37
|
return null;
|
|
37
38
|
const hookFilePath = filePath;
|
|
38
39
|
const hookTimeout = (0, getHook_js_1.getHookTimeoutDefault)('guard');
|
|
39
|
-
(0, utils_js_1.assertUsage)((0, utils_js_1.isCallable)(hookFn),
|
|
40
|
+
(0, utils_js_1.assertUsage)((0, utils_js_1.isCallable)(hookFn), `${errIntro} ${hookFilePath} should be a function`);
|
|
40
41
|
return { hookFn, hookName: 'guard', hookFilePath, hookTimeout };
|
|
41
42
|
}
|
package/dist/cjs/shared/utils.js
CHANGED
|
@@ -38,6 +38,5 @@ __exportStar(require("../utils/projectInfo.js"), exports);
|
|
|
38
38
|
__exportStar(require("../utils/isPropertyGetter.js"), exports);
|
|
39
39
|
__exportStar(require("../utils/isPromise.js"), exports);
|
|
40
40
|
__exportStar(require("../utils/checkType.js"), exports);
|
|
41
|
-
__exportStar(require("../utils/objectEntries.js"), exports);
|
|
42
41
|
__exportStar(require("../utils/getValuePrintable.js"), exports);
|
|
43
42
|
__exportStar(require("../utils/escapeRegex.js"), exports);
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.assertNodeVersion = void 0;
|
|
4
4
|
const assert_js_1 = require("./assert.js");
|
|
5
5
|
const isNodeJS_js_1 = require("./isNodeJS.js");
|
|
6
|
+
const isVersionOrAbove_js_1 = require("./isVersionOrAbove.js");
|
|
6
7
|
// package.json#engines.node isn't enough as users can ignore it
|
|
7
8
|
function assertNodeVersion() {
|
|
8
9
|
if (!(0, isNodeJS_js_1.isNodeJS)())
|
|
9
10
|
return;
|
|
10
11
|
const version = process.versions.node;
|
|
11
|
-
|
|
12
|
-
(0, assert_js_1.assertUsage)(major >= 16, `Node.js ${version} isn't supported, use Node.js >=16.0.0 instead.`);
|
|
12
|
+
(0, assert_js_1.assertUsage)((0, isVersionOrAbove_js_1.isVersionOrAbove)(version, '16.0.0'), `Node.js ${version} isn't supported, use Node.js >=16.0.0 instead.`);
|
|
13
13
|
}
|
|
14
14
|
exports.assertNodeVersion = assertNodeVersion;
|
|
@@ -3,16 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.findFile = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
function
|
|
10
|
-
|
|
9
|
+
function findFile(arg, cwd) {
|
|
10
|
+
const filenames = Array.isArray(arg) ? arg : [arg];
|
|
11
|
+
let dir = cwd;
|
|
11
12
|
while (true) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
for (const filename of filenames) {
|
|
14
|
+
const configFilePath = path_1.default.join(dir, `./${filename}`);
|
|
15
|
+
if (fs_1.default.existsSync(configFilePath)) {
|
|
16
|
+
// return toPosixPath(configFilePath)
|
|
17
|
+
return configFilePath;
|
|
18
|
+
}
|
|
16
19
|
}
|
|
17
20
|
const dirPrevious = dir;
|
|
18
21
|
dir = path_1.default.dirname(dir);
|
|
@@ -21,4 +24,4 @@ function findUserPackageJsonPath(userDir) {
|
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
|
-
exports.
|
|
27
|
+
exports.findFile = findFile;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isVersionOrAbove = void 0;
|
|
4
|
+
const assert_js_1 = require("./assert.js");
|
|
5
|
+
function isVersionOrAbove(versionActual, versionExpected) {
|
|
6
|
+
const p1 = parseVersion(versionActual);
|
|
7
|
+
const p2 = parseVersion(versionExpected);
|
|
8
|
+
// major
|
|
9
|
+
if (p1[0] !== p2[0])
|
|
10
|
+
return p1[0] > p2[0];
|
|
11
|
+
// minor
|
|
12
|
+
if (p1[1] !== p2[1])
|
|
13
|
+
return p1[1] > p2[1];
|
|
14
|
+
// patch
|
|
15
|
+
if (p1[2] !== p2[2])
|
|
16
|
+
return p1[2] > p2[2];
|
|
17
|
+
// Same version
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
exports.isVersionOrAbove = isVersionOrAbove;
|
|
21
|
+
function parseVersion(version) {
|
|
22
|
+
// Remove pre-release tag
|
|
23
|
+
version = version.split('-')[0];
|
|
24
|
+
// major.minor.patch
|
|
25
|
+
const partsStr = version.split('.');
|
|
26
|
+
(0, assert_js_1.assert)(partsStr.length === 3);
|
|
27
|
+
const parts = partsStr.map((s) => parseInt(s, 10));
|
|
28
|
+
return parts;
|
|
29
|
+
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNodeEnvDev = exports.setNodeEnvToProduction = exports.getNodeEnv = void 0;
|
|
6
|
+
exports.assertNodeEnvIsNotDev = exports.getNodeEnvDesc = exports.isNodeEnvDev = exports.setNodeEnvToProduction = exports.getNodeEnv = void 0;
|
|
7
|
+
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
8
|
+
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
9
|
+
const assert_js_1 = require("./assert.js");
|
|
10
|
+
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
4
11
|
function getNodeEnv() {
|
|
5
12
|
if (typeof process === 'undefined')
|
|
6
13
|
return null;
|
|
@@ -24,3 +31,18 @@ function isNodeEnvDev() {
|
|
|
24
31
|
return false;
|
|
25
32
|
}
|
|
26
33
|
exports.isNodeEnvDev = isNodeEnvDev;
|
|
34
|
+
function getNodeEnvDesc() {
|
|
35
|
+
const nodeEnv = getNodeEnv();
|
|
36
|
+
const isDev = isNodeEnvDev();
|
|
37
|
+
const nodeEnvDesc = `environment is set to be a ${(isDev ? 'development' : 'production')} environment by ${picocolors_1.default.cyan(`process.env.NODE_ENV === ${JSON.stringify(nodeEnv)}`)}`;
|
|
38
|
+
return nodeEnvDesc;
|
|
39
|
+
}
|
|
40
|
+
exports.getNodeEnvDesc = getNodeEnvDesc;
|
|
41
|
+
function assertNodeEnvIsNotDev(operation) {
|
|
42
|
+
const isDev = isNodeEnvDev();
|
|
43
|
+
if (!isDev)
|
|
44
|
+
return;
|
|
45
|
+
const nodeEnvDesc = getNodeEnvDesc();
|
|
46
|
+
(0, assert_js_1.assertUsage)(false, `The ${nodeEnvDesc} which is forbidden upon ${operation}, see https://vike.dev/NODE_ENV`);
|
|
47
|
+
}
|
|
48
|
+
exports.assertNodeEnvIsNotDev = assertNodeEnvIsNotDev;
|