@pnpm/symlink-dependency 1000.0.17 → 1000.0.18
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/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/safeJoinModulesDir.d.ts +1 -0
- package/lib/safeJoinModulesDir.js +25 -0
- package/lib/safeJoinModulesDir.js.map +1 -0
- package/lib/symlinkDirectRootDependency.js +2 -2
- package/lib/symlinkDirectRootDependency.js.map +1 -1
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -6,18 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.symlinkDirectRootDependency = void 0;
|
|
7
7
|
exports.symlinkDependency = symlinkDependency;
|
|
8
8
|
exports.symlinkDependencySync = symlinkDependencySync;
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
9
|
const core_loggers_1 = require("@pnpm/core-loggers");
|
|
11
10
|
const symlink_dir_1 = __importDefault(require("symlink-dir"));
|
|
11
|
+
const safeJoinModulesDir_js_1 = require("./safeJoinModulesDir.js");
|
|
12
12
|
var symlinkDirectRootDependency_js_1 = require("./symlinkDirectRootDependency.js");
|
|
13
13
|
Object.defineProperty(exports, "symlinkDirectRootDependency", { enumerable: true, get: function () { return symlinkDirectRootDependency_js_1.symlinkDirectRootDependency; } });
|
|
14
14
|
async function symlinkDependency(dependencyRealLocation, destModulesDir, importAs) {
|
|
15
|
-
const link =
|
|
15
|
+
const link = (0, safeJoinModulesDir_js_1.safeJoinModulesDir)(destModulesDir, importAs);
|
|
16
16
|
core_loggers_1.linkLogger.debug({ target: dependencyRealLocation, link });
|
|
17
17
|
return (0, symlink_dir_1.default)(dependencyRealLocation, link);
|
|
18
18
|
}
|
|
19
19
|
function symlinkDependencySync(dependencyRealLocation, destModulesDir, importAs) {
|
|
20
|
-
const link =
|
|
20
|
+
const link = (0, safeJoinModulesDir_js_1.safeJoinModulesDir)(destModulesDir, importAs);
|
|
21
21
|
core_loggers_1.linkLogger.debug({ target: dependencyRealLocation, link });
|
|
22
22
|
return symlink_dir_1.default.sync(dependencyRealLocation, link);
|
|
23
23
|
}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAOA,8CAQC;AAED,sDAQC;AAzBD,qDAA+C;AAC/C,8DAAoC;AAEpC,mEAA4D;AAE5D,mFAA8E;AAArE,6IAAA,2BAA2B,OAAA;AAE7B,KAAK,UAAU,iBAAiB,CACrC,sBAA8B,EAC9B,cAAsB,EACtB,QAAgB;IAEhB,MAAM,IAAI,GAAG,IAAA,0CAAkB,EAAC,cAAc,EAAE,QAAQ,CAAC,CAAA;IACzD,yBAAU,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,sBAAsB,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1D,OAAO,IAAA,qBAAU,EAAC,sBAAsB,EAAE,IAAI,CAAC,CAAA;AACjD,CAAC;AAED,SAAgB,qBAAqB,CACnC,sBAA8B,EAC9B,cAAsB,EACtB,QAAgB;IAEhB,MAAM,IAAI,GAAG,IAAA,0CAAkB,EAAC,cAAc,EAAE,QAAQ,CAAC,CAAA;IACzD,yBAAU,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,sBAAsB,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1D,OAAO,qBAAU,CAAC,IAAI,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAA;AACtD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function safeJoinModulesDir(modulesDir: string, alias: string): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.safeJoinModulesDir = safeJoinModulesDir;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
// `path.join(modulesDir, alias)` paired with a containment check, so a
|
|
9
|
+
// caller can't accidentally use the joined path without verifying that
|
|
10
|
+
// it lives inside `modulesDir`. Earlier passes reject path-traversal
|
|
11
|
+
// aliases at manifest-read time, but this layer also runs for paths
|
|
12
|
+
// reconstructed from lockfiles and snapshots, so the check stays here
|
|
13
|
+
// as a final guarantee.
|
|
14
|
+
function safeJoinModulesDir(modulesDir, alias) {
|
|
15
|
+
const link = path_1.default.join(modulesDir, alias);
|
|
16
|
+
const resolvedDir = path_1.default.resolve(modulesDir);
|
|
17
|
+
const resolvedLink = path_1.default.resolve(link);
|
|
18
|
+
if (resolvedLink === resolvedDir || !resolvedLink.startsWith(resolvedDir + path_1.default.sep)) {
|
|
19
|
+
const error = new Error(`Refusing to symlink dependency outside ${modulesDir}: alias ${JSON.stringify(alias)} resolves to ${resolvedLink}`);
|
|
20
|
+
error.code = 'ERR_PNPM_INVALID_DEPENDENCY_NAME';
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
return link;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=safeJoinModulesDir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safeJoinModulesDir.js","sourceRoot":"","sources":["../src/safeJoinModulesDir.ts"],"names":[],"mappings":";;;;;AAQA,gDAUC;AAlBD,gDAAuB;AAEvB,uEAAuE;AACvE,uEAAuE;AACvE,qEAAqE;AACrE,oEAAoE;AACpE,sEAAsE;AACtE,wBAAwB;AACxB,SAAgB,kBAAkB,CAAE,UAAkB,EAAE,KAAa;IACnE,MAAM,IAAI,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;IACzC,MAAM,WAAW,GAAG,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAC5C,MAAM,YAAY,GAAG,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACvC,IAAI,YAAY,KAAK,WAAW,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,WAAW,GAAG,cAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACrF,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,0CAA0C,UAAU,WAAW,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,gBAAgB,YAAY,EAAE,CAA6B,CAAA;QACvK,KAAK,CAAC,IAAI,GAAG,kCAAkC,CAAA;QAC/C,MAAM,KAAK,CAAA;IACb,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -5,10 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.symlinkDirectRootDependency = symlinkDirectRootDependency;
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
8
|
const util_1 = __importDefault(require("util"));
|
|
10
9
|
const core_loggers_1 = require("@pnpm/core-loggers");
|
|
11
10
|
const symlink_dir_1 = __importDefault(require("symlink-dir"));
|
|
11
|
+
const safeJoinModulesDir_js_1 = require("./safeJoinModulesDir.js");
|
|
12
12
|
const DEP_TYPE_BY_DEPS_FIELD_NAME = {
|
|
13
13
|
dependencies: 'prod',
|
|
14
14
|
devDependencies: 'dev',
|
|
@@ -33,7 +33,7 @@ async function symlinkDirectRootDependency(dependencyLocation, destModulesDir, i
|
|
|
33
33
|
throw err;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
const dest =
|
|
36
|
+
const dest = (0, safeJoinModulesDir_js_1.safeJoinModulesDir)(destModulesDirReal, importAs);
|
|
37
37
|
const { reused } = await (0, symlink_dir_1.default)(dependencyLocation, dest);
|
|
38
38
|
if (reused)
|
|
39
39
|
return; // if the link was already present, don't log
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symlinkDirectRootDependency.js","sourceRoot":"","sources":["../src/symlinkDirectRootDependency.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"symlinkDirectRootDependency.js","sourceRoot":"","sources":["../src/symlinkDirectRootDependency.ts"],"names":[],"mappings":";;;;;AAiBA,kEA2CC;AA5DD,2BAAmC;AACnC,gDAAuB;AACvB,qDAG2B;AAE3B,8DAAoC;AAEpC,mEAA4D;AAE5D,MAAM,2BAA2B,GAAG;IAClC,YAAY,EAAE,MAAM;IACpB,eAAe,EAAE,KAAK;IACtB,oBAAoB,EAAE,UAAU;CACjC,CAAA;AAEM,KAAK,UAAU,2BAA2B,CAC/C,kBAA0B,EAC1B,cAAsB,EACtB,QAAgB,EAChB,IAOC;IAED,iEAAiE;IACjE,gCAAgC;IAChC,gEAAgE;IAChE,0DAA0D;IAC1D,mEAAmE;IACnE,IAAI,kBAAkB,CAAA;IACtB,IAAI,CAAC;QACH,kBAAkB,GAAG,MAAM,aAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAA;IACxD,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,IAAI,cAAI,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC5E,MAAM,aAAE,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;YACnD,kBAAkB,GAAG,MAAM,aAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAG,IAAA,0CAAkB,EAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAA;IAC7D,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,qBAAU,EAAC,kBAAkB,EAAE,IAAI,CAAC,CAAA;IAC7D,IAAI,MAAM;QAAE,OAAM,CAAC,6CAA6C;IAChE,yBAAU,CAAC,KAAK,CAAC;QACf,KAAK,EAAE;YACL,cAAc,EAAE,IAAI,CAAC,qBAAqB,IAAI,2BAA2B,CAAC,IAAI,CAAC,qBAAqB,CAAmB;YACvH,UAAU,EAAE,kBAAkB;YAC9B,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI;YACjC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,OAAO;SACpC;QACD,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/symlink-dependency",
|
|
3
|
-
"version": "1000.0.
|
|
3
|
+
"version": "1000.0.18",
|
|
4
4
|
"description": "Symlink a dependency to node_modules",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"symlink-dir": "^6.0.5",
|
|
31
|
-
"@pnpm/
|
|
32
|
-
"@pnpm/
|
|
31
|
+
"@pnpm/types": "1001.3.0",
|
|
32
|
+
"@pnpm/core-loggers": "1001.0.9"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@pnpm/logger": "
|
|
35
|
+
"@pnpm/logger": "^1001.0.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@pnpm/
|
|
39
|
-
"@pnpm/
|
|
40
|
-
"@pnpm/
|
|
38
|
+
"@pnpm/symlink-dependency": "1000.0.18",
|
|
39
|
+
"@pnpm/prepare": "1000.0.17",
|
|
40
|
+
"@pnpm/logger": "1001.0.1"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=18.12"
|