vike 0.4.142-commit-6eb0dd3 → 0.4.142-commit-8bf568b
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/envVars.js +3 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +1 -1
- package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +1 -1
- package/dist/cjs/utils/getFilePathAbsolute.js +16 -12
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/node/plugin/plugins/envVars.js +4 -6
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -2
- package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +2 -2
- package/dist/esm/utils/getFilePathAbsolute.d.ts +2 -2
- package/dist/esm/utils/getFilePathAbsolute.js +15 -11
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +1 -1
|
@@ -43,11 +43,9 @@ function envVarsPlugin() {
|
|
|
43
43
|
if (isPrivate && isClientSide) {
|
|
44
44
|
if (!code.includes(varName))
|
|
45
45
|
return;
|
|
46
|
-
const
|
|
47
|
-
const errMsgAddendum = isBuild
|
|
48
|
-
|
|
49
|
-
: ' (vike will prevent your app from building for production)';
|
|
50
|
-
const errMsg = `${varName} used in ${filePathVite} and therefore included in client-side bundle which can be be a security leak${errMsgAddendum}, remove ${varName} or rename ${key} to ${keyPublic}, see https://vike.dev/env`;
|
|
46
|
+
const filePathToShowToUser = (0, utils_js_1.getFilePathRelativeToUserRootDir)(id, config.root);
|
|
47
|
+
const errMsgAddendum = isBuild ? '' : ' (vike will prevent your app from building for production)';
|
|
48
|
+
const errMsg = `${varName} used in ${filePathToShowToUser} and therefore included in client-side bundle which can be be a security leak${errMsgAddendum}, remove ${varName} or rename ${key} to ${keyPublic}, see https://vike.dev/env`;
|
|
51
49
|
if (isBuild) {
|
|
52
50
|
(0, utils_js_1.assertUsage)(false, errMsg);
|
|
53
51
|
}
|
|
@@ -122,7 +122,7 @@ function isVikeConfigModule(filePathAbsolute) {
|
|
|
122
122
|
}
|
|
123
123
|
function reloadConfig(filePath, config, configVike, op) {
|
|
124
124
|
{
|
|
125
|
-
const filePathToShowToUser = picocolors_1.default.dim((0, utils_js_1.
|
|
125
|
+
const filePathToShowToUser = picocolors_1.default.dim((0, utils_js_1.getFilePathRelativeToUserRootDir)(filePath, config.root, true));
|
|
126
126
|
const msg = `${op} ${filePathToShowToUser}`;
|
|
127
127
|
(0, loggerNotProd_js_1.logConfigInfo)(msg, 'info');
|
|
128
128
|
}
|
|
@@ -48,7 +48,7 @@ function getPrettyErrorWithCodeSnippet(err, userRootDir) {
|
|
|
48
48
|
let { id, frame } = err;
|
|
49
49
|
const msgFirstLine = [
|
|
50
50
|
picocolors_1.default.red('Failed to transpile'),
|
|
51
|
-
picocolors_1.default.bold(picocolors_1.default.red((0, utils_js_1.
|
|
51
|
+
picocolors_1.default.bold(picocolors_1.default.red((0, utils_js_1.getFilePathRelativeToUserRootDir)(normalizeId(id), userRootDir))),
|
|
52
52
|
picocolors_1.default.red('because:')
|
|
53
53
|
].join(' ');
|
|
54
54
|
const errMsg = getPrettyErrMessage(err);
|
|
@@ -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.
|
|
6
|
+
exports.getFilePathRelativeToUserRootDir = exports.getFilePathAbsolute = void 0;
|
|
7
7
|
const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
|
|
8
8
|
const assert_js_1 = require("./assert.js");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -47,20 +47,24 @@ function getFilePathAbsolute(filePath, config) {
|
|
|
47
47
|
return filePathAbsolute;
|
|
48
48
|
}
|
|
49
49
|
exports.getFilePathAbsolute = getFilePathAbsolute;
|
|
50
|
-
function
|
|
51
|
-
(0, filesystemPathHandling_js_1.assertPosixPath)(
|
|
50
|
+
function getFilePathRelativeToUserRootDir(filePathAbsolute, userRootDir, alwaysRelative = false) {
|
|
51
|
+
(0, filesystemPathHandling_js_1.assertPosixPath)(filePathAbsolute);
|
|
52
52
|
(0, filesystemPathHandling_js_1.assertPosixPath)(userRootDir);
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
let filePathRelativeToUserRootDir = path_1.default.posix.relative(userRootDir, filePathAbsolute);
|
|
54
|
+
if (filePathAbsolute.startsWith(userRootDir)) {
|
|
55
|
+
(0, assert_js_1.assert)(!filePathRelativeToUserRootDir.startsWith('.') && !filePathRelativeToUserRootDir.startsWith('/'),
|
|
56
|
+
// Surprinsingly, this assertion seem to fail sometimes: https://github.com/vikejs/vike/issues/1139
|
|
57
|
+
{ filePathRelativeToUserRootDir, filePathAbsolute, userRootDir });
|
|
58
|
+
filePathRelativeToUserRootDir = `/${filePathRelativeToUserRootDir}`;
|
|
59
|
+
return filePathRelativeToUserRootDir;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
if (alwaysRelative) {
|
|
63
|
+
return filePathRelativeToUserRootDir;
|
|
57
64
|
}
|
|
58
65
|
else {
|
|
59
|
-
return
|
|
66
|
+
return filePathAbsolute;
|
|
60
67
|
}
|
|
61
68
|
}
|
|
62
|
-
(0, assert_js_1.assert)(!filePathRelativeToRoot.startsWith('.') && !filePathRelativeToRoot.startsWith('/'));
|
|
63
|
-
const filePathVite = `/${filePathRelativeToRoot}`;
|
|
64
|
-
return filePathVite;
|
|
65
69
|
}
|
|
66
|
-
exports.
|
|
70
|
+
exports.getFilePathRelativeToUserRootDir = getFilePathRelativeToUserRootDir;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.projectInfo = void 0;
|
|
4
4
|
const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
|
|
5
|
-
const PROJECT_VERSION = '0.4.142-commit-
|
|
5
|
+
const PROJECT_VERSION = '0.4.142-commit-8bf568b';
|
|
6
6
|
const projectInfo = {
|
|
7
7
|
projectName: 'Vike',
|
|
8
8
|
projectVersion: PROJECT_VERSION,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { envVarsPlugin };
|
|
2
2
|
import { loadEnv } from 'vite';
|
|
3
|
-
import { assert, assertPosixPath, assertUsage, assertWarning,
|
|
3
|
+
import { assert, assertPosixPath, assertUsage, assertWarning, getFilePathRelativeToUserRootDir, lowerFirst } from '../utils.js';
|
|
4
4
|
function envVarsPlugin() {
|
|
5
5
|
let envsAll;
|
|
6
6
|
let config;
|
|
@@ -41,11 +41,9 @@ function envVarsPlugin() {
|
|
|
41
41
|
if (isPrivate && isClientSide) {
|
|
42
42
|
if (!code.includes(varName))
|
|
43
43
|
return;
|
|
44
|
-
const
|
|
45
|
-
const errMsgAddendum = isBuild
|
|
46
|
-
|
|
47
|
-
: ' (vike will prevent your app from building for production)';
|
|
48
|
-
const errMsg = `${varName} used in ${filePathVite} and therefore included in client-side bundle which can be be a security leak${errMsgAddendum}, remove ${varName} or rename ${key} to ${keyPublic}, see https://vike.dev/env`;
|
|
44
|
+
const filePathToShowToUser = getFilePathRelativeToUserRootDir(id, config.root);
|
|
45
|
+
const errMsgAddendum = isBuild ? '' : ' (vike will prevent your app from building for production)';
|
|
46
|
+
const errMsg = `${varName} used in ${filePathToShowToUser} and therefore included in client-side bundle which can be be a security leak${errMsgAddendum}, remove ${varName} or rename ${key} to ${keyPublic}, see https://vike.dev/env`;
|
|
49
47
|
if (isBuild) {
|
|
50
48
|
assertUsage(false, errMsg);
|
|
51
49
|
}
|
|
@@ -3,7 +3,7 @@ import { normalizePath } from 'vite';
|
|
|
3
3
|
import { getConfigVike } from '../../../shared/getConfigVike.js';
|
|
4
4
|
import { getVirtualFilePageConfigValuesAll } from './v1-design/getVirtualFilePageConfigValuesAll.js';
|
|
5
5
|
import { getVirtualFileImportUserCode } from './getVirtualFileImportUserCode.js';
|
|
6
|
-
import { assert, assertPosixPath,
|
|
6
|
+
import { assert, assertPosixPath, getFilePathRelativeToUserRootDir, getVirtualFileId, isDev1, isDev1_onConfigureServer, isVirtualFileId, resolveVirtualFileId } from '../../utils.js';
|
|
7
7
|
import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
8
8
|
import { isVirtualFileIdImportUserCode } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
9
9
|
import { vikeConfigDependencies, reloadVikeConfig, isVikeConfigFile } from './v1-design/getVikeConfig.js';
|
|
@@ -116,7 +116,7 @@ function isVikeConfigModule(filePathAbsolute) {
|
|
|
116
116
|
}
|
|
117
117
|
function reloadConfig(filePath, config, configVike, op) {
|
|
118
118
|
{
|
|
119
|
-
const filePathToShowToUser = pc.dim(
|
|
119
|
+
const filePathToShowToUser = pc.dim(getFilePathRelativeToUserRootDir(filePath, config.root, true));
|
|
120
120
|
const msg = `${op} ${filePathToShowToUser}`;
|
|
121
121
|
logConfigInfo(msg, 'info');
|
|
122
122
|
}
|
|
@@ -7,7 +7,7 @@ export { isEquivalentErrorWithCodeSnippet };
|
|
|
7
7
|
export { getPrettyErrMessage };
|
|
8
8
|
// Copied & adapted from https://github.com/vitejs/vite/blob/9c114c5c72a6af87e3330d5573362554b4511265/packages/vite/src/node/server/middlewares/error.ts
|
|
9
9
|
import pc from '@brillout/picocolors';
|
|
10
|
-
import { assert, escapeRegex,
|
|
10
|
+
import { assert, escapeRegex, getFilePathRelativeToUserRootDir, isObject, removeEmptyLines, stripAnsi, toPosixPath } from '../../utils.js';
|
|
11
11
|
function isErrorWithCodeSnippet(err) {
|
|
12
12
|
if (!isObject(err)) {
|
|
13
13
|
return false;
|
|
@@ -46,7 +46,7 @@ function getPrettyErrorWithCodeSnippet(err, userRootDir) {
|
|
|
46
46
|
let { id, frame } = err;
|
|
47
47
|
const msgFirstLine = [
|
|
48
48
|
pc.red('Failed to transpile'),
|
|
49
|
-
pc.bold(pc.red(
|
|
49
|
+
pc.bold(pc.red(getFilePathRelativeToUserRootDir(normalizeId(id), userRootDir))),
|
|
50
50
|
pc.red('because:')
|
|
51
51
|
].join(' ');
|
|
52
52
|
const errMsg = getPrettyErrMessage(err);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getFilePathAbsolute };
|
|
2
|
-
export {
|
|
2
|
+
export { getFilePathRelativeToUserRootDir };
|
|
3
3
|
import type { ResolvedConfig } from 'vite';
|
|
4
4
|
declare function getFilePathAbsolute(filePath: string, config: ResolvedConfig): string;
|
|
5
|
-
declare function
|
|
5
|
+
declare function getFilePathRelativeToUserRootDir(filePathAbsolute: string, userRootDir: string, alwaysRelative?: boolean): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getFilePathAbsolute };
|
|
2
|
-
export {
|
|
2
|
+
export { getFilePathRelativeToUserRootDir };
|
|
3
3
|
import { assertPosixPath, toPosixPath } from './filesystemPathHandling.js';
|
|
4
4
|
import { assert } from './assert.js';
|
|
5
5
|
import path from 'path';
|
|
@@ -42,19 +42,23 @@ function getFilePathAbsolute(filePath, config) {
|
|
|
42
42
|
assertPathIsFilesystemAbsolute(filePathAbsolute);
|
|
43
43
|
return filePathAbsolute;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
assertPosixPath(
|
|
45
|
+
function getFilePathRelativeToUserRootDir(filePathAbsolute, userRootDir, alwaysRelative = false) {
|
|
46
|
+
assertPosixPath(filePathAbsolute);
|
|
47
47
|
assertPosixPath(userRootDir);
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
let filePathRelativeToUserRootDir = path.posix.relative(userRootDir, filePathAbsolute);
|
|
49
|
+
if (filePathAbsolute.startsWith(userRootDir)) {
|
|
50
|
+
assert(!filePathRelativeToUserRootDir.startsWith('.') && !filePathRelativeToUserRootDir.startsWith('/'),
|
|
51
|
+
// Surprinsingly, this assertion seem to fail sometimes: https://github.com/vikejs/vike/issues/1139
|
|
52
|
+
{ filePathRelativeToUserRootDir, filePathAbsolute, userRootDir });
|
|
53
|
+
filePathRelativeToUserRootDir = `/${filePathRelativeToUserRootDir}`;
|
|
54
|
+
return filePathRelativeToUserRootDir;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
if (alwaysRelative) {
|
|
58
|
+
return filePathRelativeToUserRootDir;
|
|
52
59
|
}
|
|
53
60
|
else {
|
|
54
|
-
return
|
|
61
|
+
return filePathAbsolute;
|
|
55
62
|
}
|
|
56
63
|
}
|
|
57
|
-
assert(!filePathRelativeToRoot.startsWith('.') && !filePathRelativeToRoot.startsWith('/'));
|
|
58
|
-
const filePathVite = `/${filePathRelativeToRoot}`;
|
|
59
|
-
return filePathVite;
|
|
60
64
|
}
|
|
@@ -5,7 +5,7 @@ type ProjectVersion = typeof projectInfo.projectVersion;
|
|
|
5
5
|
type ProjectTag = `[${PackageName}]` | `[${PackageName}@${ProjectVersion}]`;
|
|
6
6
|
declare const projectInfo: {
|
|
7
7
|
projectName: "Vike";
|
|
8
|
-
projectVersion: "0.4.142-commit-
|
|
8
|
+
projectVersion: "0.4.142-commit-8bf568b";
|
|
9
9
|
npmPackageName: "vike";
|
|
10
10
|
githubRepository: "https://github.com/vikejs/vike";
|
|
11
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
import { onProjectInfo } from './assertSingleInstance.js';
|
|
3
|
-
const PROJECT_VERSION = '0.4.142-commit-
|
|
3
|
+
const PROJECT_VERSION = '0.4.142-commit-8bf568b';
|
|
4
4
|
const projectInfo = {
|
|
5
5
|
projectName: 'Vike',
|
|
6
6
|
projectVersion: PROJECT_VERSION,
|