vike 0.4.176-commit-1442a4a → 0.4.177-commit-ff3d6cd
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/crawlPlusFiles.js +129 -18
- package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +2 -2
- package/dist/cjs/utils/assertSingleInstance.js +5 -1
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +130 -19
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.js +2 -2
- package/dist/esm/shared/page-configs/PageConfig.d.ts +3 -3
- package/dist/esm/utils/assertSingleInstance.js +2 -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/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -6,12 +6,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.crawlPlusFiles = void 0;
|
|
7
7
|
const utils_js_1 = require("../../../../utils.js");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
10
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
10
11
|
const child_process_1 = require("child_process");
|
|
11
12
|
const util_1 = require("util");
|
|
12
13
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
14
|
const transpileAndExecuteFile_js_1 = require("./transpileAndExecuteFile.js");
|
|
14
15
|
const execA = (0, util_1.promisify)(child_process_1.exec);
|
|
16
|
+
const TOO_MANY_UNTRACKED_FILES = 5;
|
|
15
17
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
16
18
|
(0, utils_js_1.assertIsSingleModuleInstance)('crawlPlusFiles.ts');
|
|
17
19
|
let gitIsNotUsable = false;
|
|
@@ -35,15 +37,17 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev, craw
|
|
|
35
37
|
let files = [];
|
|
36
38
|
const res = crawlWithGit !== false && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
|
|
37
39
|
if (res &&
|
|
38
|
-
// Fallback to fast-glob for users that dynamically generate plus files. (Assuming
|
|
39
|
-
res.length > 0) {
|
|
40
|
-
files = res;
|
|
40
|
+
// Fallback to fast-glob for users that dynamically generate plus files. (Assuming that no plus file is found because of the user's .gitignore list.)
|
|
41
|
+
res.files.length > 0) {
|
|
42
|
+
files = res.files;
|
|
43
|
+
// We cannot find files inside symlink directories with `$ git ls-files` => we use fast-glob
|
|
44
|
+
files.push(...(await crawlSymlinkDirs(res.symlinkDirs, userRootDir, outDirRelativeFromUserRootDir)));
|
|
41
45
|
}
|
|
42
46
|
else {
|
|
43
47
|
files = await fastGlob(userRootDir, outDirRelativeFromUserRootDir);
|
|
44
48
|
}
|
|
45
49
|
// Filter build files
|
|
46
|
-
files = files.filter((
|
|
50
|
+
files = files.filter((filePath) => !(0, transpileAndExecuteFile_js_1.isTemporaryBuildFile)(filePath));
|
|
47
51
|
// Check performance
|
|
48
52
|
{
|
|
49
53
|
const timeAfter = new Date().getTime();
|
|
@@ -82,20 +86,27 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
82
86
|
'git',
|
|
83
87
|
preserveUTF8,
|
|
84
88
|
'ls-files',
|
|
85
|
-
|
|
89
|
+
// We don't filter because:
|
|
90
|
+
// - It would skip symlink directories
|
|
91
|
+
// - Performance gain seems negligible: https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
92
|
+
// ...scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
93
|
+
// Performance gain is non-negligible.
|
|
94
|
+
// - https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
95
|
+
// - When node_modules/ is untracked the performance gain could be significant?
|
|
86
96
|
...ignoreAsPatterns.map((pattern) => `--exclude="${pattern}"`),
|
|
87
|
-
// --others
|
|
88
|
-
// --cached
|
|
89
|
-
|
|
97
|
+
// --others --exclude-standard => list untracked files (--others) while using .gitignore (--exclude-standard)
|
|
98
|
+
// --cached => list tracked files
|
|
99
|
+
// --stage => get file modes which we use to find symlink directories
|
|
100
|
+
'--others --exclude-standard --cached --stage'
|
|
90
101
|
].join(' ');
|
|
91
|
-
let
|
|
102
|
+
let resultLines;
|
|
92
103
|
let filesDeleted;
|
|
93
104
|
try {
|
|
94
105
|
;
|
|
95
|
-
[
|
|
106
|
+
[resultLines, filesDeleted] = await Promise.all([
|
|
96
107
|
// Main command
|
|
97
108
|
runCmd1(cmd, userRootDir),
|
|
98
|
-
// Get tracked
|
|
109
|
+
// Get tracked but deleted files
|
|
99
110
|
runCmd1('git ls-files --deleted', userRootDir)
|
|
100
111
|
]);
|
|
101
112
|
}
|
|
@@ -106,11 +117,40 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
106
117
|
}
|
|
107
118
|
throw err;
|
|
108
119
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
const filePaths = resultLines.map(parseGitLsResultLine);
|
|
121
|
+
// If there are too many files without mode we fallback to fast-glob
|
|
122
|
+
if (filePaths.filter((f) => !f.mode).length > TOO_MANY_UNTRACKED_FILES)
|
|
123
|
+
return null;
|
|
124
|
+
const symlinkDirs = [];
|
|
125
|
+
const files = [];
|
|
126
|
+
for (const { filePath, mode } of filePaths) {
|
|
127
|
+
// Deleted?
|
|
128
|
+
if (filesDeleted.includes(filePath))
|
|
129
|
+
continue;
|
|
130
|
+
// We have to repeat the same exclusion logic here because the option --exclude of `$ git ls-files` only applies to untracked files. (We use --exclude only to speed up the `$ git ls-files` command.)
|
|
131
|
+
if (!ignoreAsFilterFn(filePath))
|
|
132
|
+
continue;
|
|
133
|
+
// Symlink directory?
|
|
134
|
+
{
|
|
135
|
+
const isSymlinkDir = await isSymlinkDirectory(mode, filePath, userRootDir);
|
|
136
|
+
if (isSymlinkDir) {
|
|
137
|
+
symlinkDirs.push(filePath);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
// Skip deleted files and non-symlink directories
|
|
141
|
+
if (isSymlinkDir === null) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// + file?
|
|
146
|
+
if (!path_1.default.posix.basename(filePath).startsWith('+'))
|
|
147
|
+
continue;
|
|
148
|
+
// JavaScript file?
|
|
149
|
+
if (!(0, utils_js_1.isScriptFile)(filePath))
|
|
150
|
+
continue;
|
|
151
|
+
files.push(filePath);
|
|
152
|
+
}
|
|
153
|
+
return { files, symlinkDirs };
|
|
114
154
|
}
|
|
115
155
|
// Same as gitLsFiles() but using fast-glob
|
|
116
156
|
async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
@@ -121,7 +161,7 @@ async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
121
161
|
});
|
|
122
162
|
return files;
|
|
123
163
|
}
|
|
124
|
-
// Same as
|
|
164
|
+
// Same as getIgnoreAsFilterFn() but as glob pattern
|
|
125
165
|
function getIgnoreAsPatterns(outDirRelativeFromUserRootDir) {
|
|
126
166
|
const ignoreAsPatterns = [
|
|
127
167
|
'**/node_modules/**',
|
|
@@ -138,7 +178,7 @@ function getIgnoreAsPatterns(outDirRelativeFromUserRootDir) {
|
|
|
138
178
|
}
|
|
139
179
|
return ignoreAsPatterns;
|
|
140
180
|
}
|
|
141
|
-
// Same as
|
|
181
|
+
// Same as getIgnoreAsPatterns() but for Array.filter()
|
|
142
182
|
function getIgnoreAsFilterFn(outDirRelativeFromUserRootDir) {
|
|
143
183
|
(0, utils_js_1.assert)(outDirRelativeFromUserRootDir === null || !outDirRelativeFromUserRootDir.startsWith('/'));
|
|
144
184
|
return (file) => !file.includes('node_modules/') &&
|
|
@@ -175,6 +215,77 @@ async function isGitNotUsable(userRootDir) {
|
|
|
175
215
|
return false;
|
|
176
216
|
}
|
|
177
217
|
}
|
|
218
|
+
async function crawlSymlinkDirs(symlinkDirs, userRootDir, outDirRelativeFromUserRootDir) {
|
|
219
|
+
const filesInSymlinkDirs = (await Promise.all(symlinkDirs.map(async (symlinkDir) => (await fastGlob(path_1.default.posix.join(userRootDir, symlinkDir), outDirRelativeFromUserRootDir)).map((filePath) => path_1.default.posix.join(symlinkDir, filePath))))).flat();
|
|
220
|
+
return filesInSymlinkDirs;
|
|
221
|
+
}
|
|
222
|
+
// Parse:
|
|
223
|
+
// ```
|
|
224
|
+
// some/not/tracked/path
|
|
225
|
+
// 100644 f6928073402b241b468b199893ff6f4aed0b7195 0\tpages/index/+Page.tsx
|
|
226
|
+
// ```
|
|
227
|
+
function parseGitLsResultLine(resultLine) {
|
|
228
|
+
const [part1, part2, ...rest] = resultLine.split('\t');
|
|
229
|
+
(0, utils_js_1.assert)(part1);
|
|
230
|
+
(0, utils_js_1.assert)(rest.length === 0);
|
|
231
|
+
// Git doesn't provide the mode for untracked paths.
|
|
232
|
+
// `resultLine` is:
|
|
233
|
+
// ```
|
|
234
|
+
// some/not/tracked/path
|
|
235
|
+
// ```
|
|
236
|
+
if (part2 === undefined) {
|
|
237
|
+
return { filePath: part1, mode: null };
|
|
238
|
+
}
|
|
239
|
+
(0, utils_js_1.assert)(part2);
|
|
240
|
+
// `resultLine` is:
|
|
241
|
+
// ```
|
|
242
|
+
// 100644 f6928073402b241b468b199893ff6f4aed0b7195 0\tpages/index/+Page.tsx
|
|
243
|
+
// ```
|
|
244
|
+
const [mode, _, __, ...rest2] = part1.split(' ');
|
|
245
|
+
(0, utils_js_1.assert)(mode && _ && __ && rest2.length === 0);
|
|
246
|
+
return { filePath: part2, mode };
|
|
247
|
+
}
|
|
248
|
+
async function isSymlinkDirectory(mode, filePath, userRootDir) {
|
|
249
|
+
const filePathAbsolute = path_1.default.posix.join(userRootDir, filePath);
|
|
250
|
+
let stats = null;
|
|
251
|
+
let isSymlink = false;
|
|
252
|
+
if (mode === '120000') {
|
|
253
|
+
isSymlink = true;
|
|
254
|
+
}
|
|
255
|
+
else if (mode === null) {
|
|
256
|
+
// `$ git ls-files` doesn't provide the mode when Git doesn't track the path
|
|
257
|
+
stats = await getFileStats(filePathAbsolute);
|
|
258
|
+
if (stats === null)
|
|
259
|
+
return null;
|
|
260
|
+
isSymlink = stats.isSymbolicLink();
|
|
261
|
+
if (!isSymlink && stats.isDirectory())
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
(0, utils_js_1.assert)(mode);
|
|
266
|
+
}
|
|
267
|
+
if (!isSymlink)
|
|
268
|
+
return false;
|
|
269
|
+
if (!stats)
|
|
270
|
+
stats = await getFileStats(filePathAbsolute);
|
|
271
|
+
if (stats === null)
|
|
272
|
+
return null;
|
|
273
|
+
const isDirectory = stats.isDirectory();
|
|
274
|
+
return isDirectory;
|
|
275
|
+
}
|
|
276
|
+
async function getFileStats(filePathAbsolute) {
|
|
277
|
+
let stats;
|
|
278
|
+
try {
|
|
279
|
+
stats = await promises_1.default.lstat(filePathAbsolute);
|
|
280
|
+
}
|
|
281
|
+
catch (err) {
|
|
282
|
+
// File was deleted, usually a temporary file such as +config.js.build-j95xb988fpln.mjs
|
|
283
|
+
// ENOENT: no such file or directory
|
|
284
|
+
(0, utils_js_1.assert)(err.code === 'ENOENT');
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
return stats;
|
|
288
|
+
}
|
|
178
289
|
async function runCmd1(cmd, cwd) {
|
|
179
290
|
const { stdout } = await execA(cmd, { cwd });
|
|
180
291
|
/* Not always true: https://github.com/vikejs/vike/issues/1440#issuecomment-1892831303
|
|
@@ -35,8 +35,8 @@ function warnMissingErrorPage(isV1) {
|
|
|
35
35
|
if (!globalContext.isProduction) {
|
|
36
36
|
const msg = [
|
|
37
37
|
`No ${isV1 ? 'error page' : picocolors_1.default.cyan('_error.page.js')} found,`,
|
|
38
|
-
'we recommend defining
|
|
39
|
-
'
|
|
38
|
+
'we recommend defining one',
|
|
39
|
+
'https://vike.dev/error-page'
|
|
40
40
|
].join(' ');
|
|
41
41
|
(0, utils_js_1.assertWarning)(false, msg, { onlyOnce: true });
|
|
42
42
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
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
6
|
exports.onAssertModuleLoad = exports.onClientEntry_ClientRouting = exports.onClientEntry_ServerRouting = void 0;
|
|
4
7
|
// - Throw error if there are two different versions of vike loaded
|
|
@@ -7,6 +10,7 @@ exports.onAssertModuleLoad = exports.onClientEntry_ClientRouting = exports.onCli
|
|
|
7
10
|
const unique_js_1 = require("./unique.js");
|
|
8
11
|
const getGlobalObject_js_1 = require("./getGlobalObject.js");
|
|
9
12
|
const projectInfo_js_1 = require("./projectInfo.js");
|
|
13
|
+
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
10
14
|
/* Use original assertUsage() & assertWarning() after all CJS is removed from node_modules/vike/dist/
|
|
11
15
|
import { assertUsage, assertWarning } from './assert.js'
|
|
12
16
|
*/
|
|
@@ -21,7 +25,7 @@ function assertSingleInstance() {
|
|
|
21
25
|
const versions = (0, unique_js_1.unique)(globalObject.instances);
|
|
22
26
|
assertUsage(versions.length <= 1,
|
|
23
27
|
// DO *NOT* patch vike to remove this error: because of multiple conflicting versions, you *will* eventually encounter insidious issues that hard to debug and potentially a security hazard, see for example https://github.com/vikejs/vike/issues/1108
|
|
24
|
-
`
|
|
28
|
+
`vike@${picocolors_1.default.bold(versions[0])} and vike@${picocolors_1.default.bold(versions[1])} loaded but only one version should be loaded`);
|
|
25
29
|
}
|
|
26
30
|
if (globalObject.checkSingleInstance && globalObject.instances.length > 1) {
|
|
27
31
|
/*/ Not sure whether circular dependency can cause problems? In principle not since client-side code is ESM.
|
|
@@ -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.
|
|
4
|
+
const PROJECT_VERSION = '0.4.177-commit-ff3d6cd';
|
|
5
5
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
6
6
|
const projectInfo = {
|
|
7
7
|
projectName: 'Vike',
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
|
-
import { assertPosixPath, assert, assertWarning,
|
|
2
|
+
import { assertPosixPath, assert, assertWarning, scriptFileExtensions, humanizeTime, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile } from '../../../../utils.js';
|
|
3
3
|
import path from 'path';
|
|
4
|
+
import fs from 'fs/promises';
|
|
4
5
|
import glob from 'fast-glob';
|
|
5
6
|
import { exec } from 'child_process';
|
|
6
7
|
import { promisify } from 'util';
|
|
7
8
|
import pc from '@brillout/picocolors';
|
|
8
9
|
import { isTemporaryBuildFile } from './transpileAndExecuteFile.js';
|
|
9
10
|
const execA = promisify(exec);
|
|
11
|
+
const TOO_MANY_UNTRACKED_FILES = 5;
|
|
10
12
|
assertIsNotProductionRuntime();
|
|
11
13
|
assertIsSingleModuleInstance('crawlPlusFiles.ts');
|
|
12
14
|
let gitIsNotUsable = false;
|
|
@@ -30,15 +32,17 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev, craw
|
|
|
30
32
|
let files = [];
|
|
31
33
|
const res = crawlWithGit !== false && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
|
|
32
34
|
if (res &&
|
|
33
|
-
// Fallback to fast-glob for users that dynamically generate plus files. (Assuming
|
|
34
|
-
res.length > 0) {
|
|
35
|
-
files = res;
|
|
35
|
+
// Fallback to fast-glob for users that dynamically generate plus files. (Assuming that no plus file is found because of the user's .gitignore list.)
|
|
36
|
+
res.files.length > 0) {
|
|
37
|
+
files = res.files;
|
|
38
|
+
// We cannot find files inside symlink directories with `$ git ls-files` => we use fast-glob
|
|
39
|
+
files.push(...(await crawlSymlinkDirs(res.symlinkDirs, userRootDir, outDirRelativeFromUserRootDir)));
|
|
36
40
|
}
|
|
37
41
|
else {
|
|
38
42
|
files = await fastGlob(userRootDir, outDirRelativeFromUserRootDir);
|
|
39
43
|
}
|
|
40
44
|
// Filter build files
|
|
41
|
-
files = files.filter((
|
|
45
|
+
files = files.filter((filePath) => !isTemporaryBuildFile(filePath));
|
|
42
46
|
// Check performance
|
|
43
47
|
{
|
|
44
48
|
const timeAfter = new Date().getTime();
|
|
@@ -76,20 +80,27 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
76
80
|
'git',
|
|
77
81
|
preserveUTF8,
|
|
78
82
|
'ls-files',
|
|
79
|
-
|
|
83
|
+
// We don't filter because:
|
|
84
|
+
// - It would skip symlink directories
|
|
85
|
+
// - Performance gain seems negligible: https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
86
|
+
// ...scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
87
|
+
// Performance gain is non-negligible.
|
|
88
|
+
// - https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
89
|
+
// - When node_modules/ is untracked the performance gain could be significant?
|
|
80
90
|
...ignoreAsPatterns.map((pattern) => `--exclude="${pattern}"`),
|
|
81
|
-
// --others
|
|
82
|
-
// --cached
|
|
83
|
-
|
|
91
|
+
// --others --exclude-standard => list untracked files (--others) while using .gitignore (--exclude-standard)
|
|
92
|
+
// --cached => list tracked files
|
|
93
|
+
// --stage => get file modes which we use to find symlink directories
|
|
94
|
+
'--others --exclude-standard --cached --stage'
|
|
84
95
|
].join(' ');
|
|
85
|
-
let
|
|
96
|
+
let resultLines;
|
|
86
97
|
let filesDeleted;
|
|
87
98
|
try {
|
|
88
99
|
;
|
|
89
|
-
[
|
|
100
|
+
[resultLines, filesDeleted] = await Promise.all([
|
|
90
101
|
// Main command
|
|
91
102
|
runCmd1(cmd, userRootDir),
|
|
92
|
-
// Get tracked
|
|
103
|
+
// Get tracked but deleted files
|
|
93
104
|
runCmd1('git ls-files --deleted', userRootDir)
|
|
94
105
|
]);
|
|
95
106
|
}
|
|
@@ -100,11 +111,40 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
100
111
|
}
|
|
101
112
|
throw err;
|
|
102
113
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
114
|
+
const filePaths = resultLines.map(parseGitLsResultLine);
|
|
115
|
+
// If there are too many files without mode we fallback to fast-glob
|
|
116
|
+
if (filePaths.filter((f) => !f.mode).length > TOO_MANY_UNTRACKED_FILES)
|
|
117
|
+
return null;
|
|
118
|
+
const symlinkDirs = [];
|
|
119
|
+
const files = [];
|
|
120
|
+
for (const { filePath, mode } of filePaths) {
|
|
121
|
+
// Deleted?
|
|
122
|
+
if (filesDeleted.includes(filePath))
|
|
123
|
+
continue;
|
|
124
|
+
// We have to repeat the same exclusion logic here because the option --exclude of `$ git ls-files` only applies to untracked files. (We use --exclude only to speed up the `$ git ls-files` command.)
|
|
125
|
+
if (!ignoreAsFilterFn(filePath))
|
|
126
|
+
continue;
|
|
127
|
+
// Symlink directory?
|
|
128
|
+
{
|
|
129
|
+
const isSymlinkDir = await isSymlinkDirectory(mode, filePath, userRootDir);
|
|
130
|
+
if (isSymlinkDir) {
|
|
131
|
+
symlinkDirs.push(filePath);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
// Skip deleted files and non-symlink directories
|
|
135
|
+
if (isSymlinkDir === null) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// + file?
|
|
140
|
+
if (!path.posix.basename(filePath).startsWith('+'))
|
|
141
|
+
continue;
|
|
142
|
+
// JavaScript file?
|
|
143
|
+
if (!isScriptFile(filePath))
|
|
144
|
+
continue;
|
|
145
|
+
files.push(filePath);
|
|
146
|
+
}
|
|
147
|
+
return { files, symlinkDirs };
|
|
108
148
|
}
|
|
109
149
|
// Same as gitLsFiles() but using fast-glob
|
|
110
150
|
async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
@@ -115,7 +155,7 @@ async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
115
155
|
});
|
|
116
156
|
return files;
|
|
117
157
|
}
|
|
118
|
-
// Same as
|
|
158
|
+
// Same as getIgnoreAsFilterFn() but as glob pattern
|
|
119
159
|
function getIgnoreAsPatterns(outDirRelativeFromUserRootDir) {
|
|
120
160
|
const ignoreAsPatterns = [
|
|
121
161
|
'**/node_modules/**',
|
|
@@ -132,7 +172,7 @@ function getIgnoreAsPatterns(outDirRelativeFromUserRootDir) {
|
|
|
132
172
|
}
|
|
133
173
|
return ignoreAsPatterns;
|
|
134
174
|
}
|
|
135
|
-
// Same as
|
|
175
|
+
// Same as getIgnoreAsPatterns() but for Array.filter()
|
|
136
176
|
function getIgnoreAsFilterFn(outDirRelativeFromUserRootDir) {
|
|
137
177
|
assert(outDirRelativeFromUserRootDir === null || !outDirRelativeFromUserRootDir.startsWith('/'));
|
|
138
178
|
return (file) => !file.includes('node_modules/') &&
|
|
@@ -169,6 +209,77 @@ async function isGitNotUsable(userRootDir) {
|
|
|
169
209
|
return false;
|
|
170
210
|
}
|
|
171
211
|
}
|
|
212
|
+
async function crawlSymlinkDirs(symlinkDirs, userRootDir, outDirRelativeFromUserRootDir) {
|
|
213
|
+
const filesInSymlinkDirs = (await Promise.all(symlinkDirs.map(async (symlinkDir) => (await fastGlob(path.posix.join(userRootDir, symlinkDir), outDirRelativeFromUserRootDir)).map((filePath) => path.posix.join(symlinkDir, filePath))))).flat();
|
|
214
|
+
return filesInSymlinkDirs;
|
|
215
|
+
}
|
|
216
|
+
// Parse:
|
|
217
|
+
// ```
|
|
218
|
+
// some/not/tracked/path
|
|
219
|
+
// 100644 f6928073402b241b468b199893ff6f4aed0b7195 0\tpages/index/+Page.tsx
|
|
220
|
+
// ```
|
|
221
|
+
function parseGitLsResultLine(resultLine) {
|
|
222
|
+
const [part1, part2, ...rest] = resultLine.split('\t');
|
|
223
|
+
assert(part1);
|
|
224
|
+
assert(rest.length === 0);
|
|
225
|
+
// Git doesn't provide the mode for untracked paths.
|
|
226
|
+
// `resultLine` is:
|
|
227
|
+
// ```
|
|
228
|
+
// some/not/tracked/path
|
|
229
|
+
// ```
|
|
230
|
+
if (part2 === undefined) {
|
|
231
|
+
return { filePath: part1, mode: null };
|
|
232
|
+
}
|
|
233
|
+
assert(part2);
|
|
234
|
+
// `resultLine` is:
|
|
235
|
+
// ```
|
|
236
|
+
// 100644 f6928073402b241b468b199893ff6f4aed0b7195 0\tpages/index/+Page.tsx
|
|
237
|
+
// ```
|
|
238
|
+
const [mode, _, __, ...rest2] = part1.split(' ');
|
|
239
|
+
assert(mode && _ && __ && rest2.length === 0);
|
|
240
|
+
return { filePath: part2, mode };
|
|
241
|
+
}
|
|
242
|
+
async function isSymlinkDirectory(mode, filePath, userRootDir) {
|
|
243
|
+
const filePathAbsolute = path.posix.join(userRootDir, filePath);
|
|
244
|
+
let stats = null;
|
|
245
|
+
let isSymlink = false;
|
|
246
|
+
if (mode === '120000') {
|
|
247
|
+
isSymlink = true;
|
|
248
|
+
}
|
|
249
|
+
else if (mode === null) {
|
|
250
|
+
// `$ git ls-files` doesn't provide the mode when Git doesn't track the path
|
|
251
|
+
stats = await getFileStats(filePathAbsolute);
|
|
252
|
+
if (stats === null)
|
|
253
|
+
return null;
|
|
254
|
+
isSymlink = stats.isSymbolicLink();
|
|
255
|
+
if (!isSymlink && stats.isDirectory())
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
assert(mode);
|
|
260
|
+
}
|
|
261
|
+
if (!isSymlink)
|
|
262
|
+
return false;
|
|
263
|
+
if (!stats)
|
|
264
|
+
stats = await getFileStats(filePathAbsolute);
|
|
265
|
+
if (stats === null)
|
|
266
|
+
return null;
|
|
267
|
+
const isDirectory = stats.isDirectory();
|
|
268
|
+
return isDirectory;
|
|
269
|
+
}
|
|
270
|
+
async function getFileStats(filePathAbsolute) {
|
|
271
|
+
let stats;
|
|
272
|
+
try {
|
|
273
|
+
stats = await fs.lstat(filePathAbsolute);
|
|
274
|
+
}
|
|
275
|
+
catch (err) {
|
|
276
|
+
// File was deleted, usually a temporary file such as +config.js.build-j95xb988fpln.mjs
|
|
277
|
+
// ENOENT: no such file or directory
|
|
278
|
+
assert(err.code === 'ENOENT');
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
return stats;
|
|
282
|
+
}
|
|
172
283
|
async function runCmd1(cmd, cwd) {
|
|
173
284
|
const { stdout } = await execA(cmd, { cwd });
|
|
174
285
|
/* Not always true: https://github.com/vikejs/vike/issues/1440#issuecomment-1892831303
|
|
@@ -29,8 +29,8 @@ function warnMissingErrorPage(isV1) {
|
|
|
29
29
|
if (!globalContext.isProduction) {
|
|
30
30
|
const msg = [
|
|
31
31
|
`No ${isV1 ? 'error page' : pc.cyan('_error.page.js')} found,`,
|
|
32
|
-
'we recommend defining
|
|
33
|
-
'
|
|
32
|
+
'we recommend defining one',
|
|
33
|
+
'https://vike.dev/error-page'
|
|
34
34
|
].join(' ');
|
|
35
35
|
assertWarning(false, msg, { onlyOnce: true });
|
|
36
36
|
}
|
|
@@ -67,9 +67,9 @@ type ConfigEnv = {
|
|
|
67
67
|
/** For Vike internal use */
|
|
68
68
|
type ConfigEnvInternal = Omit<ConfigEnv, 'client'> & {
|
|
69
69
|
client?: boolean | 'if-client-routing';
|
|
70
|
-
/** Always load value,
|
|
71
|
-
eager?:
|
|
72
|
-
/** Load value only in production or only in development. */
|
|
70
|
+
/** Always load value, no matter which page is loaded. */
|
|
71
|
+
eager?: true;
|
|
72
|
+
/** Load value only in production, or only in development. */
|
|
73
73
|
production?: boolean;
|
|
74
74
|
};
|
|
75
75
|
type ConfigValueSource = {
|
|
@@ -7,6 +7,7 @@ export { onAssertModuleLoad };
|
|
|
7
7
|
import { unique } from './unique.js';
|
|
8
8
|
import { getGlobalObject } from './getGlobalObject.js';
|
|
9
9
|
import { projectInfo } from './projectInfo.js';
|
|
10
|
+
import pc from '@brillout/picocolors';
|
|
10
11
|
/* Use original assertUsage() & assertWarning() after all CJS is removed from node_modules/vike/dist/
|
|
11
12
|
import { assertUsage, assertWarning } from './assert.js'
|
|
12
13
|
*/
|
|
@@ -21,7 +22,7 @@ function assertSingleInstance() {
|
|
|
21
22
|
const versions = unique(globalObject.instances);
|
|
22
23
|
assertUsage(versions.length <= 1,
|
|
23
24
|
// DO *NOT* patch vike to remove this error: because of multiple conflicting versions, you *will* eventually encounter insidious issues that hard to debug and potentially a security hazard, see for example https://github.com/vikejs/vike/issues/1108
|
|
24
|
-
`
|
|
25
|
+
`vike@${pc.bold(versions[0])} and vike@${pc.bold(versions[1])} loaded but only one version should be loaded`);
|
|
25
26
|
}
|
|
26
27
|
if (globalObject.checkSingleInstance && globalObject.instances.length > 1) {
|
|
27
28
|
/*/ Not sure whether circular dependency can cause problems? In principle not since client-side code is ESM.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
|
-
declare const PROJECT_VERSION: "0.4.
|
|
3
|
+
declare const PROJECT_VERSION: "0.4.177-commit-ff3d6cd";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.
|
|
6
|
+
projectVersion: "0.4.177-commit-ff3d6cd";
|
|
7
7
|
};
|