vike 0.4.172-commit-c1dcd5f → 0.4.172-commit-8bdf055
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/plugin/plugins/commonConfig.js +4 -8
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +129 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +10 -32
- package/dist/cjs/node/plugin/shared/loggerNotProd/log.js +1 -1
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/cjs/node/plugin/shared/loggerVite.js +1 -1
- package/dist/cjs/node/plugin/utils.js +1 -1
- package/dist/cjs/node/runtime/onLoad.js +4 -0
- package/dist/cjs/node/{plugin/shared → shared}/isErrorDebug.js +1 -1
- package/dist/cjs/node/shared/utils.js +1 -0
- package/dist/cjs/utils/assert.js +7 -1
- package/dist/cjs/utils/findFile.js +5 -3
- package/dist/cjs/utils/findPackageJson.js +19 -0
- package/dist/cjs/utils/joinEnglish.js +1 -1
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +5 -9
- package/dist/esm/node/plugin/plugins/devConfig/index.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.d.ts +5 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +123 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +10 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +9 -31
- package/dist/esm/node/plugin/shared/loggerNotProd/log.js +1 -1
- package/dist/esm/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/esm/node/plugin/shared/loggerVite.js +1 -1
- package/dist/esm/node/plugin/utils.d.ts +1 -1
- package/dist/esm/node/plugin/utils.js +1 -1
- package/dist/esm/node/runtime/onLoad.js +4 -0
- package/dist/esm/node/{plugin/shared → shared}/isErrorDebug.js +1 -1
- package/dist/esm/node/shared/utils.d.ts +1 -0
- package/dist/esm/node/shared/utils.js +1 -0
- package/dist/esm/shared/page-configs/Config.d.ts +6 -0
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/assert.d.ts +2 -0
- package/dist/esm/utils/assert.js +6 -0
- package/dist/esm/utils/findFile.js +5 -3
- package/dist/esm/utils/findPackageJson.d.ts +5 -0
- package/dist/esm/utils/findPackageJson.js +16 -0
- package/dist/esm/utils/joinEnglish.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +1 -1
- /package/dist/esm/node/{plugin/shared → shared}/isErrorDebug.d.ts +0 -0
|
@@ -9,11 +9,7 @@ const buildConfig_js_1 = require("./buildConfig.js");
|
|
|
9
9
|
const require_shim_1 = require("@brillout/require-shim");
|
|
10
10
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const module_1 = require("module");
|
|
13
12
|
const assertResolveAlias_js_1 = require("./commonConfig/assertResolveAlias.js");
|
|
14
|
-
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
15
|
-
const importMetaUrl = `file://${__filename}`;
|
|
16
|
-
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
17
13
|
const pluginName = 'vike:commonConfig-1';
|
|
18
14
|
function commonConfig() {
|
|
19
15
|
return [
|
|
@@ -70,11 +66,11 @@ function workaroundCI(config) {
|
|
|
70
66
|
}
|
|
71
67
|
}
|
|
72
68
|
function assertEsm(userViteRoot) {
|
|
73
|
-
const
|
|
74
|
-
if (!
|
|
69
|
+
const found = (0, utils_js_1.findPackageJson)(userViteRoot);
|
|
70
|
+
if (!found)
|
|
75
71
|
return;
|
|
76
|
-
const packageJson =
|
|
77
|
-
let dir = path_1.default.dirname(packageJsonPath);
|
|
72
|
+
const { packageJson, packageJsonPath } = found;
|
|
73
|
+
let dir = path_1.default.posix.dirname(packageJsonPath);
|
|
78
74
|
if (dir !== '/') {
|
|
79
75
|
(0, utils_js_1.assert)(!dir.endsWith('/'));
|
|
80
76
|
dir = dir + '/';
|
|
@@ -6,7 +6,7 @@ const determineFsAllowList_js_1 = require("./determineFsAllowList.js");
|
|
|
6
6
|
const addSsrMiddleware_js_1 = require("../../shared/addSsrMiddleware.js");
|
|
7
7
|
const utils_js_1 = require("../../utils.js");
|
|
8
8
|
const loggerVite_js_1 = require("../../shared/loggerVite.js");
|
|
9
|
-
const isErrorDebug_js_1 = require("
|
|
9
|
+
const isErrorDebug_js_1 = require("../../../shared/isErrorDebug.js");
|
|
10
10
|
const getHttpRequestAsyncStore_js_1 = require("../../shared/getHttpRequestAsyncStore.js");
|
|
11
11
|
if ((0, isErrorDebug_js_1.isErrorDebug)()) {
|
|
12
12
|
Error.stackTraceLimit = Infinity;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.assertExtensionsPeerDependencies = exports.assertExtensionsConventions = void 0;
|
|
7
|
+
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
8
|
+
const isObjectOfStrings_js_1 = require("../../../../../utils/isObjectOfStrings.js");
|
|
9
|
+
const utils_js_1 = require("../../../utils.js");
|
|
10
|
+
const getVikeConfig_js_1 = require("./getVikeConfig.js");
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const semver_1 = __importDefault(require("semver"));
|
|
13
|
+
function assertExtensionsConventions(interfaceFile) {
|
|
14
|
+
assertExtensionName(interfaceFile);
|
|
15
|
+
assertConfigExportPath(interfaceFile);
|
|
16
|
+
}
|
|
17
|
+
exports.assertExtensionsConventions = assertExtensionsConventions;
|
|
18
|
+
function assertConfigExportPath(interfaceFile) {
|
|
19
|
+
const { importPathAbsolute } = interfaceFile.filePath;
|
|
20
|
+
(0, utils_js_1.assert)(importPathAbsolute);
|
|
21
|
+
const name = getConfigNameValue(interfaceFile);
|
|
22
|
+
(0, utils_js_1.assert)(name); // already asserted in assertExtensionName()
|
|
23
|
+
const importPathAbsoluteExpected = `${name}/config`;
|
|
24
|
+
(0, utils_js_1.assertWarning)(importPathAbsolute === importPathAbsoluteExpected, `The Vike configuration of ${picocolors_1.default.bold(name)} is exported at ${picocolors_1.default.bold(importPathAbsolute)} but it should be exported at ${picocolors_1.default.bold(importPathAbsoluteExpected)} instead.`, { onlyOnce: true });
|
|
25
|
+
}
|
|
26
|
+
function assertExtensionName(interfaceFile) {
|
|
27
|
+
let nameDeduced;
|
|
28
|
+
{
|
|
29
|
+
const { importPathAbsolute } = interfaceFile.filePath;
|
|
30
|
+
(0, utils_js_1.assert)(importPathAbsolute);
|
|
31
|
+
nameDeduced = importPathAbsolute
|
|
32
|
+
.split('/')
|
|
33
|
+
.slice(0, importPathAbsolute.startsWith('@') ? 2 : 1)
|
|
34
|
+
.join('/');
|
|
35
|
+
}
|
|
36
|
+
const name = getConfigNameValue(interfaceFile);
|
|
37
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
38
|
+
if (name) {
|
|
39
|
+
(0, utils_js_1.assertWarning)(name === nameDeduced, `The setting ${picocolors_1.default.bold('name')} defined at ${filePathToShowToUser} is ${picocolors_1.default.bold(name)} but it should be ${picocolors_1.default.bold(nameDeduced)} instead (the name of the npm package).`, { onlyOnce: true });
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
if (
|
|
43
|
+
// Let's eventually remove this
|
|
44
|
+
[
|
|
45
|
+
'vike-react',
|
|
46
|
+
'vike-react-query',
|
|
47
|
+
'vike-react-zustand',
|
|
48
|
+
'vike-vue',
|
|
49
|
+
'vike-vue-query',
|
|
50
|
+
'vike-vue-pinia',
|
|
51
|
+
'vike-pinia',
|
|
52
|
+
'vike-solid'
|
|
53
|
+
].includes(nameDeduced)) {
|
|
54
|
+
(0, utils_js_1.assertUsage)(false, `Update ${nameDeduced} to its latest version.`);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
(0, utils_js_1.assertUsage)(false, `The setting ${picocolors_1.default.bold('name')} is missing: it should be set by the config ${filePathToShowToUser} of ${picocolors_1.default.bold(nameDeduced)}.`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function assertExtensionsPeerDependencies(interfaceFilesRelevantList) {
|
|
62
|
+
// Get installed extensions
|
|
63
|
+
const extensions = {};
|
|
64
|
+
interfaceFilesRelevantList.forEach((interfaceFile) => {
|
|
65
|
+
const name = getConfigNameValue(interfaceFile);
|
|
66
|
+
if (name) {
|
|
67
|
+
const version = getExtensionVersion(name, interfaceFile);
|
|
68
|
+
extensions[name] = version;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
// Enforce peer dependencies
|
|
72
|
+
interfaceFilesRelevantList.forEach((interfaceFile) => {
|
|
73
|
+
const require = getConfigRequireValue(interfaceFile);
|
|
74
|
+
if (!require)
|
|
75
|
+
return;
|
|
76
|
+
const name = getConfigNameValue(interfaceFile);
|
|
77
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
78
|
+
(0, utils_js_1.assertUsage)(name, `Setting ${picocolors_1.default.bold('name')} is required for being able to use setting ${picocolors_1.default.bold('require')} in ${filePathToShowToUser}.`);
|
|
79
|
+
Object.entries(require).forEach(([reqName, reqVersion]) => {
|
|
80
|
+
const errBase = `${picocolors_1.default.bold(name)} requires ${picocolors_1.default.bold(reqName)}`;
|
|
81
|
+
if (reqName === 'vike') {
|
|
82
|
+
(0, utils_js_1.assertUsage)(semver_1.default.satisfies(utils_js_1.PROJECT_VERSION, reqVersion), `${errBase} version ${picocolors_1.default.bold(reqVersion)} but ${picocolors_1.default.bold(utils_js_1.PROJECT_VERSION)} is installed.`);
|
|
83
|
+
}
|
|
84
|
+
const extensionVersion = extensions[reqName];
|
|
85
|
+
(0, utils_js_1.assertUsage)(extensionVersion, `${errBase}.`);
|
|
86
|
+
(0, utils_js_1.assertUsage)(semver_1.default.satisfies(extensionVersion, reqVersion), `${errBase} version ${picocolors_1.default.bold(reqVersion)} but ${picocolors_1.default.bold(extensionVersion)} is installed.`);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
exports.assertExtensionsPeerDependencies = assertExtensionsPeerDependencies;
|
|
91
|
+
function getConfigRequireValue(interfaceFile) {
|
|
92
|
+
const require = (0, getVikeConfig_js_1.getConfigValueInterfaceFile)(interfaceFile, 'require');
|
|
93
|
+
if (!require)
|
|
94
|
+
return null;
|
|
95
|
+
const { filePathToShowToUserResolved } = interfaceFile.filePath;
|
|
96
|
+
(0, utils_js_1.assert)(filePathToShowToUserResolved);
|
|
97
|
+
(0, utils_js_1.assertUsage)((0, isObjectOfStrings_js_1.isObjectOfStrings)(require), `The setting ${picocolors_1.default.bold('require')} defined at ${filePathToShowToUserResolved} should be an object with string values (${picocolors_1.default.bold('Record<string, string>')}).`);
|
|
98
|
+
return require;
|
|
99
|
+
}
|
|
100
|
+
function getConfigNameValue(interfaceFile) {
|
|
101
|
+
const name = (0, getVikeConfig_js_1.getConfigValueInterfaceFile)(interfaceFile, 'name');
|
|
102
|
+
if (!name)
|
|
103
|
+
return null;
|
|
104
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
105
|
+
(0, utils_js_1.assertUsage)(typeof name === 'string', `The setting ${picocolors_1.default.bold('name')} defined at ${filePathToShowToUser} should be a string.`);
|
|
106
|
+
return name;
|
|
107
|
+
}
|
|
108
|
+
// We use a forever cache: users need to restart the dev server anyways when touching node_modules/**/* (I presume Vite doesn't pick up node_modules/**/* changes).
|
|
109
|
+
const extensionsVersion = {};
|
|
110
|
+
function getExtensionVersion(name, interfaceFile) {
|
|
111
|
+
if (!extensionsVersion[name]) {
|
|
112
|
+
const extensionConfigFilePath = interfaceFile.filePath.filePathAbsoluteFilesystem;
|
|
113
|
+
const found = (0, utils_js_1.findPackageJson)(path_1.default.posix.dirname(extensionConfigFilePath));
|
|
114
|
+
(0, utils_js_1.assert)(found);
|
|
115
|
+
const { packageJson, packageJsonPath } = found;
|
|
116
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
117
|
+
const nameExpected = packageJson.name;
|
|
118
|
+
(0, utils_js_1.assertWarning)(name === nameExpected, `The setting ${picocolors_1.default.bold('name')} defined at ${filePathToShowToUser} is ${picocolors_1.default.bold(JSON.stringify(name))} but it should be equal to ${picocolors_1.default.bold(JSON.stringify(nameExpected))} (the value of ${packageJsonPath}${picocolors_1.default.dim('#')}${picocolors_1.default.bold('name')})`, { onlyOnce: true });
|
|
119
|
+
const { version } = packageJson;
|
|
120
|
+
(0, utils_js_1.assert)(typeof version === 'string');
|
|
121
|
+
extensionsVersion[name] = version;
|
|
122
|
+
}
|
|
123
|
+
return extensionsVersion[name];
|
|
124
|
+
}
|
|
125
|
+
function getFilePathToShowToUser(interfaceFile) {
|
|
126
|
+
const { filePathToShowToUserResolved } = interfaceFile.filePath;
|
|
127
|
+
(0, utils_js_1.assert)(filePathToShowToUserResolved);
|
|
128
|
+
return filePathToShowToUserResolved;
|
|
129
|
+
}
|
|
@@ -3,7 +3,7 @@ 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.isV1Design = exports.isVikeConfigFile = exports.vikeConfigDependencies = exports.reloadVikeConfig = exports.getVikeConfig = void 0;
|
|
6
|
+
exports.getConfigValueInterfaceFile = exports.isV1Design = exports.isVikeConfigFile = exports.vikeConfigDependencies = exports.reloadVikeConfig = exports.getVikeConfig = void 0;
|
|
7
7
|
const utils_js_1 = require("../../../utils.js");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const configDefinitionsBuiltIn_js_1 = require("./getVikeConfig/configDefinitionsBuiltIn.js");
|
|
@@ -22,6 +22,7 @@ const resolvePointerImport_js_1 = require("./getVikeConfig/resolvePointerImport.
|
|
|
22
22
|
const getFilePath_js_1 = require("../../../shared/getFilePath.js");
|
|
23
23
|
const getConfigValueBuildTime_js_1 = require("../../../../../shared/page-configs/getConfigValueBuildTime.js");
|
|
24
24
|
const getConfigVike_js_1 = require("../../../../shared/getConfigVike.js");
|
|
25
|
+
const assertExtensions_js_1 = require("./assertExtensions.js");
|
|
25
26
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
26
27
|
let devServerIsCorrupt = false;
|
|
27
28
|
let wasConfigInvalid = null;
|
|
@@ -125,29 +126,7 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, crawlWithGit)
|
|
|
125
126
|
```
|
|
126
127
|
*/
|
|
127
128
|
const interfaceFile = getInterfaceFileFromConfigFile(extendsConfig, true, locationId);
|
|
128
|
-
|
|
129
|
-
const alreadyMigrated = [
|
|
130
|
-
'vike-react',
|
|
131
|
-
'vike-react-query',
|
|
132
|
-
'vike-react-zustand',
|
|
133
|
-
'vike-vue',
|
|
134
|
-
'vike-pinia',
|
|
135
|
-
'vike-solid'
|
|
136
|
-
];
|
|
137
|
-
(0, utils_js_1.assert)(extendsConfig.filePath.importPathAbsolute);
|
|
138
|
-
const extensionName = extendsConfig.filePath.importPathAbsolute.split('/')[0];
|
|
139
|
-
const warnMsg = alreadyMigrated.includes(extensionName)
|
|
140
|
-
? `You're using a deprecated version of the Vike extension ${extensionName}, update ${extensionName} to its latest version.`
|
|
141
|
-
: `The config of the Vike extension ${extensionName} should set a ${picocolors_1.default.cyan('name')} value`;
|
|
142
|
-
const isNameDefined = interfaceFile.fileExportsByConfigName.name?.configValue;
|
|
143
|
-
if (alreadyMigrated) {
|
|
144
|
-
// Eventually always make it a assertUsage()
|
|
145
|
-
(0, utils_js_1.assertWarning)(isNameDefined, warnMsg, { onlyOnce: true });
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
(0, utils_js_1.assertUsage)(isNameDefined, warnMsg);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
129
|
+
(0, assertExtensions_js_1.assertExtensionsConventions)(interfaceFile);
|
|
151
130
|
interfaceFilesByLocationId[locationId].push(interfaceFile);
|
|
152
131
|
});
|
|
153
132
|
}),
|
|
@@ -265,9 +244,11 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
|
265
244
|
.filter(([_pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
|
|
266
245
|
.map(async ([locationId]) => {
|
|
267
246
|
const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesByLocationId, locationId);
|
|
247
|
+
const interfaceFilesRelevantList = Object.values(interfaceFilesByLocationId).flat(1);
|
|
248
|
+
(0, assertExtensions_js_1.assertExtensionsPeerDependencies)(interfaceFilesRelevantList);
|
|
268
249
|
const configDefinitions = getConfigDefinitions(interfaceFilesRelevant);
|
|
269
250
|
// Load value files of custom config-only configs
|
|
270
|
-
await Promise.all(
|
|
251
|
+
await Promise.all(interfaceFilesRelevantList.map(async (interfaceFile) => {
|
|
271
252
|
if (!interfaceFile.isValueFile)
|
|
272
253
|
return;
|
|
273
254
|
const { configName } = interfaceFile;
|
|
@@ -355,13 +336,6 @@ function getInterfaceFilesRelevant(interfaceFilesByLocationId, locationIdPage) {
|
|
|
355
336
|
.sort(([locationId1], [locationId2]) => (0, filesystemRouting_js_1.sortAfterInheritanceOrder)(locationId1, locationId2, locationIdPage)));
|
|
356
337
|
return interfaceFilesRelevant;
|
|
357
338
|
}
|
|
358
|
-
function getInterfaceFileList(interfaceFilesByLocationId) {
|
|
359
|
-
const interfaceFiles = [];
|
|
360
|
-
Object.values(interfaceFilesByLocationId).forEach((interfaceFiles_) => {
|
|
361
|
-
interfaceFiles.push(...interfaceFiles_);
|
|
362
|
-
});
|
|
363
|
-
return interfaceFiles;
|
|
364
|
-
}
|
|
365
339
|
async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded) {
|
|
366
340
|
const locationIds = (0, utils_js_1.objectKeys)(interfaceFilesByLocationId);
|
|
367
341
|
const interfaceFilesGlobal = (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(interfaceFilesByLocationId).filter(([locationId]) => {
|
|
@@ -975,3 +949,7 @@ function sortConfigValueSources(configValueSources, locationIdPage) {
|
|
|
975
949
|
// Sort after the filesystem inheritance of the config value
|
|
976
950
|
.sort(([, [source1]], [, [source2]]) => (0, utils_js_1.reverse)((0, filesystemRouting_js_1.sortAfterInheritanceOrder)(source1.locationId, source2.locationId, locationIdPage))));
|
|
977
951
|
}
|
|
952
|
+
function getConfigValueInterfaceFile(interfaceFile, configName) {
|
|
953
|
+
return interfaceFile.fileExportsByConfigName[configName]?.configValue;
|
|
954
|
+
}
|
|
955
|
+
exports.getConfigValueInterfaceFile = getConfigValueInterfaceFile;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.applyViteSourceMapToStackTrace = exports.screenHasErrors = exports.clearScreen = exports.isFirstLog = exports.logDirectly = exports.logWithVikeTag = exports.logWithViteTag = void 0;
|
|
7
7
|
const utils_js_1 = require("../../utils.js");
|
|
8
8
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
|
-
const isErrorDebug_js_1 = require("
|
|
9
|
+
const isErrorDebug_js_1 = require("../../../shared/isErrorDebug.js");
|
|
10
10
|
const globalContext_js_1 = require("../../../runtime/globalContext.js");
|
|
11
11
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
12
12
|
let isFirstLog = true;
|
|
@@ -15,7 +15,7 @@ const globalContext_js_1 = require("../../runtime/globalContext.js");
|
|
|
15
15
|
const loggerRuntime_js_1 = require("../../runtime/renderPage/loggerRuntime.js");
|
|
16
16
|
const utils_js_1 = require("../utils.js");
|
|
17
17
|
const getHttpRequestAsyncStore_js_1 = require("./getHttpRequestAsyncStore.js");
|
|
18
|
-
const isErrorDebug_js_1 = require("
|
|
18
|
+
const isErrorDebug_js_1 = require("../../shared/isErrorDebug.js");
|
|
19
19
|
const errorWithCodeSnippet_js_1 = require("./loggerNotProd/errorWithCodeSnippet.js");
|
|
20
20
|
const transpileAndExecuteFile_js_1 = require("../plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js");
|
|
21
21
|
const log_js_1 = require("./loggerNotProd/log.js");
|
|
@@ -5,7 +5,7 @@ const utils_js_1 = require("../utils.js");
|
|
|
5
5
|
const loggerNotProd_js_1 = require("./loggerNotProd.js");
|
|
6
6
|
const getHttpRequestAsyncStore_js_1 = require("./getHttpRequestAsyncStore.js");
|
|
7
7
|
const removeSuperfluousViteLog_js_1 = require("./loggerVite/removeSuperfluousViteLog.js");
|
|
8
|
-
const isErrorDebug_js_1 = require("
|
|
8
|
+
const isErrorDebug_js_1 = require("../../shared/isErrorDebug.js");
|
|
9
9
|
function improveViteLogs(config) {
|
|
10
10
|
intercept('info', config);
|
|
11
11
|
intercept('warn', config);
|
|
@@ -32,7 +32,7 @@ __exportStar(require("../../utils/escapeRegex.js"), exports);
|
|
|
32
32
|
__exportStar(require("../../utils/stripAnsi.js"), exports);
|
|
33
33
|
__exportStar(require("../../utils/trimWithAnsi.js"), exports);
|
|
34
34
|
__exportStar(require("../../utils/removeEmptyLines.js"), exports);
|
|
35
|
-
__exportStar(require("../../utils/
|
|
35
|
+
__exportStar(require("../../utils/findPackageJson.js"), exports);
|
|
36
36
|
__exportStar(require("../../utils/getPropAccessNotation.js"), exports);
|
|
37
37
|
__exportStar(require("../../utils/deepEqual.js"), exports);
|
|
38
38
|
__exportStar(require("../../utils/assertKeys.js"), exports);
|
|
@@ -4,9 +4,13 @@ exports.onLoad = void 0;
|
|
|
4
4
|
const assertIsNotBrowser_js_1 = require("../../utils/assertIsNotBrowser.js");
|
|
5
5
|
const assertNodeVersion_js_1 = require("../../utils/assertNodeVersion.js");
|
|
6
6
|
const require_shim_1 = require("@brillout/require-shim");
|
|
7
|
+
const utils_js_1 = require("./utils.js");
|
|
8
|
+
const isErrorDebug_js_1 = require("../shared/isErrorDebug.js");
|
|
7
9
|
function onLoad() {
|
|
8
10
|
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
9
11
|
(0, assertNodeVersion_js_1.assertNodeVersion)();
|
|
10
12
|
(0, require_shim_1.installRequireShim)();
|
|
13
|
+
if ((0, isErrorDebug_js_1.isErrorDebug)())
|
|
14
|
+
(0, utils_js_1.setAlwaysShowStackTrace)();
|
|
11
15
|
}
|
|
12
16
|
exports.onLoad = onLoad;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isErrorDebug = void 0;
|
|
4
|
-
const utils_js_1 = require("
|
|
4
|
+
const utils_js_1 = require("./utils.js");
|
|
5
5
|
function isErrorDebug() {
|
|
6
6
|
return (0, utils_js_1.isDebugActivated)('vike:error');
|
|
7
7
|
}
|
|
@@ -32,3 +32,4 @@ __exportStar(require("../../utils/virtual-files.js"), exports);
|
|
|
32
32
|
__exportStar(require("../../utils/assertIsNotBrowser.js"), exports);
|
|
33
33
|
__exportStar(require("../../utils/isNotNullish.js"), exports);
|
|
34
34
|
__exportStar(require("../../utils/unique.js"), exports);
|
|
35
|
+
__exportStar(require("../../utils/debug.js"), exports);
|
package/dist/cjs/utils/assert.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.isBug = exports.overwriteAssertProductionLogger = exports.getAssertErrMsg = exports.addOnBeforeLogHook = exports.getProjectError = exports.assertInfo = exports.assertWarning = exports.assertUsage = exports.assert = void 0;
|
|
6
|
+
exports.setAlwaysShowStackTrace = exports.isBug = exports.overwriteAssertProductionLogger = exports.getAssertErrMsg = exports.addOnBeforeLogHook = exports.getProjectError = exports.assertInfo = exports.assertWarning = exports.assertUsage = exports.assert = void 0;
|
|
7
7
|
const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
|
|
8
8
|
const createErrorWithCleanStackTrace_js_1 = require("./createErrorWithCleanStackTrace.js");
|
|
9
9
|
const getGlobalObject_js_1 = require("./getGlobalObject.js");
|
|
@@ -55,6 +55,7 @@ exports.assert = assert;
|
|
|
55
55
|
function assertUsage(condition, errMsg, { showStackTrace } = {}) {
|
|
56
56
|
if (condition)
|
|
57
57
|
return;
|
|
58
|
+
showStackTrace = showStackTrace || globalObject.alwaysShowStackTrace;
|
|
58
59
|
errMsg = addWhitespace(errMsg);
|
|
59
60
|
errMsg = addPrefixAssertType(errMsg, 'Wrong Usage');
|
|
60
61
|
errMsg = addPrefixProjctName(errMsg);
|
|
@@ -77,6 +78,7 @@ exports.getProjectError = getProjectError;
|
|
|
77
78
|
function assertWarning(condition, msg, { onlyOnce, showStackTrace }) {
|
|
78
79
|
if (condition)
|
|
79
80
|
return;
|
|
81
|
+
showStackTrace = showStackTrace || globalObject.alwaysShowStackTrace;
|
|
80
82
|
msg = addWhitespace(msg);
|
|
81
83
|
msg = addPrefixAssertType(msg, 'Warning');
|
|
82
84
|
msg = addPrefixProjctName(msg);
|
|
@@ -193,3 +195,7 @@ function isBug(err) {
|
|
|
193
195
|
return !String(err).includes('[Bug]');
|
|
194
196
|
}
|
|
195
197
|
exports.isBug = isBug;
|
|
198
|
+
function setAlwaysShowStackTrace() {
|
|
199
|
+
globalObject.alwaysShowStackTrace = true;
|
|
200
|
+
}
|
|
201
|
+
exports.setAlwaysShowStackTrace = setAlwaysShowStackTrace;
|
|
@@ -7,19 +7,21 @@ exports.findFile = void 0;
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const isArray_js_1 = require("./isArray.js");
|
|
10
|
+
const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
|
|
10
11
|
function findFile(arg, cwd) {
|
|
12
|
+
(0, filesystemPathHandling_js_1.assertPosixPath)(cwd);
|
|
11
13
|
const filenames = (0, isArray_js_1.isArray)(arg) ? arg : [arg];
|
|
12
14
|
let dir = cwd;
|
|
13
15
|
while (true) {
|
|
14
16
|
for (const filename of filenames) {
|
|
15
|
-
const configFilePath = path_1.default.join(dir, `./${filename}`);
|
|
17
|
+
const configFilePath = path_1.default.posix.join(dir, `./${filename}`);
|
|
16
18
|
if (fs_1.default.existsSync(configFilePath)) {
|
|
17
|
-
|
|
19
|
+
(0, filesystemPathHandling_js_1.assertPosixPath)(configFilePath);
|
|
18
20
|
return configFilePath;
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
const dirPrevious = dir;
|
|
22
|
-
dir = path_1.default.dirname(dir);
|
|
24
|
+
dir = path_1.default.posix.dirname(dir);
|
|
23
25
|
if (dir === dirPrevious) {
|
|
24
26
|
return null;
|
|
25
27
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findPackageJson = void 0;
|
|
4
|
+
const findFile_js_1 = require("./findFile.js");
|
|
5
|
+
const module_1 = require("module");
|
|
6
|
+
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
7
|
+
const importMetaUrl = `file://${__filename}`;
|
|
8
|
+
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
9
|
+
function findPackageJson(cwd) {
|
|
10
|
+
const packageJsonPath = (0, findFile_js_1.findFile)('package.json', cwd);
|
|
11
|
+
if (!packageJsonPath)
|
|
12
|
+
return null;
|
|
13
|
+
const packageJson = require_(packageJsonPath);
|
|
14
|
+
return {
|
|
15
|
+
packageJson,
|
|
16
|
+
packageJsonPath
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.findPackageJson = findPackageJson;
|
|
@@ -9,6 +9,6 @@ function joinEnglish(arr, conjunction, colorizer = (s) => s) {
|
|
|
9
9
|
return colorizer(arr[0]);
|
|
10
10
|
const firsts = arr.slice(0, arr.length - 1);
|
|
11
11
|
const last = arr[arr.length - 1];
|
|
12
|
-
return firsts.map(colorizer).join(', ') +
|
|
12
|
+
return firsts.map(colorizer).join(', ') + `, ${conjunction} ` + colorizer(last);
|
|
13
13
|
}
|
|
14
14
|
exports.joinEnglish = joinEnglish;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROJECT_VERSION = exports.projectInfo = void 0;
|
|
4
|
-
const PROJECT_VERSION = '0.4.172-commit-
|
|
4
|
+
const PROJECT_VERSION = '0.4.172-commit-8bdf055';
|
|
5
5
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
6
6
|
const projectInfo = {
|
|
7
7
|
projectName: 'Vike',
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
export { commonConfig };
|
|
2
|
-
import { assert, assertUsage, assertWarning,
|
|
2
|
+
import { assert, assertUsage, assertWarning, findPackageJson } from '../utils.js';
|
|
3
3
|
import { assertRollupInput } from './buildConfig.js';
|
|
4
4
|
import { installRequireShim_setUserRootDir } from '@brillout/require-shim';
|
|
5
5
|
import pc from '@brillout/picocolors';
|
|
6
6
|
import path from 'path';
|
|
7
|
-
import { createRequire } from 'module';
|
|
8
7
|
import { assertResolveAlias } from './commonConfig/assertResolveAlias.js';
|
|
9
|
-
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
10
|
-
const importMetaUrl = import.meta.url;
|
|
11
|
-
const require_ = createRequire(importMetaUrl);
|
|
12
8
|
const pluginName = 'vike:commonConfig-1';
|
|
13
9
|
function commonConfig() {
|
|
14
10
|
return [
|
|
@@ -64,11 +60,11 @@ function workaroundCI(config) {
|
|
|
64
60
|
}
|
|
65
61
|
}
|
|
66
62
|
function assertEsm(userViteRoot) {
|
|
67
|
-
const
|
|
68
|
-
if (!
|
|
63
|
+
const found = findPackageJson(userViteRoot);
|
|
64
|
+
if (!found)
|
|
69
65
|
return;
|
|
70
|
-
const packageJson =
|
|
71
|
-
let dir = path.dirname(packageJsonPath);
|
|
66
|
+
const { packageJson, packageJsonPath } = found;
|
|
67
|
+
let dir = path.posix.dirname(packageJsonPath);
|
|
72
68
|
if (dir !== '/') {
|
|
73
69
|
assert(!dir.endsWith('/'));
|
|
74
70
|
dir = dir + '/';
|
|
@@ -4,7 +4,7 @@ import { determineFsAllowList } from './determineFsAllowList.js';
|
|
|
4
4
|
import { addSsrMiddleware } from '../../shared/addSsrMiddleware.js';
|
|
5
5
|
import { markEnvAsViteDev } from '../../utils.js';
|
|
6
6
|
import { improveViteLogs } from '../../shared/loggerVite.js';
|
|
7
|
-
import { isErrorDebug } from '
|
|
7
|
+
import { isErrorDebug } from '../../../shared/isErrorDebug.js';
|
|
8
8
|
import { installHttpRequestAsyncStore } from '../../shared/getHttpRequestAsyncStore.js';
|
|
9
9
|
if (isErrorDebug()) {
|
|
10
10
|
Error.stackTraceLimit = Infinity;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { assertExtensionsConventions };
|
|
2
|
+
export { assertExtensionsPeerDependencies };
|
|
3
|
+
import { type InterfaceFile } from './getVikeConfig.js';
|
|
4
|
+
declare function assertExtensionsConventions(interfaceFile: InterfaceFile): void;
|
|
5
|
+
declare function assertExtensionsPeerDependencies(interfaceFilesRelevantList: InterfaceFile[]): void;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
export { assertExtensionsConventions };
|
|
2
|
+
export { assertExtensionsPeerDependencies };
|
|
3
|
+
import pc from '@brillout/picocolors';
|
|
4
|
+
import { isObjectOfStrings } from '../../../../../utils/isObjectOfStrings.js';
|
|
5
|
+
import { PROJECT_VERSION, assert, assertUsage, assertWarning, findPackageJson } from '../../../utils.js';
|
|
6
|
+
import { getConfigValueInterfaceFile } from './getVikeConfig.js';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import semver from 'semver';
|
|
9
|
+
function assertExtensionsConventions(interfaceFile) {
|
|
10
|
+
assertExtensionName(interfaceFile);
|
|
11
|
+
assertConfigExportPath(interfaceFile);
|
|
12
|
+
}
|
|
13
|
+
function assertConfigExportPath(interfaceFile) {
|
|
14
|
+
const { importPathAbsolute } = interfaceFile.filePath;
|
|
15
|
+
assert(importPathAbsolute);
|
|
16
|
+
const name = getConfigNameValue(interfaceFile);
|
|
17
|
+
assert(name); // already asserted in assertExtensionName()
|
|
18
|
+
const importPathAbsoluteExpected = `${name}/config`;
|
|
19
|
+
assertWarning(importPathAbsolute === importPathAbsoluteExpected, `The Vike configuration of ${pc.bold(name)} is exported at ${pc.bold(importPathAbsolute)} but it should be exported at ${pc.bold(importPathAbsoluteExpected)} instead.`, { onlyOnce: true });
|
|
20
|
+
}
|
|
21
|
+
function assertExtensionName(interfaceFile) {
|
|
22
|
+
let nameDeduced;
|
|
23
|
+
{
|
|
24
|
+
const { importPathAbsolute } = interfaceFile.filePath;
|
|
25
|
+
assert(importPathAbsolute);
|
|
26
|
+
nameDeduced = importPathAbsolute
|
|
27
|
+
.split('/')
|
|
28
|
+
.slice(0, importPathAbsolute.startsWith('@') ? 2 : 1)
|
|
29
|
+
.join('/');
|
|
30
|
+
}
|
|
31
|
+
const name = getConfigNameValue(interfaceFile);
|
|
32
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
33
|
+
if (name) {
|
|
34
|
+
assertWarning(name === nameDeduced, `The setting ${pc.bold('name')} defined at ${filePathToShowToUser} is ${pc.bold(name)} but it should be ${pc.bold(nameDeduced)} instead (the name of the npm package).`, { onlyOnce: true });
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
if (
|
|
38
|
+
// Let's eventually remove this
|
|
39
|
+
[
|
|
40
|
+
'vike-react',
|
|
41
|
+
'vike-react-query',
|
|
42
|
+
'vike-react-zustand',
|
|
43
|
+
'vike-vue',
|
|
44
|
+
'vike-vue-query',
|
|
45
|
+
'vike-vue-pinia',
|
|
46
|
+
'vike-pinia',
|
|
47
|
+
'vike-solid'
|
|
48
|
+
].includes(nameDeduced)) {
|
|
49
|
+
assertUsage(false, `Update ${nameDeduced} to its latest version.`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
assertUsage(false, `The setting ${pc.bold('name')} is missing: it should be set by the config ${filePathToShowToUser} of ${pc.bold(nameDeduced)}.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function assertExtensionsPeerDependencies(interfaceFilesRelevantList) {
|
|
57
|
+
// Get installed extensions
|
|
58
|
+
const extensions = {};
|
|
59
|
+
interfaceFilesRelevantList.forEach((interfaceFile) => {
|
|
60
|
+
const name = getConfigNameValue(interfaceFile);
|
|
61
|
+
if (name) {
|
|
62
|
+
const version = getExtensionVersion(name, interfaceFile);
|
|
63
|
+
extensions[name] = version;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
// Enforce peer dependencies
|
|
67
|
+
interfaceFilesRelevantList.forEach((interfaceFile) => {
|
|
68
|
+
const require = getConfigRequireValue(interfaceFile);
|
|
69
|
+
if (!require)
|
|
70
|
+
return;
|
|
71
|
+
const name = getConfigNameValue(interfaceFile);
|
|
72
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
73
|
+
assertUsage(name, `Setting ${pc.bold('name')} is required for being able to use setting ${pc.bold('require')} in ${filePathToShowToUser}.`);
|
|
74
|
+
Object.entries(require).forEach(([reqName, reqVersion]) => {
|
|
75
|
+
const errBase = `${pc.bold(name)} requires ${pc.bold(reqName)}`;
|
|
76
|
+
if (reqName === 'vike') {
|
|
77
|
+
assertUsage(semver.satisfies(PROJECT_VERSION, reqVersion), `${errBase} version ${pc.bold(reqVersion)} but ${pc.bold(PROJECT_VERSION)} is installed.`);
|
|
78
|
+
}
|
|
79
|
+
const extensionVersion = extensions[reqName];
|
|
80
|
+
assertUsage(extensionVersion, `${errBase}.`);
|
|
81
|
+
assertUsage(semver.satisfies(extensionVersion, reqVersion), `${errBase} version ${pc.bold(reqVersion)} but ${pc.bold(extensionVersion)} is installed.`);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function getConfigRequireValue(interfaceFile) {
|
|
86
|
+
const require = getConfigValueInterfaceFile(interfaceFile, 'require');
|
|
87
|
+
if (!require)
|
|
88
|
+
return null;
|
|
89
|
+
const { filePathToShowToUserResolved } = interfaceFile.filePath;
|
|
90
|
+
assert(filePathToShowToUserResolved);
|
|
91
|
+
assertUsage(isObjectOfStrings(require), `The setting ${pc.bold('require')} defined at ${filePathToShowToUserResolved} should be an object with string values (${pc.bold('Record<string, string>')}).`);
|
|
92
|
+
return require;
|
|
93
|
+
}
|
|
94
|
+
function getConfigNameValue(interfaceFile) {
|
|
95
|
+
const name = getConfigValueInterfaceFile(interfaceFile, 'name');
|
|
96
|
+
if (!name)
|
|
97
|
+
return null;
|
|
98
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
99
|
+
assertUsage(typeof name === 'string', `The setting ${pc.bold('name')} defined at ${filePathToShowToUser} should be a string.`);
|
|
100
|
+
return name;
|
|
101
|
+
}
|
|
102
|
+
// We use a forever cache: users need to restart the dev server anyways when touching node_modules/**/* (I presume Vite doesn't pick up node_modules/**/* changes).
|
|
103
|
+
const extensionsVersion = {};
|
|
104
|
+
function getExtensionVersion(name, interfaceFile) {
|
|
105
|
+
if (!extensionsVersion[name]) {
|
|
106
|
+
const extensionConfigFilePath = interfaceFile.filePath.filePathAbsoluteFilesystem;
|
|
107
|
+
const found = findPackageJson(path.posix.dirname(extensionConfigFilePath));
|
|
108
|
+
assert(found);
|
|
109
|
+
const { packageJson, packageJsonPath } = found;
|
|
110
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
111
|
+
const nameExpected = packageJson.name;
|
|
112
|
+
assertWarning(name === nameExpected, `The setting ${pc.bold('name')} defined at ${filePathToShowToUser} is ${pc.bold(JSON.stringify(name))} but it should be equal to ${pc.bold(JSON.stringify(nameExpected))} (the value of ${packageJsonPath}${pc.dim('#')}${pc.bold('name')})`, { onlyOnce: true });
|
|
113
|
+
const { version } = packageJson;
|
|
114
|
+
assert(typeof version === 'string');
|
|
115
|
+
extensionsVersion[name] = version;
|
|
116
|
+
}
|
|
117
|
+
return extensionsVersion[name];
|
|
118
|
+
}
|
|
119
|
+
function getFilePathToShowToUser(interfaceFile) {
|
|
120
|
+
const { filePathToShowToUserResolved } = interfaceFile.filePath;
|
|
121
|
+
assert(filePathToShowToUserResolved);
|
|
122
|
+
return filePathToShowToUserResolved;
|
|
123
|
+
}
|
|
@@ -3,12 +3,15 @@ export { reloadVikeConfig };
|
|
|
3
3
|
export { vikeConfigDependencies };
|
|
4
4
|
export { isVikeConfigFile };
|
|
5
5
|
export { isV1Design };
|
|
6
|
+
export { getConfigValueInterfaceFile };
|
|
6
7
|
export type { VikeConfigObject };
|
|
7
8
|
export type { InterfaceValueFile };
|
|
9
|
+
export type { InterfaceFile };
|
|
8
10
|
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
|
|
9
11
|
import { type LocationId } from './getVikeConfig/filesystemRouting.js';
|
|
10
12
|
import type { ResolvedConfig } from 'vite';
|
|
11
13
|
import type { FilePathResolved } from '../../../../../shared/page-configs/FilePath.js';
|
|
14
|
+
type InterfaceFile = InterfaceConfigFile | InterfaceValueFile;
|
|
12
15
|
type InterfaceFileCommons = {
|
|
13
16
|
locationId: LocationId;
|
|
14
17
|
filePath: FilePathResolved;
|
|
@@ -16,6 +19,12 @@ type InterfaceFileCommons = {
|
|
|
16
19
|
configValue?: unknown;
|
|
17
20
|
}>;
|
|
18
21
|
};
|
|
22
|
+
type InterfaceConfigFile = InterfaceFileCommons & {
|
|
23
|
+
isConfigFile: true;
|
|
24
|
+
isValueFile: false;
|
|
25
|
+
extendsFilePaths: string[];
|
|
26
|
+
isConfigExtend: boolean;
|
|
27
|
+
};
|
|
19
28
|
type InterfaceValueFile = InterfaceFileCommons & {
|
|
20
29
|
isConfigFile: false;
|
|
21
30
|
isValueFile: true;
|
|
@@ -35,3 +44,4 @@ declare function getVikeConfig(config: ResolvedConfig, isDev: boolean, { crawlWi
|
|
|
35
44
|
}): Promise<VikeConfigObject>;
|
|
36
45
|
declare function isV1Design(config: ResolvedConfig, isDev: boolean): Promise<boolean>;
|
|
37
46
|
declare function isVikeConfigFile(filePath: string): boolean;
|
|
47
|
+
declare function getConfigValueInterfaceFile(interfaceFile: InterfaceFile, configName: string): unknown;
|
|
@@ -3,6 +3,7 @@ export { reloadVikeConfig };
|
|
|
3
3
|
export { vikeConfigDependencies };
|
|
4
4
|
export { isVikeConfigFile };
|
|
5
5
|
export { isV1Design };
|
|
6
|
+
export { getConfigValueInterfaceFile };
|
|
6
7
|
import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEntries, hasProp, arrayIncludes, assertIsNotProductionRuntime, getMostSimilar, joinEnglish, lowerFirst, getOutDirs, assertKeys, objectKeys, objectFromEntries, makeFirst, isNpmPackageImport, reverse } from '../../../utils.js';
|
|
7
8
|
import path from 'path';
|
|
8
9
|
import { configDefinitionsBuiltIn, configDefinitionsBuiltInGlobal } from './getVikeConfig/configDefinitionsBuiltIn.js';
|
|
@@ -21,6 +22,7 @@ import { clearFilesEnvMap, resolvePointerImportOfConfig } from './getVikeConfig/
|
|
|
21
22
|
import { getFilePathResolved } from '../../../shared/getFilePath.js';
|
|
22
23
|
import { getConfigValueBuildTime } from '../../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
23
24
|
import { getConfigVike } from '../../../../shared/getConfigVike.js';
|
|
25
|
+
import { assertExtensionsPeerDependencies, assertExtensionsConventions } from './assertExtensions.js';
|
|
24
26
|
assertIsNotProductionRuntime();
|
|
25
27
|
let devServerIsCorrupt = false;
|
|
26
28
|
let wasConfigInvalid = null;
|
|
@@ -120,29 +122,7 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, crawlWithGit)
|
|
|
120
122
|
```
|
|
121
123
|
*/
|
|
122
124
|
const interfaceFile = getInterfaceFileFromConfigFile(extendsConfig, true, locationId);
|
|
123
|
-
|
|
124
|
-
const alreadyMigrated = [
|
|
125
|
-
'vike-react',
|
|
126
|
-
'vike-react-query',
|
|
127
|
-
'vike-react-zustand',
|
|
128
|
-
'vike-vue',
|
|
129
|
-
'vike-pinia',
|
|
130
|
-
'vike-solid'
|
|
131
|
-
];
|
|
132
|
-
assert(extendsConfig.filePath.importPathAbsolute);
|
|
133
|
-
const extensionName = extendsConfig.filePath.importPathAbsolute.split('/')[0];
|
|
134
|
-
const warnMsg = alreadyMigrated.includes(extensionName)
|
|
135
|
-
? `You're using a deprecated version of the Vike extension ${extensionName}, update ${extensionName} to its latest version.`
|
|
136
|
-
: `The config of the Vike extension ${extensionName} should set a ${pc.cyan('name')} value`;
|
|
137
|
-
const isNameDefined = interfaceFile.fileExportsByConfigName.name?.configValue;
|
|
138
|
-
if (alreadyMigrated) {
|
|
139
|
-
// Eventually always make it a assertUsage()
|
|
140
|
-
assertWarning(isNameDefined, warnMsg, { onlyOnce: true });
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
assertUsage(isNameDefined, warnMsg);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
125
|
+
assertExtensionsConventions(interfaceFile);
|
|
146
126
|
interfaceFilesByLocationId[locationId].push(interfaceFile);
|
|
147
127
|
});
|
|
148
128
|
}),
|
|
@@ -260,9 +240,11 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
|
260
240
|
.filter(([_pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
|
|
261
241
|
.map(async ([locationId]) => {
|
|
262
242
|
const interfaceFilesRelevant = getInterfaceFilesRelevant(interfaceFilesByLocationId, locationId);
|
|
243
|
+
const interfaceFilesRelevantList = Object.values(interfaceFilesByLocationId).flat(1);
|
|
244
|
+
assertExtensionsPeerDependencies(interfaceFilesRelevantList);
|
|
263
245
|
const configDefinitions = getConfigDefinitions(interfaceFilesRelevant);
|
|
264
246
|
// Load value files of custom config-only configs
|
|
265
|
-
await Promise.all(
|
|
247
|
+
await Promise.all(interfaceFilesRelevantList.map(async (interfaceFile) => {
|
|
266
248
|
if (!interfaceFile.isValueFile)
|
|
267
249
|
return;
|
|
268
250
|
const { configName } = interfaceFile;
|
|
@@ -350,13 +332,6 @@ function getInterfaceFilesRelevant(interfaceFilesByLocationId, locationIdPage) {
|
|
|
350
332
|
.sort(([locationId1], [locationId2]) => sortAfterInheritanceOrder(locationId1, locationId2, locationIdPage)));
|
|
351
333
|
return interfaceFilesRelevant;
|
|
352
334
|
}
|
|
353
|
-
function getInterfaceFileList(interfaceFilesByLocationId) {
|
|
354
|
-
const interfaceFiles = [];
|
|
355
|
-
Object.values(interfaceFilesByLocationId).forEach((interfaceFiles_) => {
|
|
356
|
-
interfaceFiles.push(...interfaceFiles_);
|
|
357
|
-
});
|
|
358
|
-
return interfaceFiles;
|
|
359
|
-
}
|
|
360
335
|
async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded) {
|
|
361
336
|
const locationIds = objectKeys(interfaceFilesByLocationId);
|
|
362
337
|
const interfaceFilesGlobal = objectFromEntries(objectEntries(interfaceFilesByLocationId).filter(([locationId]) => {
|
|
@@ -969,3 +944,6 @@ function sortConfigValueSources(configValueSources, locationIdPage) {
|
|
|
969
944
|
// Sort after the filesystem inheritance of the config value
|
|
970
945
|
.sort(([, [source1]], [, [source2]]) => reverse(sortAfterInheritanceOrder(source1.locationId, source2.locationId, locationIdPage))));
|
|
971
946
|
}
|
|
947
|
+
function getConfigValueInterfaceFile(interfaceFile, configName) {
|
|
948
|
+
return interfaceFile.fileExportsByConfigName[configName]?.configValue;
|
|
949
|
+
}
|
|
@@ -7,7 +7,7 @@ export { screenHasErrors };
|
|
|
7
7
|
export { applyViteSourceMapToStackTrace };
|
|
8
8
|
import { assert, projectInfo, stripAnsi, hasProp, assertIsNotProductionRuntime } from '../../utils.js';
|
|
9
9
|
import pc from '@brillout/picocolors';
|
|
10
|
-
import { isErrorDebug } from '
|
|
10
|
+
import { isErrorDebug } from '../../../shared/isErrorDebug.js';
|
|
11
11
|
import { getViteDevServer } from '../../../runtime/globalContext.js';
|
|
12
12
|
assertIsNotProductionRuntime();
|
|
13
13
|
let isFirstLog = true;
|
|
@@ -16,7 +16,7 @@ import { getViteConfig } from '../../runtime/globalContext.js';
|
|
|
16
16
|
import { overwriteRuntimeProductionLogger } from '../../runtime/renderPage/loggerRuntime.js';
|
|
17
17
|
import { assert, assertIsNotProductionRuntime, formatHintLog, getAssertErrMsg, overwriteAssertProductionLogger, stripAnsi, warnIfErrorIsNotObject } from '../utils.js';
|
|
18
18
|
import { getHttpRequestAsyncStore } from './getHttpRequestAsyncStore.js';
|
|
19
|
-
import { isErrorDebug } from '
|
|
19
|
+
import { isErrorDebug } from '../../shared/isErrorDebug.js';
|
|
20
20
|
import { isErrorWithCodeSnippet, getPrettyErrorWithCodeSnippet } from './loggerNotProd/errorWithCodeSnippet.js';
|
|
21
21
|
import { getConfigExecutionErrorIntroMsg, getConfigBuildErrorFormatted } from '../plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js';
|
|
22
22
|
import { logWithVikeTag, logWithViteTag, logDirectly, isFirstLog, screenHasErrors, clearScreen, applyViteSourceMapToStackTrace } from './loggerNotProd/log.js';
|
|
@@ -3,7 +3,7 @@ import { assert, removeEmptyLines, trimWithAnsi, trimWithAnsiTrailOnly } from '.
|
|
|
3
3
|
import { logViteError, logViteAny, clearLogs } from './loggerNotProd.js';
|
|
4
4
|
import { getHttpRequestAsyncStore } from './getHttpRequestAsyncStore.js';
|
|
5
5
|
import { removeSuperfluousViteLog } from './loggerVite/removeSuperfluousViteLog.js';
|
|
6
|
-
import { isErrorDebug } from '
|
|
6
|
+
import { isErrorDebug } from '../../shared/isErrorDebug.js';
|
|
7
7
|
function improveViteLogs(config) {
|
|
8
8
|
intercept('info', config);
|
|
9
9
|
intercept('warn', config);
|
|
@@ -10,7 +10,7 @@ export * from '../../utils/escapeRegex.js';
|
|
|
10
10
|
export * from '../../utils/stripAnsi.js';
|
|
11
11
|
export * from '../../utils/trimWithAnsi.js';
|
|
12
12
|
export * from '../../utils/removeEmptyLines.js';
|
|
13
|
-
export * from '../../utils/
|
|
13
|
+
export * from '../../utils/findPackageJson.js';
|
|
14
14
|
export * from '../../utils/getPropAccessNotation.js';
|
|
15
15
|
export * from '../../utils/deepEqual.js';
|
|
16
16
|
export * from '../../utils/assertKeys.js';
|
|
@@ -16,7 +16,7 @@ export * from '../../utils/escapeRegex.js';
|
|
|
16
16
|
export * from '../../utils/stripAnsi.js';
|
|
17
17
|
export * from '../../utils/trimWithAnsi.js';
|
|
18
18
|
export * from '../../utils/removeEmptyLines.js';
|
|
19
|
-
export * from '../../utils/
|
|
19
|
+
export * from '../../utils/findPackageJson.js';
|
|
20
20
|
export * from '../../utils/getPropAccessNotation.js';
|
|
21
21
|
export * from '../../utils/deepEqual.js';
|
|
22
22
|
export * from '../../utils/assertKeys.js';
|
|
@@ -2,8 +2,12 @@ export { onLoad };
|
|
|
2
2
|
import { assertIsNotBrowser } from '../../utils/assertIsNotBrowser.js';
|
|
3
3
|
import { assertNodeVersion } from '../../utils/assertNodeVersion.js';
|
|
4
4
|
import { installRequireShim } from '@brillout/require-shim';
|
|
5
|
+
import { setAlwaysShowStackTrace } from './utils.js';
|
|
6
|
+
import { isErrorDebug } from '../shared/isErrorDebug.js';
|
|
5
7
|
function onLoad() {
|
|
6
8
|
assertIsNotBrowser();
|
|
7
9
|
assertNodeVersion();
|
|
8
10
|
installRequireShim();
|
|
11
|
+
if (isErrorDebug())
|
|
12
|
+
setAlwaysShowStackTrace();
|
|
9
13
|
}
|
|
@@ -5,6 +5,7 @@ export type { ConfigMeta };
|
|
|
5
5
|
export type { HookName };
|
|
6
6
|
export type { HookNamePage };
|
|
7
7
|
export type { HookNameGlobal };
|
|
8
|
+
export type { ImportString };
|
|
8
9
|
export type { DataAsync };
|
|
9
10
|
export type { DataSync };
|
|
10
11
|
export type { GuardAsync };
|
|
@@ -358,6 +359,11 @@ type ConfigBuiltIn = {
|
|
|
358
359
|
* https://vike.dev/extends
|
|
359
360
|
*/
|
|
360
361
|
name?: string;
|
|
362
|
+
/** Used by Vike extensions to enforce their peer dependencies.
|
|
363
|
+
*
|
|
364
|
+
* https://vike.dev/require
|
|
365
|
+
*/
|
|
366
|
+
require?: Record<string, string>;
|
|
361
367
|
};
|
|
362
368
|
type ConfigMeta = Record<string, ConfigDefinition>;
|
|
363
369
|
type ImportString = `import:${string}`;
|
|
@@ -6,7 +6,7 @@ export type { PageContextClientWithServerRouting } from '../shared/types.js';
|
|
|
6
6
|
export type { PageContextBuiltInServer } from '../shared/types.js';
|
|
7
7
|
export type { PageContextBuiltInClientWithClientRouting } from '../shared/types.js';
|
|
8
8
|
export type { PageContextBuiltInClientWithServerRouting } from '../shared/types.js';
|
|
9
|
-
export type { Config, ConfigMeta as Meta, DataAsync, DataSync, GuardAsync, GuardSync, OnBeforePrerenderStartAsync, OnBeforePrerenderStartSync, OnBeforeRenderAsync, OnBeforeRenderSync, OnBeforeRouteAsync, OnBeforeRouteSync, OnHydrationEndAsync, OnHydrationEndSync, OnPageTransitionEndAsync, OnPageTransitionEndSync, OnPageTransitionStartAsync, OnPageTransitionStartSync, OnPrerenderStartAsync, OnPrerenderStartSync, OnRenderClientAsync, OnRenderClientSync, OnRenderHtmlAsync, OnRenderHtmlSync, RouteAsync, RouteSync } from '../shared/page-configs/Config.js';
|
|
9
|
+
export type { Config, ConfigMeta as Meta, ImportString, DataAsync, DataSync, GuardAsync, GuardSync, OnBeforePrerenderStartAsync, OnBeforePrerenderStartSync, OnBeforeRenderAsync, OnBeforeRenderSync, OnBeforeRouteAsync, OnBeforeRouteSync, OnHydrationEndAsync, OnHydrationEndSync, OnPageTransitionEndAsync, OnPageTransitionEndSync, OnPageTransitionStartAsync, OnPageTransitionStartSync, OnPrerenderStartAsync, OnPrerenderStartSync, OnRenderClientAsync, OnRenderClientSync, OnRenderHtmlAsync, OnRenderHtmlSync, RouteAsync, RouteSync } from '../shared/page-configs/Config.js';
|
|
10
10
|
export type { ConfigEnv } from '../shared/page-configs/PageConfig.js';
|
|
11
11
|
export type { ConfigDefinition, ConfigEffect } from '../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js';
|
|
12
12
|
export type { ConfigEntries } from '../shared/getPageFiles/getExports.js';
|
|
@@ -7,6 +7,7 @@ export { addOnBeforeLogHook };
|
|
|
7
7
|
export { getAssertErrMsg };
|
|
8
8
|
export { overwriteAssertProductionLogger };
|
|
9
9
|
export { isBug };
|
|
10
|
+
export { setAlwaysShowStackTrace };
|
|
10
11
|
type Logger = (msg: string | Error, logType: 'warn' | 'info') => void;
|
|
11
12
|
declare function assert(condition: unknown, debugInfo?: unknown): asserts condition;
|
|
12
13
|
declare function assertUsage(condition: unknown, errMsg: string, { showStackTrace }?: {
|
|
@@ -27,3 +28,4 @@ declare function getAssertErrMsg(thing: unknown): {
|
|
|
27
28
|
} | null;
|
|
28
29
|
declare function overwriteAssertProductionLogger(logger: Logger): void;
|
|
29
30
|
declare function isBug(err: unknown): boolean;
|
|
31
|
+
declare function setAlwaysShowStackTrace(): void;
|
package/dist/esm/utils/assert.js
CHANGED
|
@@ -7,6 +7,7 @@ export { addOnBeforeLogHook };
|
|
|
7
7
|
export { getAssertErrMsg };
|
|
8
8
|
export { overwriteAssertProductionLogger };
|
|
9
9
|
export { isBug };
|
|
10
|
+
export { setAlwaysShowStackTrace };
|
|
10
11
|
import { onAssertModuleLoad } from './assertSingleInstance.js';
|
|
11
12
|
import { createErrorWithCleanStackTrace } from './createErrorWithCleanStackTrace.js';
|
|
12
13
|
import { getGlobalObject } from './getGlobalObject.js';
|
|
@@ -57,6 +58,7 @@ function assert(condition, debugInfo) {
|
|
|
57
58
|
function assertUsage(condition, errMsg, { showStackTrace } = {}) {
|
|
58
59
|
if (condition)
|
|
59
60
|
return;
|
|
61
|
+
showStackTrace = showStackTrace || globalObject.alwaysShowStackTrace;
|
|
60
62
|
errMsg = addWhitespace(errMsg);
|
|
61
63
|
errMsg = addPrefixAssertType(errMsg, 'Wrong Usage');
|
|
62
64
|
errMsg = addPrefixProjctName(errMsg);
|
|
@@ -77,6 +79,7 @@ function getProjectError(errMsg) {
|
|
|
77
79
|
function assertWarning(condition, msg, { onlyOnce, showStackTrace }) {
|
|
78
80
|
if (condition)
|
|
79
81
|
return;
|
|
82
|
+
showStackTrace = showStackTrace || globalObject.alwaysShowStackTrace;
|
|
80
83
|
msg = addWhitespace(msg);
|
|
81
84
|
msg = addPrefixAssertType(msg, 'Warning');
|
|
82
85
|
msg = addPrefixProjctName(msg);
|
|
@@ -187,3 +190,6 @@ function overwriteAssertProductionLogger(logger) {
|
|
|
187
190
|
function isBug(err) {
|
|
188
191
|
return !String(err).includes('[Bug]');
|
|
189
192
|
}
|
|
193
|
+
function setAlwaysShowStackTrace() {
|
|
194
|
+
globalObject.alwaysShowStackTrace = true;
|
|
195
|
+
}
|
|
@@ -2,19 +2,21 @@ export { findFile };
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import { isArray } from './isArray.js';
|
|
5
|
+
import { assertPosixPath } from './filesystemPathHandling.js';
|
|
5
6
|
function findFile(arg, cwd) {
|
|
7
|
+
assertPosixPath(cwd);
|
|
6
8
|
const filenames = isArray(arg) ? arg : [arg];
|
|
7
9
|
let dir = cwd;
|
|
8
10
|
while (true) {
|
|
9
11
|
for (const filename of filenames) {
|
|
10
|
-
const configFilePath = path.join(dir, `./${filename}`);
|
|
12
|
+
const configFilePath = path.posix.join(dir, `./${filename}`);
|
|
11
13
|
if (fs.existsSync(configFilePath)) {
|
|
12
|
-
|
|
14
|
+
assertPosixPath(configFilePath);
|
|
13
15
|
return configFilePath;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
const dirPrevious = dir;
|
|
17
|
-
dir = path.dirname(dir);
|
|
19
|
+
dir = path.posix.dirname(dir);
|
|
18
20
|
if (dir === dirPrevious) {
|
|
19
21
|
return null;
|
|
20
22
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { findPackageJson };
|
|
2
|
+
import { findFile } from './findFile.js';
|
|
3
|
+
import { createRequire } from 'module';
|
|
4
|
+
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
5
|
+
const importMetaUrl = import.meta.url;
|
|
6
|
+
const require_ = createRequire(importMetaUrl);
|
|
7
|
+
function findPackageJson(cwd) {
|
|
8
|
+
const packageJsonPath = findFile('package.json', cwd);
|
|
9
|
+
if (!packageJsonPath)
|
|
10
|
+
return null;
|
|
11
|
+
const packageJson = require_(packageJsonPath);
|
|
12
|
+
return {
|
|
13
|
+
packageJson,
|
|
14
|
+
packageJsonPath
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -7,5 +7,5 @@ function joinEnglish(arr, conjunction, colorizer = (s) => s) {
|
|
|
7
7
|
return colorizer(arr[0]);
|
|
8
8
|
const firsts = arr.slice(0, arr.length - 1);
|
|
9
9
|
const last = arr[arr.length - 1];
|
|
10
|
-
return firsts.map(colorizer).join(', ') +
|
|
10
|
+
return firsts.map(colorizer).join(', ') + `, ${conjunction} ` + colorizer(last);
|
|
11
11
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
|
-
declare const PROJECT_VERSION: "0.4.172-commit-
|
|
3
|
+
declare const PROJECT_VERSION: "0.4.172-commit-8bdf055";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.172-commit-
|
|
6
|
+
projectVersion: "0.4.172-commit-8bdf055";
|
|
7
7
|
};
|
package/package.json
CHANGED
|
File without changes
|