pnpm-link 1.0.1 → 1.0.3
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/index.js +63 -4
- package/package.json +6 -3
package/dist/index.js
CHANGED
|
@@ -6,6 +6,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
};
|
|
9
12
|
var __copyProps = (to, from, except, desc) => {
|
|
10
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
14
|
for (let key of __getOwnPropNames(from))
|
|
@@ -23,6 +26,52 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
26
|
mod
|
|
24
27
|
));
|
|
25
28
|
|
|
29
|
+
// package.json
|
|
30
|
+
var require_package = __commonJS({
|
|
31
|
+
"package.json"(exports2, module2) {
|
|
32
|
+
module2.exports = {
|
|
33
|
+
name: "pnpm-link",
|
|
34
|
+
version: "1.0.2",
|
|
35
|
+
description: "\u628A\u5168\u5C40\u5DF2 link \u7684\u5305\u6216\u672C\u5730\u5305\u5199\u5165\u5F53\u524D\u9879\u76EE\u4F9D\u8D56\uFF0C\u9002\u7528\u4E8E pnpm \u5DE5\u4F5C\u6D41",
|
|
36
|
+
keywords: [
|
|
37
|
+
"pnpm",
|
|
38
|
+
"link",
|
|
39
|
+
"dependencies",
|
|
40
|
+
"devDependencies",
|
|
41
|
+
"package.json",
|
|
42
|
+
"workspace",
|
|
43
|
+
"cli"
|
|
44
|
+
],
|
|
45
|
+
license: "ISC",
|
|
46
|
+
author: "zyrong",
|
|
47
|
+
type: "commonjs",
|
|
48
|
+
bin: {
|
|
49
|
+
"pnpm-link": "./dist/index.js"
|
|
50
|
+
},
|
|
51
|
+
files: [
|
|
52
|
+
"dist"
|
|
53
|
+
],
|
|
54
|
+
scripts: {
|
|
55
|
+
build: "tsup",
|
|
56
|
+
typecheck: "tsc",
|
|
57
|
+
test: "pnpm build && vitest run",
|
|
58
|
+
"test:watch": "vitest",
|
|
59
|
+
release: 'pnpm build && pnpm version patch -m "chore(release): %s" && git push --follow-tags && pnpm publish',
|
|
60
|
+
"release:minor": 'pnpm build && pnpm version minor -m "chore(release): %s" && git push --follow-tags && pnpm publish',
|
|
61
|
+
"release:major": 'pnpm build && pnpm version major -m "chore(release): %s" && git push --follow-tags && pnpm publish'
|
|
62
|
+
},
|
|
63
|
+
packageManager: "pnpm@10.28.0",
|
|
64
|
+
devDependencies: {
|
|
65
|
+
"@types/node": "^22.19.15",
|
|
66
|
+
cac: "^7.0.0",
|
|
67
|
+
tsup: "^8.5.1",
|
|
68
|
+
typescript: "^7.0.2",
|
|
69
|
+
vitest: "^4.0.18"
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
26
75
|
// src/cli.ts
|
|
27
76
|
var import_node_path2 = __toESM(require("path"));
|
|
28
77
|
|
|
@@ -646,8 +695,16 @@ var cac = (name = "") => new CAC(name);
|
|
|
646
695
|
var import_node_child_process = require("child_process");
|
|
647
696
|
var import_node_fs = __toESM(require("fs"));
|
|
648
697
|
var import_node_path = __toESM(require("path"));
|
|
698
|
+
var SCOPED_PACKAGE_RE = /^@[^/\\]+\/[^/\\]+$/;
|
|
649
699
|
function isLocalPackageReference(value) {
|
|
650
|
-
return value.startsWith("./") || value.startsWith("../") || value.startsWith("/") || value.startsWith("file:") || value.includes("
|
|
700
|
+
return value.startsWith("./") || value.startsWith("../") || value.startsWith("/") || value.startsWith("file:") || value.includes("\\") || value.includes("/") && !SCOPED_PACKAGE_RE.test(value);
|
|
701
|
+
}
|
|
702
|
+
function assertValidPackageInput(value) {
|
|
703
|
+
if (value.startsWith("@") && !SCOPED_PACKAGE_RE.test(value)) {
|
|
704
|
+
throw new Error(
|
|
705
|
+
`"${value}" is not a valid scoped package name. Expected "@scope/name".`
|
|
706
|
+
);
|
|
707
|
+
}
|
|
651
708
|
}
|
|
652
709
|
function readPackageNameFromDir(dirPath) {
|
|
653
710
|
const pkgJsonPath = import_node_path.default.join(dirPath, "package.json");
|
|
@@ -662,6 +719,7 @@ function readPackageNameFromDir(dirPath) {
|
|
|
662
719
|
}
|
|
663
720
|
}
|
|
664
721
|
function resolvePackageLocation(packageName) {
|
|
722
|
+
assertValidPackageInput(packageName);
|
|
665
723
|
if (isLocalPackageReference(packageName)) {
|
|
666
724
|
const absolutePath = import_node_path.default.resolve(packageName);
|
|
667
725
|
if (!import_node_fs.default.existsSync(absolutePath)) {
|
|
@@ -692,7 +750,7 @@ function linkPackageToProject(options) {
|
|
|
692
750
|
packageName,
|
|
693
751
|
targetPkgPath = "./package.json",
|
|
694
752
|
depType = "dependencies",
|
|
695
|
-
protocol = "
|
|
753
|
+
protocol = "link"
|
|
696
754
|
} = options;
|
|
697
755
|
const targetAbs = import_node_path.default.resolve(targetPkgPath);
|
|
698
756
|
if (!import_node_fs.default.existsSync(targetAbs)) {
|
|
@@ -722,6 +780,7 @@ function linkPackageToProject(options) {
|
|
|
722
780
|
}
|
|
723
781
|
|
|
724
782
|
// src/cli.ts
|
|
783
|
+
var { version: cliVersion } = require_package();
|
|
725
784
|
function resolveDepType(options) {
|
|
726
785
|
if (options.saveDev) return "devDependencies";
|
|
727
786
|
if (options.saveProd) return "dependencies";
|
|
@@ -747,12 +806,12 @@ function runLinkCommand(packageName, options) {
|
|
|
747
806
|
}
|
|
748
807
|
var cli = cac("pnpm-link");
|
|
749
808
|
cli.command("<package-name>", "\u5C06\u5168\u5C40\u5DF2 link \u7684\u5305\u6216\u672C\u5730\u76F8\u5BF9\u8DEF\u5F84\u5305\u5199\u5165\u5F53\u524D\u9879\u76EE\u4F9D\u8D56").option("-D, --save-dev", "\u5199\u5165 devDependencies").option("-P, --save-prod", "\u5199\u5165 dependencies").option("-p, --protocol <protocol>", "\u534F\u8BAE\u7C7B\u578B (file|link)", {
|
|
750
|
-
default: "
|
|
809
|
+
default: "link"
|
|
751
810
|
}).example("pnpm-link my-package --save-dev").example("pnpm-link ./packages/my-lib --protocol file").action((packageName, options) => {
|
|
752
811
|
runLinkCommand(packageName, options);
|
|
753
812
|
});
|
|
754
813
|
if (require.main === module) {
|
|
755
814
|
cli.help();
|
|
756
|
-
cli.version(
|
|
815
|
+
cli.version(cliVersion);
|
|
757
816
|
cli.parse();
|
|
758
817
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pnpm-link",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "把全局已 link 的包或本地包写入当前项目依赖,适用于 pnpm 工作流",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -24,7 +24,10 @@
|
|
|
24
24
|
"build": "tsup",
|
|
25
25
|
"typecheck": "tsc",
|
|
26
26
|
"test": "pnpm build && vitest run",
|
|
27
|
-
"test:watch": "vitest"
|
|
27
|
+
"test:watch": "vitest",
|
|
28
|
+
"release": "pnpm build && pnpm version patch -m \"chore(release): %s\" && git push --follow-tags",
|
|
29
|
+
"release:minor": "pnpm build && pnpm version minor -m \"chore(release): %s\" && git push --follow-tags",
|
|
30
|
+
"release:major": "pnpm build && pnpm version major -m \"chore(release): %s\" && git push --follow-tags"
|
|
28
31
|
},
|
|
29
32
|
"packageManager": "pnpm@10.28.0",
|
|
30
33
|
"devDependencies": {
|
|
@@ -34,4 +37,4 @@
|
|
|
34
37
|
"typescript": "^7.0.2",
|
|
35
38
|
"vitest": "^4.0.18"
|
|
36
39
|
}
|
|
37
|
-
}
|
|
40
|
+
}
|