binary-collections 2.0.5 → 2.0.7

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 (126) hide show
  1. package/bin/bash-dummy +7 -2
  2. package/bin/clean-nodemodule +7 -2
  3. package/bin/clean-nodemodules +7 -2
  4. package/bin/dev +7 -2
  5. package/bin/empty +7 -2
  6. package/bin/git-diff.cmd +4 -0
  7. package/bin/git-fix-encoding +7 -2
  8. package/bin/git-fix-encoding.cmd +0 -0
  9. package/bin/git-reduce-size +7 -2
  10. package/bin/kill-process +7 -2
  11. package/bin/nodekill +7 -2
  12. package/bin/nodekill.cmd +0 -0
  13. package/bin/nodekill.ps1 +0 -0
  14. package/bin/prod +7 -2
  15. package/bin/rmfind +7 -2
  16. package/bin/rmpath +7 -2
  17. package/bin/rmx +9 -3
  18. package/bin/submodule +13 -2
  19. package/bin/submodule-install +7 -2
  20. package/bin/submodule-remove +7 -2
  21. package/lib/chunk-3LOB2P54.mjs +202 -0
  22. package/lib/chunk-4LEXWIIF.mjs +173 -0
  23. package/lib/chunk-BSD5CIRU.mjs +52 -0
  24. package/lib/chunk-FB6YIQYR.mjs +42 -0
  25. package/lib/chunk-JL32QDSH.mjs +20 -0
  26. package/lib/chunk-OKYLF2MU.mjs +53 -0
  27. package/lib/chunk-VXZQNLPU.mjs +23 -0
  28. package/lib/del-gradle.cjs +72 -0
  29. package/lib/del-gradle.d.mts +2 -0
  30. package/lib/del-gradle.d.ts +1 -0
  31. package/lib/del-gradle.js +15 -0
  32. package/lib/del-gradle.mjs +28 -0
  33. package/lib/del-node-modules.cjs +72 -0
  34. package/lib/del-node-modules.d.mts +2 -0
  35. package/lib/del-node-modules.d.ts +1 -0
  36. package/lib/del-node-modules.js +11 -15
  37. package/lib/del-node-modules.mjs +28 -0
  38. package/lib/del-ps.cjs +93 -0
  39. package/lib/del-ps.d.mts +2 -0
  40. package/lib/del-ps.d.ts +1 -0
  41. package/lib/del-ps.js +31 -0
  42. package/lib/del-ps.mjs +43 -0
  43. package/lib/del-yarn-caches.cjs +65 -0
  44. package/lib/del-yarn-caches.d.mts +2 -0
  45. package/lib/del-yarn-caches.d.ts +1 -0
  46. package/lib/del-yarn-caches.js +6 -9
  47. package/lib/del-yarn-caches.mjs +21 -0
  48. package/lib/find-node-modules-cli.cjs +59 -0
  49. package/lib/find-node-modules-cli.d.mts +1 -0
  50. package/lib/find-node-modules-cli.d.ts +2 -0
  51. package/lib/find-node-modules-cli.js +3 -0
  52. package/lib/find-node-modules-cli.mjs +14 -0
  53. package/lib/find-node-modules.cjs +34 -0
  54. package/lib/find-node-modules.d.mts +10 -0
  55. package/lib/find-node-modules.d.ts +9 -0
  56. package/lib/find-node-modules.js +41 -13
  57. package/lib/find-node-modules.mjs +7 -0
  58. package/lib/git-diff.cjs +74 -0
  59. package/lib/git-diff.d.cts +2 -0
  60. package/lib/git-diff.d.mts +87 -0
  61. package/lib/git-diff.d.ts +87 -0
  62. package/lib/git-diff.mjs +83 -0
  63. package/lib/git-purge.cjs +91 -0
  64. package/lib/git-purge.d.mts +2 -0
  65. package/lib/git-purge.d.ts +1 -0
  66. package/lib/git-purge.js +59 -0
  67. package/lib/git-purge.mjs +47 -0
  68. package/lib/index.cjs +92 -0
  69. package/lib/index.d.mts +1 -0
  70. package/lib/index.d.ts +2 -0
  71. package/lib/index.js +8 -0
  72. package/lib/index.mjs +18 -0
  73. package/lib/npm-run-series.cjs +61 -0
  74. package/lib/npm-run-series.d.mts +1 -0
  75. package/lib/npm-run-series.d.ts +2 -0
  76. package/lib/npm-run-series.js +80 -39
  77. package/lib/npm-run-series.mjs +47 -0
  78. package/lib/package-resolutions.cjs +28 -0
  79. package/lib/package-resolutions.d.mts +25 -0
  80. package/lib/package-resolutions.d.ts +25 -0
  81. package/lib/package-resolutions.mjs +31 -0
  82. package/lib/ps/connected-domain.cjs +156 -0
  83. package/lib/ps/connected-domain.d.mts +3 -0
  84. package/lib/ps/connected-domain.d.ts +2 -0
  85. package/lib/ps/connected-domain.js +202 -0
  86. package/lib/ps/connected-domain.mjs +7 -0
  87. package/lib/ps/index.cjs +555 -0
  88. package/lib/ps/index.d.cjs +17 -0
  89. package/lib/ps/index.d.d.mts +26 -0
  90. package/lib/ps/index.d.d.ts +26 -0
  91. package/lib/ps/index.d.mjs +8 -0
  92. package/lib/ps/index.d.mts +26 -0
  93. package/lib/ps/index.d.ts +2 -0
  94. package/lib/ps/index.js +250 -0
  95. package/lib/ps/index.mjs +203 -0
  96. package/lib/ps/isWin.cjs +3 -0
  97. package/lib/ps/isWin.d.mts +3 -0
  98. package/lib/ps/isWin.d.ts +2 -0
  99. package/lib/ps/isWin.js +2 -0
  100. package/lib/ps/isWin.mjs +7 -0
  101. package/lib/ps/table-parser.cjs +359 -0
  102. package/lib/ps/table-parser.d.mts +3 -0
  103. package/lib/ps/table-parser.d.ts +1 -0
  104. package/lib/ps/table-parser.js +268 -0
  105. package/lib/ps/table-parser.mjs +8 -0
  106. package/lib/submodule-install.cjs +118 -0
  107. package/lib/submodule-install.d.cts +2 -0
  108. package/lib/submodule-install.d.mts +141 -0
  109. package/lib/submodule-install.d.ts +141 -0
  110. package/lib/submodule-install.mjs +116 -0
  111. package/lib/utils.cjs +35 -0
  112. package/lib/utils.d.mts +20 -0
  113. package/lib/utils.d.ts +16 -0
  114. package/lib/utils.js +42 -28
  115. package/lib/utils.mjs +7 -0
  116. package/lib/yarn-reinstall.cjs +42 -0
  117. package/lib/yarn-reinstall.d.cts +1 -0
  118. package/lib/yarn-reinstall.d.mts +45 -0
  119. package/lib/yarn-reinstall.d.ts +45 -0
  120. package/lib/yarn-reinstall.mjs +50 -0
  121. package/package.json +80 -38
  122. package/readme.md +188 -40
  123. package/src/ps/index.js +285 -0
  124. package/test/package.json +19 -0
  125. package/index.js +0 -1
  126. package/lib/package-resolutions.json +0 -22
@@ -0,0 +1,250 @@
1
+ var ChildProcess = require("child_process");
2
+ var IS_WIN = require("./isWin");
3
+ var TableParser = require("./table-parser");
4
+ /**
5
+ * End of line.
6
+ * Basically, the EOL should be:
7
+ * - windows: \r\n
8
+ * - *nix: \n
9
+ * But i'm trying to get every possibilities covered.
10
+ */
11
+ var EOL = /(\r\n)|(\n\r)|\n|\r/;
12
+ var SystemEOL = require("os").EOL;
13
+ // ps-node
14
+ /**
15
+ * Execute child process
16
+ * @type {Function}
17
+ * @param {String[]} args
18
+ * @param {Function} callback
19
+ * @param {Object=null} callback.err
20
+ * @param {Object[]} callback.stdout
21
+ */
22
+ var Exec = (module.exports =
23
+ exports =
24
+ function (args, callback) {
25
+ var spawn = ChildProcess.spawn;
26
+ // on windows, if use ChildProcess.exec(`wmic process get`), the stdout will gives you nothing
27
+ // that's why I use `cmd` instead
28
+ if (IS_WIN) {
29
+ var CMD = spawn("cmd");
30
+ var stdout = "";
31
+ var stderr = null;
32
+ CMD.stdout.on("data", function (data) {
33
+ stdout += data.toString();
34
+ });
35
+ CMD.stderr.on("data", function (data) {
36
+ if (stderr === null) {
37
+ stderr = data.toString();
38
+ }
39
+ else {
40
+ stderr += data.toString();
41
+ }
42
+ });
43
+ CMD.on("exit", function () {
44
+ var beginRow;
45
+ stdout = stdout.split(EOL);
46
+ // Find the line index for the titles
47
+ stdout.forEach(function (out, index) {
48
+ if (out && typeof beginRow == "undefined" && out.indexOf("CommandLine") === 0) {
49
+ beginRow = index;
50
+ }
51
+ });
52
+ // get rid of the start (copyright) and the end (current pwd)
53
+ stdout.splice(stdout.length - 1, 1);
54
+ stdout.splice(0, beginRow);
55
+ callback(stderr, stdout.join(SystemEOL) || false);
56
+ });
57
+ CMD.stdin.write("wmic process get ProcessId,ParentProcessId,CommandLine \n");
58
+ CMD.stdin.end();
59
+ }
60
+ else {
61
+ if (typeof args === "string") {
62
+ args = args.split(/\s+/);
63
+ }
64
+ const child = spawn("ps", args);
65
+ stdout = "";
66
+ stderr = null;
67
+ child.stdout.on("data", function (data) {
68
+ stdout += data.toString();
69
+ });
70
+ child.stderr.on("data", function (data) {
71
+ if (stderr === null) {
72
+ stderr = data.toString();
73
+ }
74
+ else {
75
+ stderr += data.toString();
76
+ }
77
+ });
78
+ child.on("exit", function () {
79
+ if (stderr) {
80
+ return callback(stderr.toString());
81
+ }
82
+ else {
83
+ callback(null, stdout || false);
84
+ }
85
+ });
86
+ }
87
+ });
88
+ /**
89
+ * Query Process: Focus on pid & cmd
90
+ * @param query
91
+ * @param {String|String[]} query.pid
92
+ * @param {String} query.command RegExp String
93
+ * @param {String} query.arguments RegExp String
94
+ * @param {String|array} query.psargs
95
+ * @param {Function} callback
96
+ * @param {Object=null} callback.err
97
+ * @param {Object[]} callback.processList
98
+ * @return {Object}
99
+ */
100
+ exports.lookup = function (query, callback) {
101
+ /**
102
+ * add 'lx' as default ps arguments, since the default ps output in linux like "ubuntu", wont include command arguments
103
+ */
104
+ var exeArgs = query.psargs || ["lx"];
105
+ var filter = {};
106
+ var idList;
107
+ // Lookup by PID
108
+ if (query.pid) {
109
+ if (Array.isArray(query.pid)) {
110
+ idList = query.pid;
111
+ }
112
+ else {
113
+ idList = [query.pid];
114
+ }
115
+ // Cast all PIDs as Strings
116
+ idList = idList.map(function (v) {
117
+ return String(v);
118
+ });
119
+ }
120
+ if (query.command) {
121
+ filter["command"] = new RegExp(query.command, "i");
122
+ }
123
+ if (query.arguments) {
124
+ filter["arguments"] = new RegExp(query.arguments, "i");
125
+ }
126
+ if (query.ppid) {
127
+ filter["ppid"] = new RegExp(query.ppid);
128
+ }
129
+ return Exec(exeArgs, function (err, output) {
130
+ if (err) {
131
+ return callback(err);
132
+ }
133
+ else {
134
+ var processList = parseGrid(output);
135
+ var resultList = [];
136
+ processList.forEach(function (p) {
137
+ var flt;
138
+ var type;
139
+ var result = true;
140
+ if (idList && idList.indexOf(String(p.pid)) < 0) {
141
+ return;
142
+ }
143
+ for (type in filter) {
144
+ flt = filter[type];
145
+ result = flt.test(p[type]) ? result : false;
146
+ }
147
+ if (result) {
148
+ resultList.push(p);
149
+ }
150
+ });
151
+ callback(null, resultList);
152
+ }
153
+ });
154
+ };
155
+ /**
156
+ * Kill process
157
+ * @param pid
158
+ * @param {Object|String} signal
159
+ * @param {String} signal.signal
160
+ * @param {number} signal.timeout
161
+ * @param next
162
+ */
163
+ exports.kill = function (pid, signal, next) {
164
+ //opts are optional
165
+ if (arguments.length == 2 && typeof signal == "function") {
166
+ next = signal;
167
+ signal = undefined;
168
+ }
169
+ var checkTimeoutSeconds = (signal && signal.timeout) || 30;
170
+ if (typeof signal === "object") {
171
+ signal = signal.signal;
172
+ }
173
+ try {
174
+ process.kill(pid, signal);
175
+ }
176
+ catch (e) {
177
+ return next && next(e);
178
+ }
179
+ var checkConfident = 0;
180
+ var checkTimeoutTimer = null;
181
+ var checkIsTimeout = false;
182
+ function checkKilled(finishCallback) {
183
+ exports.lookup({ pid: pid }, function (err, list) {
184
+ if (checkIsTimeout)
185
+ return;
186
+ if (err) {
187
+ clearTimeout(checkTimeoutTimer);
188
+ finishCallback && finishCallback(err);
189
+ }
190
+ else if (list.length > 0) {
191
+ checkConfident = checkConfident - 1 || 0;
192
+ checkKilled(finishCallback);
193
+ }
194
+ else {
195
+ checkConfident++;
196
+ if (checkConfident === 5) {
197
+ clearTimeout(checkTimeoutTimer);
198
+ finishCallback && finishCallback();
199
+ }
200
+ else {
201
+ checkKilled(finishCallback);
202
+ }
203
+ }
204
+ });
205
+ }
206
+ next && checkKilled(next);
207
+ checkTimeoutTimer =
208
+ next &&
209
+ setTimeout(function () {
210
+ checkIsTimeout = true;
211
+ next(new Error("Kill process timeout"));
212
+ }, checkTimeoutSeconds * 1000);
213
+ };
214
+ /**
215
+ * Parse the stdout into readable object.
216
+ * @param {String} output
217
+ */
218
+ function parseGrid(output) {
219
+ if (!output) {
220
+ return [];
221
+ }
222
+ return formatOutput(TableParser.parse(output));
223
+ }
224
+ /**
225
+ * format the structure, extract pid, command, arguments, ppid
226
+ * @param data
227
+ * @return {Array}
228
+ */
229
+ function formatOutput(data) {
230
+ var formatedData = [];
231
+ data.forEach(function (d) {
232
+ var pid = (d.PID && d.PID[0]) || (d.ProcessId && d.ProcessId[0]) || undefined;
233
+ var cmd = d.CMD || d.CommandLine || d.COMMAND || undefined;
234
+ var ppid = (d.PPID && d.PPID[0]) || (d.ParentProcessId && d.ParentProcessId[0]) || undefined;
235
+ if (pid && cmd) {
236
+ var command = cmd[0];
237
+ var args = "";
238
+ if (cmd.length > 1) {
239
+ args = cmd.slice(1);
240
+ }
241
+ formatedData.push({
242
+ pid: pid,
243
+ command: command,
244
+ arguments: args,
245
+ ppid: ppid
246
+ });
247
+ }
248
+ });
249
+ return formatedData;
250
+ }
@@ -0,0 +1,203 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_table_parser
4
+ } from "../chunk-3LOB2P54.mjs";
5
+ import "../chunk-4LEXWIIF.mjs";
6
+ import {
7
+ require_isWin
8
+ } from "../chunk-JL32QDSH.mjs";
9
+ import {
10
+ init_esm_shims
11
+ } from "../chunk-VXZQNLPU.mjs";
12
+ import {
13
+ __commonJS,
14
+ __require
15
+ } from "../chunk-FB6YIQYR.mjs";
16
+
17
+ // src/ps/index.js
18
+ var require_ps = __commonJS({
19
+ "src/ps/index.js"(exports, module) {
20
+ init_esm_shims();
21
+ var ChildProcess = __require("child_process");
22
+ var IS_WIN = require_isWin();
23
+ var TableParser = require_table_parser();
24
+ var EOL = /(\r\n)|(\n\r)|\n|\r/;
25
+ var SystemEOL = __require("os").EOL;
26
+ var Exec = module.exports = exports = function(args, callback) {
27
+ var spawn = ChildProcess.spawn;
28
+ if (IS_WIN) {
29
+ var CMD = spawn("cmd");
30
+ var stdout = "";
31
+ var stderr = null;
32
+ CMD.stdout.on("data", function(data) {
33
+ stdout += data.toString();
34
+ });
35
+ CMD.stderr.on("data", function(data) {
36
+ if (stderr === null) {
37
+ stderr = data.toString();
38
+ } else {
39
+ stderr += data.toString();
40
+ }
41
+ });
42
+ CMD.on("exit", function() {
43
+ var beginRow;
44
+ stdout = stdout.split(EOL);
45
+ stdout.forEach(function(out, index) {
46
+ if (out && typeof beginRow == "undefined" && out.indexOf("CommandLine") === 0) {
47
+ beginRow = index;
48
+ }
49
+ });
50
+ stdout.splice(stdout.length - 1, 1);
51
+ stdout.splice(0, beginRow);
52
+ callback(stderr, stdout.join(SystemEOL) || false);
53
+ });
54
+ CMD.stdin.write("wmic process get ProcessId,ParentProcessId,CommandLine \n");
55
+ CMD.stdin.end();
56
+ } else {
57
+ if (typeof args === "string") {
58
+ args = args.split(/\s+/);
59
+ }
60
+ const child = spawn("ps", args);
61
+ stdout = "";
62
+ stderr = null;
63
+ child.stdout.on("data", function(data) {
64
+ stdout += data.toString();
65
+ });
66
+ child.stderr.on("data", function(data) {
67
+ if (stderr === null) {
68
+ stderr = data.toString();
69
+ } else {
70
+ stderr += data.toString();
71
+ }
72
+ });
73
+ child.on("exit", function() {
74
+ if (stderr) {
75
+ return callback(stderr.toString());
76
+ } else {
77
+ callback(null, stdout || false);
78
+ }
79
+ });
80
+ }
81
+ };
82
+ exports.lookup = function(query, callback) {
83
+ var exeArgs = query.psargs || ["lx"];
84
+ var filter = {};
85
+ var idList;
86
+ if (query.pid) {
87
+ if (Array.isArray(query.pid)) {
88
+ idList = query.pid;
89
+ } else {
90
+ idList = [query.pid];
91
+ }
92
+ idList = idList.map(function(v) {
93
+ return String(v);
94
+ });
95
+ }
96
+ if (query.command) {
97
+ filter["command"] = new RegExp(query.command, "i");
98
+ }
99
+ if (query.arguments) {
100
+ filter["arguments"] = new RegExp(query.arguments, "i");
101
+ }
102
+ if (query.ppid) {
103
+ filter["ppid"] = new RegExp(query.ppid);
104
+ }
105
+ return Exec(exeArgs, function(err, output) {
106
+ if (err) {
107
+ return callback(err);
108
+ } else {
109
+ var processList = parseGrid(output);
110
+ var resultList = [];
111
+ processList.forEach(function(p) {
112
+ var flt;
113
+ var type;
114
+ var result = true;
115
+ if (idList && idList.indexOf(String(p.pid)) < 0) {
116
+ return;
117
+ }
118
+ for (type in filter) {
119
+ flt = filter[type];
120
+ result = flt.test(p[type]) ? result : false;
121
+ }
122
+ if (result) {
123
+ resultList.push(p);
124
+ }
125
+ });
126
+ callback(null, resultList);
127
+ }
128
+ });
129
+ };
130
+ exports.kill = function(pid, signal, next) {
131
+ if (arguments.length == 2 && typeof signal == "function") {
132
+ next = signal;
133
+ signal = void 0;
134
+ }
135
+ var checkTimeoutSeconds = signal && signal.timeout || 30;
136
+ if (typeof signal === "object") {
137
+ signal = signal.signal;
138
+ }
139
+ try {
140
+ process.kill(pid, signal);
141
+ } catch (e) {
142
+ return next && next(e);
143
+ }
144
+ var checkConfident = 0;
145
+ var checkTimeoutTimer = null;
146
+ var checkIsTimeout = false;
147
+ function checkKilled(finishCallback) {
148
+ exports.lookup({ pid }, function(err, list) {
149
+ if (checkIsTimeout) return;
150
+ if (err) {
151
+ clearTimeout(checkTimeoutTimer);
152
+ finishCallback && finishCallback(err);
153
+ } else if (list.length > 0) {
154
+ checkConfident = checkConfident - 1 || 0;
155
+ checkKilled(finishCallback);
156
+ } else {
157
+ checkConfident++;
158
+ if (checkConfident === 5) {
159
+ clearTimeout(checkTimeoutTimer);
160
+ finishCallback && finishCallback();
161
+ } else {
162
+ checkKilled(finishCallback);
163
+ }
164
+ }
165
+ });
166
+ }
167
+ next && checkKilled(next);
168
+ checkTimeoutTimer = next && setTimeout(function() {
169
+ checkIsTimeout = true;
170
+ next(new Error("Kill process timeout"));
171
+ }, checkTimeoutSeconds * 1e3);
172
+ };
173
+ function parseGrid(output) {
174
+ if (!output) {
175
+ return [];
176
+ }
177
+ return formatOutput(TableParser.parse(output));
178
+ }
179
+ function formatOutput(data) {
180
+ var formatedData = [];
181
+ data.forEach(function(d) {
182
+ var pid = d.PID && d.PID[0] || d.ProcessId && d.ProcessId[0] || void 0;
183
+ var cmd = d.CMD || d.CommandLine || d.COMMAND || void 0;
184
+ var ppid = d.PPID && d.PPID[0] || d.ParentProcessId && d.ParentProcessId[0] || void 0;
185
+ if (pid && cmd) {
186
+ var command = cmd[0];
187
+ var args = "";
188
+ if (cmd.length > 1) {
189
+ args = cmd.slice(1);
190
+ }
191
+ formatedData.push({
192
+ pid,
193
+ command,
194
+ arguments: args,
195
+ ppid
196
+ });
197
+ }
198
+ });
199
+ return formatedData;
200
+ }
201
+ }
202
+ });
203
+ export default require_ps();
@@ -0,0 +1,3 @@
1
+ // src/ps/isWin.js
2
+ var isWin = process.platform === "win32";
3
+ module.exports = isWin;
@@ -0,0 +1,3 @@
1
+ declare const isWin: boolean;
2
+
3
+ export { isWin as default };
@@ -0,0 +1,2 @@
1
+ export = isWin;
2
+ declare const isWin: boolean;
@@ -0,0 +1,2 @@
1
+ const isWin = process.platform === "win32";
2
+ module.exports = isWin;
@@ -0,0 +1,7 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_isWin
4
+ } from "../chunk-JL32QDSH.mjs";
5
+ import "../chunk-VXZQNLPU.mjs";
6
+ import "../chunk-FB6YIQYR.mjs";
7
+ export default require_isWin();