binary-collections 2.0.8 → 2.0.10

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 (250) hide show
  1. package/binaries/binary-executor.cjs +43 -0
  2. package/{bin → binaries}/clean-nodemodule +0 -0
  3. package/binaries/clean-nodemodule.cjs +43 -0
  4. package/binaries/clean-nodemodule.cmd +4 -0
  5. package/{bin → binaries}/clean-nodemodules +0 -0
  6. package/binaries/clean-nodemodules.cjs +43 -0
  7. package/binaries/clean-nodemodules.cmd +5 -0
  8. package/{bin → binaries}/dev +0 -0
  9. package/binaries/dev.cjs +43 -0
  10. package/{bin → binaries}/empty +0 -0
  11. package/binaries/empty.cjs +43 -0
  12. package/{bin → binaries}/git-reduce-size +0 -0
  13. package/binaries/git-reduce-size.cjs +43 -0
  14. package/binaries/javakill.cjs +43 -0
  15. package/{bin → binaries}/javakill.cmd +0 -0
  16. package/{bin → binaries}/kill-process +0 -0
  17. package/binaries/kill-process.cjs +43 -0
  18. package/binaries/nodekill.cjs +43 -0
  19. package/{bin → binaries}/nodekill.ps1 +0 -0
  20. package/{bin → binaries}/prod +0 -0
  21. package/binaries/prod.cjs +43 -0
  22. package/{bin → binaries}/rmfind +0 -0
  23. package/binaries/rmfind.cjs +43 -0
  24. package/{bin → binaries}/rmx +0 -0
  25. package/binaries/rmx.cjs +43 -0
  26. package/{bin → binaries}/submodule-token +0 -0
  27. package/binaries/submodule-token.cjs +43 -0
  28. package/docs-src/clean-github-actions-caches.md +26 -0
  29. package/docs-src/free-chatgpt.md +26 -0
  30. package/lib/binary-collections-config.cjs +3 -2
  31. package/lib/binary-collections-config.mjs +2 -2
  32. package/lib/binary-collections.cjs +452 -87
  33. package/lib/binary-collections.mjs +247 -8
  34. package/lib/changelog.cjs +328 -0
  35. package/lib/changelog.mjs +205 -0
  36. package/lib/chunk-4EWQC6GZ.mjs +382 -0
  37. package/lib/chunk-4ZI7BQKQ.mjs +381 -0
  38. package/lib/chunk-5J2BEPY5.mjs +83 -0
  39. package/lib/{chunk-4BYBVEYC.mjs → chunk-66PAU5PS.mjs} +5 -4
  40. package/lib/chunk-6HHJRKFB.mjs +59 -0
  41. package/lib/chunk-6S4NXESK.mjs +26 -0
  42. package/lib/{chunk-ZYAQRPUL.mjs → chunk-7YD7IPFF.mjs} +2 -2
  43. package/lib/{chunk-SH3L6HHV.mjs → chunk-A2JQXI5Z.mjs} +2 -2
  44. package/lib/{chunk-EGSSKVDH.mjs → chunk-A3VUZEJK.mjs} +1 -1
  45. package/lib/chunk-AGZYRDC2.mjs +323 -0
  46. package/lib/{chunk-VVEZVNIV.mjs → chunk-AI4CVPJ7.mjs} +6 -6
  47. package/lib/chunk-BDCHCWHD.mjs +136 -0
  48. package/lib/chunk-BEZKJ25G.mjs +140 -0
  49. package/lib/chunk-DI5MDPSN.mjs +386 -0
  50. package/lib/{chunk-ONIBBBQ3.mjs → chunk-E6FDDAOO.mjs} +4 -3
  51. package/lib/chunk-FKI7IEB5.mjs +172 -0
  52. package/lib/chunk-GJTGHXRA.mjs +356 -0
  53. package/lib/{chunk-YV7DO3YV.mjs → chunk-HLGOWBEO.mjs} +1 -1
  54. package/lib/chunk-HMRMTYZM.mjs +40 -0
  55. package/lib/chunk-HN52G2YL.mjs +305 -0
  56. package/lib/chunk-HO6GHCOB.mjs +385 -0
  57. package/lib/chunk-LEM5OMRP.mjs +384 -0
  58. package/lib/{chunk-YX5U7XDR.mjs → chunk-M3YIYRHT.mjs} +6 -5
  59. package/lib/chunk-O6SWBEOQ.mjs +81 -0
  60. package/lib/{chunk-JGR2NW6D.mjs → chunk-PDSXF5HY.mjs} +3 -3
  61. package/lib/{chunk-AASHBCRW.mjs → chunk-QQ4A6DLD.mjs} +8 -0
  62. package/lib/chunk-RCP7DHVY.mjs +190 -0
  63. package/lib/chunk-SBNDSKG5.mjs +136 -0
  64. package/lib/chunk-U6SO4QEV.mjs +320 -0
  65. package/lib/{chunk-APBWENF6.mjs → chunk-V3N3JEUF.mjs} +3 -3
  66. package/lib/chunk-XD6BJK6Q.mjs +351 -0
  67. package/lib/chunk-XVBFFVCJ.mjs +209 -0
  68. package/lib/chunk-YXSFGA2D.mjs +383 -0
  69. package/lib/clean-github-actions-caches.cjs +243 -148
  70. package/lib/clean-github-actions-caches.mjs +4 -3
  71. package/lib/del-gradle.cjs +2 -2
  72. package/lib/del-gradle.js +1 -1
  73. package/lib/del-gradle.mjs +2 -2
  74. package/lib/del-node-modules.cjs +2 -2
  75. package/lib/del-node-modules.js +1 -1
  76. package/lib/del-node-modules.mjs +2 -2
  77. package/lib/del-ps.cjs +29 -8
  78. package/lib/del-ps.js +2 -2
  79. package/lib/del-ps.mjs +7 -5
  80. package/lib/del-yarn-caches.cjs +26 -5
  81. package/lib/del-yarn-caches.js +38 -3
  82. package/lib/del-yarn-caches.mjs +6 -6
  83. package/lib/find-node-modules-cli.cjs +5 -4
  84. package/lib/find-node-modules-cli.js +1 -1
  85. package/lib/find-node-modules-cli.mjs +2 -2
  86. package/lib/find-node-modules.cjs +4 -3
  87. package/lib/{find-node-modules.d.ts → find-node-modules.d.cts} +1 -1
  88. package/lib/find-node-modules.mjs +2 -2
  89. package/lib/free-chatgpt.cjs +548 -0
  90. package/lib/free-chatgpt.d.ts +1 -0
  91. package/lib/free-chatgpt.js +51 -0
  92. package/lib/free-chatgpt.mjs +50 -0
  93. package/lib/git/gitattributes.cjs +1 -1
  94. package/lib/git/{gitattributes.d.mts → gitattributes.d.cts} +5 -7
  95. package/lib/git/gitattributes.mjs +2 -2
  96. package/lib/git/line-endings.cjs +297 -64
  97. package/lib/git/line-endings.mjs +4 -4
  98. package/lib/git/normalize.cjs +26 -36
  99. package/lib/git/normalize.mjs +2 -2
  100. package/lib/git/permissions.cjs +77 -11
  101. package/lib/git/permissions.mjs +3 -3
  102. package/lib/git/pull-strategy.cjs +76 -9
  103. package/lib/git/pull-strategy.mjs +3 -3
  104. package/lib/git/user-config.cjs +266 -83
  105. package/lib/git/user-config.mjs +4 -4
  106. package/lib/git/utils.cjs +40 -60
  107. package/lib/git/utils.mjs +2 -2
  108. package/lib/git-diff-cli.cjs +651 -0
  109. package/lib/git-diff-cli.d.ts +1 -0
  110. package/lib/git-diff-cli.js +15 -0
  111. package/lib/git-diff-cli.mjs +16 -0
  112. package/lib/git-diff.cjs +657 -58
  113. package/lib/git-diff.d.ts +38 -83
  114. package/lib/git-diff.js +152 -0
  115. package/lib/git-diff.mjs +23 -85
  116. package/lib/git-fix.cjs +685 -97
  117. package/lib/git-fix.mjs +12 -11
  118. package/lib/git-purge.cjs +3 -3
  119. package/lib/git-purge.d.cts +1 -0
  120. package/lib/git-purge.mjs +43 -37
  121. package/lib/index.cjs +7 -6
  122. package/lib/index.d.ts +1 -1
  123. package/lib/index.js +2 -5
  124. package/lib/index.mjs +4 -4
  125. package/lib/npm-run-series.cjs +3 -3
  126. package/lib/npm-run-series.mjs +42 -36
  127. package/lib/package-resolutions-updater.cjs +174 -1
  128. package/lib/package-resolutions-updater.mjs +270 -290
  129. package/lib/print-directory-tree.cjs +275 -210
  130. package/lib/print-directory-tree.mjs +2 -2
  131. package/lib/ps/connected-domain.cjs +25 -2
  132. package/lib/ps/connected-domain.d.ts +10 -2
  133. package/lib/ps/connected-domain.js +5 -2
  134. package/lib/ps/connected-domain.mjs +8 -4
  135. package/lib/ps/index.cjs +345 -322
  136. package/lib/ps/index.d.mjs +1 -1
  137. package/lib/ps/index.js +1 -1
  138. package/lib/ps/index.mjs +179 -182
  139. package/lib/ps/isWin.cjs +24 -1
  140. package/lib/ps/isWin.d.ts +1 -1
  141. package/lib/ps/isWin.js +3 -1
  142. package/lib/ps/isWin.mjs +8 -4
  143. package/lib/ps/table-parser.cjs +167 -159
  144. package/lib/ps/table-parser.d.ts +5 -0
  145. package/lib/ps/table-parser.js +10 -4
  146. package/lib/ps/table-parser.mjs +9 -5
  147. package/lib/remove-module.cjs +262 -0
  148. package/lib/remove-module.d.mts +1 -0
  149. package/lib/remove-module.mjs +111 -0
  150. package/lib/rmpath.cjs +274 -0
  151. package/lib/rmpath.d.mts +3 -0
  152. package/lib/rmpath.mjs +108 -0
  153. package/lib/submodule-install.cjs +264 -85
  154. package/lib/submodule-install.mjs +56 -7
  155. package/lib/submodule-remove-cli.cjs +103 -0
  156. package/lib/submodule-remove-cli.d.ts +1 -0
  157. package/lib/submodule-remove-cli.js +31 -0
  158. package/lib/submodule-remove-cli.mjs +28 -0
  159. package/lib/submodule-remove.cjs +43 -0
  160. package/lib/submodule-remove.d.cts +2 -0
  161. package/lib/submodule-remove.mjs +6 -0
  162. package/lib/utils/chatgpt.cjs +383 -0
  163. package/lib/utils/chatgpt.d.ts +31 -0
  164. package/lib/utils/chatgpt.js +541 -0
  165. package/lib/utils/chatgpt.mjs +8 -0
  166. package/lib/{utils.cjs → utils/index.cjs} +1 -1
  167. package/lib/{utils.mjs → utils/index.mjs} +2 -2
  168. package/lib/yarn-reinstall.cjs +172 -38
  169. package/lib/yarn-reinstall.mjs +2 -2
  170. package/package.json +91 -71
  171. package/readme.md +43 -69
  172. package/releases/readme.md +36 -0
  173. package/test/README.md +101 -0
  174. package/test/package.json +2 -1
  175. package/test-project/readme.md +26 -0
  176. package/tmp/test-repo/README.md +35 -0
  177. package/tmp/typedoc/readme.md +320 -0
  178. package/bin/bash-dummy +0 -56
  179. package/bin/bash-dummy.cmd +0 -25
  180. package/bin/dir-tree.cmd +0 -7
  181. package/bin/git-diff +0 -4
  182. package/bin/git-diff.cmd +0 -7
  183. package/bin/git-fix +0 -36
  184. package/bin/git-fix.cmd +0 -7
  185. package/bin/rmpath +0 -70
  186. package/bin/submodule-install.txt +0 -118
  187. package/bin/submodule-remove +0 -46
  188. package/bin/submodule.txt +0 -172
  189. package/lib/binary-collections-config.d.mts +0 -18
  190. package/lib/binary-collections-config.js +0 -39
  191. package/lib/binary-collections.d.mts +0 -121
  192. package/lib/binary-collections.d.ts +0 -121
  193. package/lib/chunk-DPKAJKFO.mjs +0 -171
  194. package/lib/chunk-G3THLIDT.mjs +0 -200
  195. package/lib/chunk-W3ENOM53.mjs +0 -18
  196. package/lib/clean-github-actions-caches.d.mts +0 -169
  197. package/lib/clean-github-actions-caches.d.ts +0 -169
  198. package/lib/del-gradle.d.mts +0 -2
  199. package/lib/del-node-modules.d.mts +0 -2
  200. package/lib/del-ps.d.mts +0 -2
  201. package/lib/del-yarn-caches.d.mts +0 -2
  202. package/lib/find-node-modules-cli.d.mts +0 -1
  203. package/lib/find-node-modules.d.mts +0 -13
  204. package/lib/find-node-modules.js +0 -53
  205. package/lib/git/line-endings.d.mts +0 -83
  206. package/lib/git/line-endings.d.ts +0 -83
  207. package/lib/git/normalize.d.mts +0 -43
  208. package/lib/git/normalize.d.ts +0 -43
  209. package/lib/git/permissions.d.mts +0 -17
  210. package/lib/git/permissions.d.ts +0 -17
  211. package/lib/git/pull-strategy.d.mts +0 -15
  212. package/lib/git/pull-strategy.d.ts +0 -15
  213. package/lib/git/user-config.d.mts +0 -105
  214. package/lib/git/user-config.d.ts +0 -105
  215. package/lib/git/utils.d.mts +0 -69
  216. package/lib/git/utils.d.ts +0 -69
  217. package/lib/git-diff.d.mts +0 -84
  218. package/lib/git-fix.d.mts +0 -141
  219. package/lib/git-fix.d.ts +0 -141
  220. package/lib/git-purge.d.mts +0 -2
  221. package/lib/git-purge.js +0 -59
  222. package/lib/index.d.mts +0 -1
  223. package/lib/npm-run-series.d.mts +0 -1
  224. package/lib/npm-run-series.d.ts +0 -2
  225. package/lib/npm-run-series.js +0 -86
  226. package/lib/package-resolutions-updater.d.ts +0 -326
  227. package/lib/print-directory-tree.d.mts +0 -234
  228. package/lib/print-directory-tree.d.ts +0 -234
  229. package/lib/ps/connected-domain.d.mts +0 -3
  230. package/lib/ps/index.d.d.mts +0 -26
  231. package/lib/ps/index.d.d.ts +0 -26
  232. package/lib/ps/index.d.mts +0 -26
  233. package/lib/ps/isWin.d.mts +0 -3
  234. package/lib/ps/table-parser.d.mts +0 -3
  235. package/lib/submodule-install.d.mts +0 -121
  236. package/lib/submodule-install.d.ts +0 -121
  237. package/lib/utils.d.mts +0 -40
  238. package/lib/utils.js +0 -181
  239. package/lib/yarn-reinstall.d.mts +0 -49
  240. package/lib/yarn-reinstall.d.ts +0 -49
  241. package/src/package-resolutions-updater.mjs +0 -325
  242. package/src/print-directory-tree.cjs +0 -234
  243. package/src/ps/index.js +0 -286
  244. package/src/yarn-reinstall.cjs +0 -49
  245. /package/{bin → binaries}/nodekill +0 -0
  246. /package/{bin → binaries}/nodekill.cmd +0 -0
  247. /package/lib/{binary-collections-config.d.ts → binary-collections-config.d.cts} +0 -0
  248. /package/lib/{git-purge.d.ts → changelog.d.cts} +0 -0
  249. /package/lib/{git-diff.d.cts → npm-run-series.d.cts} +0 -0
  250. /package/lib/{utils.d.ts → utils/index.d.cts} +0 -0
@@ -1,7 +1,8 @@
1
- // src/binary-collections-config.js
1
+ // src/binary-collections-config.cjs
2
2
  var path = require("path");
3
+ require("dotenv").config({ path: path.join(process.cwd(), ".env") });
3
4
  function getTempDir() {
4
- return process.env.TEMP_DIR || "tmp";
5
+ return process.env.TEMP_DIR || path.join(process.cwd(), "tmp");
5
6
  }
6
7
  function getTempPath(...segments) {
7
8
  return path.join(getTempDir(), ...segments);
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_binary_collections_config
4
- } from "./chunk-4BYBVEYC.mjs";
5
- import "./chunk-AASHBCRW.mjs";
4
+ } from "./chunk-66PAU5PS.mjs";
5
+ import "./chunk-QQ4A6DLD.mjs";
6
6
  export default require_binary_collections_config();
@@ -1,105 +1,470 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- const { spawn } = require("child_process");
4
- const { glob } = require("glob");
5
- const path = require("path");
6
- const { getArgs } = require("./utils.js");
7
- /**
8
- * Main binary-collections script that dynamically finds and executes other scripts
9
- * Usage: npx binary-collections <script-name> [...args]
10
- * Example: npx binary-collections git-diff -s
11
- */
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/utils/index.cjs
17
+ var require_utils = __commonJS({
18
+ "src/utils/index.cjs"(exports2, module2) {
19
+ init_cjs_shims();
20
+ var fs2 = require("fs");
21
+ var path2 = require("upath");
22
+ var argv = require("minimist")(process.argv.slice(2));
23
+ var { exec } = require("child_process");
24
+ var { URL: URL2 } = require("url");
25
+ var { promisify } = require("util");
26
+ var execAsync = promisify(exec);
27
+ async function parseGitRemotes() {
28
+ try {
29
+ const { stdout } = await execAsync("git remote -v");
30
+ const lines = stdout.split("\n");
31
+ const remotes = {};
32
+ lines.forEach((line) => {
33
+ const [name, url] = line.split(" ");
34
+ if (name && url) {
35
+ const [repoUrl] = url.split(" ");
36
+ try {
37
+ const parsedUrl = new URL2(repoUrl);
38
+ const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
39
+ if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
40
+ let repoPath = pathParts.join("/");
41
+ if (repoPath.endsWith(".git")) {
42
+ repoPath = repoPath.slice(0, -4);
43
+ }
44
+ remotes[name] = repoPath;
45
+ }
46
+ } catch (e) {
47
+ console.error("URL Parsing Error:", e.message);
48
+ }
49
+ }
50
+ });
51
+ return remotes;
52
+ } catch (error) {
53
+ console.error("Error:", error.message);
54
+ return {};
55
+ }
56
+ }
57
+ module2.exports.parseGitRemotes = parseGitRemotes;
58
+ function joinPathPreserveDriveLetter(...segments) {
59
+ let fullPath = require("path").join(...segments);
60
+ if (/^[a-z]:\\/.test(fullPath)) {
61
+ fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
62
+ }
63
+ return fullPath;
64
+ }
65
+ module2.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
66
+ function getArgs2() {
67
+ return argv;
68
+ }
69
+ module2.exports.getArgs = getArgs2;
70
+ function del(fullPath) {
71
+ if (fs2.statSync(fullPath).isDirectory()) {
72
+ const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
73
+ for (let i = 0; i < subdir.length; i++) {
74
+ del(subdir[i]);
75
+ }
76
+ } else {
77
+ try {
78
+ fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
79
+ console.log("deleted", fullPath);
80
+ } catch (_) {
81
+ console.log("failed delete", fullPath);
82
+ }
83
+ }
84
+ }
85
+ module2.exports.del = del;
86
+ function delStream(globStream) {
87
+ globStream.stream().on("data", (result) => {
88
+ const fullPath = path2.resolve(process.cwd(), result);
89
+ if (fs2.statSync(fullPath).isDirectory()) {
90
+ const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
91
+ for (let i = 0; i < subdir.length; i++) {
92
+ del(subdir[i]);
93
+ }
94
+ }
95
+ del(fullPath);
96
+ });
97
+ }
98
+ module2.exports.delStream = delStream;
99
+ function getFileTreeString(hashArray) {
100
+ const tree = {};
101
+ const hashMap = {};
102
+ for (const entry of hashArray) {
103
+ const [filePath, hash] = entry.split(" ");
104
+ hashMap[filePath] = hash;
105
+ const parts = filePath.split("/");
106
+ let current = tree;
107
+ for (let i = 0; i < parts.length; i++) {
108
+ const part = parts[i];
109
+ if (i === parts.length - 1) {
110
+ current[part] = null;
111
+ } else {
112
+ current[part] = current[part] || {};
113
+ current = current[part];
114
+ }
115
+ }
116
+ }
117
+ function printNode(node, prefix = "", parentPath = "") {
118
+ const keys = Object.keys(node).sort();
119
+ let lines = [];
120
+ keys.forEach((key, idx) => {
121
+ const isLast = idx === keys.length - 1;
122
+ const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
123
+ const currentPath = parentPath ? parentPath + "/" + key : key;
124
+ if (node[key] === null) {
125
+ lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
126
+ } else {
127
+ lines.push(prefix + branch + key + "/");
128
+ lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "\u2502 "), currentPath));
129
+ }
130
+ });
131
+ return lines;
132
+ }
133
+ return printNode(tree, "", "").join("\n");
134
+ }
135
+ module2.exports.getFileTreeString = getFileTreeString;
136
+ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
137
+ module2.exports.delay = delay;
138
+ }
139
+ });
140
+
141
+ // package.json
142
+ var require_package = __commonJS({
143
+ "package.json"(exports2, module2) {
144
+ module2.exports = {
145
+ name: "binary-collections",
146
+ version: "2.0.10",
147
+ description: "Utility to clean any programming caches and more",
148
+ keywords: [
149
+ "cache",
150
+ "cleaner",
151
+ "utility"
152
+ ],
153
+ homepage: "https://www.webmanajemen.com/",
154
+ bugs: {
155
+ url: "https://github.com/dimaslanjaka/bin/issues"
156
+ },
157
+ license: "MIT",
158
+ author: {
159
+ name: "dimaslanjaka",
160
+ email: "dimaslanjaka@gmail.com",
161
+ url: "https://webmanajemen.com"
162
+ },
163
+ type: "module",
164
+ main: "lib/index.js",
165
+ exports: {
166
+ ".": {
167
+ require: {
168
+ default: "./lib/index.cjs",
169
+ types: "./lib/index.d.ts"
170
+ },
171
+ import: {
172
+ default: "./lib/index.mjs",
173
+ types: "./lib/index.d.mts"
174
+ }
175
+ },
176
+ "./package.json": "./package.json"
177
+ },
178
+ types: "lib/index.d.ts",
179
+ files: [
180
+ "binaries",
181
+ "lib",
182
+ "package.json",
183
+ "docs-src/**/*.md",
184
+ "readme.md"
185
+ ],
186
+ bin: {
187
+ "binary-collections": "lib/binary-collections.cjs",
188
+ "binary-executor": "binaries/binary-executor.cjs",
189
+ changelog: "lib/changelog.cjs",
190
+ chatgpt: "lib/free-chatgpt.cjs",
191
+ "clean-github-actions-cache": "lib/clean-github-actions-caches.cjs",
192
+ "clean-github-actions-caches": "lib/clean-github-actions-caches.cjs",
193
+ "clean-nodemodule": "binaries/clean-nodemodule.cjs",
194
+ "clean-nodemodules": "binaries/clean-nodemodules.cjs",
195
+ "clear-gh-caches": "lib/clean-github-actions-caches.cjs",
196
+ "clear-github-actions-cache": "lib/clean-github-actions-caches.cjs",
197
+ "clear-github-actions-caches": "lib/clean-github-actions-caches.cjs",
198
+ "del-gradle": "lib/del-gradle.cjs",
199
+ "del-node-modules": "lib/del-node-modules.cjs",
200
+ "del-nodemodules": "lib/del-node-modules.cjs",
201
+ "del-ps": "lib/del-ps.cjs",
202
+ "del-yarn-caches": "lib/del-yarn-caches.cjs",
203
+ "del-yarncaches": "lib/del-yarn-caches.cjs",
204
+ dev: "binaries/dev.cjs",
205
+ "dir-tree": "lib/print-directory-tree.cjs",
206
+ empty: "binaries/empty.cjs",
207
+ "find-node-modules": "lib/find-node-modules-cli.cjs",
208
+ "free-chatgpt": "lib/free-chatgpt.cjs",
209
+ "git-diff": "lib/git-diff-cli.cjs",
210
+ "git-fix": "lib/git-fix.cjs",
211
+ "git-purge": "lib/git-purge.cjs",
212
+ "git-reduce-size": "binaries/git-reduce-size.cjs",
213
+ javakill: "binaries/javakill.cjs",
214
+ "kill-process": "binaries/kill-process.cjs",
215
+ nodekill: "binaries/nodekill.cjs",
216
+ "npm-run-series": "lib/npm-run-series.cjs",
217
+ nrs: "lib/npm-run-series.cjs",
218
+ "package-resolutions-updater": "lib/package-resolutions-updater.cjs",
219
+ "pkg-res-updater": "lib/package-resolutions-updater.cjs",
220
+ "pkg-resolutions-updater": "lib/package-resolutions-updater.cjs",
221
+ "print-directory-tree": "lib/print-directory-tree.cjs",
222
+ "print-tree": "lib/print-directory-tree.cjs",
223
+ prod: "binaries/prod.cjs",
224
+ "remove-module": "lib/remove-module.cjs",
225
+ rmfind: "binaries/rmfind.cjs",
226
+ rmpath: "lib/rmpath.cjs",
227
+ rmx: "binaries/rmx.cjs",
228
+ "run-s": "lib/npm-run-series.cjs",
229
+ "run-series": "lib/npm-run-series.cjs",
230
+ "submodule-install": "lib/submodule-install.cjs",
231
+ "submodule-remove": "lib/submodule-remove-cli.cjs",
232
+ "submodule-token": "binaries/submodule-token.cjs",
233
+ "yarn-reinstall": "lib/yarn-reinstall.cjs"
234
+ },
235
+ scripts: {
236
+ build: "tsc -b tsconfig.build.json && npm run build:tsup && npm run postbuild",
237
+ "build:packages": "yarn workspaces foreach --worktree --exclude=binary-collections --no-private run build",
238
+ "build:rollup": "rollup -c rollup.config.js",
239
+ "build:tsup": "node build.tsup.js",
240
+ clean: "rimraf lib tmp/dist binaries",
241
+ pack: "node packer.cjs --yarn --filename=bin",
242
+ postbuild: "node -r ts-node/register -r dotenv/config build.exports.mjs && yarn run pack",
243
+ prepare: "husky",
244
+ test: 'npx jest --runInBand --forceExit --testTimeout=120000 --testPathIgnorePatterns="\\.mjs$"',
245
+ "test:coverage": "npm test --coverage --detectOpenHandles",
246
+ "test:esm": 'node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --forceExit --testTimeout=120000 --testPathIgnorePatterns="\\.(ts|js|cjs)$"',
247
+ "test:nrs": "npm test -- nrs build:**",
248
+ "test:watch": "npm test --watch",
249
+ "update:ncu": "npx npm-check-updates -u -x jsdom,chalk,hexo,deepmerge-ts --enginesNode --root",
250
+ "update:packer": "curl -L https://github.com/dimaslanjaka/nodejs-package-types/raw/main/packer.js > packer.cjs"
251
+ },
252
+ repository: {
253
+ type: "git",
254
+ url: "git+https://github.com/dimaslanjaka/bin"
255
+ },
256
+ dependencies: {
257
+ "ansi-colors": "^4.1.3",
258
+ axios: "^1.11.0",
259
+ dotenv: "^17.2.1",
260
+ execa: "^9.6.0",
261
+ "fs-extra": "^11.3.1",
262
+ "git-command-helper": "^2.1.0",
263
+ glob: "^11.0.3",
264
+ minimatch: "^10.0.3",
265
+ minimist: "^1.2.8",
266
+ "ps-node": "^0.1.6",
267
+ puppeteer: "^24.17.0",
268
+ "puppeteer-extra": "^3.3.6",
269
+ "puppeteer-extra-plugin-stealth": "^2.11.2",
270
+ remove: "^0.1.5",
271
+ "sbg-utility": "^2.0.10",
272
+ upath: "^2.0.1",
273
+ yaml: "^2.8.1",
274
+ yarn: "^1.22.22"
275
+ },
276
+ devDependencies: {
277
+ "@babel/core": "^7.28.3",
278
+ "@babel/preset-env": "^7.28.3",
279
+ "@babel/preset-typescript": "^7.27.1",
280
+ "@eslint/eslintrc": "^3.3.1",
281
+ "@eslint/js": "^9.34.0",
282
+ "@rollup/plugin-babel": "^6.0.4",
283
+ "@rollup/plugin-commonjs": "^28.0.6",
284
+ "@rollup/plugin-json": "^6.1.0",
285
+ "@rollup/plugin-node-resolve": "^16.0.1",
286
+ "@types/babel__core": "^7",
287
+ "@types/babel__preset-env": "^7",
288
+ "@types/eslint": "^9",
289
+ "@types/fs-extra": "^11",
290
+ "@types/jest": "^30.0.0",
291
+ "@types/minimist": "^1",
292
+ "@types/node": "^24.3.0",
293
+ "@types/prettier": "^3",
294
+ "@types/ps-node": "^0",
295
+ "@types/yargs": "^17",
296
+ "@typescript-eslint/eslint-plugin": "^8.40.0",
297
+ "@typescript-eslint/parser": "^8.40.0",
298
+ "babel-jest": "^30.0.5",
299
+ "browser-sync": "^3.0.4",
300
+ "cross-env": "^10.0.0",
301
+ "cross-spawn": "https://github.com/dimaslanjaka/node-cross-spawn/raw/private/release/cross-spawn.tgz",
302
+ eslint: "^9.34.0",
303
+ "eslint-config-prettier": "^10.1.8",
304
+ "eslint-plugin-prettier": "^5.5.4",
305
+ globals: "^16.3.0",
306
+ gulp: "^5.0.1",
307
+ husky: "^9.1.7",
308
+ jest: "^30.0.5",
309
+ "lint-staged": "^16.1.5",
310
+ marked: "^16.2.0",
311
+ prettier: "^3.6.2",
312
+ rimraf: "^6.0.1",
313
+ rollup: "^4.48.1",
314
+ "ts-jest": "^29.4.1",
315
+ "ts-node": "^10.9.2",
316
+ tsup: "^8.5.0",
317
+ typedoc: "^0.28.11",
318
+ "typedoc-plugin-ga": "^1.0.5",
319
+ typescript: "^5.9.2"
320
+ },
321
+ directories: {
322
+ lib: "lib",
323
+ bin: "binaries"
324
+ },
325
+ workspaces: [
326
+ "packages/*"
327
+ ],
328
+ packageManager: "yarn@4.9.2",
329
+ resolutions: {
330
+ "cross-spawn": "https://github.com/dimaslanjaka/node-cross-spawn/raw/80999ac7a7031a81e11ddb5fab0f8ba433041c98/release/cross-spawn.tgz",
331
+ "git-command-helper": "https://github.com/dimaslanjaka/git-command-helper/raw/47133aa918c1292c15949c7f190be9cb302cd6f4/release/git-command-helper.tgz",
332
+ "sbg-utility": "https://github.com/dimaslanjaka/static-blog-generator/raw/f58af787eab404891d8394fe0570ce603e0d7308/packages/sbg-utility/release/sbg-utility.tgz"
333
+ }
334
+ };
335
+ }
336
+ });
337
+
338
+ // src/binary-collections.cjs
339
+ init_cjs_shims();
340
+ var { spawn } = require("child_process");
341
+ var { glob } = require("glob");
342
+ var path = require("upath");
343
+ var { getArgs } = require_utils();
344
+ var pkgJson = require_package();
345
+ var fs = require("fs-extra");
12
346
  function showHelp() {
13
- console.log("🚀 Binary Collections - Dynamic Script Runner");
14
- console.log("═══════════════════════════════════════════════");
15
- console.log("");
16
- console.log("📋 Usage: npx binary-collections <script-name> [...args]");
17
- console.log("");
18
- console.log(" Examples:");
19
- console.log(" 📊 npx binary-collections git-diff -s");
20
- console.log(" 🧹 npx binary-collections del-node-modules");
21
- console.log(" 🔍 npx binary-collections find-node-modules --help");
22
- console.log("");
23
- console.log("ℹ️ This tool will search for <script-name>.{cjs,js,mjs} in the script's directory");
24
- console.log(" and execute it with the provided arguments.");
25
- console.log("");
26
- console.log("⚙️ Options:");
27
- console.log(" --help, -h Show this help message");
28
- process.exit(0);
347
+ console.log("\u{1F680} Binary Collections - Dynamic Script Runner");
348
+ console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
349
+ console.log("");
350
+ console.log("\u{1F4CB} Usage: npx binary-collections <script-name> [...args]");
351
+ console.log("");
352
+ console.log("\u2728 Examples:");
353
+ console.log(" \u{1F4CA} npx binary-collections git-diff -s");
354
+ console.log(" \u{1F9F9} npx binary-collections del-node-modules");
355
+ console.log(" \u{1F50D} npx binary-collections find-node-modules --help");
356
+ console.log("");
357
+ console.log("\u2139\uFE0F This tool will search for <script-name>.{cjs,js,mjs} in the script's directory");
358
+ console.log(" and execute it with the provided arguments.");
359
+ console.log("");
360
+ console.log("\u2699\uFE0F Options:");
361
+ console.log(" --help, -h Show this help message");
362
+ process.exit(0);
29
363
  }
30
364
  function findScript(scriptName, searchDir = null) {
31
- if (!searchDir)
32
- searchDir = __dirname;
33
- // Define ignore patterns for library config and utils
34
- const ignorePatterns = [
35
- `**/*config*.{cjs,js,mjs}`,
36
- `**/utils.{cjs,js,mjs}`,
37
- `**/index.{cjs,js,mjs}`,
38
- `**/chunk-*.{cjs,js,mjs}`,
39
- `**/*.d.{ts,cts,mts}` // ignore TypeScript declaration files
40
- ];
41
- try {
42
- // Use glob to find script files, excluding ignored patterns
43
- // Use cwd option for better path handling
44
- const pattern = `${scriptName}.{cjs,js,mjs}`;
45
- const files = glob.sync(pattern, {
46
- cwd: searchDir,
47
- ignore: ignorePatterns,
48
- absolute: true
49
- });
50
- // Return the first match if found
51
- if (files.length > 0) {
52
- return files[0];
365
+ if (!searchDir) searchDir = __dirname;
366
+ let result;
367
+ const ignorePatterns = [
368
+ `**/*config*.{cjs,js,mjs}`,
369
+ `**/utils.{cjs,js,mjs}`,
370
+ `**/index.{cjs,js,mjs}`,
371
+ `**/chunk-*.{cjs,js,mjs}`,
372
+ `**/*.d.{ts,cts,mts}`
373
+ // ignore TypeScript declaration files
374
+ ];
375
+ try {
376
+ const pattern = `${scriptName}.{cjs,js,mjs}`;
377
+ const files = glob.sync(pattern, {
378
+ cwd: searchDir,
379
+ ignore: ignorePatterns,
380
+ absolute: true
381
+ });
382
+ if (files.length > 0) {
383
+ result = files[0];
384
+ } else {
385
+ if (pkgJson.bin[scriptName]) {
386
+ const find = [
387
+ path.join(searchDir, pkgJson.bin[scriptName]),
388
+ path.join(process.cwd(), "node_modules/binary-collections", pkgJson.bin[scriptName]),
389
+ path.join(__dirname, pkgJson.bin[scriptName]),
390
+ path.join(path.join(__dirname, ".."), pkgJson.bin[scriptName])
391
+ ];
392
+ const filtered = find.filter((file) => fs.existsSync(file));
393
+ if (filtered.length > 0) {
394
+ result = filtered[0];
395
+ } else {
396
+ console.warn(`\u26A0\uFE0F Script "${scriptName}" not found in ${searchDir}.`);
397
+ console.warn(`\u{1F50D} Searched for: ${pattern} in ${searchDir}`);
53
398
  }
399
+ }
54
400
  }
55
- catch (error) {
56
- console.error(`🔍 Error searching for script: ${error.message}`);
401
+ } catch (error) {
402
+ console.error(`\u{1F50D} Error searching for script: ${error.message}`);
403
+ }
404
+ if (result && !result.includes("-cli")) {
405
+ const ext = path.extname(result);
406
+ const filename = path.basename(result, ext);
407
+ const cliFile = path.join(path.dirname(result), `${filename}-cli${ext}`);
408
+ if (fs.existsSync(cliFile)) {
409
+ result = cliFile;
410
+ console.log(`\u{1F50D} Found CLI version: ${cliFile}`);
57
411
  }
58
- return null;
412
+ }
413
+ return result;
59
414
  }
60
415
  function executeScript(scriptPath, args) {
61
- const child = spawn("node", [scriptPath, ...args], {
62
- stdio: "inherit",
63
- shell: true
64
- });
65
- child.on("error", (error) => {
66
- console.error(`❌ Error executing script: ${error.message}`);
67
- process.exit(1);
68
- });
69
- child.on("close", (code) => {
70
- process.exit(code);
71
- });
416
+ console.log(`\u{1F527} Executing script: ${scriptPath} args: ${args.join(" ")}`);
417
+ const child = spawn("node", [scriptPath, ...args], {
418
+ stdio: "inherit",
419
+ shell: true
420
+ });
421
+ child.on("error", (error) => {
422
+ console.error(`\u274C Error executing script: ${error.message}`);
423
+ process.exit(1);
424
+ });
425
+ child.on("close", (code) => {
426
+ process.exit(code);
427
+ });
72
428
  }
73
429
  function main() {
74
- const args = getArgs();
75
- const positional = args._ || [];
76
- // Show help if no arguments or if help is requested without a script name
77
- if (positional.length === 0 || (positional.length === 1 && (args.help || args.h))) {
78
- showHelp();
79
- }
80
- const scriptName = positional[0];
81
- const scriptArgs = positional.slice(1);
82
- // Find the script in current directory
83
- const scriptPath = findScript(scriptName);
84
- if (!scriptPath) {
85
- console.error(`❌ Error: Script "${scriptName}" not found.`);
86
- console.error(`🔍 Searched for: ${scriptName}.{cjs,js,mjs} in ${__dirname}`);
87
- console.error("");
88
- console.error("📝 Available extensions: .cjs, .js, .mjs");
89
- process.exit(1);
430
+ const args = getArgs();
431
+ const positional = args._ || [];
432
+ console.log(`\u{1F50D} Parsed arguments: ${JSON.stringify(args)}`);
433
+ if (positional.length === 0) {
434
+ return showHelp();
435
+ }
436
+ const scriptName = positional[0];
437
+ const scriptArgs = [];
438
+ scriptArgs.push(...positional.slice(1));
439
+ Object.keys(args).forEach((key) => {
440
+ if (key !== "_") {
441
+ const value = args[key];
442
+ if (typeof value === "boolean" && value) {
443
+ scriptArgs.push(key.length === 1 ? `-${key}` : `--${key}`);
444
+ } else if (value !== true && value !== false) {
445
+ scriptArgs.push(key.length === 1 ? `-${key}` : `--${key}`);
446
+ scriptArgs.push(value);
447
+ }
90
448
  }
91
- // Show relative path from current working directory
92
- const relativePath = path.relative(process.cwd(), scriptPath);
93
- console.log(`✅ Found script: ${relativePath}`);
94
- executeScript(scriptPath, scriptArgs);
449
+ });
450
+ const scriptPath = findScript(scriptName);
451
+ if (!scriptPath) {
452
+ console.error(`\u274C Error: Script "${scriptName}" not found.`);
453
+ console.error(`\u{1F50D} Searched for: ${scriptName}.{cjs,js,mjs} in ${__dirname}`);
454
+ console.error("");
455
+ console.error("\u{1F4DD} Available extensions: .cjs, .js, .mjs");
456
+ process.exit(1);
457
+ }
458
+ const relativePath = path.relative(process.cwd(), scriptPath);
459
+ console.log(`\u2705 Found script: ${relativePath}`);
460
+ executeScript(scriptPath, scriptArgs);
95
461
  }
96
- // Handle uncaught exceptions
97
462
  process.on("uncaughtException", (error) => {
98
- console.error("💥 Uncaught Exception:", error.message);
99
- process.exit(1);
463
+ console.error("\u{1F4A5} Uncaught Exception:", error.message);
464
+ process.exit(1);
100
465
  });
101
466
  process.on("unhandledRejection", (reason, promise) => {
102
- console.error("⚠️ Unhandled Rejection at:", promise, "reason:", reason);
103
- process.exit(1);
467
+ console.error("\u26A0\uFE0F Unhandled Rejection at:", promise, "reason:", reason);
468
+ process.exit(1);
104
469
  });
105
470
  main();