binary-collections 2.0.12 → 2.0.13

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 (231) hide show
  1. package/binaries/binary-executor.cjs +89 -13
  2. package/binaries/clean-nodemodule.cjs +89 -13
  3. package/binaries/clean-nodemodules.cjs +89 -13
  4. package/binaries/dev.cjs +89 -13
  5. package/binaries/empty.cjs +89 -13
  6. package/binaries/git-reduce-size.cjs +89 -13
  7. package/binaries/javakill.cjs +89 -13
  8. package/binaries/kill-process.cjs +89 -13
  9. package/binaries/nodekill.cjs +89 -13
  10. package/binaries/prod.cjs +89 -13
  11. package/binaries/py.cjs +89 -13
  12. package/binaries/rmfind.cjs +89 -13
  13. package/binaries/rmx.cjs +89 -13
  14. package/binaries/submodule-token.cjs +89 -13
  15. package/binaries/test-cjs.cjs +89 -13
  16. package/binaries/test-esm.cjs +89 -13
  17. package/binaries/yarn-clean.cjs +89 -13
  18. package/binaries/yc +22 -1
  19. package/binaries/yc.cjs +89 -13
  20. package/binaries/ycw +256 -0
  21. package/binaries/ycw.cjs +254 -0
  22. package/docs-src/binary-collections.md +34 -0
  23. package/docs-src/changelog.md +26 -0
  24. package/docs-src/clean-github-actions-caches.md +115 -0
  25. package/docs-src/copy-move-file.md +59 -0
  26. package/docs-src/del-gradle.md +17 -0
  27. package/docs-src/del-ps.md +28 -0
  28. package/docs-src/downloader.md +62 -0
  29. package/docs-src/env-helpers.md +29 -0
  30. package/docs-src/find-node-modules.md +17 -0
  31. package/docs-src/free-chatgpt.md +26 -0
  32. package/docs-src/git-diff.md +33 -0
  33. package/docs-src/git-fix.md +34 -0
  34. package/docs-src/git-purge.md +17 -0
  35. package/docs-src/git-reduce-size.md +17 -0
  36. package/docs-src/git-undo.md +21 -0
  37. package/docs-src/kill-night-crows.md +26 -0
  38. package/docs-src/node-cache-cleaner.md +182 -0
  39. package/docs-src/node-executor.md +50 -0
  40. package/docs-src/node-package-packer.md +48 -0
  41. package/docs-src/npm-run-series.md +43 -0
  42. package/docs-src/package-resolutions-updater.md +22 -0
  43. package/docs-src/php-cs-fixer-staged.md +19 -0
  44. package/docs-src/print-directory-tree.md +35 -0
  45. package/docs-src/print-tarball-tree.md +55 -0
  46. package/docs-src/py.md +19 -0
  47. package/docs-src/remove-module.md +32 -0
  48. package/docs-src/rmfind-rmx.md +21 -0
  49. package/docs-src/rmpath.md +38 -0
  50. package/docs-src/run-by-checksum.md +87 -0
  51. package/docs-src/submodule-install.md +31 -0
  52. package/docs-src/submodule-remove.md +22 -0
  53. package/docs-src/submodule-token.md +17 -0
  54. package/docs-src/test-runners.md +21 -0
  55. package/docs-src/yarn-install.md +31 -0
  56. package/docs-src/yarn-reinstall.md +27 -0
  57. package/lib/binary-collections/config.cjs +1 -1
  58. package/lib/binary-collections/config.mjs +1 -1
  59. package/lib/binary-collections/findScript.cjs +35 -10
  60. package/lib/binary-collections/findScript.mjs +2 -2
  61. package/lib/binary-collections/listScript.cjs +35 -10
  62. package/lib/binary-collections/listScript.mjs +2 -2
  63. package/lib/binary-collections.cjs +45 -25
  64. package/lib/binary-collections.mjs +11 -11
  65. package/lib/changelog.cjs +7 -12
  66. package/lib/changelog.mjs +2 -2
  67. package/lib/{chunk-SPTECFE5.mjs → chunk-2MN4VPV2.mjs} +86 -20
  68. package/lib/{chunk-V2IBPCEV.mjs → chunk-6C7KTYGZ.mjs} +3 -1
  69. package/lib/{chunk-5RTXZVCW.mjs → chunk-6RK5UCTP.mjs} +5 -10
  70. package/lib/{chunk-FB2WKVJD.mjs → chunk-CD3HF3LK.mjs} +67 -35
  71. package/lib/{chunk-6PU7BAHB.mjs → chunk-FLYSZFLW.mjs} +1 -1
  72. package/lib/chunk-KLKAIFKI.mjs +40 -0
  73. package/lib/chunk-LVSPEFU2.mjs +86 -0
  74. package/lib/{chunk-2LSRSEXF.mjs → chunk-MGPYPKIE.mjs} +2 -2
  75. package/lib/{chunk-ZOWVMII3.mjs → chunk-NQXUYO67.mjs} +35 -10
  76. package/lib/{chunk-C6D2TTYU.mjs → chunk-OBXLTXFJ.mjs} +4 -2
  77. package/lib/chunk-QD4T255Z.mjs +40 -0
  78. package/lib/{chunk-XPJGCDOD.mjs → chunk-QII2EKCS.mjs} +14 -2
  79. package/lib/chunk-RDGDLSPD.mjs +76 -0
  80. package/lib/{chunk-NCZPTKDV.mjs → chunk-RDN6HF5Z.mjs} +1 -1
  81. package/lib/chunk-RJKTSUAX.mjs +123 -0
  82. package/lib/{chunk-66KDU4TX.mjs → chunk-TBWXE7ST.mjs} +36 -61
  83. package/lib/{chunk-M3YIYRHT.mjs → chunk-UY5VUEA3.mjs} +1 -1
  84. package/lib/chunk-WSHVPGNM.mjs +44 -0
  85. package/lib/{chunk-G5UUEWUO.mjs → chunk-X2B3X7D4.mjs} +1 -1
  86. package/lib/clean-github-actions-caches-cli.cjs +255 -213
  87. package/lib/clean-github-actions-caches-cli.mjs +25 -7
  88. package/lib/clean-github-actions-caches.cjs +231 -35
  89. package/lib/clean-github-actions-caches.d.cts +39 -1
  90. package/lib/clean-github-actions-caches.mjs +2 -1
  91. package/lib/cross-env/command.cjs +2 -2
  92. package/lib/cross-env/command.js +2 -2
  93. package/lib/cross-env/command.mjs +2 -2
  94. package/lib/cross-env/index.cjs +2 -2
  95. package/lib/cross-env/index.mjs +3 -3
  96. package/lib/cross-env/variable.mjs +2 -2
  97. package/lib/del-gradle.cjs +6 -11
  98. package/lib/del-gradle.mjs +1 -1
  99. package/lib/del-node-modules.cjs +185 -3
  100. package/lib/del-node-modules.js +3 -3
  101. package/lib/del-node-modules.mjs +6 -3
  102. package/lib/{del-ps.cjs → del-ps-cli.cjs} +36 -41
  103. package/lib/del-ps-cli.mjs +44 -0
  104. package/lib/del-yarn-caches.cjs +6 -11
  105. package/lib/del-yarn-caches.mjs +1 -1
  106. package/lib/downloader-cli.cjs +256 -0
  107. package/lib/downloader-cli.d.cts +2 -0
  108. package/lib/downloader-cli.mjs +90 -0
  109. package/lib/file/copy-cli.cjs +183 -2
  110. package/lib/file/copy-cli.mjs +6 -2
  111. package/lib/file/move-cli.cjs +183 -2
  112. package/lib/file/move-cli.mjs +6 -2
  113. package/lib/find-node-modules-cli.cjs +1 -1
  114. package/lib/find-node-modules-cli.mjs +1 -1
  115. package/lib/find-node-modules.cjs +1 -1
  116. package/lib/find-node-modules.mjs +1 -1
  117. package/lib/free-chatgpt.cjs +6 -11
  118. package/lib/free-chatgpt.mjs +1 -1
  119. package/lib/git/user-config.cjs +7 -12
  120. package/lib/git/user-config.mjs +2 -2
  121. package/lib/git-diff-cli.cjs +91 -30
  122. package/lib/git-diff-cli.mjs +3 -3
  123. package/lib/git-diff.cjs +91 -30
  124. package/lib/git-diff.js +85 -28
  125. package/lib/git-diff.mjs +3 -3
  126. package/lib/git-fix.cjs +7 -12
  127. package/lib/git-fix.mjs +2 -2
  128. package/lib/git-purge.cjs +7 -12
  129. package/lib/git-purge.mjs +2 -2
  130. package/lib/index.cjs +1 -1
  131. package/lib/index.mjs +1 -1
  132. package/lib/node-cache-cleaner-cli.cjs +185 -2
  133. package/lib/node-cache-cleaner-cli.js +2 -5
  134. package/lib/node-cache-cleaner-cli.mjs +8 -4
  135. package/lib/node-executor.cjs +183 -2
  136. package/lib/node-executor.mjs +5 -2
  137. package/lib/node-package-packer/build-readme.cjs +150 -0
  138. package/lib/node-package-packer/build-readme.d.mts +10 -0
  139. package/lib/node-package-packer/build-readme.mjs +10 -0
  140. package/lib/node-package-packer/build-tarball.cjs +495 -0
  141. package/lib/node-package-packer/build-tarball.d.mts +33 -0
  142. package/lib/node-package-packer/build-tarball.mjs +175 -0
  143. package/lib/node-package-packer-cli.cjs +525 -0
  144. package/lib/node-package-packer-cli.d.mts +1 -0
  145. package/lib/node-package-packer-cli.mjs +34 -0
  146. package/lib/npm-run-series.cjs +7 -12
  147. package/lib/npm-run-series.mjs +2 -2
  148. package/lib/package-resolutions-updater-cli.cjs +73 -76
  149. package/lib/package-resolutions-updater-cli.mjs +4 -3
  150. package/lib/package-resolutions-updater.cjs +71 -74
  151. package/lib/package-resolutions-updater.d.mts +34 -0
  152. package/lib/package-resolutions-updater.mjs +3 -2
  153. package/lib/php-cs-fixer-staged.cjs +1 -1
  154. package/lib/php-cs-fixer-staged.mjs +1 -1
  155. package/lib/print-directory-tree.cjs +16 -18
  156. package/lib/print-directory-tree.mjs +11 -8
  157. package/lib/print-tarball-tree.cjs +262 -0
  158. package/lib/print-tarball-tree.d.mts +1 -0
  159. package/lib/print-tarball-tree.mjs +68 -0
  160. package/lib/ps/index.cjs +10 -10
  161. package/lib/ps/index.mjs +4 -4
  162. package/lib/ps/table-parser.d.ts +3 -4
  163. package/lib/ps/table-parser.js +9 -16
  164. package/lib/remove-module.cjs +17 -22
  165. package/lib/remove-module.mjs +2 -2
  166. package/lib/rm-node-module-cli.cjs +171 -4
  167. package/lib/rm-node-module-cli.mjs +7 -4
  168. package/lib/rmpath-cli.cjs +285 -0
  169. package/lib/rmpath-cli.d.mts +1 -0
  170. package/lib/rmpath-cli.mjs +23 -0
  171. package/lib/rmpath.cjs +6 -217
  172. package/lib/rmpath.mjs +5 -101
  173. package/lib/run-by-checksum/cache.cjs +69 -0
  174. package/lib/run-by-checksum/cache.d.ts +19 -0
  175. package/lib/run-by-checksum/cache.js +50 -0
  176. package/lib/run-by-checksum/cache.mjs +12 -0
  177. package/lib/run-by-checksum/hash.cjs +72 -0
  178. package/lib/run-by-checksum/hash.d.ts +14 -0
  179. package/lib/run-by-checksum/hash.js +85 -0
  180. package/lib/{ps/isWin.mjs → run-by-checksum/hash.mjs} +5 -5
  181. package/lib/run-by-checksum/run.cjs +169 -0
  182. package/lib/run-by-checksum/run.d.ts +22 -0
  183. package/lib/run-by-checksum/run.js +93 -0
  184. package/lib/run-by-checksum/run.mjs +10 -0
  185. package/lib/run-by-checksum-cli.cjs +382 -0
  186. package/lib/run-by-checksum-cli.d.ts +2 -0
  187. package/lib/run-by-checksum-cli.js +43 -0
  188. package/lib/run-by-checksum-cli.mjs +56 -0
  189. package/lib/submodule-install.cjs +8 -13
  190. package/lib/submodule-install.mjs +3 -3
  191. package/lib/submodule-remove-cli.cjs +169 -2
  192. package/lib/submodule-remove-cli.js +2 -2
  193. package/lib/submodule-remove-cli.mjs +5 -2
  194. package/lib/utils/fetchResponse.cjs +24 -0
  195. package/lib/utils/fetchResponse.d.cts +25 -0
  196. package/lib/utils/fetchResponse.mjs +6 -0
  197. package/lib/utils/index.cjs +5 -10
  198. package/lib/utils/index.d.cts +2 -9
  199. package/lib/utils/index.mjs +1 -1
  200. package/lib/utils/isWindows.mjs +3 -1
  201. package/lib/utils/runBash.cjs +1 -1
  202. package/lib/utils/runBash.mjs +1 -1
  203. package/lib/yarn-per-branch-lock-installer.cjs +202 -11
  204. package/lib/yarn-per-branch-lock-installer.mjs +24 -11
  205. package/lib/yarn-reinstall.cjs +6 -11
  206. package/lib/yarn-reinstall.mjs +1 -1
  207. package/package.json +35 -10
  208. package/readme.html +2 -2
  209. package/readme.md +5 -5
  210. package/releases/readme.md +6 -3
  211. package/tmp/test-repo-runChecksum/test-complex-glob/README.md +1 -0
  212. package/tmp/test-repo-runChecksum/test-mixed-args/README.md +1 -0
  213. package/.opencode/package.json +0 -5
  214. package/lib/chunk-6S4NXESK.mjs +0 -26
  215. package/lib/del-ps.js +0 -32
  216. package/lib/del-ps.mjs +0 -43
  217. package/lib/ps/isWin.cjs +0 -26
  218. package/lib/ps/isWin.d.ts +0 -2
  219. package/lib/ps/isWin.js +0 -4
  220. package/test/package.json +0 -20
  221. package/test-project/package.json +0 -22
  222. package/test-project/workspaces/workspace-a/package.json +0 -135
  223. package/test-project/workspaces/workspace-a/test/demo/package.json +0 -25
  224. package/test-project/workspaces/workspace-b/package.json +0 -139
  225. package/test-project/workspaces/workspace-b/test/sample-project/package.json +0 -7
  226. package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/package.json +0 -96
  227. package/tmp/rm-node-modules-test-project/package.json +0 -17
  228. package/tmp/rm-node-modules-test-project/packages/workspace-a/package.json +0 -16
  229. package/tmp/rm-node-modules-test-project/packages/workspace-b/package.json +0 -16
  230. package/tmp/test-repo/package.json +0 -17
  231. /package/lib/{del-ps.d.ts → del-ps-cli.d.mts} +0 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_utils
4
+ } from "./chunk-6RK5UCTP.mjs";
5
+ import {
6
+ __toESM,
7
+ init_esm_shims
8
+ } from "./chunk-QQ4A6DLD.mjs";
9
+
10
+ // src/node-package-packer-cli.mjs
11
+ init_esm_shims();
12
+ var import_utils = __toESM(require_utils(), 1);
13
+ import path from "upath";
14
+ var args = (0, import_utils.getArgs)({ boolean: ["h", "help"] });
15
+ if (args.h || args.help) {
16
+ const scriptName = path.basename(new URL(import.meta.url).pathname);
17
+ console.log(`Automated tarball (tgz) creator for release folder`);
18
+ console.log(``);
19
+ console.log(`Usage: node ${scriptName} [options]`);
20
+ console.log(``);
21
+ console.log(`Options:`);
22
+ console.log(` -h, --help Show this help message`);
23
+ console.log(` -y, --yarn Force yarn pack instead of npm pack`);
24
+ console.log(` -d, --verbose Enable verbose output`);
25
+ console.log(` --fn, --filename Set output filename variant`);
26
+ process.exit(0);
27
+ }
28
+ (async () => {
29
+ const { bundle } = await import("./node-package-packer/build-tarball.mjs");
30
+ await bundle();
31
+ })().catch((error) => {
32
+ console.error(error);
33
+ process.exit(1);
34
+ });
@@ -19,9 +19,9 @@ var require_utils = __commonJS({
19
19
  init_cjs_shims();
20
20
  var fs2 = require("fs");
21
21
  var path2 = require("upath");
22
- var argv = require("minimist")(process.argv.slice(2));
22
+ var minimistLib = require("minimist");
23
+ var argv = minimistLib(process.argv.slice(2));
23
24
  var { exec } = require("child_process");
24
- var { URL: URL2 } = require("url");
25
25
  var { promisify } = require("util");
26
26
  var execAsync = promisify(exec);
27
27
  async function parseGitRemotes() {
@@ -34,7 +34,7 @@ var require_utils = __commonJS({
34
34
  if (name && url) {
35
35
  const [repoUrl] = url.split(" ");
36
36
  try {
37
- const parsedUrl = new URL2(repoUrl);
37
+ const parsedUrl = new URL(repoUrl);
38
38
  const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
39
39
  if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
40
40
  let repoPath = pathParts.join("/");
@@ -55,15 +55,10 @@ var require_utils = __commonJS({
55
55
  }
56
56
  }
57
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);
58
+ function getArgs2(opts) {
59
+ if (opts) {
60
+ return minimistLib(process.argv.slice(2), opts);
62
61
  }
63
- return fullPath;
64
- }
65
- module2.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
66
- function getArgs2() {
67
62
  return argv;
68
63
  }
69
64
  module2.exports.getArgs = getArgs2;
@@ -189,7 +184,7 @@ var require_utils = __commonJS({
189
184
  init_cjs_shims();
190
185
  var { spawnSync } = require("child_process");
191
186
  var fs = require("fs");
192
- var path = require("path");
187
+ var path = require("upath");
193
188
  var { Minimatch } = require("minimatch");
194
189
  var { getArgs } = require_utils();
195
190
  var args = getArgs();
@@ -2,7 +2,7 @@
2
2
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
3
3
  import {
4
4
  require_utils
5
- } from "./chunk-5RTXZVCW.mjs";
5
+ } from "./chunk-6RK5UCTP.mjs";
6
6
  import {
7
7
  __commonJS,
8
8
  __require,
@@ -15,7 +15,7 @@ var require_npm_run_series = __commonJS({
15
15
  init_esm_shims();
16
16
  var { spawnSync } = __require("child_process");
17
17
  var fs = __require("fs");
18
- var path = __require("path");
18
+ var path = __require("upath");
19
19
  var { Minimatch } = __require("minimatch");
20
20
  var { getArgs } = require_utils();
21
21
  var args = getArgs();
@@ -40,9 +40,9 @@ var require_utils = __commonJS({
40
40
  init_cjs_shims();
41
41
  var fs3 = require("fs");
42
42
  var path3 = require("upath");
43
- var argv = require("minimist")(process.argv.slice(2));
43
+ var minimistLib = require("minimist");
44
+ var argv = minimistLib(process.argv.slice(2));
44
45
  var { exec } = require("child_process");
45
- var { URL: URL2 } = require("url");
46
46
  var { promisify } = require("util");
47
47
  var execAsync = promisify(exec);
48
48
  async function parseGitRemotes() {
@@ -55,7 +55,7 @@ var require_utils = __commonJS({
55
55
  if (name && url) {
56
56
  const [repoUrl] = url.split(" ");
57
57
  try {
58
- const parsedUrl = new URL2(repoUrl);
58
+ const parsedUrl = new URL(repoUrl);
59
59
  const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
60
60
  if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
61
61
  let repoPath = pathParts.join("/");
@@ -76,15 +76,10 @@ var require_utils = __commonJS({
76
76
  }
77
77
  }
78
78
  module2.exports.parseGitRemotes = parseGitRemotes;
79
- function joinPathPreserveDriveLetter(...segments) {
80
- let fullPath = require("path").join(...segments);
81
- if (/^[a-z]:\\/.test(fullPath)) {
82
- fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
79
+ function getArgs2(opts) {
80
+ if (opts) {
81
+ return minimistLib(process.argv.slice(2), opts);
83
82
  }
84
- return fullPath;
85
- }
86
- module2.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
87
- function getArgs2() {
88
83
  return argv;
89
84
  }
90
85
  module2.exports.getArgs = getArgs2;
@@ -206,6 +201,36 @@ var require_utils = __commonJS({
206
201
  }
207
202
  });
208
203
 
204
+ // src/utils/fetchResponse.cjs
205
+ var require_fetchResponse = __commonJS({
206
+ "src/utils/fetchResponse.cjs"(exports2, module2) {
207
+ init_cjs_shims();
208
+ var axios = require("axios");
209
+ async function fetchResponse2(url, options = {}) {
210
+ var _a, _b, _c;
211
+ const response = await axios.get(url, {
212
+ maxRedirects: 5,
213
+ responseType: "arraybuffer",
214
+ validateStatus: () => true,
215
+ ...options
216
+ });
217
+ const finalUrl = ((_b = (_a = response.request) == null ? void 0 : _a.res) == null ? void 0 : _b.responseUrl) ?? ((_c = response.request) == null ? void 0 : _c.responseURL) ?? url;
218
+ return {
219
+ finalUrl,
220
+ status: response.status,
221
+ statusText: response.statusText,
222
+ contentType: response.headers["content-type"],
223
+ contentLength: response.headers["content-length"],
224
+ dataLength: Buffer.isBuffer(response.data) ? response.data.length : void 0,
225
+ data: response.data
226
+ };
227
+ }
228
+ module2.exports = fetchResponse2;
229
+ module2.exports.fetchResponse = fetchResponse2;
230
+ module2.exports.default = fetchResponse2;
231
+ }
232
+ });
233
+
209
234
  // src/utils/findEnvFiles.cjs
210
235
  var require_findEnvFiles = __commonJS({
211
236
  "src/utils/findEnvFiles.cjs"(exports2, module2) {
@@ -305,21 +330,20 @@ var require_findEnvFiles = __commonJS({
305
330
  init_cjs_shims();
306
331
  var import_ansi_colors = __toESM(require("ansi-colors"), 1);
307
332
  var import_fs2 = __toESM(require("fs"), 1);
308
- var import_path2 = __toESM(require("path"), 1);
333
+ var import_upath2 = __toESM(require("upath"), 1);
309
334
 
310
335
  // src/package-resolutions-updater.mjs
311
336
  init_cjs_shims();
312
337
  var dotenv = __toESM(require("dotenv"), 1);
313
338
  var import_fs = __toESM(require("fs"), 1);
314
- var import_https = __toESM(require("https"), 1);
315
339
  var import_os = __toESM(require("os"), 1);
316
- var import_path = __toESM(require("path"), 1);
340
+ var import_upath = __toESM(require("upath"), 1);
317
341
  var utils = __toESM(require_utils(), 1);
342
+ var import_fetchResponse = __toESM(require_fetchResponse(), 1);
318
343
  var import_findEnvFiles = __toESM(require_findEnvFiles(), 1);
319
344
  var import_git_command_helper = require("git-command-helper");
320
- var import_axios = __toESM(require("axios"), 1);
321
345
  var projectDir = process.cwd();
322
- var envPath = import_path.default.join(projectDir, ".env");
346
+ var envPath = import_upath.default.join(projectDir, ".env");
323
347
  var args = utils.getArgs();
324
348
  if (!import_fs.default.existsSync(envPath)) {
325
349
  const envFiles = (0, import_findEnvFiles.findEnvFiles)(projectDir, (file) => {
@@ -333,7 +357,7 @@ if (!import_fs.default.existsSync(envPath)) {
333
357
  if (import_fs.default.existsSync(envPath)) {
334
358
  dotenv.config({ path: envPath, quiet: true, override: true });
335
359
  }
336
- var ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
360
+ var ACCESS_TOKEN = process.env.ACCESS_TOKEN || process.env.GITHUB_TOKEN;
337
361
  if (args.help || args.h) {
338
362
  showHelp();
339
363
  }
@@ -373,8 +397,8 @@ var GITHUB_USER_AGENTS = [
373
397
  "PostmanRuntime/7.32.3",
374
398
  "binary-collections-resolver/1.0 (+https://github.com/dimaslanjaka/bin)"
375
399
  ];
376
- var userAgentDir = import_path.default.join(import_os.default.tmpdir(), "nodejs");
377
- var userAgentFile = import_path.default.join(userAgentDir, "useragent.txt");
400
+ var userAgentDir = import_upath.default.join(import_os.default.tmpdir(), "nodejs");
401
+ var userAgentFile = import_upath.default.join(userAgentDir, "useragent.txt");
378
402
  var selectedUserAgent;
379
403
  try {
380
404
  if (!import_fs.default.existsSync(userAgentDir)) import_fs.default.mkdirSync(userAgentDir, { recursive: true });
@@ -391,33 +415,23 @@ try {
391
415
  } catch (_e) {
392
416
  selectedUserAgent = GITHUB_USER_AGENTS[Math.floor(Math.random() * GITHUB_USER_AGENTS.length)];
393
417
  }
394
- function fetchJson(url) {
395
- const headers = {
396
- "User-Agent": selectedUserAgent,
397
- Accept: "application/vnd.github.v3+json",
398
- "X-GitHub-Api-Version": "2022-11-28",
399
- ...ACCESS_TOKEN ? { Authorization: `token ${ACCESS_TOKEN}` } : {}
400
- };
401
- return new Promise((resolve, reject) => {
402
- import_https.default.get(url, { headers }, (res) => {
403
- let data = "";
404
- res.on("data", (chunk) => data += chunk);
405
- res.on("end", () => {
406
- try {
407
- const json = JSON.parse(data);
408
- if (res.statusCode < 200 || res.statusCode >= 300) {
409
- return reject(
410
- new Error(`GitHub API Error ${res.statusCode}: ${json.message || "Unknown error"}
411
- URL: ${url}`)
412
- );
413
- }
414
- resolve(json);
415
- } catch {
416
- reject(new Error(`Invalid JSON from: ${url}`));
417
- }
418
- });
419
- }).on("error", reject);
418
+ async function fetchJson(url) {
419
+ var _a;
420
+ const response = await (0, import_fetchResponse.default)(url, {
421
+ headers: {
422
+ "User-Agent": selectedUserAgent,
423
+ Accept: "application/vnd.github.v3+json",
424
+ "X-GitHub-Api-Version": "2022-11-28",
425
+ ...ACCESS_TOKEN ? { Authorization: `token ${ACCESS_TOKEN}` } : {}
426
+ },
427
+ responseType: "json"
420
428
  });
429
+ if (response.status < 200 || response.status >= 300) {
430
+ const message = ((_a = response.data) == null ? void 0 : _a.message) || "Unknown error";
431
+ throw new Error(`GitHub API Error ${response.status}: ${message}
432
+ URL: ${url}`);
433
+ }
434
+ return response.data;
421
435
  }
422
436
  async function getLatestCommit(owner, repo, branch = "main") {
423
437
  var _a, _b, _c, _d;
@@ -503,34 +517,8 @@ async function resolvePackageResolutionUpdates(resolutions, specialPackageOverri
503
517
  const override = specialPackageOverrides.find((p) => p.pkg === currentPkgName);
504
518
  const latest = override ? await getLatestCommit(override.owner, override.repo, override.branch) : await getLatestCommitAcrossBranches(repo.owner, repo.repo);
505
519
  const new_url = replaceRawWithLatestHash(url, latest.sha);
506
- await import_axios.default.head(new_url, {
507
- headers: {
508
- "User-Agent": selectedUserAgent,
509
- Accept: "application/vnd.github.v3+json",
510
- "X-GitHub-Api-Version": "2022-11-28",
511
- ...ACCESS_TOKEN ? { Authorization: `token ${ACCESS_TOKEN}` } : {}
512
- }
513
- }).then((response) => {
514
- if (response.status < 200 || response.status >= 300) {
515
- updates.push({
516
- failed: true,
517
- currentPkgName,
518
- url,
519
- new_url,
520
- repo,
521
- latest,
522
- error: new Error(`New URL is not accessible, status code: ${response.status}`)
523
- });
524
- return;
525
- }
526
- updates.push({
527
- currentPkgName,
528
- url,
529
- new_url,
530
- repo,
531
- latest
532
- });
533
- }).catch((e) => {
520
+ const response = await (0, import_fetchResponse.default)(new_url);
521
+ if (response.status < 200 || response.status >= 300) {
534
522
  updates.push({
535
523
  failed: true,
536
524
  currentPkgName,
@@ -538,9 +526,18 @@ async function resolvePackageResolutionUpdates(resolutions, specialPackageOverri
538
526
  new_url,
539
527
  repo,
540
528
  latest,
541
- error: new Error(`New URL is not accessible: ${e.message}`)
529
+ error: new Error(`New URL not accessible (status ${response.status}).
530
+ original: ${url}
531
+ new: ${new_url}`)
542
532
  });
543
- return null;
533
+ continue;
534
+ }
535
+ updates.push({
536
+ currentPkgName,
537
+ url,
538
+ new_url,
539
+ repo,
540
+ latest
544
541
  });
545
542
  } catch (error) {
546
543
  updates.push({
@@ -588,7 +585,7 @@ async function resolvePackageResolutionUpdates(resolutions, specialPackageOverri
588
585
  // { pkg: "@types/hexo", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
589
586
  { pkg: "@types/git-command-helper", branch: "pre-release", repo: "git-command-helper", owner: "dimaslanjaka" }
590
587
  ];
591
- const pkgPath = import_path2.default.join(process.cwd(), "package.json");
588
+ const pkgPath = import_upath2.default.join(process.cwd(), "package.json");
592
589
  let pkg;
593
590
  try {
594
591
  pkg = JSON.parse(import_fs2.default.readFileSync(pkgPath, "utf-8"));
@@ -1,9 +1,10 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  resolvePackageResolutionUpdates
4
- } from "./chunk-66KDU4TX.mjs";
4
+ } from "./chunk-TBWXE7ST.mjs";
5
+ import "./chunk-KLKAIFKI.mjs";
5
6
  import "./chunk-H44UWUFY.mjs";
6
- import "./chunk-5RTXZVCW.mjs";
7
+ import "./chunk-6RK5UCTP.mjs";
7
8
  import {
8
9
  init_esm_shims
9
10
  } from "./chunk-QQ4A6DLD.mjs";
@@ -12,7 +13,7 @@ import {
12
13
  init_esm_shims();
13
14
  import ansiColors from "ansi-colors";
14
15
  import fs from "fs";
15
- import path from "path";
16
+ import path from "upath";
16
17
  (async () => {
17
18
  const specialPackageOverrides = [
18
19
  // SBG packages
@@ -44,9 +44,9 @@ var require_utils = __commonJS({
44
44
  init_cjs_shims();
45
45
  var fs2 = require("fs");
46
46
  var path2 = require("upath");
47
- var argv = require("minimist")(process.argv.slice(2));
47
+ var minimistLib = require("minimist");
48
+ var argv = minimistLib(process.argv.slice(2));
48
49
  var { exec } = require("child_process");
49
- var { URL: URL2 } = require("url");
50
50
  var { promisify } = require("util");
51
51
  var execAsync = promisify(exec);
52
52
  async function parseGitRemotes() {
@@ -59,7 +59,7 @@ var require_utils = __commonJS({
59
59
  if (name && url) {
60
60
  const [repoUrl] = url.split(" ");
61
61
  try {
62
- const parsedUrl = new URL2(repoUrl);
62
+ const parsedUrl = new URL(repoUrl);
63
63
  const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
64
64
  if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
65
65
  let repoPath = pathParts.join("/");
@@ -80,15 +80,10 @@ var require_utils = __commonJS({
80
80
  }
81
81
  }
82
82
  module2.exports.parseGitRemotes = parseGitRemotes;
83
- function joinPathPreserveDriveLetter(...segments) {
84
- let fullPath = require("path").join(...segments);
85
- if (/^[a-z]:\\/.test(fullPath)) {
86
- fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
83
+ function getArgs2(opts) {
84
+ if (opts) {
85
+ return minimistLib(process.argv.slice(2), opts);
87
86
  }
88
- return fullPath;
89
- }
90
- module2.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
91
- function getArgs2() {
92
87
  return argv;
93
88
  }
94
89
  module2.exports.getArgs = getArgs2;
@@ -210,6 +205,36 @@ var require_utils = __commonJS({
210
205
  }
211
206
  });
212
207
 
208
+ // src/utils/fetchResponse.cjs
209
+ var require_fetchResponse = __commonJS({
210
+ "src/utils/fetchResponse.cjs"(exports2, module2) {
211
+ init_cjs_shims();
212
+ var axios = require("axios");
213
+ async function fetchResponse2(url, options = {}) {
214
+ var _a, _b, _c;
215
+ const response = await axios.get(url, {
216
+ maxRedirects: 5,
217
+ responseType: "arraybuffer",
218
+ validateStatus: () => true,
219
+ ...options
220
+ });
221
+ const finalUrl = ((_b = (_a = response.request) == null ? void 0 : _a.res) == null ? void 0 : _b.responseUrl) ?? ((_c = response.request) == null ? void 0 : _c.responseURL) ?? url;
222
+ return {
223
+ finalUrl,
224
+ status: response.status,
225
+ statusText: response.statusText,
226
+ contentType: response.headers["content-type"],
227
+ contentLength: response.headers["content-length"],
228
+ dataLength: Buffer.isBuffer(response.data) ? response.data.length : void 0,
229
+ data: response.data
230
+ };
231
+ }
232
+ module2.exports = fetchResponse2;
233
+ module2.exports.fetchResponse = fetchResponse2;
234
+ module2.exports.default = fetchResponse2;
235
+ }
236
+ });
237
+
213
238
  // src/utils/findEnvFiles.cjs
214
239
  var require_findEnvFiles = __commonJS({
215
240
  "src/utils/findEnvFiles.cjs"(exports2, module2) {
@@ -319,15 +344,14 @@ module.exports = __toCommonJS(package_resolutions_updater_exports);
319
344
  init_cjs_shims();
320
345
  var dotenv = __toESM(require("dotenv"), 1);
321
346
  var import_fs = __toESM(require("fs"), 1);
322
- var import_https = __toESM(require("https"), 1);
323
347
  var import_os = __toESM(require("os"), 1);
324
- var import_path = __toESM(require("path"), 1);
348
+ var import_upath = __toESM(require("upath"), 1);
325
349
  var utils = __toESM(require_utils(), 1);
350
+ var import_fetchResponse = __toESM(require_fetchResponse(), 1);
326
351
  var import_findEnvFiles = __toESM(require_findEnvFiles(), 1);
327
352
  var import_git_command_helper = require("git-command-helper");
328
- var import_axios = __toESM(require("axios"), 1);
329
353
  var projectDir = process.cwd();
330
- var envPath = import_path.default.join(projectDir, ".env");
354
+ var envPath = import_upath.default.join(projectDir, ".env");
331
355
  var args = utils.getArgs();
332
356
  if (!import_fs.default.existsSync(envPath)) {
333
357
  const envFiles = (0, import_findEnvFiles.findEnvFiles)(projectDir, (file) => {
@@ -341,7 +365,7 @@ if (!import_fs.default.existsSync(envPath)) {
341
365
  if (import_fs.default.existsSync(envPath)) {
342
366
  dotenv.config({ path: envPath, quiet: true, override: true });
343
367
  }
344
- var ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
368
+ var ACCESS_TOKEN = process.env.ACCESS_TOKEN || process.env.GITHUB_TOKEN;
345
369
  if (args.help || args.h) {
346
370
  showHelp();
347
371
  }
@@ -381,8 +405,8 @@ var GITHUB_USER_AGENTS = [
381
405
  "PostmanRuntime/7.32.3",
382
406
  "binary-collections-resolver/1.0 (+https://github.com/dimaslanjaka/bin)"
383
407
  ];
384
- var userAgentDir = import_path.default.join(import_os.default.tmpdir(), "nodejs");
385
- var userAgentFile = import_path.default.join(userAgentDir, "useragent.txt");
408
+ var userAgentDir = import_upath.default.join(import_os.default.tmpdir(), "nodejs");
409
+ var userAgentFile = import_upath.default.join(userAgentDir, "useragent.txt");
386
410
  var selectedUserAgent;
387
411
  try {
388
412
  if (!import_fs.default.existsSync(userAgentDir)) import_fs.default.mkdirSync(userAgentDir, { recursive: true });
@@ -399,33 +423,23 @@ try {
399
423
  } catch (_e) {
400
424
  selectedUserAgent = GITHUB_USER_AGENTS[Math.floor(Math.random() * GITHUB_USER_AGENTS.length)];
401
425
  }
402
- function fetchJson(url) {
403
- const headers = {
404
- "User-Agent": selectedUserAgent,
405
- Accept: "application/vnd.github.v3+json",
406
- "X-GitHub-Api-Version": "2022-11-28",
407
- ...ACCESS_TOKEN ? { Authorization: `token ${ACCESS_TOKEN}` } : {}
408
- };
409
- return new Promise((resolve, reject) => {
410
- import_https.default.get(url, { headers }, (res) => {
411
- let data = "";
412
- res.on("data", (chunk) => data += chunk);
413
- res.on("end", () => {
414
- try {
415
- const json = JSON.parse(data);
416
- if (res.statusCode < 200 || res.statusCode >= 300) {
417
- return reject(
418
- new Error(`GitHub API Error ${res.statusCode}: ${json.message || "Unknown error"}
419
- URL: ${url}`)
420
- );
421
- }
422
- resolve(json);
423
- } catch {
424
- reject(new Error(`Invalid JSON from: ${url}`));
425
- }
426
- });
427
- }).on("error", reject);
426
+ async function fetchJson(url) {
427
+ var _a;
428
+ const response = await (0, import_fetchResponse.default)(url, {
429
+ headers: {
430
+ "User-Agent": selectedUserAgent,
431
+ Accept: "application/vnd.github.v3+json",
432
+ "X-GitHub-Api-Version": "2022-11-28",
433
+ ...ACCESS_TOKEN ? { Authorization: `token ${ACCESS_TOKEN}` } : {}
434
+ },
435
+ responseType: "json"
428
436
  });
437
+ if (response.status < 200 || response.status >= 300) {
438
+ const message = ((_a = response.data) == null ? void 0 : _a.message) || "Unknown error";
439
+ throw new Error(`GitHub API Error ${response.status}: ${message}
440
+ URL: ${url}`);
441
+ }
442
+ return response.data;
429
443
  }
430
444
  async function getLatestCommit(owner, repo, branch = "main") {
431
445
  var _a, _b, _c, _d;
@@ -511,34 +525,8 @@ async function resolvePackageResolutionUpdates(resolutions, specialPackageOverri
511
525
  const override = specialPackageOverrides.find((p) => p.pkg === currentPkgName);
512
526
  const latest = override ? await getLatestCommit(override.owner, override.repo, override.branch) : await getLatestCommitAcrossBranches(repo.owner, repo.repo);
513
527
  const new_url = replaceRawWithLatestHash(url, latest.sha);
514
- await import_axios.default.head(new_url, {
515
- headers: {
516
- "User-Agent": selectedUserAgent,
517
- Accept: "application/vnd.github.v3+json",
518
- "X-GitHub-Api-Version": "2022-11-28",
519
- ...ACCESS_TOKEN ? { Authorization: `token ${ACCESS_TOKEN}` } : {}
520
- }
521
- }).then((response) => {
522
- if (response.status < 200 || response.status >= 300) {
523
- updates.push({
524
- failed: true,
525
- currentPkgName,
526
- url,
527
- new_url,
528
- repo,
529
- latest,
530
- error: new Error(`New URL is not accessible, status code: ${response.status}`)
531
- });
532
- return;
533
- }
534
- updates.push({
535
- currentPkgName,
536
- url,
537
- new_url,
538
- repo,
539
- latest
540
- });
541
- }).catch((e) => {
528
+ const response = await (0, import_fetchResponse.default)(new_url);
529
+ if (response.status < 200 || response.status >= 300) {
542
530
  updates.push({
543
531
  failed: true,
544
532
  currentPkgName,
@@ -546,9 +534,18 @@ async function resolvePackageResolutionUpdates(resolutions, specialPackageOverri
546
534
  new_url,
547
535
  repo,
548
536
  latest,
549
- error: new Error(`New URL is not accessible: ${e.message}`)
537
+ error: new Error(`New URL not accessible (status ${response.status}).
538
+ original: ${url}
539
+ new: ${new_url}`)
550
540
  });
551
- return null;
541
+ continue;
542
+ }
543
+ updates.push({
544
+ currentPkgName,
545
+ url,
546
+ new_url,
547
+ repo,
548
+ latest
552
549
  });
553
550
  } catch (error) {
554
551
  updates.push({
@@ -38,7 +38,39 @@ export function resolvePackageResolutionUpdates(resolutions: any, specialPackage
38
38
  url: any;
39
39
  error: unknown;
40
40
  failed?: undefined;
41
+ new_url?: undefined;
41
42
  repo?: undefined;
43
+ latest?: undefined;
44
+ } | {
45
+ failed: boolean;
46
+ currentPkgName: string;
47
+ url: any;
48
+ new_url: string;
49
+ repo: import("git-command-helper").ParsedGitHubUrl;
50
+ latest: {
51
+ owner: any;
52
+ repo: any;
53
+ branch: any;
54
+ sha: any;
55
+ date: any;
56
+ };
57
+ error: Error;
58
+ skipped?: undefined;
59
+ } | {
60
+ currentPkgName: string;
61
+ url: any;
62
+ new_url: string;
63
+ repo: import("git-command-helper").ParsedGitHubUrl;
64
+ latest: {
65
+ owner: any;
66
+ repo: any;
67
+ branch: any;
68
+ sha: any;
69
+ date: any;
70
+ };
71
+ skipped?: undefined;
72
+ error?: undefined;
73
+ failed?: undefined;
42
74
  } | {
43
75
  failed: boolean;
44
76
  currentPkgName: string;
@@ -46,6 +78,8 @@ export function resolvePackageResolutionUpdates(resolutions: any, specialPackage
46
78
  repo: import("git-command-helper").ParsedGitHubUrl;
47
79
  error: unknown;
48
80
  skipped?: undefined;
81
+ new_url?: undefined;
82
+ latest?: undefined;
49
83
  })[]>;
50
84
  export { parseGitHubUrl };
51
85
  import { parseGitHubUrl } from 'git-command-helper';
@@ -6,9 +6,10 @@ import {
6
6
  parseGitHubUrl,
7
7
  replaceRawWithLatestHash,
8
8
  resolvePackageResolutionUpdates
9
- } from "./chunk-66KDU4TX.mjs";
9
+ } from "./chunk-TBWXE7ST.mjs";
10
+ import "./chunk-KLKAIFKI.mjs";
10
11
  import "./chunk-H44UWUFY.mjs";
11
- import "./chunk-5RTXZVCW.mjs";
12
+ import "./chunk-6RK5UCTP.mjs";
12
13
  import "./chunk-QQ4A6DLD.mjs";
13
14
  export {
14
15
  fetchJson,
@@ -4,7 +4,7 @@ var { exec } = require("child_process");
4
4
  var { spawn, spawnSync } = require("child_process");
5
5
  var util = require("util");
6
6
  var fs = require("fs");
7
- var path = require("path");
7
+ var path = require("upath");
8
8
  var execP = util.promisify(exec);
9
9
  function log(...args) {
10
10
  console.log("[php-cs-fixer-staged]", ...args);
@@ -13,7 +13,7 @@ var require_php_cs_fixer_staged = __commonJS({
13
13
  var { spawn, spawnSync } = __require("child_process");
14
14
  var util = __require("util");
15
15
  var fs = __require("fs");
16
- var path = __require("path");
16
+ var path = __require("upath");
17
17
  var execP = util.promisify(exec);
18
18
  function log(...args) {
19
19
  console.log("[php-cs-fixer-staged]", ...args);