vike 0.4.181-commit-b6b5064 → 0.4.181-commit-3fe2549
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/importUserCode/v1-design/getVikeConfig.js +44 -27
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +44 -27
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +1 -1
|
@@ -255,33 +255,6 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
|
255
255
|
if (isGlobalConfig(configName))
|
|
256
256
|
return;
|
|
257
257
|
const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
|
|
258
|
-
// TODO/soon: refactor
|
|
259
|
-
// - Dedupe: most of the code below is a copy-paste of the assertUsage() inside getGlobalConfigs()
|
|
260
|
-
// - update comment above `await Promise.all`
|
|
261
|
-
if (configDef.global) {
|
|
262
|
-
const locationIds = (0, utils_js_1.objectKeys)(interfaceFilesByLocationId);
|
|
263
|
-
if (!(0, filesystemRouting_js_1.isGlobalLocation)(interfaceFile.locationId, locationIds)) {
|
|
264
|
-
const interfaceFilesGlobal = (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(interfaceFilesByLocationId).filter(([locationId]) => {
|
|
265
|
-
return (0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds);
|
|
266
|
-
}));
|
|
267
|
-
const interfaceFilesGlobalPaths = [];
|
|
268
|
-
(0, utils_js_1.objectEntries)(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
|
|
269
|
-
(0, utils_js_1.assert)((0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds));
|
|
270
|
-
interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
|
|
271
|
-
if (filePathAbsoluteUserRootDir) {
|
|
272
|
-
interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir);
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path_1.default.posix.dirname(p))));
|
|
277
|
-
(0, utils_js_1.assertUsage)(false, [
|
|
278
|
-
`${interfaceFile.filePath.filePathToShowToUser} defines the config ${picocolors_1.default.cyan(configName)} which is global:`,
|
|
279
|
-
globalPaths.length
|
|
280
|
-
? `define ${picocolors_1.default.cyan(configName)} in ${(0, utils_js_1.joinEnglish)(globalPaths, 'or')} instead`
|
|
281
|
-
: `create a global config (e.g. /pages/+config.js) and define ${picocolors_1.default.cyan(configName)} there instead`
|
|
282
|
-
].join(' '));
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
258
|
if (!isLoadableAtBuildTime(configDef))
|
|
286
259
|
return;
|
|
287
260
|
const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
|
|
@@ -304,6 +277,7 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
|
304
277
|
const { routeFilesystem, isErrorPage } = determineRouteFilesystem(locationId, configValueSources);
|
|
305
278
|
applyEffectsAll(configValueSources, configDefinitions);
|
|
306
279
|
const configValuesComputed = getComputed(configValueSources, configDefinitions);
|
|
280
|
+
assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions, interfaceFilesByLocationId);
|
|
307
281
|
const pageConfig = {
|
|
308
282
|
pageId: locationId,
|
|
309
283
|
isErrorPage,
|
|
@@ -317,6 +291,49 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
|
317
291
|
assertPageConfigs(pageConfigs);
|
|
318
292
|
return { pageConfigs, pageConfigGlobal, globalVikeConfig };
|
|
319
293
|
}
|
|
294
|
+
// TODO/soon: refactor
|
|
295
|
+
// - Dedupe: most of the assertUsageGlobalConfigs() code below is a copy-paste of the assertUsage() logic inside getGlobalConfigs()
|
|
296
|
+
// Global configs should be defined at global locations
|
|
297
|
+
function assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions, interfaceFilesByLocationId) {
|
|
298
|
+
interfaceFilesRelevantList.forEach(async (interfaceFile) => {
|
|
299
|
+
const configNames = [];
|
|
300
|
+
if (interfaceFile.isValueFile) {
|
|
301
|
+
configNames.push(interfaceFile.configName);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
configNames.push(...Object.keys(interfaceFile.fileExportsByConfigName));
|
|
305
|
+
}
|
|
306
|
+
configNames.forEach((configName) => {
|
|
307
|
+
if (isGlobalConfig(configName))
|
|
308
|
+
return;
|
|
309
|
+
const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
|
|
310
|
+
if (configDef.global) {
|
|
311
|
+
const locationIds = (0, utils_js_1.objectKeys)(interfaceFilesByLocationId);
|
|
312
|
+
if (!(0, filesystemRouting_js_1.isGlobalLocation)(interfaceFile.locationId, locationIds)) {
|
|
313
|
+
const interfaceFilesGlobal = (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(interfaceFilesByLocationId).filter(([locationId]) => {
|
|
314
|
+
return (0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds);
|
|
315
|
+
}));
|
|
316
|
+
const interfaceFilesGlobalPaths = [];
|
|
317
|
+
(0, utils_js_1.objectEntries)(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
|
|
318
|
+
(0, utils_js_1.assert)((0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds));
|
|
319
|
+
interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
|
|
320
|
+
if (filePathAbsoluteUserRootDir) {
|
|
321
|
+
interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir);
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path_1.default.posix.dirname(p))));
|
|
326
|
+
(0, utils_js_1.assertUsage)(false, [
|
|
327
|
+
`${interfaceFile.filePath.filePathToShowToUser} defines the config ${picocolors_1.default.cyan(configName)} which is global:`,
|
|
328
|
+
globalPaths.length
|
|
329
|
+
? `define ${picocolors_1.default.cyan(configName)} in ${(0, utils_js_1.joinEnglish)(globalPaths, 'or')} instead`
|
|
330
|
+
: `create a global config (e.g. /pages/+config.js) and define ${picocolors_1.default.cyan(configName)} there instead`
|
|
331
|
+
].join(' '));
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
}
|
|
320
337
|
function deriveConfigEnvFromFileName(env, fileName) {
|
|
321
338
|
env = { ...env };
|
|
322
339
|
if (fileName.includes('.server.')) {
|
|
@@ -251,33 +251,6 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
|
251
251
|
if (isGlobalConfig(configName))
|
|
252
252
|
return;
|
|
253
253
|
const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
|
|
254
|
-
// TODO/soon: refactor
|
|
255
|
-
// - Dedupe: most of the code below is a copy-paste of the assertUsage() inside getGlobalConfigs()
|
|
256
|
-
// - update comment above `await Promise.all`
|
|
257
|
-
if (configDef.global) {
|
|
258
|
-
const locationIds = objectKeys(interfaceFilesByLocationId);
|
|
259
|
-
if (!isGlobalLocation(interfaceFile.locationId, locationIds)) {
|
|
260
|
-
const interfaceFilesGlobal = objectFromEntries(objectEntries(interfaceFilesByLocationId).filter(([locationId]) => {
|
|
261
|
-
return isGlobalLocation(locationId, locationIds);
|
|
262
|
-
}));
|
|
263
|
-
const interfaceFilesGlobalPaths = [];
|
|
264
|
-
objectEntries(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
|
|
265
|
-
assert(isGlobalLocation(locationId, locationIds));
|
|
266
|
-
interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
|
|
267
|
-
if (filePathAbsoluteUserRootDir) {
|
|
268
|
-
interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir);
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path.posix.dirname(p))));
|
|
273
|
-
assertUsage(false, [
|
|
274
|
-
`${interfaceFile.filePath.filePathToShowToUser} defines the config ${pc.cyan(configName)} which is global:`,
|
|
275
|
-
globalPaths.length
|
|
276
|
-
? `define ${pc.cyan(configName)} in ${joinEnglish(globalPaths, 'or')} instead`
|
|
277
|
-
: `create a global config (e.g. /pages/+config.js) and define ${pc.cyan(configName)} there instead`
|
|
278
|
-
].join(' '));
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
254
|
if (!isLoadableAtBuildTime(configDef))
|
|
282
255
|
return;
|
|
283
256
|
const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
|
|
@@ -300,6 +273,7 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
|
300
273
|
const { routeFilesystem, isErrorPage } = determineRouteFilesystem(locationId, configValueSources);
|
|
301
274
|
applyEffectsAll(configValueSources, configDefinitions);
|
|
302
275
|
const configValuesComputed = getComputed(configValueSources, configDefinitions);
|
|
276
|
+
assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions, interfaceFilesByLocationId);
|
|
303
277
|
const pageConfig = {
|
|
304
278
|
pageId: locationId,
|
|
305
279
|
isErrorPage,
|
|
@@ -313,6 +287,49 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
|
313
287
|
assertPageConfigs(pageConfigs);
|
|
314
288
|
return { pageConfigs, pageConfigGlobal, globalVikeConfig };
|
|
315
289
|
}
|
|
290
|
+
// TODO/soon: refactor
|
|
291
|
+
// - Dedupe: most of the assertUsageGlobalConfigs() code below is a copy-paste of the assertUsage() logic inside getGlobalConfigs()
|
|
292
|
+
// Global configs should be defined at global locations
|
|
293
|
+
function assertUsageGlobalConfigs(interfaceFilesRelevantList, configDefinitions, interfaceFilesByLocationId) {
|
|
294
|
+
interfaceFilesRelevantList.forEach(async (interfaceFile) => {
|
|
295
|
+
const configNames = [];
|
|
296
|
+
if (interfaceFile.isValueFile) {
|
|
297
|
+
configNames.push(interfaceFile.configName);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
configNames.push(...Object.keys(interfaceFile.fileExportsByConfigName));
|
|
301
|
+
}
|
|
302
|
+
configNames.forEach((configName) => {
|
|
303
|
+
if (isGlobalConfig(configName))
|
|
304
|
+
return;
|
|
305
|
+
const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
|
|
306
|
+
if (configDef.global) {
|
|
307
|
+
const locationIds = objectKeys(interfaceFilesByLocationId);
|
|
308
|
+
if (!isGlobalLocation(interfaceFile.locationId, locationIds)) {
|
|
309
|
+
const interfaceFilesGlobal = objectFromEntries(objectEntries(interfaceFilesByLocationId).filter(([locationId]) => {
|
|
310
|
+
return isGlobalLocation(locationId, locationIds);
|
|
311
|
+
}));
|
|
312
|
+
const interfaceFilesGlobalPaths = [];
|
|
313
|
+
objectEntries(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
|
|
314
|
+
assert(isGlobalLocation(locationId, locationIds));
|
|
315
|
+
interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
|
|
316
|
+
if (filePathAbsoluteUserRootDir) {
|
|
317
|
+
interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path.posix.dirname(p))));
|
|
322
|
+
assertUsage(false, [
|
|
323
|
+
`${interfaceFile.filePath.filePathToShowToUser} defines the config ${pc.cyan(configName)} which is global:`,
|
|
324
|
+
globalPaths.length
|
|
325
|
+
? `define ${pc.cyan(configName)} in ${joinEnglish(globalPaths, 'or')} instead`
|
|
326
|
+
: `create a global config (e.g. /pages/+config.js) and define ${pc.cyan(configName)} there instead`
|
|
327
|
+
].join(' '));
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
}
|
|
316
333
|
function deriveConfigEnvFromFileName(env, fileName) {
|
|
317
334
|
env = { ...env };
|
|
318
335
|
if (fileName.includes('.server.')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.181-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.181-commit-3fe2549";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.181-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.181-commit-3fe2549';
|