vike 0.4.148-commit-7596dcd → 0.4.148-commit-70e7518
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 +30 -18
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +30 -18
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +2 -2
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -13,19 +13,24 @@ const execA = (0, util_1.promisify)(child_process_1.exec);
|
|
|
13
13
|
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
14
14
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
15
15
|
(0, utils_js_1.assertPosixPath)(outDirAbsoluteFilesystem);
|
|
16
|
+
// Vike prepends userRootDir without resolving, e.g. outDirRelativeFromUserRootDir can be /home/rom/my-monorepo/my-app/../my-build/dist/ while userRootDir is /home/rom/my-monorepo/my-app/
|
|
16
17
|
(0, utils_js_1.assert)(outDirAbsoluteFilesystem.startsWith(userRootDir));
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
let outDirRelativeFromUserRootDir = path_1.default.posix.relative(userRootDir, outDirAbsoluteFilesystem);
|
|
19
|
+
if (outDirRelativeFromUserRootDir.startsWith('../')) {
|
|
20
|
+
// config.outDir is outside of config.root => it's going to be ignored anyways
|
|
21
|
+
outDirRelativeFromUserRootDir = null;
|
|
22
|
+
}
|
|
23
|
+
(0, utils_js_1.assert)(outDirRelativeFromUserRootDir === null || !outDirRelativeFromUserRootDir.startsWith('.'));
|
|
19
24
|
const timeBase = new Date().getTime();
|
|
20
25
|
let files = [];
|
|
21
|
-
const res = await gitLsFiles(userRootDir,
|
|
26
|
+
const res = await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir);
|
|
22
27
|
if (res &&
|
|
23
28
|
// Fallback to fast-glob for users that dynamically generate plus files (we assume generetad plus files to be skipped because they are usually included in .gitignore)
|
|
24
29
|
res.length > 0) {
|
|
25
30
|
files = res;
|
|
26
31
|
}
|
|
27
32
|
else {
|
|
28
|
-
files = await fastGlob(userRootDir,
|
|
33
|
+
files = await fastGlob(userRootDir, outDirRelativeFromUserRootDir);
|
|
29
34
|
}
|
|
30
35
|
{
|
|
31
36
|
const time = new Date().getTime() - timeBase;
|
|
@@ -50,23 +55,23 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
50
55
|
}
|
|
51
56
|
exports.crawlPlusFiles = crawlPlusFiles;
|
|
52
57
|
// Same as fastGlob() but using `$ git ls-files`
|
|
53
|
-
async function gitLsFiles(userRootDir,
|
|
54
|
-
// Test
|
|
58
|
+
async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
59
|
+
// Test whether Git is installed and whether userRootDir is inside a Git repository
|
|
55
60
|
{
|
|
56
61
|
let stdout;
|
|
57
62
|
try {
|
|
58
|
-
const res = await execA('git --
|
|
63
|
+
const res = await execA('git rev-parse --is-inside-work-tree', { cwd: userRootDir });
|
|
59
64
|
stdout = res.stdout;
|
|
60
65
|
}
|
|
61
66
|
catch {
|
|
62
67
|
return null;
|
|
63
68
|
}
|
|
64
|
-
(0, utils_js_1.assert)(stdout.
|
|
69
|
+
(0, utils_js_1.assert)(stdout.trim() === 'true');
|
|
65
70
|
}
|
|
66
71
|
const cmd = [
|
|
67
72
|
'git ls-files',
|
|
68
73
|
...utils_js_1.scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
69
|
-
...getIgnorePatterns(
|
|
74
|
+
...getIgnorePatterns(outDirRelativeFromUserRootDir).map((pattern) => `--exclude="${pattern}"`),
|
|
70
75
|
// --others lists untracked files only (but using .gitignore because --exclude-standard)
|
|
71
76
|
// --cached adds the tracked files to the output
|
|
72
77
|
'--others --cached --exclude-standard'
|
|
@@ -82,26 +87,24 @@ async function gitLsFiles(userRootDir, outDir) {
|
|
|
82
87
|
throw err;
|
|
83
88
|
}
|
|
84
89
|
let files = stdout.split('\n').filter(Boolean);
|
|
85
|
-
(0, utils_js_1.assert)(!outDir.startsWith('/'));
|
|
86
90
|
files = files.filter(
|
|
87
91
|
// We have to repeat the same exclusion logic here because the `git ls-files` option --exclude only applies to untracked files. (We use --exclude only to speed up the command.)
|
|
88
|
-
(file) => getIgnoreFilter(file,
|
|
92
|
+
(file) => getIgnoreFilter(file, outDirRelativeFromUserRootDir));
|
|
89
93
|
return files;
|
|
90
94
|
}
|
|
91
95
|
// Same as gitLsFiles() but using fast-glob
|
|
92
|
-
async function fastGlob(userRootDir,
|
|
96
|
+
async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
93
97
|
const files = await (0, fast_glob_1.default)(`**/+*.${utils_js_1.scriptFileExtensions}`, {
|
|
94
|
-
ignore: getIgnorePatterns(
|
|
98
|
+
ignore: getIgnorePatterns(outDirRelativeFromUserRootDir),
|
|
95
99
|
cwd: userRootDir,
|
|
96
100
|
dot: false
|
|
97
101
|
});
|
|
98
102
|
return files;
|
|
99
103
|
}
|
|
100
104
|
// Same as getIgnoreFilter() but as glob pattern
|
|
101
|
-
function getIgnorePatterns(
|
|
102
|
-
|
|
105
|
+
function getIgnorePatterns(outDirRelativeFromUserRootDir) {
|
|
106
|
+
const ignorePatterns = [
|
|
103
107
|
'**/node_modules/**',
|
|
104
|
-
`${outDir}/**`,
|
|
105
108
|
// Allow:
|
|
106
109
|
// ```
|
|
107
110
|
// +Page.js
|
|
@@ -109,8 +112,17 @@ function getIgnorePatterns(outDir) {
|
|
|
109
112
|
// ```
|
|
110
113
|
'**/*.telefunc.*'
|
|
111
114
|
];
|
|
115
|
+
if (outDirRelativeFromUserRootDir) {
|
|
116
|
+
(0, utils_js_1.assert)(!outDirRelativeFromUserRootDir.startsWith('/'));
|
|
117
|
+
ignorePatterns.push(`${outDirRelativeFromUserRootDir}/**`);
|
|
118
|
+
}
|
|
119
|
+
return ignorePatterns;
|
|
112
120
|
}
|
|
113
121
|
// Same as getIgnorePatterns() but for Array.filter()
|
|
114
|
-
function getIgnoreFilter(file,
|
|
115
|
-
|
|
122
|
+
function getIgnoreFilter(file, outDirRelativeFromUserRootDir) {
|
|
123
|
+
(0, utils_js_1.assert)(!file.startsWith('/'));
|
|
124
|
+
(0, utils_js_1.assert)(outDirRelativeFromUserRootDir === null || !outDirRelativeFromUserRootDir.startsWith('/'));
|
|
125
|
+
return (!file.includes('node_modules/') &&
|
|
126
|
+
!file.includes('.telefunc.') &&
|
|
127
|
+
(!outDirRelativeFromUserRootDir || !file.startsWith(`${outDirRelativeFromUserRootDir}/`)));
|
|
116
128
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROJECT_VERSION = exports.projectInfo = void 0;
|
|
4
4
|
const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
|
|
5
|
-
const PROJECT_VERSION = '0.4.148-commit-
|
|
5
|
+
const PROJECT_VERSION = '0.4.148-commit-70e7518';
|
|
6
6
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
7
7
|
const projectInfo = {
|
|
8
8
|
projectName: 'Vike',
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -8,19 +8,24 @@ const execA = promisify(exec);
|
|
|
8
8
|
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
9
9
|
assertPosixPath(userRootDir);
|
|
10
10
|
assertPosixPath(outDirAbsoluteFilesystem);
|
|
11
|
+
// Vike prepends userRootDir without resolving, e.g. outDirRelativeFromUserRootDir can be /home/rom/my-monorepo/my-app/../my-build/dist/ while userRootDir is /home/rom/my-monorepo/my-app/
|
|
11
12
|
assert(outDirAbsoluteFilesystem.startsWith(userRootDir));
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
let outDirRelativeFromUserRootDir = path.posix.relative(userRootDir, outDirAbsoluteFilesystem);
|
|
14
|
+
if (outDirRelativeFromUserRootDir.startsWith('../')) {
|
|
15
|
+
// config.outDir is outside of config.root => it's going to be ignored anyways
|
|
16
|
+
outDirRelativeFromUserRootDir = null;
|
|
17
|
+
}
|
|
18
|
+
assert(outDirRelativeFromUserRootDir === null || !outDirRelativeFromUserRootDir.startsWith('.'));
|
|
14
19
|
const timeBase = new Date().getTime();
|
|
15
20
|
let files = [];
|
|
16
|
-
const res = await gitLsFiles(userRootDir,
|
|
21
|
+
const res = await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir);
|
|
17
22
|
if (res &&
|
|
18
23
|
// Fallback to fast-glob for users that dynamically generate plus files (we assume generetad plus files to be skipped because they are usually included in .gitignore)
|
|
19
24
|
res.length > 0) {
|
|
20
25
|
files = res;
|
|
21
26
|
}
|
|
22
27
|
else {
|
|
23
|
-
files = await fastGlob(userRootDir,
|
|
28
|
+
files = await fastGlob(userRootDir, outDirRelativeFromUserRootDir);
|
|
24
29
|
}
|
|
25
30
|
{
|
|
26
31
|
const time = new Date().getTime() - timeBase;
|
|
@@ -44,23 +49,23 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
44
49
|
return plusFiles;
|
|
45
50
|
}
|
|
46
51
|
// Same as fastGlob() but using `$ git ls-files`
|
|
47
|
-
async function gitLsFiles(userRootDir,
|
|
48
|
-
// Test
|
|
52
|
+
async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
53
|
+
// Test whether Git is installed and whether userRootDir is inside a Git repository
|
|
49
54
|
{
|
|
50
55
|
let stdout;
|
|
51
56
|
try {
|
|
52
|
-
const res = await execA('git --
|
|
57
|
+
const res = await execA('git rev-parse --is-inside-work-tree', { cwd: userRootDir });
|
|
53
58
|
stdout = res.stdout;
|
|
54
59
|
}
|
|
55
60
|
catch {
|
|
56
61
|
return null;
|
|
57
62
|
}
|
|
58
|
-
assert(stdout.
|
|
63
|
+
assert(stdout.trim() === 'true');
|
|
59
64
|
}
|
|
60
65
|
const cmd = [
|
|
61
66
|
'git ls-files',
|
|
62
67
|
...scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
63
|
-
...getIgnorePatterns(
|
|
68
|
+
...getIgnorePatterns(outDirRelativeFromUserRootDir).map((pattern) => `--exclude="${pattern}"`),
|
|
64
69
|
// --others lists untracked files only (but using .gitignore because --exclude-standard)
|
|
65
70
|
// --cached adds the tracked files to the output
|
|
66
71
|
'--others --cached --exclude-standard'
|
|
@@ -76,26 +81,24 @@ async function gitLsFiles(userRootDir, outDir) {
|
|
|
76
81
|
throw err;
|
|
77
82
|
}
|
|
78
83
|
let files = stdout.split('\n').filter(Boolean);
|
|
79
|
-
assert(!outDir.startsWith('/'));
|
|
80
84
|
files = files.filter(
|
|
81
85
|
// We have to repeat the same exclusion logic here because the `git ls-files` option --exclude only applies to untracked files. (We use --exclude only to speed up the command.)
|
|
82
|
-
(file) => getIgnoreFilter(file,
|
|
86
|
+
(file) => getIgnoreFilter(file, outDirRelativeFromUserRootDir));
|
|
83
87
|
return files;
|
|
84
88
|
}
|
|
85
89
|
// Same as gitLsFiles() but using fast-glob
|
|
86
|
-
async function fastGlob(userRootDir,
|
|
90
|
+
async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
87
91
|
const files = await glob(`**/+*.${scriptFileExtensions}`, {
|
|
88
|
-
ignore: getIgnorePatterns(
|
|
92
|
+
ignore: getIgnorePatterns(outDirRelativeFromUserRootDir),
|
|
89
93
|
cwd: userRootDir,
|
|
90
94
|
dot: false
|
|
91
95
|
});
|
|
92
96
|
return files;
|
|
93
97
|
}
|
|
94
98
|
// Same as getIgnoreFilter() but as glob pattern
|
|
95
|
-
function getIgnorePatterns(
|
|
96
|
-
|
|
99
|
+
function getIgnorePatterns(outDirRelativeFromUserRootDir) {
|
|
100
|
+
const ignorePatterns = [
|
|
97
101
|
'**/node_modules/**',
|
|
98
|
-
`${outDir}/**`,
|
|
99
102
|
// Allow:
|
|
100
103
|
// ```
|
|
101
104
|
// +Page.js
|
|
@@ -103,8 +106,17 @@ function getIgnorePatterns(outDir) {
|
|
|
103
106
|
// ```
|
|
104
107
|
'**/*.telefunc.*'
|
|
105
108
|
];
|
|
109
|
+
if (outDirRelativeFromUserRootDir) {
|
|
110
|
+
assert(!outDirRelativeFromUserRootDir.startsWith('/'));
|
|
111
|
+
ignorePatterns.push(`${outDirRelativeFromUserRootDir}/**`);
|
|
112
|
+
}
|
|
113
|
+
return ignorePatterns;
|
|
106
114
|
}
|
|
107
115
|
// Same as getIgnorePatterns() but for Array.filter()
|
|
108
|
-
function getIgnoreFilter(file,
|
|
109
|
-
|
|
116
|
+
function getIgnoreFilter(file, outDirRelativeFromUserRootDir) {
|
|
117
|
+
assert(!file.startsWith('/'));
|
|
118
|
+
assert(outDirRelativeFromUserRootDir === null || !outDirRelativeFromUserRootDir.startsWith('/'));
|
|
119
|
+
return (!file.includes('node_modules/') &&
|
|
120
|
+
!file.includes('.telefunc.') &&
|
|
121
|
+
(!outDirRelativeFromUserRootDir || !file.startsWith(`${outDirRelativeFromUserRootDir}/`)));
|
|
110
122
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export type { ProjectTag };
|
|
3
3
|
export { PROJECT_VERSION };
|
|
4
|
-
declare const PROJECT_VERSION: "0.4.148-commit-
|
|
4
|
+
declare const PROJECT_VERSION: "0.4.148-commit-70e7518";
|
|
5
5
|
type PackageName = typeof projectInfo.npmPackageName;
|
|
6
6
|
type ProjectVersion = typeof projectInfo.projectVersion;
|
|
7
7
|
type ProjectTag = `[${PackageName}]` | `[${PackageName}@${ProjectVersion}]`;
|
|
8
8
|
declare const projectInfo: {
|
|
9
9
|
projectName: "Vike";
|
|
10
|
-
projectVersion: "0.4.148-commit-
|
|
10
|
+
projectVersion: "0.4.148-commit-70e7518";
|
|
11
11
|
npmPackageName: "vike";
|
|
12
12
|
githubRepository: "https://github.com/vikejs/vike";
|
|
13
13
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
3
|
import { onProjectInfo } from './assertSingleInstance.js';
|
|
4
|
-
const PROJECT_VERSION = '0.4.148-commit-
|
|
4
|
+
const PROJECT_VERSION = '0.4.148-commit-70e7518';
|
|
5
5
|
const projectInfo = {
|
|
6
6
|
projectName: 'Vike',
|
|
7
7
|
projectVersion: PROJECT_VERSION,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.148-commit-
|
|
3
|
+
"version": "0.4.148-commit-70e7518",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "tsc --watch",
|
|
6
6
|
"build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
"vike": "./node/cli/bin-entry.js"
|
|
163
163
|
},
|
|
164
164
|
"devDependencies": {
|
|
165
|
-
"@brillout/release-me": "^0.1.
|
|
165
|
+
"@brillout/release-me": "^0.1.10",
|
|
166
166
|
"@types/estree": "^1.0.0",
|
|
167
167
|
"@types/jest": "^27.4.1",
|
|
168
168
|
"@types/node": "^20.1.0",
|