vike 0.4.238-commit-d48a597 → 0.4.239-commit-050a4a3
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/runtime/globalContext.js +1 -0
- package/dist/cjs/node/vite/onLoad.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBaseUrls.js +32 -28
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +24 -20
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +76 -74
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +18 -14
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +4 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +4 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +20 -18
- package/dist/cjs/node/vite/plugins/pluginCommon.js +7 -21
- package/dist/cjs/node/vite/plugins/pluginDev.js +51 -47
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +63 -57
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +101 -91
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +24 -16
- package/dist/cjs/node/vite/plugins/pluginFileEnv.js +67 -57
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +26 -20
- package/dist/cjs/node/vite/plugins/pluginPreview.js +30 -24
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +41 -33
- package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +4 -2
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +50 -37
- package/dist/cjs/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +8 -6
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertNodeVersion.js +3 -1
- package/dist/cjs/utils/assertVersion.js +26 -5
- package/dist/cjs/utils/joinEnglish.js +2 -1
- package/dist/esm/node/runtime/globalContext.d.ts +2 -0
- package/dist/esm/node/runtime/globalContext.js +1 -0
- package/dist/esm/node/vite/onLoad.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBaseUrls.js +32 -28
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +24 -20
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +76 -74
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +18 -14
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +4 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +4 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +20 -18
- package/dist/esm/node/vite/plugins/pluginCommon.js +8 -22
- package/dist/esm/node/vite/plugins/pluginDev.js +51 -47
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +63 -57
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +101 -91
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +24 -16
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +67 -57
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +26 -20
- package/dist/esm/node/vite/plugins/pluginPreview.js +30 -24
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +41 -33
- package/dist/esm/node/vite/plugins/pluginSetGlobalContext.js +4 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +2 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +51 -38
- package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +8 -6
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +2 -2
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assertNodeVersion.js +3 -1
- package/dist/esm/utils/assertVersion.d.ts +4 -3
- package/dist/esm/utils/assertVersion.js +23 -5
- package/dist/esm/utils/joinEnglish.js +2 -1
- package/package.json +2 -2
|
@@ -14,32 +14,38 @@ function pluginPreview() {
|
|
|
14
14
|
return {
|
|
15
15
|
name: 'vike:pluginPreview',
|
|
16
16
|
apply: applyPreview,
|
|
17
|
-
config
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
config: {
|
|
18
|
+
handler() {
|
|
19
|
+
return {
|
|
20
|
+
appType: 'custom',
|
|
21
|
+
};
|
|
22
|
+
},
|
|
21
23
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
configResolved: {
|
|
25
|
+
async handler(config_) {
|
|
26
|
+
config = config_;
|
|
27
|
+
vikeConfig = await getVikeConfigInternal();
|
|
28
|
+
logDockerHint(config.preview.host);
|
|
29
|
+
// vikeConfig = await getVikeConfig(config)
|
|
30
|
+
},
|
|
27
31
|
},
|
|
28
|
-
configurePreviewServer
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
configurePreviewServer: {
|
|
33
|
+
handler(server) {
|
|
34
|
+
/* - Couldn't make `appType: 'mpa'` work as of npm:@brillout/vite@5.0.0-beta.14.0426910c
|
|
35
|
+
- This ugly hack to set appType for preview won't be need once https://github.com/vitejs/vite/pull/14855 is merged.
|
|
36
|
+
config.appType = 'mpa'
|
|
37
|
+
*/
|
|
38
|
+
return () => {
|
|
39
|
+
const { isPrerenderingEnabledForAllPages, isPrerenderingEnabled } = vikeConfig.prerenderContext;
|
|
40
|
+
assertDist(isPrerenderingEnabledForAllPages);
|
|
41
|
+
// We cannot re-use Vite's static middleware: https://github.com/vitejs/vite/pull/14836#issuecomment-1788540300
|
|
42
|
+
addStaticAssetsMiddleware(server.middlewares);
|
|
43
|
+
if (!isPrerenderingEnabledForAllPages) {
|
|
44
|
+
addSsrMiddleware(server.middlewares, config, true, isPrerenderingEnabled);
|
|
45
|
+
}
|
|
46
|
+
addStatic404Middleware(server.middlewares);
|
|
47
|
+
};
|
|
48
|
+
},
|
|
43
49
|
},
|
|
44
50
|
};
|
|
45
51
|
function assertDist(isPrerenderingEnabledForAllPages) {
|
|
@@ -9,41 +9,49 @@ function pluginReplaceConstants() {
|
|
|
9
9
|
name: 'vike:pluginReplaceConstants',
|
|
10
10
|
enforce: 'post',
|
|
11
11
|
apply: 'build',
|
|
12
|
-
configResolved
|
|
13
|
-
|
|
12
|
+
configResolved: {
|
|
13
|
+
handler(config_) {
|
|
14
|
+
config = config_;
|
|
15
|
+
},
|
|
14
16
|
},
|
|
15
|
-
transform
|
|
16
|
-
id
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
assertPosixPath(config.root);
|
|
21
|
-
if (!id.startsWith(config.root))
|
|
22
|
-
return;
|
|
23
|
-
if (!code.includes('import.meta.env.'))
|
|
24
|
-
return;
|
|
25
|
-
const isBuild = config.command === 'build';
|
|
26
|
-
assert(isBuild);
|
|
27
|
-
// Used by vike.dev
|
|
28
|
-
// https://github.com/vikejs/vike/blob/08a1ff55c80ddca64ca6d4417fefd45fefeb4ffb/docs/vite.config.ts#L12
|
|
29
|
-
// @ts-expect-error
|
|
30
|
-
if (config._skipVikeReplaceConstants?.(id))
|
|
31
|
-
return;
|
|
32
|
-
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
33
|
-
const constantsMap = [];
|
|
34
|
-
constantsMap.push({
|
|
35
|
-
constants: ['pageContext.isClientSide', 'globalContext.isClientSide', 'pageContext.globalContext.isClientSide'],
|
|
36
|
-
replacement: !isViteServerSide_extraSafe(config, this.environment, options),
|
|
37
|
-
});
|
|
38
|
-
constantsMap.forEach(({ constants, replacement }) => {
|
|
39
|
-
if (!constants.some((c) => code.includes(c)))
|
|
17
|
+
transform: {
|
|
18
|
+
handler(code, id, options) {
|
|
19
|
+
id = normalizeId(id);
|
|
20
|
+
assertPosixPath(id);
|
|
21
|
+
if (id.includes('/node_modules/'))
|
|
40
22
|
return;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
23
|
+
assertPosixPath(config.root);
|
|
24
|
+
if (!id.startsWith(config.root))
|
|
25
|
+
return;
|
|
26
|
+
if (!code.includes('import.meta.env.'))
|
|
27
|
+
return;
|
|
28
|
+
const isBuild = config.command === 'build';
|
|
29
|
+
assert(isBuild);
|
|
30
|
+
// Used by vike.dev
|
|
31
|
+
// https://github.com/vikejs/vike/blob/08a1ff55c80ddca64ca6d4417fefd45fefeb4ffb/docs/vite.config.ts#L12
|
|
32
|
+
// @ts-expect-error
|
|
33
|
+
if (config._skipVikeReplaceConstants?.(id))
|
|
34
|
+
return;
|
|
35
|
+
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
36
|
+
const constantsMap = [];
|
|
37
|
+
constantsMap.push({
|
|
38
|
+
constants: [
|
|
39
|
+
'pageContext.isClientSide',
|
|
40
|
+
'globalContext.isClientSide',
|
|
41
|
+
'pageContext.globalContext.isClientSide',
|
|
42
|
+
],
|
|
43
|
+
replacement: !isViteServerSide_extraSafe(config, this.environment, options),
|
|
44
|
+
});
|
|
45
|
+
constantsMap.forEach(({ constants, replacement }) => {
|
|
46
|
+
if (!constants.some((c) => code.includes(c)))
|
|
47
|
+
return;
|
|
48
|
+
const regExp = getConstantRegExp(constants);
|
|
49
|
+
magicString.replaceAll(regExp, JSON.stringify(replacement));
|
|
50
|
+
});
|
|
51
|
+
if (!magicString.hasChanged())
|
|
52
|
+
return null;
|
|
53
|
+
return getMagicStringResult();
|
|
54
|
+
},
|
|
47
55
|
},
|
|
48
56
|
};
|
|
49
57
|
}
|
|
@@ -20,8 +20,10 @@ function pluginSetGlobalContext() {
|
|
|
20
20
|
markSetup_viteDevServer();
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
|
-
configurePreviewServer
|
|
24
|
-
|
|
23
|
+
configurePreviewServer: {
|
|
24
|
+
handler() {
|
|
25
|
+
markSetup_vitePreviewServer();
|
|
26
|
+
},
|
|
25
27
|
},
|
|
26
28
|
config: {
|
|
27
29
|
order: 'pre',
|
package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { generateVirtualFileGlobalEntryWithOldDesign };
|
|
2
|
-
import { assert, assertPosixPath, scriptFileExtensionPattern, debugGlob,
|
|
2
|
+
import { assert, assertPosixPath, scriptFileExtensionPattern, debugGlob, isVersionMatch, assertWarning, } from '../../utils.js';
|
|
3
3
|
import { parseVirtualFileId } from '../../../shared/virtualFileId.js';
|
|
4
4
|
import { version as viteVersion } from 'vite';
|
|
5
5
|
import { fileTypes } from '../../../../shared/getPageFiles/fileTypes.js';
|
|
@@ -139,7 +139,7 @@ function getGlobs(globRoots, isBuild, fileType, query, isV1Design) {
|
|
|
139
139
|
const globExcludePath = globRoot.excludeDir ? `'!${getGlobPath(globRoot.excludeDir, fileType)}'` : null;
|
|
140
140
|
const globOptions = { eager: isEager };
|
|
141
141
|
if (query) {
|
|
142
|
-
const isNewViteInterface =
|
|
142
|
+
const isNewViteInterface = isVersionMatch(viteVersion, ['5.1.0']);
|
|
143
143
|
if (isNewViteInterface &&
|
|
144
144
|
// When used for the old design, the new syntax breaks Vike's CI (surprinsigly so). I couldn't reproduce locally (I didn't dig much).
|
|
145
145
|
isV1Design) {
|
|
@@ -8,7 +8,7 @@ import { reloadVikeConfig, isV1Design, getVikeConfigInternalOptional } from '../
|
|
|
8
8
|
import pc from '@brillout/picocolors';
|
|
9
9
|
import { logConfigInfo } from '../shared/loggerNotProd.js';
|
|
10
10
|
import { getModuleFilePathAbsolute } from '../shared/getFilePath.js';
|
|
11
|
-
import { updateUserFiles } from '../../runtime/globalContext.js';
|
|
11
|
+
import { isRunnable, updateUserFiles } from '../../runtime/globalContext.js';
|
|
12
12
|
import { isPlusFile } from '../shared/resolveVikeConfigInternal/crawlPlusFiles.js';
|
|
13
13
|
import { isTemporaryBuildFile } from '../shared/resolveVikeConfigInternal/transpileAndExecuteFile.js';
|
|
14
14
|
import { getVikeConfigError } from '../../shared/getVikeConfigError.js';
|
|
@@ -16,47 +16,57 @@ function pluginVirtualFiles() {
|
|
|
16
16
|
let config;
|
|
17
17
|
return {
|
|
18
18
|
name: 'vike:pluginVirtualFiles',
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
configResolved: {
|
|
20
|
+
async handler(config_) {
|
|
21
|
+
config = config_;
|
|
22
|
+
// TO-DO/next-major-release: remove
|
|
23
|
+
if (!isV1Design())
|
|
24
|
+
config.experimental.importGlobRestoreExtension = true;
|
|
25
|
+
},
|
|
24
26
|
},
|
|
25
|
-
resolveId
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
return await handleHotUpdate(ctx, config);
|
|
33
|
-
}
|
|
34
|
-
catch (err) {
|
|
35
|
-
// Vite swallows errors thrown by handleHotUpdate()
|
|
36
|
-
console.error(err);
|
|
37
|
-
throw err;
|
|
38
|
-
}
|
|
27
|
+
resolveId: {
|
|
28
|
+
handler(id) {
|
|
29
|
+
if (isVirtualFileId(id)) {
|
|
30
|
+
return addVirtualFileIdPrefix(id);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
39
33
|
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const isDev = config._isDev;
|
|
45
|
-
assert(typeof isDev === 'boolean');
|
|
46
|
-
const idParsed = parseVirtualFileId(id);
|
|
47
|
-
if (idParsed) {
|
|
48
|
-
if (idParsed.type === 'page-entry') {
|
|
49
|
-
const code = await generateVirtualFilePageEntry(id, isDev);
|
|
50
|
-
return code;
|
|
34
|
+
handleHotUpdate: {
|
|
35
|
+
async handler(ctx) {
|
|
36
|
+
try {
|
|
37
|
+
return await handleHotUpdate(ctx, config);
|
|
51
38
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
39
|
+
catch (err) {
|
|
40
|
+
// Vite swallows errors thrown by handleHotUpdate()
|
|
41
|
+
console.error(err);
|
|
42
|
+
throw err;
|
|
55
43
|
}
|
|
56
|
-
}
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
load: {
|
|
47
|
+
async handler(id, options) {
|
|
48
|
+
if (!isVirtualFileId(id))
|
|
49
|
+
return undefined;
|
|
50
|
+
id = removeVirtualFileIdPrefix(id);
|
|
51
|
+
const isDev = config._isDev;
|
|
52
|
+
assert(typeof isDev === 'boolean');
|
|
53
|
+
const idParsed = parseVirtualFileId(id);
|
|
54
|
+
if (idParsed) {
|
|
55
|
+
if (idParsed.type === 'page-entry') {
|
|
56
|
+
const code = await generateVirtualFilePageEntry(id, isDev);
|
|
57
|
+
return code;
|
|
58
|
+
}
|
|
59
|
+
if (idParsed.type === 'global-entry') {
|
|
60
|
+
const code = await generateVirtualFileGlobalEntryWithOldDesign(id, options, config, this.environment, isDev);
|
|
61
|
+
return code;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
57
65
|
},
|
|
58
|
-
configureServer
|
|
59
|
-
|
|
66
|
+
configureServer: {
|
|
67
|
+
handler(server) {
|
|
68
|
+
handleFileAddRemove(server, config);
|
|
69
|
+
},
|
|
60
70
|
},
|
|
61
71
|
};
|
|
62
72
|
}
|
|
@@ -125,7 +135,10 @@ async function handleHotUpdate(ctx, config) {
|
|
|
125
135
|
// Ensure we invalidate `file` *before* server.ssrLoadModule() in updateUserFiles()
|
|
126
136
|
// Vite already invalidates it, but *after* handleHotUpdate() and thus after server.ssrLoadModule()
|
|
127
137
|
ctx.modules.forEach((mod) => server.moduleGraph.invalidateModule(mod));
|
|
128
|
-
|
|
138
|
+
if (isRunnable(server)) {
|
|
139
|
+
// TODO/now: await
|
|
140
|
+
updateUserFiles();
|
|
141
|
+
}
|
|
129
142
|
}
|
|
130
143
|
}
|
|
131
144
|
}
|
|
@@ -2,12 +2,14 @@ export { pluginWorkaroundCssModuleHmr };
|
|
|
2
2
|
function pluginWorkaroundCssModuleHmr() {
|
|
3
3
|
return {
|
|
4
4
|
name: 'vike:pluginWorkaroundCssModuleHmr',
|
|
5
|
-
handleHotUpdate
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
handleHotUpdate: {
|
|
6
|
+
handler(ctx) {
|
|
7
|
+
// prevent full reload due to non self-accepting css module.
|
|
8
|
+
// here only "?direct" module should be filtered out as it doesn't have a parent module.
|
|
9
|
+
if (ctx.file.includes('module.css')) {
|
|
10
|
+
return ctx.modules.filter((m) => !m.id?.includes('?direct'));
|
|
11
|
+
}
|
|
12
|
+
},
|
|
11
13
|
},
|
|
12
14
|
};
|
|
13
15
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
2
|
export { isPlusFile };
|
|
3
3
|
export { getPlusFileValueConfigName };
|
|
4
|
-
import { assertPosixPath, assert, scriptFileExtensionPattern, assertIsNotProductionRuntime,
|
|
4
|
+
import { assertPosixPath, assert, scriptFileExtensionPattern, assertIsNotProductionRuntime, isVersionMatch, isScriptFile, scriptFileExtensionList, createDebugger, deepEqual, assertUsage, assertFilePathAbsoluteFilesystem, assertWarning, hasProp, isNotNullish, getGlobalObject, } from '../../utils.js';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { glob } from 'tinyglobby';
|
|
7
7
|
import { exec } from 'node:child_process';
|
|
@@ -147,7 +147,7 @@ async function isGitNotUsable(userRootDir) {
|
|
|
147
147
|
// - We didn't bother test which is the earliest version that works.
|
|
148
148
|
// - Git 2.32.0 doesn't seem to work: https://github.com/vikejs/vike/discussions/1549
|
|
149
149
|
// - Maybe it's because of StackBlitz: looking at the release notes, Git 2.32.0 should be working.
|
|
150
|
-
if (!
|
|
150
|
+
if (!isVersionMatch(gitVersion, ['2.43.1']))
|
|
151
151
|
return true;
|
|
152
152
|
}
|
|
153
153
|
// Is userRootDir inside a Git repository?
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.239-commit-050a4a3";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.239-commit-050a4a3';
|
|
@@ -6,5 +6,7 @@ function assertNodeVersion() {
|
|
|
6
6
|
if (!isNodeJS())
|
|
7
7
|
return;
|
|
8
8
|
const version = process.versions.node;
|
|
9
|
-
assertVersion('Node.js', version,
|
|
9
|
+
assertVersion('Node.js', version,
|
|
10
|
+
// https://gist.github.com/brillout/8e0133716e169b981b6c4e8a938b0134
|
|
11
|
+
['20.19.0', '22.12.0', '23.0.0']);
|
|
10
12
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { assertVersion };
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
declare function
|
|
2
|
+
export { isVersionMatch };
|
|
3
|
+
type Version = `${number}.${number}.${number}`;
|
|
4
|
+
declare function assertVersion(dependencyName: 'Vite' | 'Node.js', versionActual: string, versionExpectedList: Version[]): void;
|
|
5
|
+
declare function isVersionMatch(versionActual: string, versionExpectedList: Version[]): boolean;
|
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
export { assertVersion };
|
|
2
|
-
export {
|
|
2
|
+
export { isVersionMatch };
|
|
3
|
+
import pc from '@brillout/picocolors';
|
|
3
4
|
import { assert, assertUsage } from './assert.js';
|
|
4
5
|
import { assertIsNotBrowser } from './assertIsNotBrowser.js';
|
|
6
|
+
import { joinEnglish } from './joinEnglish.js';
|
|
5
7
|
assertIsNotBrowser();
|
|
6
|
-
function assertVersion(dependencyName, versionActual,
|
|
8
|
+
function assertVersion(dependencyName, versionActual, versionExpectedList) {
|
|
9
|
+
assertUsage(isVersionMatch(versionActual, versionExpectedList), `${pc.bold(dependencyName)} ${pc.red(pc.bold(versionActual))} isn't supported, use ${pc.bold(dependencyName)} ${joinEnglish([...versionExpectedList, 'above'].map((v) => pc.green(pc.bold(v))), 'or')}.`);
|
|
10
|
+
}
|
|
11
|
+
function isVersionMatch(versionActual, versionExpectedList) {
|
|
7
12
|
assert(versionActual);
|
|
8
|
-
assert(
|
|
9
|
-
|
|
13
|
+
assert(versionExpectedList);
|
|
14
|
+
assert(versionExpectedList.length > 0);
|
|
15
|
+
const versionActualMajor = parseVersion(versionActual)[0];
|
|
16
|
+
const versionExpectedListSameMajor = versionExpectedList.filter((versionExpected) => {
|
|
17
|
+
const versionExpectedMajor = parseVersion(versionExpected)[0];
|
|
18
|
+
return versionExpectedMajor === versionActualMajor;
|
|
19
|
+
});
|
|
20
|
+
assert(versionExpectedListSameMajor.length <= 1);
|
|
21
|
+
const versionExpectedSameMajor = versionExpectedListSameMajor[0];
|
|
22
|
+
if (versionExpectedSameMajor) {
|
|
23
|
+
return isSameOrAbove(versionActual, versionExpectedSameMajor);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return versionExpectedList.every((versionExpected) => isSameOrAbove(versionActual, versionExpected));
|
|
27
|
+
}
|
|
10
28
|
}
|
|
11
|
-
function
|
|
29
|
+
function isSameOrAbove(versionActual, versionExpected) {
|
|
12
30
|
const p1 = parseVersion(versionActual);
|
|
13
31
|
const p2 = parseVersion(versionExpected);
|
|
14
32
|
// major
|
|
@@ -7,5 +7,6 @@ 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
|
-
|
|
10
|
+
const lastComma = arr.length > 2 ? ',' : '';
|
|
11
|
+
return firsts.map(colorizer).join(', ') + `${lastComma} ${conjunction} ` + colorizer(last);
|
|
11
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.239-commit-050a4a3",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
}
|
|
160
160
|
},
|
|
161
161
|
"engines": {
|
|
162
|
-
"node": ">=
|
|
162
|
+
"node": ">=20.19.0"
|
|
163
163
|
},
|
|
164
164
|
"license": "MIT",
|
|
165
165
|
"description": "The Framework *You* Control - Next.js & Nuxt alternative for unprecedented flexibility and dependability.",
|