binary-collections 2.0.5 → 2.0.6

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 (104) 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-fix-encoding +7 -2
  7. package/bin/git-reduce-size +7 -2
  8. package/bin/kill-process +7 -2
  9. package/bin/nodekill +7 -2
  10. package/bin/prod +7 -2
  11. package/bin/rmfind +7 -2
  12. package/bin/rmpath +7 -2
  13. package/bin/rmx +9 -3
  14. package/bin/submodule +13 -2
  15. package/bin/submodule-install +7 -2
  16. package/bin/submodule-remove +7 -2
  17. package/eslint.config.cjs +97 -0
  18. package/lib/chunk-7MSZ52XC.mjs +14 -0
  19. package/lib/chunk-AVDT32AY.mjs +20 -0
  20. package/lib/chunk-E75HJFJO.mjs +20 -0
  21. package/lib/chunk-GA4DDV65.mjs +202 -0
  22. package/lib/chunk-LPLPQBYP.mjs +53 -0
  23. package/lib/chunk-M4IBUK4H.mjs +173 -0
  24. package/lib/chunk-S4SJ7SDW.mjs +625 -0
  25. package/lib/del-gradle.cjs +72 -0
  26. package/lib/del-gradle.d.mts +2 -0
  27. package/lib/del-gradle.d.ts +2 -0
  28. package/lib/del-gradle.js +72 -0
  29. package/lib/del-gradle.mjs +28 -0
  30. package/lib/del-node-modules.cjs +72 -0
  31. package/lib/del-node-modules.d.mts +2 -0
  32. package/lib/del-node-modules.d.ts +2 -0
  33. package/lib/del-node-modules.js +63 -10
  34. package/lib/del-node-modules.mjs +28 -0
  35. package/lib/del-ps.cjs +706 -0
  36. package/lib/del-ps.d.mts +2 -0
  37. package/lib/del-ps.d.ts +2 -0
  38. package/lib/del-ps.js +706 -0
  39. package/lib/del-ps.mjs +46 -0
  40. package/lib/del-yarn-caches.cjs +65 -0
  41. package/lib/del-yarn-caches.d.mts +2 -0
  42. package/lib/del-yarn-caches.d.ts +2 -0
  43. package/lib/del-yarn-caches.js +60 -6
  44. package/lib/del-yarn-caches.mjs +21 -0
  45. package/lib/find-node-modules.cjs +12 -0
  46. package/lib/find-node-modules.d.mts +2 -0
  47. package/lib/find-node-modules.d.ts +2 -0
  48. package/lib/find-node-modules.js +6 -7
  49. package/lib/find-node-modules.mjs +21 -0
  50. package/lib/git-purge.cjs +704 -0
  51. package/lib/git-purge.d.mts +2 -0
  52. package/lib/git-purge.d.ts +2 -0
  53. package/lib/git-purge.js +704 -0
  54. package/lib/git-purge.mjs +50 -0
  55. package/lib/index.cjs +2 -0
  56. package/lib/index.d.mts +2 -0
  57. package/lib/index.d.ts +2 -0
  58. package/{index.js → lib/index.js} +1 -0
  59. package/lib/index.mjs +9 -0
  60. package/lib/npm-run-series.cjs +61 -0
  61. package/lib/npm-run-series.d.mts +1 -0
  62. package/lib/npm-run-series.d.ts +1 -0
  63. package/lib/npm-run-series.js +37 -20
  64. package/lib/npm-run-series.mjs +47 -0
  65. package/lib/package-resolutions.cjs +28 -0
  66. package/lib/package-resolutions.d.mts +25 -0
  67. package/lib/package-resolutions.d.ts +25 -0
  68. package/lib/package-resolutions.js +28 -0
  69. package/lib/package-resolutions.mjs +31 -0
  70. package/lib/ps/connected-domain.cjs +156 -0
  71. package/lib/ps/connected-domain.d.mts +3 -0
  72. package/lib/ps/connected-domain.d.ts +3 -0
  73. package/lib/ps/connected-domain.js +156 -0
  74. package/lib/ps/connected-domain.mjs +7 -0
  75. package/lib/ps/index.cjs +555 -0
  76. package/lib/ps/index.d.cjs +17 -0
  77. package/lib/ps/index.d.d.mts +26 -0
  78. package/lib/ps/index.d.d.ts +26 -0
  79. package/lib/ps/index.d.js +17 -0
  80. package/lib/ps/index.d.mjs +8 -0
  81. package/lib/ps/index.d.mts +26 -0
  82. package/lib/ps/index.d.ts +26 -0
  83. package/lib/ps/index.js +555 -0
  84. package/lib/ps/index.mjs +203 -0
  85. package/lib/ps/isWin.cjs +3 -0
  86. package/lib/ps/isWin.d.mts +3 -0
  87. package/lib/ps/isWin.d.ts +3 -0
  88. package/lib/ps/isWin.js +3 -0
  89. package/lib/ps/isWin.mjs +7 -0
  90. package/lib/ps/table-parser.cjs +359 -0
  91. package/lib/ps/table-parser.d.mts +3 -0
  92. package/lib/ps/table-parser.d.ts +3 -0
  93. package/lib/ps/table-parser.js +359 -0
  94. package/lib/ps/table-parser.mjs +8 -0
  95. package/lib/utils.cjs +35 -0
  96. package/lib/utils.d.mts +20 -0
  97. package/lib/utils.d.ts +20 -0
  98. package/lib/utils.js +22 -23
  99. package/lib/utils.mjs +7 -0
  100. package/package.json +76 -32
  101. package/readme.md +23 -0
  102. package/src/ps/index.js +285 -0
  103. package/test/package.json +19 -0
  104. package/lib/package-resolutions.json +0 -22
package/readme.md CHANGED
@@ -11,6 +11,8 @@ git clone -b master https://github.com/dimaslanjaka/bin bin
11
11
  via npm
12
12
  ```bash
13
13
  npm install binary-collections
14
+ # or install as global package
15
+ npm install binary-collections -g
14
16
  # or
15
17
  npm install binary-collections@git+https://github.com/dimaslanjaka/bin.git
16
18
  # or
@@ -65,6 +67,11 @@ see all binary at
65
67
  - https://github.com/dimaslanjaka/bin/tree/master/lib
66
68
  - https://github.com/dimaslanjaka/bin/blob/master/package.json
67
69
 
70
+ submodule remover
71
+
72
+ ![image](https://github.com/user-attachments/assets/659c2fa3-f12f-45cb-a66f-aed3807e0023)
73
+
74
+
68
75
  ### npm scripts runner
69
76
 
70
77
  > binaries: `nrs`, `run-s`, `run-series`
@@ -106,6 +113,22 @@ del-nodemodules
106
113
  del-yarncaches
107
114
  ```
108
115
 
116
+ ## gradle caches cleaner
117
+
118
+ - delete gradle build folder
119
+
120
+ ```bash
121
+ del-gradle
122
+ ```
123
+
124
+ ## Git purge
125
+
126
+ - prune reflogs from all git repositories
127
+
128
+ ```bash
129
+ git-purge
130
+ ```
131
+
109
132
  ![image](https://github.com/dimaslanjaka/bin/assets/12471057/2805c54e-28a7-491d-b381-de2593a854b3)
110
133
 
111
134
  ## troubleshooting
@@ -0,0 +1,285 @@
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
+
14
+ // ps-node
15
+
16
+ /**
17
+ * Execute child process
18
+ * @type {Function}
19
+ * @param {String[]} args
20
+ * @param {Function} callback
21
+ * @param {Object=null} callback.err
22
+ * @param {Object[]} callback.stdout
23
+ */
24
+
25
+ var Exec =
26
+ (module.exports =
27
+ exports =
28
+ function (args, callback) {
29
+ var spawn = ChildProcess.spawn;
30
+
31
+ // on windows, if use ChildProcess.exec(`wmic process get`), the stdout will gives you nothing
32
+ // that's why I use `cmd` instead
33
+ if (IS_WIN) {
34
+ var CMD = spawn("cmd");
35
+ var stdout = "";
36
+ var stderr = null;
37
+
38
+ CMD.stdout.on("data", function (data) {
39
+ stdout += data.toString();
40
+ });
41
+
42
+ CMD.stderr.on("data", function (data) {
43
+ if (stderr === null) {
44
+ stderr = data.toString();
45
+ } else {
46
+ stderr += data.toString();
47
+ }
48
+ });
49
+
50
+ CMD.on("exit", function () {
51
+ var beginRow;
52
+ stdout = stdout.split(EOL);
53
+
54
+ // Find the line index for the titles
55
+ stdout.forEach(function (out, index) {
56
+ if (out && typeof beginRow == "undefined" && out.indexOf("CommandLine") === 0) {
57
+ beginRow = index;
58
+ }
59
+ });
60
+
61
+ // get rid of the start (copyright) and the end (current pwd)
62
+ stdout.splice(stdout.length - 1, 1);
63
+ stdout.splice(0, beginRow);
64
+
65
+ callback(stderr, stdout.join(SystemEOL) || false);
66
+ });
67
+
68
+ CMD.stdin.write("wmic process get ProcessId,ParentProcessId,CommandLine \n");
69
+ CMD.stdin.end();
70
+ } else {
71
+ if (typeof args === "string") {
72
+ args = args.split(/\s+/);
73
+ }
74
+ const child = spawn("ps", args);
75
+ stdout = "";
76
+ stderr = null;
77
+
78
+ child.stdout.on("data", function (data) {
79
+ stdout += data.toString();
80
+ });
81
+
82
+ child.stderr.on("data", function (data) {
83
+ if (stderr === null) {
84
+ stderr = data.toString();
85
+ } else {
86
+ stderr += data.toString();
87
+ }
88
+ });
89
+
90
+ child.on("exit", function () {
91
+ if (stderr) {
92
+ return callback(stderr.toString());
93
+ } else {
94
+ callback(null, stdout || false);
95
+ }
96
+ });
97
+ }
98
+ });
99
+
100
+ /**
101
+ * Query Process: Focus on pid & cmd
102
+ * @param query
103
+ * @param {String|String[]} query.pid
104
+ * @param {String} query.command RegExp String
105
+ * @param {String} query.arguments RegExp String
106
+ * @param {String|array} query.psargs
107
+ * @param {Function} callback
108
+ * @param {Object=null} callback.err
109
+ * @param {Object[]} callback.processList
110
+ * @return {Object}
111
+ */
112
+
113
+ exports.lookup = function (query, callback) {
114
+ /**
115
+ * add 'lx' as default ps arguments, since the default ps output in linux like "ubuntu", wont include command arguments
116
+ */
117
+ var exeArgs = query.psargs || ["lx"];
118
+ var filter = {};
119
+ var idList;
120
+
121
+ // Lookup by PID
122
+ if (query.pid) {
123
+ if (Array.isArray(query.pid)) {
124
+ idList = query.pid;
125
+ } else {
126
+ idList = [query.pid];
127
+ }
128
+
129
+ // Cast all PIDs as Strings
130
+ idList = idList.map(function (v) {
131
+ return String(v);
132
+ });
133
+ }
134
+
135
+ if (query.command) {
136
+ filter["command"] = new RegExp(query.command, "i");
137
+ }
138
+
139
+ if (query.arguments) {
140
+ filter["arguments"] = new RegExp(query.arguments, "i");
141
+ }
142
+
143
+ if (query.ppid) {
144
+ filter["ppid"] = new RegExp(query.ppid);
145
+ }
146
+
147
+ return Exec(exeArgs, function (err, output) {
148
+ if (err) {
149
+ return callback(err);
150
+ } else {
151
+ var processList = parseGrid(output);
152
+ var resultList = [];
153
+
154
+ processList.forEach(function (p) {
155
+ var flt;
156
+ var type;
157
+ var result = true;
158
+
159
+ if (idList && idList.indexOf(String(p.pid)) < 0) {
160
+ return;
161
+ }
162
+
163
+ for (type in filter) {
164
+ flt = filter[type];
165
+ result = flt.test(p[type]) ? result : false;
166
+ }
167
+
168
+ if (result) {
169
+ resultList.push(p);
170
+ }
171
+ });
172
+
173
+ callback(null, resultList);
174
+ }
175
+ });
176
+ };
177
+
178
+ /**
179
+ * Kill process
180
+ * @param pid
181
+ * @param {Object|String} signal
182
+ * @param {String} signal.signal
183
+ * @param {number} signal.timeout
184
+ * @param next
185
+ */
186
+
187
+ exports.kill = function (pid, signal, next) {
188
+ //opts are optional
189
+ if (arguments.length == 2 && typeof signal == "function") {
190
+ next = signal;
191
+ signal = undefined;
192
+ }
193
+
194
+ var checkTimeoutSeconds = (signal && signal.timeout) || 30;
195
+
196
+ if (typeof signal === "object") {
197
+ signal = signal.signal;
198
+ }
199
+
200
+ try {
201
+ process.kill(pid, signal);
202
+ } catch (e) {
203
+ return next && next(e);
204
+ }
205
+
206
+ var checkConfident = 0;
207
+ var checkTimeoutTimer = null;
208
+ var checkIsTimeout = false;
209
+
210
+ function checkKilled(finishCallback) {
211
+ exports.lookup({ pid: pid }, function (err, list) {
212
+ if (checkIsTimeout) return;
213
+
214
+ if (err) {
215
+ clearTimeout(checkTimeoutTimer);
216
+ finishCallback && finishCallback(err);
217
+ } else if (list.length > 0) {
218
+ checkConfident = checkConfident - 1 || 0;
219
+ checkKilled(finishCallback);
220
+ } else {
221
+ checkConfident++;
222
+ if (checkConfident === 5) {
223
+ clearTimeout(checkTimeoutTimer);
224
+ finishCallback && finishCallback();
225
+ } else {
226
+ checkKilled(finishCallback);
227
+ }
228
+ }
229
+ });
230
+ }
231
+
232
+ next && checkKilled(next);
233
+
234
+ checkTimeoutTimer =
235
+ next &&
236
+ setTimeout(function () {
237
+ checkIsTimeout = true;
238
+ next(new Error("Kill process timeout"));
239
+ }, checkTimeoutSeconds * 1000);
240
+ };
241
+
242
+ /**
243
+ * Parse the stdout into readable object.
244
+ * @param {String} output
245
+ */
246
+
247
+ function parseGrid(output) {
248
+ if (!output) {
249
+ return [];
250
+ }
251
+ return formatOutput(TableParser.parse(output));
252
+ }
253
+
254
+ /**
255
+ * format the structure, extract pid, command, arguments, ppid
256
+ * @param data
257
+ * @return {Array}
258
+ */
259
+
260
+ function formatOutput(data) {
261
+ var formatedData = [];
262
+ data.forEach(function (d) {
263
+ var pid = (d.PID && d.PID[0]) || (d.ProcessId && d.ProcessId[0]) || undefined;
264
+ var cmd = d.CMD || d.CommandLine || d.COMMAND || undefined;
265
+ var ppid = (d.PPID && d.PPID[0]) || (d.ParentProcessId && d.ParentProcessId[0]) || undefined;
266
+
267
+ if (pid && cmd) {
268
+ var command = cmd[0];
269
+ var args = "";
270
+
271
+ if (cmd.length > 1) {
272
+ args = cmd.slice(1);
273
+ }
274
+
275
+ formatedData.push({
276
+ pid: pid,
277
+ command: command,
278
+ arguments: args,
279
+ ppid: ppid
280
+ });
281
+ }
282
+ });
283
+
284
+ return formatedData;
285
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "test",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "build:a": "echo a",
8
+ "build:b": "echo b",
9
+ "build:c": "echo c",
10
+ "test": "npm-run-series build:**",
11
+ "install-deps": "npm i -D file:../"
12
+ },
13
+ "keywords": [],
14
+ "author": "",
15
+ "license": "ISC",
16
+ "devDependencies": {
17
+ "binary-collections": "./.."
18
+ }
19
+ }
@@ -1,22 +0,0 @@
1
- {
2
- "resolutions": {
3
- "cross-spawn": "https://github.com/dimaslanjaka/node-cross-spawn/raw/private/release/cross-spawn.tgz",
4
- "safelinkify": "https://github.com/dimaslanjaka/safelink/raw/monorepo/release/safelinkify.tgz",
5
- "sbg-api": "https://github.com/dimaslanjaka/static-blog-generator/raw/beta/packages/sbg-api/release/sbg-api.tgz",
6
- "sbg-cli": "https://github.com/dimaslanjaka/static-blog-generator/raw/beta/packages/sbg-cli/release/sbg-cli.tgz",
7
- "sbg-server": "https://github.com/dimaslanjaka/static-blog-generator/raw/beta/packages/sbg-server/release/sbg-server.tgz",
8
- "sbg-utility": "https://github.com/dimaslanjaka/static-blog-generator/raw/beta/packages/sbg-utility/release/sbg-utility.tgz",
9
- "sitemap-crawler": "https://github.com/dimaslanjaka/static-blog-generator/raw/beta/packages/sitemap-crawler/release/sitemap-crawler.tgz",
10
- "static-blog-generator": "https://github.com/dimaslanjaka/static-blog-generator/raw/beta/packages/static-blog-generator/release/static-blog-generator.tgz",
11
- "hexo-blogger-xml": "https://github.com/dimaslanjaka/hexo-blogger-xml/raw/monorepo/release/hexo-blogger-xml.tgz",
12
- "hexo-post-parser": "https://github.com/dimaslanjaka/hexo-post-parser/raw/monorepo/release/hexo-post-parser.tgz",
13
- "hexo-asset-link": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo-asset-link.tgz",
14
- "hexo-front-matter": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo-front-matter.tgz",
15
- "hexo": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo.tgz",
16
- "hexo-log": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo-log.tgz",
17
- "hexo-util": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo-util.tgz",
18
- "warehouse": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/warehouse.tgz",
19
- "git-command-helper": "https://github.com/dimaslanjaka/git-command-helper/raw/monorepo/release/git-command-helper.tgz",
20
- "instant-indexing": "https://github.com/dimaslanjaka/static-blog-generator/raw/beta/packages/instant-indexing/release/instant-indexing.tgz"
21
- }
22
- }