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.
Files changed (225) hide show
  1. package/.opencode/package.json +5 -0
  2. package/binaries/rmx +15 -1
  3. package/binaries/rmx.cmd +12 -0
  4. package/binaries/test-cjs +9 -1
  5. package/binaries/test-cjs.cmd +16 -1
  6. package/binaries/test-esm +16 -0
  7. package/binaries/test-esm.cjs +178 -0
  8. package/binaries/test-esm.cmd +23 -0
  9. package/binaries/yarn-clean +1 -1
  10. package/binaries/yarn-clean.cmd +1 -1
  11. package/binaries/yarn-clean.py +33 -15
  12. package/binaries/yc +110 -0
  13. package/binaries/yc.cjs +178 -0
  14. package/lib/binary-collections/config.cjs +126 -0
  15. package/lib/binary-collections/config.mjs +7 -0
  16. package/lib/binary-collections/executeScript.cjs +19 -0
  17. package/lib/binary-collections/executeScript.d.cts +12 -0
  18. package/lib/binary-collections/executeScript.mjs +6 -0
  19. package/lib/binary-collections/findScript.cjs +284 -0
  20. package/lib/binary-collections/findScript.d.cts +12 -0
  21. package/lib/binary-collections/findScript.mjs +7 -0
  22. package/lib/binary-collections/listScript.cjs +266 -0
  23. package/lib/binary-collections/listScript.d.cts +19 -0
  24. package/lib/binary-collections/listScript.mjs +7 -0
  25. package/lib/binary-collections.cjs +224 -137
  26. package/lib/binary-collections.mjs +22 -282
  27. package/lib/changelog.cjs +2 -2
  28. package/lib/changelog.mjs +1 -1
  29. package/lib/{chunk-AJDD5DZM.mjs → chunk-2LSRSEXF.mjs} +1 -1
  30. package/lib/{chunk-Z6JLYU2J.mjs → chunk-5RTXZVCW.mjs} +2 -2
  31. package/lib/{chunk-XA3SNBPA.mjs → chunk-66KDU4TX.mjs} +93 -9
  32. package/lib/chunk-6PU7BAHB.mjs +61 -0
  33. package/lib/chunk-C6D2TTYU.mjs +32 -0
  34. package/lib/chunk-FB2WKVJD.mjs +158 -0
  35. package/lib/{chunk-NCXAP7AA.mjs → chunk-G5UUEWUO.mjs} +9 -5
  36. package/lib/{chunk-N436BNBK.mjs → chunk-GAGABICI.mjs} +19 -13
  37. package/lib/chunk-H44UWUFY.mjs +105 -0
  38. package/lib/chunk-NCZPTKDV.mjs +79 -0
  39. package/lib/chunk-NGFK3EYW.mjs +28 -0
  40. package/lib/chunk-NVEG3LEZ.mjs +143 -0
  41. package/lib/chunk-OGXVGBRI.mjs +29 -0
  42. package/lib/chunk-OXV52GD5.mjs +62 -0
  43. package/lib/chunk-PXBMHE7O.mjs +35 -0
  44. package/lib/chunk-R5FJOR63.mjs +47 -0
  45. package/lib/chunk-SPTECFE5.mjs +180 -0
  46. package/lib/chunk-UXCFNAR6.mjs +55 -0
  47. package/lib/chunk-V2IBPCEV.mjs +39 -0
  48. package/lib/chunk-XPJGCDOD.mjs +14 -0
  49. package/lib/chunk-ZOWVMII3.mjs +228 -0
  50. package/lib/clean-github-actions-caches-cli.cjs +465 -0
  51. package/lib/clean-github-actions-caches-cli.d.cts +1 -0
  52. package/lib/clean-github-actions-caches-cli.mjs +56 -0
  53. package/lib/clean-github-actions-caches.cjs +149 -205
  54. package/lib/clean-github-actions-caches.d.cts +15 -1
  55. package/lib/clean-github-actions-caches.mjs +4 -130
  56. package/lib/cross-env/command.cjs +63 -0
  57. package/lib/cross-env/command.d.ts +8 -0
  58. package/lib/cross-env/command.js +45 -0
  59. package/lib/cross-env/command.mjs +9 -0
  60. package/lib/cross-env/index.cjs +178 -0
  61. package/lib/cross-env/index.d.ts +8 -0
  62. package/lib/cross-env/index.js +102 -0
  63. package/lib/cross-env/index.mjs +101 -0
  64. package/lib/cross-env/variable.cjs +60 -0
  65. package/lib/cross-env/variable.d.ts +7 -0
  66. package/lib/cross-env/variable.js +59 -0
  67. package/lib/cross-env/variable.mjs +9 -0
  68. package/lib/del-gradle.cjs +2 -2
  69. package/lib/del-gradle.js +8 -8
  70. package/lib/del-gradle.mjs +1 -1
  71. package/lib/del-node-modules.js +24 -24
  72. package/lib/del-ps.cjs +2 -2
  73. package/lib/del-ps.js +8 -8
  74. package/lib/del-ps.mjs +1 -1
  75. package/lib/del-yarn-caches.cjs +2 -2
  76. package/lib/del-yarn-caches.js +2 -2
  77. package/lib/del-yarn-caches.mjs +1 -1
  78. package/lib/file/copy-cli.cjs +92 -0
  79. package/lib/file/copy-cli.d.mts +1 -0
  80. package/lib/file/copy-cli.mjs +55 -0
  81. package/lib/file/copy.cjs +56 -0
  82. package/lib/file/copy.d.mts +1 -0
  83. package/lib/file/copy.mjs +8 -0
  84. package/lib/file/move-cli.cjs +91 -0
  85. package/lib/file/move-cli.d.mts +1 -0
  86. package/lib/file/move-cli.mjs +55 -0
  87. package/lib/file/move.cjs +55 -0
  88. package/lib/file/move.d.mts +1 -0
  89. package/lib/file/move.mjs +8 -0
  90. package/lib/find-node-modules-cli.js +1 -1
  91. package/lib/free-chatgpt.cjs +21 -15
  92. package/lib/free-chatgpt.js +10 -10
  93. package/lib/free-chatgpt.mjs +2 -2
  94. package/lib/git/user-config.cjs +2 -2
  95. package/lib/git/user-config.mjs +2 -2
  96. package/lib/git-diff-cli.cjs +188 -42
  97. package/lib/git-diff-cli.mjs +5 -4
  98. package/lib/git-diff.cjs +188 -42
  99. package/lib/git-diff.d.ts +2 -1
  100. package/lib/git-diff.js +91 -34
  101. package/lib/git-diff.mjs +5 -4
  102. package/lib/git-fix.cjs +2 -2
  103. package/lib/git-fix.mjs +2 -2
  104. package/lib/git-purge.cjs +2 -2
  105. package/lib/git-purge.mjs +1 -1
  106. package/lib/index.d.ts +1 -1
  107. package/lib/kill-night-crows.cjs +7 -7
  108. package/lib/kill-night-crows.mjs +7 -7
  109. package/lib/node-cache-cleaner/npm.cjs +65 -0
  110. package/lib/node-cache-cleaner/npm.d.ts +2 -0
  111. package/lib/node-cache-cleaner/npm.js +41 -0
  112. package/lib/node-cache-cleaner/npm.mjs +10 -0
  113. package/lib/node-cache-cleaner/npx.cjs +89 -0
  114. package/lib/node-cache-cleaner/npx.d.ts +4 -0
  115. package/lib/node-cache-cleaner/npx.js +82 -0
  116. package/lib/{ps/index.d.mjs → node-cache-cleaner/npx.mjs} +6 -5
  117. package/lib/node-cache-cleaner/yarn.cjs +73 -0
  118. package/lib/node-cache-cleaner/yarn.d.ts +2 -0
  119. package/lib/node-cache-cleaner/yarn.js +62 -0
  120. package/lib/node-cache-cleaner/yarn.mjs +10 -0
  121. package/lib/node-cache-cleaner-cli.cjs +182 -0
  122. package/lib/node-cache-cleaner-cli.d.ts +2 -0
  123. package/lib/node-cache-cleaner-cli.js +60 -0
  124. package/lib/node-cache-cleaner-cli.mjs +56 -0
  125. package/lib/node-executor.cjs +91 -0
  126. package/lib/node-executor.d.cts +2 -0
  127. package/lib/node-executor.mjs +103 -0
  128. package/lib/npm-run-series.cjs +21 -28
  129. package/lib/npm-run-series.mjs +20 -6
  130. package/lib/package-resolutions-updater-cli.cjs +213 -128
  131. package/lib/package-resolutions-updater-cli.mjs +17 -39
  132. package/lib/package-resolutions-updater.cjs +204 -98
  133. package/lib/package-resolutions-updater.d.mts +20 -1
  134. package/lib/package-resolutions-updater.mjs +7 -5
  135. package/lib/print-directory-tree.cjs +2 -2
  136. package/lib/print-directory-tree.mjs +1 -1
  137. package/lib/ps/connected-domain.js +10 -10
  138. package/lib/ps/index.cjs +1 -1
  139. package/lib/ps/index.mjs +177 -171
  140. package/lib/ps/isWin.js +1 -1
  141. package/lib/ps/table-parser.js +6 -6
  142. package/lib/remove-module.cjs +2 -2
  143. package/lib/remove-module.mjs +1 -1
  144. package/lib/rm-node-module-cli.cjs +222 -0
  145. package/lib/rm-node-module-cli.d.cts +1 -0
  146. package/lib/rm-node-module-cli.mjs +89 -0
  147. package/lib/rm-node-modules.cjs +127 -0
  148. package/lib/rm-node-modules.d.cts +35 -0
  149. package/lib/{binary-collections-config.mjs → rm-node-modules.mjs} +3 -3
  150. package/lib/rmpath.cjs +2 -2
  151. package/lib/rmpath.mjs +1 -1
  152. package/lib/submodule-install.cjs +47 -34
  153. package/lib/submodule-install.mjs +46 -33
  154. package/lib/submodule-remove-cli.cjs +1 -2
  155. package/lib/submodule-remove-cli.js +3 -3
  156. package/lib/submodule-remove-cli.mjs +1 -2
  157. package/lib/utils/chatgpt.cjs +19 -13
  158. package/lib/utils/chatgpt.js +94 -94
  159. package/lib/utils/chatgpt.mjs +1 -1
  160. package/lib/utils/findEnvFiles.cjs +28 -46
  161. package/lib/utils/findEnvFiles.d.cts +19 -0
  162. package/lib/utils/findEnvFiles.mjs +3 -5
  163. package/lib/utils/findWorkspaceRoot.js +4 -4
  164. package/lib/utils/index.cjs +2 -2
  165. package/lib/utils/index.mjs +1 -1
  166. package/lib/utils/isGithubTokenValid.js +7 -7
  167. package/lib/{ps/index.d.cjs → utils/isWindows.cjs} +17 -3
  168. package/lib/utils/isWindows.d.ts +5 -0
  169. package/lib/utils/isWindows.js +10 -0
  170. package/lib/utils/isWindows.mjs +8 -0
  171. package/lib/utils/runBash.cjs +53 -0
  172. package/lib/utils/runBash.d.cts +12 -0
  173. package/lib/utils/runBash.mjs +66 -0
  174. package/lib/yarn-per-branch-lock-installer.cjs +97 -0
  175. package/lib/yarn-per-branch-lock-installer.d.cts +2 -0
  176. package/lib/yarn-per-branch-lock-installer.mjs +109 -0
  177. package/lib/yarn-reinstall.cjs +2 -2
  178. package/lib/yarn-reinstall.mjs +1 -1
  179. package/package.json +61 -52
  180. package/readme.html +784 -0
  181. package/readme.md +106 -218
  182. package/releases/readme.md +1 -1
  183. package/test/README.md +2 -2
  184. package/test-project/package.json +8 -2
  185. package/test-project/workspaces/workspace-a/package.json +135 -0
  186. package/test-project/workspaces/workspace-a/readme.md +20 -0
  187. package/test-project/workspaces/workspace-a/release/readme.md +42 -0
  188. package/test-project/workspaces/workspace-a/test/demo/package.json +25 -0
  189. package/test-project/workspaces/workspace-a/test/readme.md +12 -0
  190. package/test-project/workspaces/workspace-b/package.json +139 -0
  191. package/test-project/workspaces/workspace-b/readme.md +94 -0
  192. package/test-project/workspaces/workspace-b/requirements.txt +1 -0
  193. package/test-project/workspaces/workspace-b/test/sample-project/package.json +7 -0
  194. package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/package.json +96 -0
  195. package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/readme.md +156 -0
  196. package/tmp/rm-node-modules-test-project/package.json +17 -0
  197. package/tmp/rm-node-modules-test-project/packages/workspace-a/package.json +16 -0
  198. package/tmp/rm-node-modules-test-project/packages/workspace-b/package.json +16 -0
  199. package/tmp/test-repo/README.md +2 -35
  200. package/tmp/test-repo/package.json +13 -3
  201. package/docs-src/clean-github-actions-caches.md +0 -26
  202. package/docs-src/free-chatgpt.md +0 -26
  203. package/lib/binary-collections-config.cjs +0 -15
  204. package/lib/chunk-2CBJCW7E.mjs +0 -81
  205. package/lib/chunk-4UHL4WVN.mjs +0 -136
  206. package/lib/chunk-66PAU5PS.mjs +0 -31
  207. package/lib/chunk-6HHJRKFB.mjs +0 -59
  208. package/lib/chunk-7XTEJHOE.mjs +0 -193
  209. package/lib/chunk-FCDQGYBF.mjs +0 -136
  210. package/lib/chunk-GEYA2USY.mjs +0 -207
  211. package/lib/chunk-GJTGHXRA.mjs +0 -356
  212. package/lib/chunk-ID2WBTE2.mjs +0 -80
  213. package/lib/chunk-JXFOHKDM.mjs +0 -239
  214. package/lib/chunk-PDSXF5HY.mjs +0 -187
  215. package/lib/chunk-RWLXRTYP.mjs +0 -109
  216. package/lib/chunk-TOIVAQF7.mjs +0 -136
  217. package/lib/chunk-V5SKYJUB.mjs +0 -136
  218. package/lib/chunk-WSRETQCA.mjs +0 -59
  219. package/lib/chunk-YYLIQQKF.mjs +0 -31
  220. package/lib/ps/index.d.ts +0 -2
  221. package/lib/ps/index.js +0 -254
  222. package/lib/utils/findEnvFiles.d.ts +0 -8
  223. package/lib/utils/findEnvFiles.js +0 -121
  224. package/tmp/typedoc/readme.md +0 -320
  225. /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.js
18
- init_esm_shims();
19
- var ChildProcess = __require("child_process");
20
- var IS_WIN = (init_isWin(), __toCommonJS(isWin_exports)).default;
21
- var TableParser = (init_table_parser(), __toCommonJS(table_parser_exports));
22
- var EOL = /(\r\n)|(\n\r)|\n|\r/;
23
- var SystemEOL = __require("os").EOL;
24
- var Exec = module.exports = exports = function(args, callback) {
25
- var spawn = ChildProcess.spawn;
26
- if (IS_WIN) {
27
- var CMD = spawn("cmd");
28
- var stdout = "";
29
- var stderr = null;
30
- CMD.stdout.on("data", function(data) {
31
- stdout += data.toString();
32
- });
33
- CMD.stderr.on("data", function(data) {
34
- if (stderr === null) {
35
- stderr = data.toString();
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
- stderr += data.toString();
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
- CMD.on("exit", function() {
41
- var beginRow;
42
- stdout = stdout.split(EOL);
43
- stdout.forEach(function(out, index) {
44
- if (out && typeof beginRow == "undefined" && out.indexOf("CommandLine") === 0) {
45
- beginRow = index;
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
- stdout.splice(stdout.length - 1, 1);
49
- stdout.splice(0, beginRow);
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
- child.on("exit", function() {
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
- exports.lookup = function(query, callback) {
81
- var exeArgs = query.psargs || ["lx"];
82
- var filter = {};
83
- var idList;
84
- if (query.pid) {
85
- if (Array.isArray(query.pid)) {
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
- checkKilled(finishCallback);
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
- if (next) checkKilled(next);
166
- checkTimeoutTimer = next && setTimeout(function() {
167
- checkIsTimeout = true;
168
- next(new Error("Kill process timeout"));
169
- }, checkTimeoutSeconds * 1e3);
170
- };
171
- function parseGrid(output) {
172
- if (!output) {
173
- return [];
174
- }
175
- return formatOutput(TableParser.parse(output));
176
- }
177
- function formatOutput(data) {
178
- var formatedData = [];
179
- data.forEach(function(d) {
180
- var pid = d.PID && d.PID[0] || d.ProcessId && d.ProcessId[0] || void 0;
181
- var cmd = d.CMD || d.CommandLine || d.COMMAND || void 0;
182
- var ppid = d.PPID && d.PPID[0] || d.ParentProcessId && d.ParentProcessId[0] || void 0;
183
- if (pid && cmd) {
184
- var command = cmd[0];
185
- var args = "";
186
- if (cmd.length > 1) {
187
- args = cmd.slice(1);
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
- formatedData.push({
190
- pid,
191
- command,
192
- arguments: args,
193
- ppid
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
- return formatedData;
198
- }
202
+ }
203
+ });
204
+ export default require_ps();
package/lib/ps/isWin.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const isWin = process.platform === "win32";
3
+ const isWin = process.platform === 'win32';
4
4
  exports.default = isWin;
@@ -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 === " " || previousItem === null) {
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 === " " || previousItem === null)) {
248
+ else if (ifInWrappedChunk === false && (previousItem === ' ' || previousItem === null)) {
249
249
  chunk = item;
250
250
  }
251
251
  // normal or quota chunk continue.
@@ -109,7 +109,7 @@ var require_utils = __commonJS({
109
109
  try {
110
110
  fs2.rmdirSync(fullPath);
111
111
  console.log("deleted", fullPath);
112
- } catch (e) {
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 (e) {
125
+ } catch (_e) {
126
126
  try {
127
127
  fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
128
128
  console.log("deleted", fullPath);
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_utils
4
- } from "./chunk-Z6JLYU2J.mjs";
4
+ } from "./chunk-5RTXZVCW.mjs";
5
5
  import {
6
6
  __toESM,
7
7
  init_esm_shims
@@ -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 {};