binary-collections 2.0.11 → 2.0.12
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/.opencode/package.json +5 -0
- package/binaries/rmx +15 -1
- package/binaries/rmx.cmd +12 -0
- package/binaries/test-cjs +9 -1
- package/binaries/test-cjs.cmd +16 -1
- package/binaries/test-esm +16 -0
- package/binaries/test-esm.cjs +178 -0
- package/binaries/test-esm.cmd +23 -0
- package/binaries/yarn-clean +1 -1
- package/binaries/yarn-clean.cmd +1 -1
- package/binaries/yarn-clean.py +33 -15
- package/binaries/yc +110 -0
- package/binaries/yc.cjs +178 -0
- package/lib/binary-collections/config.cjs +126 -0
- package/lib/binary-collections/config.mjs +7 -0
- package/lib/binary-collections/executeScript.cjs +19 -0
- package/lib/binary-collections/executeScript.d.cts +12 -0
- package/lib/binary-collections/executeScript.mjs +6 -0
- package/lib/binary-collections/findScript.cjs +284 -0
- package/lib/binary-collections/findScript.d.cts +12 -0
- package/lib/binary-collections/findScript.mjs +7 -0
- package/lib/binary-collections/listScript.cjs +266 -0
- package/lib/binary-collections/listScript.d.cts +19 -0
- package/lib/binary-collections/listScript.mjs +7 -0
- package/lib/binary-collections.cjs +224 -137
- package/lib/binary-collections.mjs +22 -282
- package/lib/changelog.cjs +2 -2
- package/lib/changelog.mjs +1 -1
- package/lib/{chunk-AJDD5DZM.mjs → chunk-2LSRSEXF.mjs} +1 -1
- package/lib/{chunk-Z6JLYU2J.mjs → chunk-5RTXZVCW.mjs} +2 -2
- package/lib/{chunk-XA3SNBPA.mjs → chunk-66KDU4TX.mjs} +93 -9
- package/lib/chunk-6PU7BAHB.mjs +61 -0
- package/lib/chunk-C6D2TTYU.mjs +32 -0
- package/lib/chunk-FB2WKVJD.mjs +158 -0
- package/lib/{chunk-NCXAP7AA.mjs → chunk-G5UUEWUO.mjs} +9 -5
- package/lib/{chunk-N436BNBK.mjs → chunk-GAGABICI.mjs} +19 -13
- package/lib/chunk-H44UWUFY.mjs +105 -0
- package/lib/chunk-NCZPTKDV.mjs +79 -0
- package/lib/chunk-NGFK3EYW.mjs +28 -0
- package/lib/chunk-NVEG3LEZ.mjs +143 -0
- package/lib/chunk-OGXVGBRI.mjs +29 -0
- package/lib/chunk-OXV52GD5.mjs +62 -0
- package/lib/chunk-PXBMHE7O.mjs +35 -0
- package/lib/chunk-R5FJOR63.mjs +47 -0
- package/lib/chunk-SPTECFE5.mjs +180 -0
- package/lib/chunk-UXCFNAR6.mjs +55 -0
- package/lib/chunk-V2IBPCEV.mjs +39 -0
- package/lib/chunk-XPJGCDOD.mjs +14 -0
- package/lib/chunk-ZOWVMII3.mjs +228 -0
- package/lib/clean-github-actions-caches-cli.cjs +465 -0
- package/lib/clean-github-actions-caches-cli.d.cts +1 -0
- package/lib/clean-github-actions-caches-cli.mjs +56 -0
- package/lib/clean-github-actions-caches.cjs +149 -205
- package/lib/clean-github-actions-caches.d.cts +15 -1
- package/lib/clean-github-actions-caches.mjs +4 -130
- package/lib/cross-env/command.cjs +63 -0
- package/lib/cross-env/command.d.ts +8 -0
- package/lib/cross-env/command.js +45 -0
- package/lib/cross-env/command.mjs +9 -0
- package/lib/cross-env/index.cjs +178 -0
- package/lib/cross-env/index.d.ts +8 -0
- package/lib/cross-env/index.js +102 -0
- package/lib/cross-env/index.mjs +101 -0
- package/lib/cross-env/variable.cjs +60 -0
- package/lib/cross-env/variable.d.ts +7 -0
- package/lib/cross-env/variable.js +59 -0
- package/lib/cross-env/variable.mjs +9 -0
- package/lib/del-gradle.cjs +2 -2
- package/lib/del-gradle.js +8 -8
- package/lib/del-gradle.mjs +1 -1
- package/lib/del-node-modules.js +24 -24
- package/lib/del-ps.cjs +2 -2
- package/lib/del-ps.js +8 -8
- package/lib/del-ps.mjs +1 -1
- package/lib/del-yarn-caches.cjs +2 -2
- package/lib/del-yarn-caches.js +2 -2
- package/lib/del-yarn-caches.mjs +1 -1
- package/lib/file/copy-cli.cjs +92 -0
- package/lib/file/copy-cli.d.mts +1 -0
- package/lib/file/copy-cli.mjs +55 -0
- package/lib/file/copy.cjs +56 -0
- package/lib/file/copy.d.mts +1 -0
- package/lib/file/copy.mjs +8 -0
- package/lib/file/move-cli.cjs +91 -0
- package/lib/file/move-cli.d.mts +1 -0
- package/lib/file/move-cli.mjs +55 -0
- package/lib/file/move.cjs +55 -0
- package/lib/file/move.d.mts +1 -0
- package/lib/file/move.mjs +8 -0
- package/lib/find-node-modules-cli.js +1 -1
- package/lib/free-chatgpt.cjs +21 -15
- package/lib/free-chatgpt.js +10 -10
- package/lib/free-chatgpt.mjs +2 -2
- package/lib/git/user-config.cjs +2 -2
- package/lib/git/user-config.mjs +2 -2
- package/lib/git-diff-cli.cjs +188 -42
- package/lib/git-diff-cli.mjs +5 -4
- package/lib/git-diff.cjs +188 -42
- package/lib/git-diff.d.ts +2 -1
- package/lib/git-diff.js +91 -34
- package/lib/git-diff.mjs +5 -4
- package/lib/git-fix.cjs +2 -2
- package/lib/git-fix.mjs +2 -2
- package/lib/git-purge.cjs +2 -2
- package/lib/git-purge.mjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/kill-night-crows.cjs +7 -7
- package/lib/kill-night-crows.mjs +7 -7
- package/lib/node-cache-cleaner/npm.cjs +65 -0
- package/lib/node-cache-cleaner/npm.d.ts +2 -0
- package/lib/node-cache-cleaner/npm.js +41 -0
- package/lib/node-cache-cleaner/npm.mjs +10 -0
- package/lib/node-cache-cleaner/npx.cjs +89 -0
- package/lib/node-cache-cleaner/npx.d.ts +4 -0
- package/lib/node-cache-cleaner/npx.js +82 -0
- package/lib/{ps/index.d.mjs → node-cache-cleaner/npx.mjs} +6 -5
- package/lib/node-cache-cleaner/yarn.cjs +73 -0
- package/lib/node-cache-cleaner/yarn.d.ts +2 -0
- package/lib/node-cache-cleaner/yarn.js +62 -0
- package/lib/node-cache-cleaner/yarn.mjs +10 -0
- package/lib/node-cache-cleaner-cli.cjs +182 -0
- package/lib/node-cache-cleaner-cli.d.ts +2 -0
- package/lib/node-cache-cleaner-cli.js +60 -0
- package/lib/node-cache-cleaner-cli.mjs +56 -0
- package/lib/node-executor.cjs +91 -0
- package/lib/node-executor.d.cts +2 -0
- package/lib/node-executor.mjs +103 -0
- package/lib/npm-run-series.cjs +21 -28
- package/lib/npm-run-series.mjs +20 -6
- package/lib/package-resolutions-updater-cli.cjs +213 -128
- package/lib/package-resolutions-updater-cli.mjs +17 -39
- package/lib/package-resolutions-updater.cjs +204 -98
- package/lib/package-resolutions-updater.d.mts +20 -1
- package/lib/package-resolutions-updater.mjs +7 -5
- package/lib/print-directory-tree.cjs +2 -2
- package/lib/print-directory-tree.mjs +1 -1
- package/lib/ps/connected-domain.js +10 -10
- package/lib/ps/index.cjs +1 -1
- package/lib/ps/index.mjs +177 -171
- package/lib/ps/isWin.js +1 -1
- package/lib/ps/table-parser.js +6 -6
- package/lib/remove-module.cjs +2 -2
- package/lib/remove-module.mjs +1 -1
- package/lib/rm-node-module-cli.cjs +222 -0
- package/lib/rm-node-module-cli.d.cts +1 -0
- package/lib/rm-node-module-cli.mjs +89 -0
- package/lib/rm-node-modules.cjs +127 -0
- package/lib/rm-node-modules.d.cts +35 -0
- package/lib/{binary-collections-config.mjs → rm-node-modules.mjs} +3 -3
- package/lib/rmpath.cjs +2 -2
- package/lib/rmpath.mjs +1 -1
- package/lib/submodule-install.cjs +47 -34
- package/lib/submodule-install.mjs +46 -33
- package/lib/submodule-remove-cli.cjs +1 -2
- package/lib/submodule-remove-cli.js +3 -3
- package/lib/submodule-remove-cli.mjs +1 -2
- package/lib/utils/chatgpt.cjs +19 -13
- package/lib/utils/chatgpt.js +94 -94
- package/lib/utils/chatgpt.mjs +1 -1
- package/lib/utils/findEnvFiles.cjs +28 -46
- package/lib/utils/findEnvFiles.d.cts +19 -0
- package/lib/utils/findEnvFiles.mjs +3 -5
- package/lib/utils/findWorkspaceRoot.js +4 -4
- package/lib/utils/index.cjs +2 -2
- package/lib/utils/index.mjs +1 -1
- package/lib/utils/isGithubTokenValid.js +7 -7
- package/lib/{ps/index.d.cjs → utils/isWindows.cjs} +17 -3
- package/lib/utils/isWindows.d.ts +5 -0
- package/lib/utils/isWindows.js +10 -0
- package/lib/utils/isWindows.mjs +8 -0
- package/lib/utils/runBash.cjs +53 -0
- package/lib/utils/runBash.d.cts +12 -0
- package/lib/utils/runBash.mjs +66 -0
- package/lib/yarn-per-branch-lock-installer.cjs +97 -0
- package/lib/yarn-per-branch-lock-installer.d.cts +2 -0
- package/lib/yarn-per-branch-lock-installer.mjs +109 -0
- package/lib/yarn-reinstall.cjs +2 -2
- package/lib/yarn-reinstall.mjs +1 -1
- package/package.json +61 -52
- package/readme.html +784 -0
- package/readme.md +106 -218
- package/releases/readme.md +1 -1
- package/test/README.md +2 -2
- package/test-project/package.json +8 -2
- package/test-project/workspaces/workspace-a/package.json +135 -0
- package/test-project/workspaces/workspace-a/readme.md +20 -0
- package/test-project/workspaces/workspace-a/release/readme.md +42 -0
- package/test-project/workspaces/workspace-a/test/demo/package.json +25 -0
- package/test-project/workspaces/workspace-a/test/readme.md +12 -0
- package/test-project/workspaces/workspace-b/package.json +139 -0
- package/test-project/workspaces/workspace-b/readme.md +94 -0
- package/test-project/workspaces/workspace-b/requirements.txt +1 -0
- package/test-project/workspaces/workspace-b/test/sample-project/package.json +7 -0
- package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/package.json +96 -0
- package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/readme.md +156 -0
- package/tmp/rm-node-modules-test-project/package.json +17 -0
- package/tmp/rm-node-modules-test-project/packages/workspace-a/package.json +16 -0
- package/tmp/rm-node-modules-test-project/packages/workspace-b/package.json +16 -0
- package/tmp/test-repo/README.md +2 -35
- package/tmp/test-repo/package.json +13 -3
- package/docs-src/clean-github-actions-caches.md +0 -26
- package/docs-src/free-chatgpt.md +0 -26
- package/lib/binary-collections-config.cjs +0 -15
- package/lib/chunk-2CBJCW7E.mjs +0 -81
- package/lib/chunk-4UHL4WVN.mjs +0 -136
- package/lib/chunk-66PAU5PS.mjs +0 -31
- package/lib/chunk-6HHJRKFB.mjs +0 -59
- package/lib/chunk-7XTEJHOE.mjs +0 -193
- package/lib/chunk-FCDQGYBF.mjs +0 -136
- package/lib/chunk-GEYA2USY.mjs +0 -207
- package/lib/chunk-GJTGHXRA.mjs +0 -356
- package/lib/chunk-ID2WBTE2.mjs +0 -80
- package/lib/chunk-JXFOHKDM.mjs +0 -239
- package/lib/chunk-PDSXF5HY.mjs +0 -187
- package/lib/chunk-RWLXRTYP.mjs +0 -109
- package/lib/chunk-TOIVAQF7.mjs +0 -136
- package/lib/chunk-V5SKYJUB.mjs +0 -136
- package/lib/chunk-WSRETQCA.mjs +0 -59
- package/lib/chunk-YYLIQQKF.mjs +0 -31
- package/lib/ps/index.d.ts +0 -2
- package/lib/ps/index.js +0 -254
- package/lib/utils/findEnvFiles.d.ts +0 -8
- package/lib/utils/findEnvFiles.js +0 -121
- package/tmp/typedoc/readme.md +0 -320
- /package/lib/{binary-collections-config.d.cts → binary-collections/config.d.cts} +0 -0
package/lib/ps/index.mjs
CHANGED
|
@@ -9,190 +9,196 @@ import {
|
|
|
9
9
|
isWin_exports
|
|
10
10
|
} from "../chunk-6S4NXESK.mjs";
|
|
11
11
|
import {
|
|
12
|
+
__commonJS,
|
|
12
13
|
__require,
|
|
13
14
|
__toCommonJS,
|
|
14
15
|
init_esm_shims
|
|
15
16
|
} from "../chunk-QQ4A6DLD.mjs";
|
|
16
17
|
|
|
17
|
-
// src/ps/index.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
stderr
|
|
18
|
+
// src/ps/index.cjs
|
|
19
|
+
var require_ps = __commonJS({
|
|
20
|
+
"src/ps/index.cjs"(exports, module) {
|
|
21
|
+
init_esm_shims();
|
|
22
|
+
var ChildProcess = __require("child_process");
|
|
23
|
+
var IS_WIN = (init_isWin(), __toCommonJS(isWin_exports)).default;
|
|
24
|
+
var TableParser = (init_table_parser(), __toCommonJS(table_parser_exports));
|
|
25
|
+
var EOL = /(\r\n)|(\n\r)|\n|\r/;
|
|
26
|
+
var SystemEOL = __require("os").EOL;
|
|
27
|
+
var Exec = module.exports = exports = function(args, callback) {
|
|
28
|
+
var spawn = ChildProcess.spawn;
|
|
29
|
+
if (IS_WIN) {
|
|
30
|
+
var CMD = spawn("cmd");
|
|
31
|
+
var stdout = "";
|
|
32
|
+
var stderr = null;
|
|
33
|
+
CMD.stdout.on("data", function(data) {
|
|
34
|
+
stdout += data.toString();
|
|
35
|
+
});
|
|
36
|
+
CMD.stderr.on("data", function(data) {
|
|
37
|
+
if (stderr === null) {
|
|
38
|
+
stderr = data.toString();
|
|
39
|
+
} else {
|
|
40
|
+
stderr += data.toString();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
CMD.on("exit", function() {
|
|
44
|
+
var beginRow;
|
|
45
|
+
stdout = stdout.split(EOL);
|
|
46
|
+
stdout.forEach(function(out, index) {
|
|
47
|
+
if (out && typeof beginRow == "undefined" && out.indexOf("CommandLine") === 0) {
|
|
48
|
+
beginRow = index;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
stdout.splice(stdout.length - 1, 1);
|
|
52
|
+
stdout.splice(0, beginRow);
|
|
53
|
+
callback(stderr, stdout.join(SystemEOL) || false);
|
|
54
|
+
});
|
|
55
|
+
CMD.stdin.write("wmic process get ProcessId,ParentProcessId,CommandLine \n");
|
|
56
|
+
CMD.stdin.end();
|
|
36
57
|
} else {
|
|
37
|
-
|
|
58
|
+
if (typeof args === "string") {
|
|
59
|
+
args = args.split(/\s+/);
|
|
60
|
+
}
|
|
61
|
+
const child = spawn("ps", args);
|
|
62
|
+
stdout = "";
|
|
63
|
+
stderr = null;
|
|
64
|
+
child.stdout.on("data", function(data) {
|
|
65
|
+
stdout += data.toString();
|
|
66
|
+
});
|
|
67
|
+
child.stderr.on("data", function(data) {
|
|
68
|
+
if (stderr === null) {
|
|
69
|
+
stderr = data.toString();
|
|
70
|
+
} else {
|
|
71
|
+
stderr += data.toString();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
child.on("exit", function() {
|
|
75
|
+
if (stderr) {
|
|
76
|
+
return callback(stderr.toString());
|
|
77
|
+
} else {
|
|
78
|
+
callback(null, stdout || false);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
38
81
|
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
82
|
+
};
|
|
83
|
+
exports.lookup = function(query, callback) {
|
|
84
|
+
var exeArgs = query.psargs || ["lx"];
|
|
85
|
+
var filter = {};
|
|
86
|
+
var idList;
|
|
87
|
+
if (query.pid) {
|
|
88
|
+
if (Array.isArray(query.pid)) {
|
|
89
|
+
idList = query.pid;
|
|
90
|
+
} else {
|
|
91
|
+
idList = [query.pid];
|
|
46
92
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
callback(stderr, stdout.join(SystemEOL) || false);
|
|
51
|
-
});
|
|
52
|
-
CMD.stdin.write("wmic process get ProcessId,ParentProcessId,CommandLine \n");
|
|
53
|
-
CMD.stdin.end();
|
|
54
|
-
} else {
|
|
55
|
-
if (typeof args === "string") {
|
|
56
|
-
args = args.split(/\s+/);
|
|
57
|
-
}
|
|
58
|
-
const child = spawn("ps", args);
|
|
59
|
-
stdout = "";
|
|
60
|
-
stderr = null;
|
|
61
|
-
child.stdout.on("data", function(data) {
|
|
62
|
-
stdout += data.toString();
|
|
63
|
-
});
|
|
64
|
-
child.stderr.on("data", function(data) {
|
|
65
|
-
if (stderr === null) {
|
|
66
|
-
stderr = data.toString();
|
|
67
|
-
} else {
|
|
68
|
-
stderr += data.toString();
|
|
93
|
+
idList = idList.map(function(v) {
|
|
94
|
+
return String(v);
|
|
95
|
+
});
|
|
69
96
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (stderr) {
|
|
73
|
-
return callback(stderr.toString());
|
|
74
|
-
} else {
|
|
75
|
-
callback(null, stdout || false);
|
|
97
|
+
if (query.command) {
|
|
98
|
+
filter["command"] = new RegExp(query.command, "i");
|
|
76
99
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
idList = query.pid;
|
|
87
|
-
} else {
|
|
88
|
-
idList = [query.pid];
|
|
89
|
-
}
|
|
90
|
-
idList = idList.map(function(v) {
|
|
91
|
-
return String(v);
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
if (query.command) {
|
|
95
|
-
filter["command"] = new RegExp(query.command, "i");
|
|
96
|
-
}
|
|
97
|
-
if (query.arguments) {
|
|
98
|
-
filter["arguments"] = new RegExp(query.arguments, "i");
|
|
99
|
-
}
|
|
100
|
-
if (query.ppid) {
|
|
101
|
-
filter["ppid"] = new RegExp(query.ppid);
|
|
102
|
-
}
|
|
103
|
-
return Exec(exeArgs, function(err, output) {
|
|
104
|
-
if (err) {
|
|
105
|
-
return callback(err);
|
|
106
|
-
} else {
|
|
107
|
-
var processList = parseGrid(output);
|
|
108
|
-
var resultList = [];
|
|
109
|
-
processList.forEach(function(p) {
|
|
110
|
-
var flt;
|
|
111
|
-
var type;
|
|
112
|
-
var result = true;
|
|
113
|
-
if (idList && idList.indexOf(String(p.pid)) < 0) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
for (type in filter) {
|
|
117
|
-
flt = filter[type];
|
|
118
|
-
result = flt.test(p[type]) ? result : false;
|
|
119
|
-
}
|
|
120
|
-
if (result) {
|
|
121
|
-
resultList.push(p);
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
callback(null, resultList);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
exports.kill = function(pid, signal, next) {
|
|
129
|
-
if (arguments.length == 2 && typeof signal == "function") {
|
|
130
|
-
next = signal;
|
|
131
|
-
signal = void 0;
|
|
132
|
-
}
|
|
133
|
-
var checkTimeoutSeconds = signal && signal.timeout || 30;
|
|
134
|
-
if (typeof signal === "object") {
|
|
135
|
-
signal = signal.signal;
|
|
136
|
-
}
|
|
137
|
-
try {
|
|
138
|
-
process.kill(pid, signal);
|
|
139
|
-
} catch (e) {
|
|
140
|
-
return next && next(e);
|
|
141
|
-
}
|
|
142
|
-
var checkConfident = 0;
|
|
143
|
-
var checkTimeoutTimer = null;
|
|
144
|
-
var checkIsTimeout = false;
|
|
145
|
-
function checkKilled(finishCallback) {
|
|
146
|
-
exports.lookup({ pid }, function(err, list) {
|
|
147
|
-
if (checkIsTimeout) return;
|
|
148
|
-
if (err) {
|
|
149
|
-
clearTimeout(checkTimeoutTimer);
|
|
150
|
-
if (finishCallback) finishCallback(err);
|
|
151
|
-
} else if (list.length > 0) {
|
|
152
|
-
checkConfident = checkConfident - 1 || 0;
|
|
153
|
-
checkKilled(finishCallback);
|
|
154
|
-
} else {
|
|
155
|
-
checkConfident++;
|
|
156
|
-
if (checkConfident === 5) {
|
|
157
|
-
clearTimeout(checkTimeoutTimer);
|
|
158
|
-
if (finishCallback) finishCallback();
|
|
100
|
+
if (query.arguments) {
|
|
101
|
+
filter["arguments"] = new RegExp(query.arguments, "i");
|
|
102
|
+
}
|
|
103
|
+
if (query.ppid) {
|
|
104
|
+
filter["ppid"] = new RegExp(query.ppid);
|
|
105
|
+
}
|
|
106
|
+
return Exec(exeArgs, function(err, output) {
|
|
107
|
+
if (err) {
|
|
108
|
+
return callback(err);
|
|
159
109
|
} else {
|
|
160
|
-
|
|
110
|
+
var processList = parseGrid(output);
|
|
111
|
+
var resultList = [];
|
|
112
|
+
processList.forEach(function(p) {
|
|
113
|
+
var flt;
|
|
114
|
+
var type;
|
|
115
|
+
var result = true;
|
|
116
|
+
if (idList && idList.indexOf(String(p.pid)) < 0) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
for (type in filter) {
|
|
120
|
+
flt = filter[type];
|
|
121
|
+
result = flt.test(p[type]) ? result : false;
|
|
122
|
+
}
|
|
123
|
+
if (result) {
|
|
124
|
+
resultList.push(p);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
callback(null, resultList);
|
|
161
128
|
}
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
exports.kill = function(pid, signal, next) {
|
|
132
|
+
if (arguments.length == 2 && typeof signal == "function") {
|
|
133
|
+
next = signal;
|
|
134
|
+
signal = void 0;
|
|
162
135
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
136
|
+
var checkTimeoutSeconds = signal && signal.timeout || 30;
|
|
137
|
+
if (typeof signal === "object") {
|
|
138
|
+
signal = signal.signal;
|
|
139
|
+
}
|
|
140
|
+
try {
|
|
141
|
+
process.kill(pid, signal);
|
|
142
|
+
} catch (e) {
|
|
143
|
+
return next && next(e);
|
|
144
|
+
}
|
|
145
|
+
var checkConfident = 0;
|
|
146
|
+
var checkTimeoutTimer = null;
|
|
147
|
+
var checkIsTimeout = false;
|
|
148
|
+
function checkKilled(finishCallback) {
|
|
149
|
+
exports.lookup({ pid }, function(err, list) {
|
|
150
|
+
if (checkIsTimeout) return;
|
|
151
|
+
if (err) {
|
|
152
|
+
clearTimeout(checkTimeoutTimer);
|
|
153
|
+
if (finishCallback) finishCallback(err);
|
|
154
|
+
} else if (list.length > 0) {
|
|
155
|
+
checkConfident = checkConfident - 1 || 0;
|
|
156
|
+
checkKilled(finishCallback);
|
|
157
|
+
} else {
|
|
158
|
+
checkConfident++;
|
|
159
|
+
if (checkConfident === 5) {
|
|
160
|
+
clearTimeout(checkTimeoutTimer);
|
|
161
|
+
if (finishCallback) finishCallback();
|
|
162
|
+
} else {
|
|
163
|
+
checkKilled(finishCallback);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
});
|
|
188
167
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
168
|
+
if (next) checkKilled(next);
|
|
169
|
+
checkTimeoutTimer = next && setTimeout(function() {
|
|
170
|
+
checkIsTimeout = true;
|
|
171
|
+
next(new Error("Kill process timeout"));
|
|
172
|
+
}, checkTimeoutSeconds * 1e3);
|
|
173
|
+
};
|
|
174
|
+
function parseGrid(output) {
|
|
175
|
+
if (!output) {
|
|
176
|
+
return [];
|
|
177
|
+
}
|
|
178
|
+
return formatOutput(TableParser.parse(output));
|
|
179
|
+
}
|
|
180
|
+
function formatOutput(data) {
|
|
181
|
+
var formatedData = [];
|
|
182
|
+
data.forEach(function(d) {
|
|
183
|
+
var pid = d.PID && d.PID[0] || d.ProcessId && d.ProcessId[0] || void 0;
|
|
184
|
+
var cmd = d.CMD || d.CommandLine || d.COMMAND || void 0;
|
|
185
|
+
var ppid = d.PPID && d.PPID[0] || d.ParentProcessId && d.ParentProcessId[0] || void 0;
|
|
186
|
+
if (pid && cmd) {
|
|
187
|
+
var command = cmd[0];
|
|
188
|
+
var args = "";
|
|
189
|
+
if (cmd.length > 1) {
|
|
190
|
+
args = cmd.slice(1);
|
|
191
|
+
}
|
|
192
|
+
formatedData.push({
|
|
193
|
+
pid,
|
|
194
|
+
command,
|
|
195
|
+
arguments: args,
|
|
196
|
+
ppid
|
|
197
|
+
});
|
|
198
|
+
}
|
|
194
199
|
});
|
|
200
|
+
return formatedData;
|
|
195
201
|
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
export default require_ps();
|
package/lib/ps/isWin.js
CHANGED
package/lib/ps/table-parser.js
CHANGED
|
@@ -67,7 +67,7 @@ function parse(output) {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
else {
|
|
70
|
-
twoDimArray[index - 1] = line.split(
|
|
70
|
+
twoDimArray[index - 1] = line.split('');
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
73
|
// In the connected-domain aspect of view, all the blanks are connected, and all the non-blanks are connected.
|
|
@@ -210,18 +210,18 @@ function splitValue(value) {
|
|
|
210
210
|
// If the match length is a even, than nothing special, if a odd, ignore the last one.
|
|
211
211
|
var maxQuotaCount = match.length % 2 == 0 ? match.length : match.length - 1;
|
|
212
212
|
var previousItem = null;
|
|
213
|
-
var values = value.split(
|
|
213
|
+
var values = value.split('');
|
|
214
214
|
values.forEach(function (item, index) {
|
|
215
|
-
if (item !==
|
|
215
|
+
if (item !== ' ') {
|
|
216
216
|
if (item === '"') {
|
|
217
217
|
// quota chunk begin
|
|
218
218
|
if (ifInWrappedChunk === false && quotaCount <= maxQuotaCount) {
|
|
219
219
|
ifInWrappedChunk = true;
|
|
220
220
|
quotaCount++;
|
|
221
221
|
// pure quota chunk begin
|
|
222
|
-
if (previousItem ===
|
|
222
|
+
if (previousItem === ' ' || previousItem === null) {
|
|
223
223
|
ifInPureWrappedChunk = true;
|
|
224
|
-
chunk =
|
|
224
|
+
chunk = '';
|
|
225
225
|
}
|
|
226
226
|
// normal continue
|
|
227
227
|
else {
|
|
@@ -245,7 +245,7 @@ function splitValue(value) {
|
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
// normal begin
|
|
248
|
-
else if (ifInWrappedChunk === false && (previousItem ===
|
|
248
|
+
else if (ifInWrappedChunk === false && (previousItem === ' ' || previousItem === null)) {
|
|
249
249
|
chunk = item;
|
|
250
250
|
}
|
|
251
251
|
// normal or quota chunk continue.
|
package/lib/remove-module.cjs
CHANGED
|
@@ -109,7 +109,7 @@ var require_utils = __commonJS({
|
|
|
109
109
|
try {
|
|
110
110
|
fs2.rmdirSync(fullPath);
|
|
111
111
|
console.log("deleted", fullPath);
|
|
112
|
-
} catch (
|
|
112
|
+
} catch (_e) {
|
|
113
113
|
try {
|
|
114
114
|
fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
115
115
|
console.log("deleted", fullPath);
|
|
@@ -122,7 +122,7 @@ var require_utils = __commonJS({
|
|
|
122
122
|
try {
|
|
123
123
|
fs2.unlinkSync(fullPath);
|
|
124
124
|
console.log("deleted", fullPath);
|
|
125
|
-
} catch (
|
|
125
|
+
} catch (_e) {
|
|
126
126
|
try {
|
|
127
127
|
fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
128
128
|
console.log("deleted", fullPath);
|
package/lib/remove-module.mjs
CHANGED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __esm = (fn, res) => function __init() {
|
|
4
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
|
+
};
|
|
6
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
7
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// node_modules/tsup/assets/cjs_shims.js
|
|
11
|
+
var init_cjs_shims = __esm({
|
|
12
|
+
"node_modules/tsup/assets/cjs_shims.js"() {
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// src/rm-node-modules.cjs
|
|
17
|
+
var require_rm_node_modules = __commonJS({
|
|
18
|
+
"src/rm-node-modules.cjs"(exports2, module2) {
|
|
19
|
+
init_cjs_shims();
|
|
20
|
+
var fs2 = require("fs-extra");
|
|
21
|
+
var path2 = require("upath");
|
|
22
|
+
var ansiColors2 = require("ansi-colors");
|
|
23
|
+
var child_process = require("child_process");
|
|
24
|
+
var os = require("os");
|
|
25
|
+
function generateBashScript(options = {}) {
|
|
26
|
+
const { dryRun = true } = options;
|
|
27
|
+
return `
|
|
28
|
+
#!/bin/bash
|
|
29
|
+
|
|
30
|
+
set -u
|
|
31
|
+
|
|
32
|
+
cwd="$(pwd)"
|
|
33
|
+
max_jobs=4
|
|
34
|
+
DRY_RUN=${dryRun ? "true" : "false"}
|
|
35
|
+
|
|
36
|
+
cleanup_letter() {
|
|
37
|
+
local letter="$1"
|
|
38
|
+
|
|
39
|
+
if [ "$DRY_RUN" = "true" ]; then
|
|
40
|
+
echo "Would remove: node_modules/\${letter}*"
|
|
41
|
+
echo "Would remove: node_modules/@types/\${letter}*"
|
|
42
|
+
echo "Would remove: node_modules/@\${letter}*"
|
|
43
|
+
else
|
|
44
|
+
rm -rf "\${cwd}/node_modules/\${letter}"*
|
|
45
|
+
echo "Removed: node_modules/\${letter}*"
|
|
46
|
+
|
|
47
|
+
rm -rf "\${cwd}/node_modules/@types/\${letter}"*
|
|
48
|
+
echo "Removed: node_modules/@types/\${letter}*"
|
|
49
|
+
|
|
50
|
+
rm -rf "\${cwd}/node_modules/@\${letter}"*
|
|
51
|
+
echo "Removed: node_modules/@\${letter}*"
|
|
52
|
+
fi
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export -f cleanup_letter
|
|
56
|
+
export cwd
|
|
57
|
+
export DRY_RUN
|
|
58
|
+
|
|
59
|
+
if [ "$DRY_RUN" = "true" ]; then
|
|
60
|
+
echo "Dry-run mode (pass --force to actually delete)"
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
echo "Cleaning \${cwd}/node_modules..."
|
|
64
|
+
|
|
65
|
+
running=0
|
|
66
|
+
|
|
67
|
+
for letter in {a..z}; do
|
|
68
|
+
cleanup_letter "$letter" &
|
|
69
|
+
|
|
70
|
+
((running++))
|
|
71
|
+
|
|
72
|
+
# limit concurrent jobs
|
|
73
|
+
if (( running >= max_jobs )); then
|
|
74
|
+
wait -n
|
|
75
|
+
((running--))
|
|
76
|
+
fi
|
|
77
|
+
done
|
|
78
|
+
|
|
79
|
+
wait
|
|
80
|
+
|
|
81
|
+
# final full cleanup (ensure nothing left behind)
|
|
82
|
+
if [ "$DRY_RUN" = "true" ]; then
|
|
83
|
+
echo "Would remove: node_modules (final cleanup)"
|
|
84
|
+
else
|
|
85
|
+
rm -rf "\${cwd}/node_modules"
|
|
86
|
+
echo "Removed: node_modules (final cleanup)"
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
if [ "$DRY_RUN" = "true" ]; then
|
|
90
|
+
echo "Done (dry-run). Run with --force to delete for real."
|
|
91
|
+
else
|
|
92
|
+
echo "Done cleaning node_modules."
|
|
93
|
+
fi
|
|
94
|
+
`.trim();
|
|
95
|
+
}
|
|
96
|
+
async function cleanUp2(rootDir, options = {}) {
|
|
97
|
+
const { dryRun = true } = options;
|
|
98
|
+
const nodeModulesDir = path2.join(rootDir, "node_modules");
|
|
99
|
+
const script = generateBashScript({ dryRun });
|
|
100
|
+
const tmpDir = os.tmpdir();
|
|
101
|
+
const name = `rm-node-modules-${Date.now()}-${Math.random().toString(36).slice(2)}.sh`;
|
|
102
|
+
const scriptPath = path2.join(tmpDir, name);
|
|
103
|
+
try {
|
|
104
|
+
fs2.writeFileSync(scriptPath, script, { encoding: "utf8" });
|
|
105
|
+
try {
|
|
106
|
+
fs2.chmodSync(scriptPath, 493);
|
|
107
|
+
} catch {
|
|
108
|
+
}
|
|
109
|
+
const result = child_process.spawnSync("bash", [scriptPath], {
|
|
110
|
+
cwd: rootDir,
|
|
111
|
+
env: process.env,
|
|
112
|
+
encoding: "utf8",
|
|
113
|
+
shell: false
|
|
114
|
+
});
|
|
115
|
+
if (result.stdout) process.stdout.write(result.stdout);
|
|
116
|
+
if (result.stderr) process.stderr.write(result.stderr);
|
|
117
|
+
if (result.error) {
|
|
118
|
+
try {
|
|
119
|
+
console.warn(
|
|
120
|
+
ansiColors2.yellow(`bash execution failed: ${result.error.message}. Falling back to Node removal.`)
|
|
121
|
+
);
|
|
122
|
+
console.log(`Cleaning ${ansiColors2.cyan(nodeModulesDir)}...`);
|
|
123
|
+
fs2.rmSync(nodeModulesDir, { recursive: true, force: true });
|
|
124
|
+
console.log(`Removed: ${ansiColors2.green("node_modules (final cleanup)")}`);
|
|
125
|
+
console.log("Done cleaning node_modules.");
|
|
126
|
+
return {
|
|
127
|
+
code: 0,
|
|
128
|
+
stdout: result.stdout || "",
|
|
129
|
+
stderr: (result.stderr || "") + `
|
|
130
|
+
${result.error.stack || result.error.message}`
|
|
131
|
+
};
|
|
132
|
+
} catch (e) {
|
|
133
|
+
return { code: 1, stdout: result.stdout || "", stderr: (result.stderr || "") + `
|
|
134
|
+
${e.stack || e.message}` };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return { code: result.status ?? 0, stdout: result.stdout ?? "", stderr: result.stderr ?? "" };
|
|
138
|
+
} finally {
|
|
139
|
+
try {
|
|
140
|
+
if (fs2.existsSync(scriptPath)) fs2.unlinkSync(scriptPath);
|
|
141
|
+
} catch {
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
module2.exports = { generateBashScript, cleanUp: cleanUp2 };
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// src/rm-node-module-cli.cjs
|
|
150
|
+
init_cjs_shims();
|
|
151
|
+
var path = require("upath");
|
|
152
|
+
var fs = require("fs-extra");
|
|
153
|
+
var minimist = require("minimist");
|
|
154
|
+
var glob = require("glob");
|
|
155
|
+
var ansiColors = require("ansi-colors");
|
|
156
|
+
var { cleanUp } = require_rm_node_modules();
|
|
157
|
+
var argv = minimist(process.argv.slice(2), {
|
|
158
|
+
boolean: ["h", "help", "force"],
|
|
159
|
+
alias: {
|
|
160
|
+
h: "help"
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
if (argv.help) {
|
|
164
|
+
console.log(`
|
|
165
|
+
rm-node-modules
|
|
166
|
+
|
|
167
|
+
Usage:
|
|
168
|
+
rm-node-modules [options]
|
|
169
|
+
|
|
170
|
+
Examples:
|
|
171
|
+
node src/rm-node-module-cli.cjs
|
|
172
|
+
node src/rm-node-module-cli.cjs --force
|
|
173
|
+
npx binary-collections rm-node-modules
|
|
174
|
+
npx binary-collections rm-node-modules --force
|
|
175
|
+
|
|
176
|
+
Options:
|
|
177
|
+
-h, --help Show this help message
|
|
178
|
+
--force Actually delete node_modules (default is dry-run mode)
|
|
179
|
+
|
|
180
|
+
Description:
|
|
181
|
+
Removes node_modules subfolders by first-letter in parallel to speed up
|
|
182
|
+
deletions. By default runs in dry-run mode (shows what would be deleted).
|
|
183
|
+
Pass --force to actually perform deletion.
|
|
184
|
+
The script writes a temporary shell script and executes it; the
|
|
185
|
+
temporary script is removed after completion. On Windows, this requires a
|
|
186
|
+
Unix-compatible shell in PATH (e.g., Git Bash or WSL).
|
|
187
|
+
`);
|
|
188
|
+
process.exit(0);
|
|
189
|
+
}
|
|
190
|
+
async function main() {
|
|
191
|
+
if (!argv.workspace) {
|
|
192
|
+
await cleanUp(process.cwd(), { dryRun: !argv.force });
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const pkgJsonPath = path.resolve(process.cwd(), argv.workspace, "package.json");
|
|
196
|
+
if (!fs.existsSync(pkgJsonPath)) {
|
|
197
|
+
console.error(`Error: package.json not found in workspace directory: ${ansiColors.red(argv.workspace)}`);
|
|
198
|
+
process.exitCode = 1;
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const workspaces = (JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8")).workspaces || []).flatMap((workspace) => {
|
|
202
|
+
return glob.sync(workspace, {
|
|
203
|
+
cwd: process.cwd(),
|
|
204
|
+
absolute: true,
|
|
205
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/build/**"]
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
for (const workspacePath of workspaces) {
|
|
209
|
+
if (fs.existsSync(path.join(workspacePath, "package.json"))) {
|
|
210
|
+
console.log(`Cleaning node_modules in workspace: ${ansiColors.cyan(workspacePath)}`);
|
|
211
|
+
await cleanUp(workspacePath, { dryRun: !argv.force });
|
|
212
|
+
} else {
|
|
213
|
+
console.warn(
|
|
214
|
+
`Warning: No package.json found in workspace path: ${ansiColors.yellow(workspacePath)}, skipping...`
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
main().catch((e) => {
|
|
220
|
+
console.error(ansiColors.red(e instanceof Error ? e.stack || e.message : String(e)));
|
|
221
|
+
process.exitCode = 1;
|
|
222
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|