binary-collections 2.0.11 → 2.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/.opencode/package.json +5 -0
  2. package/binaries/rmx +15 -1
  3. package/binaries/rmx.cmd +12 -0
  4. package/binaries/test-cjs +9 -1
  5. package/binaries/test-cjs.cmd +16 -1
  6. package/binaries/test-esm +16 -0
  7. package/binaries/test-esm.cjs +178 -0
  8. package/binaries/test-esm.cmd +23 -0
  9. package/binaries/yarn-clean +1 -1
  10. package/binaries/yarn-clean.cmd +1 -1
  11. package/binaries/yarn-clean.py +33 -15
  12. package/binaries/yc +110 -0
  13. package/binaries/yc.cjs +178 -0
  14. package/lib/binary-collections/config.cjs +126 -0
  15. package/lib/binary-collections/config.mjs +7 -0
  16. package/lib/binary-collections/executeScript.cjs +19 -0
  17. package/lib/binary-collections/executeScript.d.cts +12 -0
  18. package/lib/binary-collections/executeScript.mjs +6 -0
  19. package/lib/binary-collections/findScript.cjs +284 -0
  20. package/lib/binary-collections/findScript.d.cts +12 -0
  21. package/lib/binary-collections/findScript.mjs +7 -0
  22. package/lib/binary-collections/listScript.cjs +266 -0
  23. package/lib/binary-collections/listScript.d.cts +19 -0
  24. package/lib/binary-collections/listScript.mjs +7 -0
  25. package/lib/binary-collections.cjs +224 -137
  26. package/lib/binary-collections.mjs +22 -282
  27. package/lib/changelog.cjs +2 -2
  28. package/lib/changelog.mjs +1 -1
  29. package/lib/{chunk-AJDD5DZM.mjs → chunk-2LSRSEXF.mjs} +1 -1
  30. package/lib/{chunk-Z6JLYU2J.mjs → chunk-5RTXZVCW.mjs} +2 -2
  31. package/lib/{chunk-XA3SNBPA.mjs → chunk-66KDU4TX.mjs} +93 -9
  32. package/lib/chunk-6PU7BAHB.mjs +61 -0
  33. package/lib/chunk-C6D2TTYU.mjs +32 -0
  34. package/lib/chunk-FB2WKVJD.mjs +158 -0
  35. package/lib/{chunk-NCXAP7AA.mjs → chunk-G5UUEWUO.mjs} +9 -5
  36. package/lib/{chunk-N436BNBK.mjs → chunk-GAGABICI.mjs} +19 -13
  37. package/lib/chunk-H44UWUFY.mjs +105 -0
  38. package/lib/chunk-NCZPTKDV.mjs +79 -0
  39. package/lib/chunk-NGFK3EYW.mjs +28 -0
  40. package/lib/chunk-NVEG3LEZ.mjs +143 -0
  41. package/lib/chunk-OGXVGBRI.mjs +29 -0
  42. package/lib/chunk-OXV52GD5.mjs +62 -0
  43. package/lib/chunk-PXBMHE7O.mjs +35 -0
  44. package/lib/chunk-R5FJOR63.mjs +47 -0
  45. package/lib/chunk-SPTECFE5.mjs +180 -0
  46. package/lib/chunk-UXCFNAR6.mjs +55 -0
  47. package/lib/chunk-V2IBPCEV.mjs +39 -0
  48. package/lib/chunk-XPJGCDOD.mjs +14 -0
  49. package/lib/chunk-ZOWVMII3.mjs +228 -0
  50. package/lib/clean-github-actions-caches-cli.cjs +465 -0
  51. package/lib/clean-github-actions-caches-cli.d.cts +1 -0
  52. package/lib/clean-github-actions-caches-cli.mjs +56 -0
  53. package/lib/clean-github-actions-caches.cjs +149 -205
  54. package/lib/clean-github-actions-caches.d.cts +15 -1
  55. package/lib/clean-github-actions-caches.mjs +4 -130
  56. package/lib/cross-env/command.cjs +63 -0
  57. package/lib/cross-env/command.d.ts +8 -0
  58. package/lib/cross-env/command.js +45 -0
  59. package/lib/cross-env/command.mjs +9 -0
  60. package/lib/cross-env/index.cjs +178 -0
  61. package/lib/cross-env/index.d.ts +8 -0
  62. package/lib/cross-env/index.js +102 -0
  63. package/lib/cross-env/index.mjs +101 -0
  64. package/lib/cross-env/variable.cjs +60 -0
  65. package/lib/cross-env/variable.d.ts +7 -0
  66. package/lib/cross-env/variable.js +59 -0
  67. package/lib/cross-env/variable.mjs +9 -0
  68. package/lib/del-gradle.cjs +2 -2
  69. package/lib/del-gradle.js +8 -8
  70. package/lib/del-gradle.mjs +1 -1
  71. package/lib/del-node-modules.js +24 -24
  72. package/lib/del-ps.cjs +2 -2
  73. package/lib/del-ps.js +8 -8
  74. package/lib/del-ps.mjs +1 -1
  75. package/lib/del-yarn-caches.cjs +2 -2
  76. package/lib/del-yarn-caches.js +2 -2
  77. package/lib/del-yarn-caches.mjs +1 -1
  78. package/lib/file/copy-cli.cjs +92 -0
  79. package/lib/file/copy-cli.d.mts +1 -0
  80. package/lib/file/copy-cli.mjs +55 -0
  81. package/lib/file/copy.cjs +56 -0
  82. package/lib/file/copy.d.mts +1 -0
  83. package/lib/file/copy.mjs +8 -0
  84. package/lib/file/move-cli.cjs +91 -0
  85. package/lib/file/move-cli.d.mts +1 -0
  86. package/lib/file/move-cli.mjs +55 -0
  87. package/lib/file/move.cjs +55 -0
  88. package/lib/file/move.d.mts +1 -0
  89. package/lib/file/move.mjs +8 -0
  90. package/lib/find-node-modules-cli.js +1 -1
  91. package/lib/free-chatgpt.cjs +21 -15
  92. package/lib/free-chatgpt.js +10 -10
  93. package/lib/free-chatgpt.mjs +2 -2
  94. package/lib/git/user-config.cjs +2 -2
  95. package/lib/git/user-config.mjs +2 -2
  96. package/lib/git-diff-cli.cjs +188 -42
  97. package/lib/git-diff-cli.mjs +5 -4
  98. package/lib/git-diff.cjs +188 -42
  99. package/lib/git-diff.d.ts +2 -1
  100. package/lib/git-diff.js +91 -34
  101. package/lib/git-diff.mjs +5 -4
  102. package/lib/git-fix.cjs +2 -2
  103. package/lib/git-fix.mjs +2 -2
  104. package/lib/git-purge.cjs +2 -2
  105. package/lib/git-purge.mjs +1 -1
  106. package/lib/index.d.ts +1 -1
  107. package/lib/kill-night-crows.cjs +7 -7
  108. package/lib/kill-night-crows.mjs +7 -7
  109. package/lib/node-cache-cleaner/npm.cjs +65 -0
  110. package/lib/node-cache-cleaner/npm.d.ts +2 -0
  111. package/lib/node-cache-cleaner/npm.js +41 -0
  112. package/lib/node-cache-cleaner/npm.mjs +10 -0
  113. package/lib/node-cache-cleaner/npx.cjs +89 -0
  114. package/lib/node-cache-cleaner/npx.d.ts +4 -0
  115. package/lib/node-cache-cleaner/npx.js +82 -0
  116. package/lib/{ps/index.d.mjs → node-cache-cleaner/npx.mjs} +6 -5
  117. package/lib/node-cache-cleaner/yarn.cjs +73 -0
  118. package/lib/node-cache-cleaner/yarn.d.ts +2 -0
  119. package/lib/node-cache-cleaner/yarn.js +62 -0
  120. package/lib/node-cache-cleaner/yarn.mjs +10 -0
  121. package/lib/node-cache-cleaner-cli.cjs +182 -0
  122. package/lib/node-cache-cleaner-cli.d.ts +2 -0
  123. package/lib/node-cache-cleaner-cli.js +60 -0
  124. package/lib/node-cache-cleaner-cli.mjs +56 -0
  125. package/lib/node-executor.cjs +91 -0
  126. package/lib/node-executor.d.cts +2 -0
  127. package/lib/node-executor.mjs +103 -0
  128. package/lib/npm-run-series.cjs +21 -28
  129. package/lib/npm-run-series.mjs +20 -6
  130. package/lib/package-resolutions-updater-cli.cjs +213 -128
  131. package/lib/package-resolutions-updater-cli.mjs +17 -39
  132. package/lib/package-resolutions-updater.cjs +204 -98
  133. package/lib/package-resolutions-updater.d.mts +20 -1
  134. package/lib/package-resolutions-updater.mjs +7 -5
  135. package/lib/print-directory-tree.cjs +2 -2
  136. package/lib/print-directory-tree.mjs +1 -1
  137. package/lib/ps/connected-domain.js +10 -10
  138. package/lib/ps/index.cjs +1 -1
  139. package/lib/ps/index.mjs +177 -171
  140. package/lib/ps/isWin.js +1 -1
  141. package/lib/ps/table-parser.js +6 -6
  142. package/lib/remove-module.cjs +2 -2
  143. package/lib/remove-module.mjs +1 -1
  144. package/lib/rm-node-module-cli.cjs +222 -0
  145. package/lib/rm-node-module-cli.d.cts +1 -0
  146. package/lib/rm-node-module-cli.mjs +89 -0
  147. package/lib/rm-node-modules.cjs +127 -0
  148. package/lib/rm-node-modules.d.cts +35 -0
  149. package/lib/{binary-collections-config.mjs → rm-node-modules.mjs} +3 -3
  150. package/lib/rmpath.cjs +2 -2
  151. package/lib/rmpath.mjs +1 -1
  152. package/lib/submodule-install.cjs +47 -34
  153. package/lib/submodule-install.mjs +46 -33
  154. package/lib/submodule-remove-cli.cjs +1 -2
  155. package/lib/submodule-remove-cli.js +3 -3
  156. package/lib/submodule-remove-cli.mjs +1 -2
  157. package/lib/utils/chatgpt.cjs +19 -13
  158. package/lib/utils/chatgpt.js +94 -94
  159. package/lib/utils/chatgpt.mjs +1 -1
  160. package/lib/utils/findEnvFiles.cjs +28 -46
  161. package/lib/utils/findEnvFiles.d.cts +19 -0
  162. package/lib/utils/findEnvFiles.mjs +3 -5
  163. package/lib/utils/findWorkspaceRoot.js +4 -4
  164. package/lib/utils/index.cjs +2 -2
  165. package/lib/utils/index.mjs +1 -1
  166. package/lib/utils/isGithubTokenValid.js +7 -7
  167. package/lib/{ps/index.d.cjs → utils/isWindows.cjs} +17 -3
  168. package/lib/utils/isWindows.d.ts +5 -0
  169. package/lib/utils/isWindows.js +10 -0
  170. package/lib/utils/isWindows.mjs +8 -0
  171. package/lib/utils/runBash.cjs +53 -0
  172. package/lib/utils/runBash.d.cts +12 -0
  173. package/lib/utils/runBash.mjs +66 -0
  174. package/lib/yarn-per-branch-lock-installer.cjs +97 -0
  175. package/lib/yarn-per-branch-lock-installer.d.cts +2 -0
  176. package/lib/yarn-per-branch-lock-installer.mjs +109 -0
  177. package/lib/yarn-reinstall.cjs +2 -2
  178. package/lib/yarn-reinstall.mjs +1 -1
  179. package/package.json +61 -52
  180. package/readme.html +784 -0
  181. package/readme.md +106 -218
  182. package/releases/readme.md +1 -1
  183. package/test/README.md +2 -2
  184. package/test-project/package.json +8 -2
  185. package/test-project/workspaces/workspace-a/package.json +135 -0
  186. package/test-project/workspaces/workspace-a/readme.md +20 -0
  187. package/test-project/workspaces/workspace-a/release/readme.md +42 -0
  188. package/test-project/workspaces/workspace-a/test/demo/package.json +25 -0
  189. package/test-project/workspaces/workspace-a/test/readme.md +12 -0
  190. package/test-project/workspaces/workspace-b/package.json +139 -0
  191. package/test-project/workspaces/workspace-b/readme.md +94 -0
  192. package/test-project/workspaces/workspace-b/requirements.txt +1 -0
  193. package/test-project/workspaces/workspace-b/test/sample-project/package.json +7 -0
  194. package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/package.json +96 -0
  195. package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/readme.md +156 -0
  196. package/tmp/rm-node-modules-test-project/package.json +17 -0
  197. package/tmp/rm-node-modules-test-project/packages/workspace-a/package.json +16 -0
  198. package/tmp/rm-node-modules-test-project/packages/workspace-b/package.json +16 -0
  199. package/tmp/test-repo/README.md +2 -35
  200. package/tmp/test-repo/package.json +13 -3
  201. package/docs-src/clean-github-actions-caches.md +0 -26
  202. package/docs-src/free-chatgpt.md +0 -26
  203. package/lib/binary-collections-config.cjs +0 -15
  204. package/lib/chunk-2CBJCW7E.mjs +0 -81
  205. package/lib/chunk-4UHL4WVN.mjs +0 -136
  206. package/lib/chunk-66PAU5PS.mjs +0 -31
  207. package/lib/chunk-6HHJRKFB.mjs +0 -59
  208. package/lib/chunk-7XTEJHOE.mjs +0 -193
  209. package/lib/chunk-FCDQGYBF.mjs +0 -136
  210. package/lib/chunk-GEYA2USY.mjs +0 -207
  211. package/lib/chunk-GJTGHXRA.mjs +0 -356
  212. package/lib/chunk-ID2WBTE2.mjs +0 -80
  213. package/lib/chunk-JXFOHKDM.mjs +0 -239
  214. package/lib/chunk-PDSXF5HY.mjs +0 -187
  215. package/lib/chunk-RWLXRTYP.mjs +0 -109
  216. package/lib/chunk-TOIVAQF7.mjs +0 -136
  217. package/lib/chunk-V5SKYJUB.mjs +0 -136
  218. package/lib/chunk-WSRETQCA.mjs +0 -59
  219. package/lib/chunk-YYLIQQKF.mjs +0 -31
  220. package/lib/ps/index.d.ts +0 -2
  221. package/lib/ps/index.js +0 -254
  222. package/lib/utils/findEnvFiles.d.ts +0 -8
  223. package/lib/utils/findEnvFiles.js +0 -121
  224. package/tmp/typedoc/readme.md +0 -320
  225. /package/lib/{binary-collections-config.d.cts → binary-collections/config.d.cts} +0 -0
@@ -38,8 +38,8 @@ var init_cjs_shims = __esm({
38
38
  var require_utils = __commonJS({
39
39
  "src/utils/index.cjs"(exports2, module2) {
40
40
  init_cjs_shims();
41
- var fs4 = require("fs");
42
- var path4 = require("upath");
41
+ var fs3 = require("fs");
42
+ var path3 = require("upath");
43
43
  var argv = require("minimist")(process.argv.slice(2));
44
44
  var { exec } = require("child_process");
45
45
  var { URL: URL2 } = require("url");
@@ -90,11 +90,11 @@ var require_utils = __commonJS({
90
90
  module2.exports.getArgs = getArgs2;
91
91
  function del(fullPath) {
92
92
  try {
93
- if (!fs4.existsSync(fullPath)) return;
94
- const stat = fs4.lstatSync(fullPath);
93
+ if (!fs3.existsSync(fullPath)) return;
94
+ const stat = fs3.lstatSync(fullPath);
95
95
  if (stat.isSymbolicLink()) {
96
96
  try {
97
- fs4.unlinkSync(fullPath);
97
+ fs3.unlinkSync(fullPath);
98
98
  console.log("deleted symlink", fullPath);
99
99
  } catch (e) {
100
100
  console.log("failed delete symlink", fullPath, e && e.message);
@@ -102,16 +102,16 @@ var require_utils = __commonJS({
102
102
  return;
103
103
  }
104
104
  if (stat.isDirectory()) {
105
- const subdir = fs4.readdirSync(fullPath).map((dirPath) => path4.resolve(fullPath, dirPath));
105
+ const subdir = fs3.readdirSync(fullPath).map((dirPath) => path3.resolve(fullPath, dirPath));
106
106
  for (let i = 0; i < subdir.length; i++) {
107
107
  del(subdir[i]);
108
108
  }
109
109
  try {
110
- fs4.rmdirSync(fullPath);
110
+ fs3.rmdirSync(fullPath);
111
111
  console.log("deleted", fullPath);
112
- } catch (e) {
112
+ } catch (_e) {
113
113
  try {
114
- fs4.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
114
+ fs3.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
115
115
  console.log("deleted", fullPath);
116
116
  } catch (ee) {
117
117
  console.log("failed delete", fullPath, ee && ee.message);
@@ -120,11 +120,11 @@ var require_utils = __commonJS({
120
120
  return;
121
121
  }
122
122
  try {
123
- fs4.unlinkSync(fullPath);
123
+ fs3.unlinkSync(fullPath);
124
124
  console.log("deleted", fullPath);
125
- } catch (e) {
125
+ } catch (_e) {
126
126
  try {
127
- fs4.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
127
+ fs3.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
128
128
  console.log("deleted", fullPath);
129
129
  } catch (ee) {
130
130
  console.log("failed delete", fullPath, ee && ee.message);
@@ -137,13 +137,13 @@ var require_utils = __commonJS({
137
137
  module2.exports.del = del;
138
138
  function delStream(globStream) {
139
139
  globStream.stream().on("data", (result) => {
140
- const fullPath = path4.resolve(process.cwd(), result);
140
+ const fullPath = path3.resolve(process.cwd(), result);
141
141
  try {
142
- if (fs4.existsSync(fullPath)) {
143
- const stat = fs4.lstatSync(fullPath);
142
+ if (fs3.existsSync(fullPath)) {
143
+ const stat = fs3.lstatSync(fullPath);
144
144
  if (stat.isSymbolicLink()) {
145
145
  try {
146
- fs4.unlinkSync(fullPath);
146
+ fs3.unlinkSync(fullPath);
147
147
  console.log("deleted symlink", fullPath);
148
148
  } catch (e) {
149
149
  console.log("failed delete symlink", fullPath, e && e.message);
@@ -151,7 +151,7 @@ var require_utils = __commonJS({
151
151
  return;
152
152
  }
153
153
  if (stat.isDirectory()) {
154
- const subdir = fs4.readdirSync(fullPath).map((dirPath) => path4.resolve(fullPath, dirPath));
154
+ const subdir = fs3.readdirSync(fullPath).map((dirPath) => path3.resolve(fullPath, dirPath));
155
155
  for (let i = 0; i < subdir.length; i++) {
156
156
  del(subdir[i]);
157
157
  }
@@ -206,6 +206,101 @@ var require_utils = __commonJS({
206
206
  }
207
207
  });
208
208
 
209
+ // src/utils/findEnvFiles.cjs
210
+ var require_findEnvFiles = __commonJS({
211
+ "src/utils/findEnvFiles.cjs"(exports2, module2) {
212
+ init_cjs_shims();
213
+ var fs3 = require("fs");
214
+ var path3 = require("path");
215
+ var glob = require("glob");
216
+ var DEFAULT_IGNORES = [
217
+ "**/node_modules/**",
218
+ "**/.git/**",
219
+ "**/.yarn/**",
220
+ "**/.pnpm/**",
221
+ "**/dist/**",
222
+ "**/build/**",
223
+ "**/coverage/**",
224
+ "**/vendor/**",
225
+ "**/tmp/**",
226
+ "**/.cache/**",
227
+ "**/assets/**",
228
+ "**/logs/**",
229
+ "**/output/**",
230
+ "**/public/**",
231
+ "**/static/**",
232
+ "**/temp/**",
233
+ "**/backup/**",
234
+ "**/backups/**",
235
+ "**/examples/**",
236
+ "**/docs/**",
237
+ "**/tests/**",
238
+ "**/__tests__/**",
239
+ "**/spec/**",
240
+ "**/__specs__/**",
241
+ "**/scripts/**",
242
+ "**/bin/**",
243
+ "**/hooks/**",
244
+ "**/config/**",
245
+ "**/configs/**",
246
+ "**/settings/**",
247
+ "**/.vscode/**",
248
+ "**/.idea/**"
249
+ ];
250
+ function findEnvFiles2(startDir = process.cwd(), filter) {
251
+ const found = /* @__PURE__ */ new Set();
252
+ function addFile(file) {
253
+ const normalized = path3.normalize(file);
254
+ if (typeof filter === "function" && !filter(normalized)) {
255
+ return;
256
+ }
257
+ found.add(normalized);
258
+ }
259
+ let current = path3.resolve(startDir);
260
+ while (true) {
261
+ const envPath2 = path3.join(current, ".env");
262
+ if (fs3.existsSync(envPath2)) {
263
+ addFile(envPath2);
264
+ }
265
+ const parent = path3.dirname(current);
266
+ if (parent === current) {
267
+ break;
268
+ }
269
+ current = parent;
270
+ }
271
+ const files = glob.globSync("**/.env*", {
272
+ cwd: startDir,
273
+ absolute: true,
274
+ nodir: true,
275
+ ignore: DEFAULT_IGNORES
276
+ });
277
+ for (const file of files) {
278
+ addFile(file);
279
+ }
280
+ return [...found];
281
+ }
282
+ function findEnvWithToken(startDir = process.cwd(), tokenName = "GITHUB_TOKEN") {
283
+ const envFiles = findEnvFiles2(startDir);
284
+ return envFiles.find((file) => {
285
+ try {
286
+ const content = fs3.readFileSync(file, "utf-8");
287
+ const regex = new RegExp(`^\\s*${tokenName}\\s*=`, "m");
288
+ return regex.test(content);
289
+ } catch (err) {
290
+ console.warn(`Failed to read ${file}: ${err instanceof Error ? err.message : String(err)}`);
291
+ return false;
292
+ }
293
+ });
294
+ }
295
+ module2.exports = {
296
+ DEFAULT_IGNORES,
297
+ findEnvFiles: findEnvFiles2,
298
+ findEnvWithToken,
299
+ default: findEnvFiles2
300
+ };
301
+ }
302
+ });
303
+
209
304
  // src/package-resolutions-updater-cli.mjs
210
305
  init_cjs_shims();
211
306
  var import_ansi_colors = __toESM(require("ansi-colors"), 1);
@@ -220,86 +315,14 @@ var import_https = __toESM(require("https"), 1);
220
315
  var import_os = __toESM(require("os"), 1);
221
316
  var import_path = __toESM(require("path"), 1);
222
317
  var utils = __toESM(require_utils(), 1);
223
-
224
- // src/utils/findEnvFiles.js
225
- init_cjs_shims();
226
- var import_node_fs = __toESM(require("fs"), 1);
227
- var import_node_path = __toESM(require("path"), 1);
228
- var glob = __toESM(require("glob"), 1);
229
- var DEFAULT_IGNORES = [
230
- "**/node_modules/**",
231
- "**/.git/**",
232
- "**/.yarn/**",
233
- "**/.pnpm/**",
234
- "**/dist/**",
235
- "**/build/**",
236
- "**/coverage/**",
237
- "**/vendor/**",
238
- "**/tmp/**",
239
- "**/.cache/**",
240
- "**/assets/**",
241
- "**/logs/**",
242
- "**/output/**",
243
- "**/public/**",
244
- "**/static/**",
245
- "**/temp/**",
246
- "**/backup/**",
247
- "**/backups/**",
248
- "**/examples/**",
249
- "**/docs/**",
250
- "**/tests/**",
251
- "**/__tests__/**",
252
- "**/spec/**",
253
- "**/__specs__/**",
254
- "**/scripts/**",
255
- "**/bin/**",
256
- "**/hooks/**",
257
- "**/config/**",
258
- "**/configs/**",
259
- "**/settings/**",
260
- "**/.vscode/**",
261
- "**/.idea/**"
262
- ];
263
- function findEnvFiles(startDir = process.cwd(), filter) {
264
- const found = /* @__PURE__ */ new Set();
265
- function addFile(file) {
266
- const normalized = import_node_path.default.normalize(file);
267
- if (typeof filter === "function" && !filter(normalized)) {
268
- return;
269
- }
270
- found.add(normalized);
271
- }
272
- let current = import_node_path.default.resolve(startDir);
273
- while (true) {
274
- const envPath2 = import_node_path.default.join(current, ".env");
275
- if (import_node_fs.default.existsSync(envPath2)) {
276
- addFile(envPath2);
277
- }
278
- const parent = import_node_path.default.dirname(current);
279
- if (parent === current) {
280
- break;
281
- }
282
- current = parent;
283
- }
284
- const files = glob.globSync("**/.env*", {
285
- cwd: startDir,
286
- absolute: true,
287
- nodir: true,
288
- ignore: DEFAULT_IGNORES
289
- });
290
- for (const file of files) {
291
- addFile(file);
292
- }
293
- return [...found];
294
- }
295
-
296
- // src/package-resolutions-updater.mjs
318
+ var import_findEnvFiles = __toESM(require_findEnvFiles(), 1);
297
319
  var import_git_command_helper = require("git-command-helper");
320
+ var import_axios = __toESM(require("axios"), 1);
298
321
  var projectDir = process.cwd();
299
322
  var envPath = import_path.default.join(projectDir, ".env");
300
323
  var args = utils.getArgs();
301
324
  if (!import_fs.default.existsSync(envPath)) {
302
- const envFiles = findEnvFiles(projectDir, (file) => {
325
+ const envFiles = (0, import_findEnvFiles.findEnvFiles)(projectDir, (file) => {
303
326
  const content = import_fs.default.readFileSync(file, "utf-8");
304
327
  return /GITHUB_TOKEN|ACCESS_TOKEN/.test(content);
305
328
  });
@@ -445,10 +468,91 @@ async function getLatestCommitAcrossBranches(owner, repo) {
445
468
  };
446
469
  }
447
470
  function replaceRawWithLatestHash(url, latestHash) {
448
- const match = url.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/raw\/([^/]+)\/(.+)$/);
449
- if (!match) throw new Error("Invalid GitHub raw URL");
450
- const [, owner, repo, _oldHash, path4] = match;
451
- return `https://github.com/${owner}/${repo}/raw/${latestHash}/${path4}`;
471
+ const parsed = (0, import_git_command_helper.parseGitHubUrl)(url);
472
+ if (!parsed || !parsed.owner || !parsed.repo || !parsed.branch) {
473
+ throw new Error("Invalid GitHub raw URL");
474
+ }
475
+ const branchPrefix = `${parsed.branch}/`;
476
+ const rawPrefix = parsed.host === "github.com" ? `raw/${branchPrefix}` : branchPrefix;
477
+ const refsPrefix = `refs/heads/${branchPrefix}`;
478
+ const path3 = parsed.path.startsWith(rawPrefix) ? parsed.path.slice(rawPrefix.length) : parsed.path.startsWith(refsPrefix) ? parsed.path.slice(refsPrefix.length) : parsed.path.startsWith(branchPrefix) ? parsed.path.slice(branchPrefix.length) : parsed.path;
479
+ if (parsed.host === "github.com") {
480
+ return `https://github.com/${parsed.owner}/${parsed.repo}/raw/${latestHash}/${path3}`;
481
+ }
482
+ if (parsed.host === "raw.githubusercontent.com") {
483
+ return `https://raw.githubusercontent.com/${parsed.owner}/${parsed.repo}/${latestHash}/${path3}`;
484
+ }
485
+ throw new Error("Invalid GitHub raw URL");
486
+ }
487
+ async function resolvePackageResolutionUpdates(resolutions, specialPackageOverrides = []) {
488
+ const updates = [];
489
+ for (const [currentPkgName, url] of Object.entries(resolutions || {})) {
490
+ let repo;
491
+ try {
492
+ repo = (0, import_git_command_helper.parseGitHubUrl)(url);
493
+ } catch (error) {
494
+ updates.push({
495
+ skipped: true,
496
+ currentPkgName,
497
+ url,
498
+ error
499
+ });
500
+ continue;
501
+ }
502
+ try {
503
+ const override = specialPackageOverrides.find((p) => p.pkg === currentPkgName);
504
+ const latest = override ? await getLatestCommit(override.owner, override.repo, override.branch) : await getLatestCommitAcrossBranches(repo.owner, repo.repo);
505
+ 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) => {
534
+ updates.push({
535
+ failed: true,
536
+ currentPkgName,
537
+ url,
538
+ new_url,
539
+ repo,
540
+ latest,
541
+ error: new Error(`New URL is not accessible: ${e.message}`)
542
+ });
543
+ return null;
544
+ });
545
+ } catch (error) {
546
+ updates.push({
547
+ failed: true,
548
+ currentPkgName,
549
+ url,
550
+ repo,
551
+ error
552
+ });
553
+ }
554
+ }
555
+ return updates;
452
556
  }
453
557
 
454
558
  // src/package-resolutions-updater-cli.mjs
@@ -464,12 +568,6 @@ function replaceRawWithLatestHash(url, latestHash) {
464
568
  // Hexo family
465
569
  // { pkg: "hexo", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
466
570
  // { pkg: "hexo-util", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
467
- // { pkg: "warehouse", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
468
- // { pkg: "hexo-server", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
469
- // { pkg: "hexo-log", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
470
- // { pkg: "hexo-front-matter", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
471
- // { pkg: "hexo-cli", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
472
- // { pkg: "hexo-asset-link", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
473
571
  { pkg: "hexo-post-parser", branch: "pre-release", repo: "hexo-post-parser", owner: "dimaslanjaka" },
474
572
  { pkg: "hexo-seo", branch: "pre-release", repo: "hexo-seo", owner: "dimaslanjaka" },
475
573
  { pkg: "hexo-is", branch: "master", repo: "hexo-is", owner: "dimaslanjaka" },
@@ -503,38 +601,25 @@ function replaceRawWithLatestHash(url, latestHash) {
503
601
  console.log(import_ansi_colors.default.yellow("No resolutions found in package.json"));
504
602
  return;
505
603
  }
506
- console.log(`Processing ${entries.length} resolution(s)...`);
507
- const updates = [];
508
- for (const [currentPkgName, url] of entries) {
509
- let repo;
510
- try {
511
- repo = (0, import_git_command_helper.parseGitHubUrl)(url);
512
- } catch (error) {
513
- console.log(`\u23ED\uFE0F Skipping ${import_ansi_colors.default.yellow(currentPkgName)}: ${error.message}`);
514
- continue;
604
+ console.log(`\u2699\uFE0F Processing ${entries.length} resolution(s)...`);
605
+ const updates = await resolvePackageResolutionUpdates(pkg.resolutions, specialPackageOverrides);
606
+ const validUpdates = updates.filter((u) => !u.skipped && !u.failed);
607
+ for (const update of updates) {
608
+ if (update.skipped) {
609
+ console.log(`\u23ED\uFE0F Skipping ${import_ansi_colors.default.yellow(update.currentPkgName)}: ${update.error.message}`);
515
610
  }
516
- try {
517
- const override = specialPackageOverrides.find((p) => p.pkg === currentPkgName);
518
- const latest = override ? await getLatestCommit(override.owner, override.repo, override.branch) : await getLatestCommitAcrossBranches(repo.owner, repo.repo);
519
- const new_url = replaceRawWithLatestHash(url, latest.sha);
520
- updates.push({
521
- currentPkgName,
522
- url,
523
- new_url,
524
- repo,
525
- latest
526
- });
527
- } catch (error) {
528
- console.log(`\u274C Failed to process ${import_ansi_colors.default.red(currentPkgName)}: ${error.message}`);
611
+ if (update.failed) {
612
+ console.log(`\u274C Failed to process ${import_ansi_colors.default.red(update.currentPkgName)}: ${update.error.message}`);
529
613
  }
530
614
  }
531
- if (updates.length === 0) {
615
+ console.log("");
616
+ if (validUpdates.length === 0) {
532
617
  console.log(import_ansi_colors.default.yellow("No GitHub URLs were processed"));
533
618
  return;
534
619
  }
535
- console.log(`\u{1F4DD} Applying updates to ${updates.length} GitHub URL(s)...`);
620
+ console.log(`\u{1F4DD} Applying updates to ${validUpdates.length} GitHub URL(s)...`);
536
621
  let changed = false;
537
- for (const { currentPkgName, url, new_url, repo, latest } of updates) {
622
+ for (const { currentPkgName, url, new_url, repo, latest } of validUpdates) {
538
623
  if (url !== new_url) {
539
624
  console.log(`${import_ansi_colors.default.cyan(currentPkgName)}:`);
540
625
  console.log(" from:", url.replace(repo.branch, import_ansi_colors.default.red(repo.branch)));
@@ -548,7 +633,7 @@ function replaceRawWithLatestHash(url, latestHash) {
548
633
  console.log("\n\u{1F4CC} Summary:");
549
634
  if (changed) {
550
635
  try {
551
- import_fs2.default.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "");
636
+ import_fs2.default.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
552
637
  console.log(`\u2705 package.json updated successfully`);
553
638
  } catch (e) {
554
639
  console.error(import_ansi_colors.default.red(`Failed to write package.json: ${e.message}`));
@@ -1,12 +1,9 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
- getLatestCommit,
4
- getLatestCommitAcrossBranches,
5
- parseGitHubUrl,
6
- replaceRawWithLatestHash
7
- } from "./chunk-XA3SNBPA.mjs";
8
- import "./chunk-ID2WBTE2.mjs";
9
- import "./chunk-Z6JLYU2J.mjs";
3
+ resolvePackageResolutionUpdates
4
+ } from "./chunk-66KDU4TX.mjs";
5
+ import "./chunk-H44UWUFY.mjs";
6
+ import "./chunk-5RTXZVCW.mjs";
10
7
  import {
11
8
  init_esm_shims
12
9
  } from "./chunk-QQ4A6DLD.mjs";
@@ -28,12 +25,6 @@ import path from "path";
28
25
  // Hexo family
29
26
  // { pkg: "hexo", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
30
27
  // { pkg: "hexo-util", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
31
- // { pkg: "warehouse", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
32
- // { pkg: "hexo-server", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
33
- // { pkg: "hexo-log", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
34
- // { pkg: "hexo-front-matter", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
35
- // { pkg: "hexo-cli", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
36
- // { pkg: "hexo-asset-link", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
37
28
  { pkg: "hexo-post-parser", branch: "pre-release", repo: "hexo-post-parser", owner: "dimaslanjaka" },
38
29
  { pkg: "hexo-seo", branch: "pre-release", repo: "hexo-seo", owner: "dimaslanjaka" },
39
30
  { pkg: "hexo-is", branch: "master", repo: "hexo-is", owner: "dimaslanjaka" },
@@ -67,38 +58,25 @@ import path from "path";
67
58
  console.log(ansiColors.yellow("No resolutions found in package.json"));
68
59
  return;
69
60
  }
70
- console.log(`Processing ${entries.length} resolution(s)...`);
71
- const updates = [];
72
- for (const [currentPkgName, url] of entries) {
73
- let repo;
74
- try {
75
- repo = parseGitHubUrl(url);
76
- } catch (error) {
77
- console.log(`\u23ED\uFE0F Skipping ${ansiColors.yellow(currentPkgName)}: ${error.message}`);
78
- continue;
61
+ console.log(`\u2699\uFE0F Processing ${entries.length} resolution(s)...`);
62
+ const updates = await resolvePackageResolutionUpdates(pkg.resolutions, specialPackageOverrides);
63
+ const validUpdates = updates.filter((u) => !u.skipped && !u.failed);
64
+ for (const update of updates) {
65
+ if (update.skipped) {
66
+ console.log(`\u23ED\uFE0F Skipping ${ansiColors.yellow(update.currentPkgName)}: ${update.error.message}`);
79
67
  }
80
- try {
81
- const override = specialPackageOverrides.find((p) => p.pkg === currentPkgName);
82
- const latest = override ? await getLatestCommit(override.owner, override.repo, override.branch) : await getLatestCommitAcrossBranches(repo.owner, repo.repo);
83
- const new_url = replaceRawWithLatestHash(url, latest.sha);
84
- updates.push({
85
- currentPkgName,
86
- url,
87
- new_url,
88
- repo,
89
- latest
90
- });
91
- } catch (error) {
92
- console.log(`\u274C Failed to process ${ansiColors.red(currentPkgName)}: ${error.message}`);
68
+ if (update.failed) {
69
+ console.log(`\u274C Failed to process ${ansiColors.red(update.currentPkgName)}: ${update.error.message}`);
93
70
  }
94
71
  }
95
- if (updates.length === 0) {
72
+ console.log("");
73
+ if (validUpdates.length === 0) {
96
74
  console.log(ansiColors.yellow("No GitHub URLs were processed"));
97
75
  return;
98
76
  }
99
- console.log(`\u{1F4DD} Applying updates to ${updates.length} GitHub URL(s)...`);
77
+ console.log(`\u{1F4DD} Applying updates to ${validUpdates.length} GitHub URL(s)...`);
100
78
  let changed = false;
101
- for (const { currentPkgName, url, new_url, repo, latest } of updates) {
79
+ for (const { currentPkgName, url, new_url, repo, latest } of validUpdates) {
102
80
  if (url !== new_url) {
103
81
  console.log(`${ansiColors.cyan(currentPkgName)}:`);
104
82
  console.log(" from:", url.replace(repo.branch, ansiColors.red(repo.branch)));
@@ -112,7 +90,7 @@ import path from "path";
112
90
  console.log("\n\u{1F4CC} Summary:");
113
91
  if (changed) {
114
92
  try {
115
- fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "");
93
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
116
94
  console.log(`\u2705 package.json updated successfully`);
117
95
  } catch (e) {
118
96
  console.error(ansiColors.red(`Failed to write package.json: ${e.message}`));