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
@@ -12,6 +12,173 @@ var init_cjs_shims = __esm({
12
12
  }
13
13
  });
14
14
 
15
+ // src/utils/index.cjs
16
+ var require_utils = __commonJS({
17
+ "src/utils/index.cjs"(exports2, module2) {
18
+ init_cjs_shims();
19
+ var fs = require("fs");
20
+ var path = require("upath");
21
+ var minimistLib = require("minimist");
22
+ var argv2 = minimistLib(process.argv.slice(2));
23
+ var { exec } = require("child_process");
24
+ var { promisify } = require("util");
25
+ var execAsync = promisify(exec);
26
+ async function parseGitRemotes() {
27
+ try {
28
+ const { stdout } = await execAsync("git remote -v");
29
+ const lines = stdout.split("\n");
30
+ const remotes = {};
31
+ lines.forEach((line) => {
32
+ const [name, url] = line.split(" ");
33
+ if (name && url) {
34
+ const [repoUrl] = url.split(" ");
35
+ try {
36
+ const parsedUrl = new URL(repoUrl);
37
+ const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
38
+ if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
39
+ let repoPath = pathParts.join("/");
40
+ if (repoPath.endsWith(".git")) {
41
+ repoPath = repoPath.slice(0, -4);
42
+ }
43
+ remotes[name] = repoPath;
44
+ }
45
+ } catch (e) {
46
+ console.error("URL Parsing Error:", e.message);
47
+ }
48
+ }
49
+ });
50
+ return remotes;
51
+ } catch (error) {
52
+ console.error("Error:", error.message);
53
+ return {};
54
+ }
55
+ }
56
+ module2.exports.parseGitRemotes = parseGitRemotes;
57
+ function getArgs2(opts) {
58
+ if (opts) {
59
+ return minimistLib(process.argv.slice(2), opts);
60
+ }
61
+ return argv2;
62
+ }
63
+ module2.exports.getArgs = getArgs2;
64
+ function del(fullPath) {
65
+ try {
66
+ if (!fs.existsSync(fullPath)) return;
67
+ const stat = fs.lstatSync(fullPath);
68
+ if (stat.isSymbolicLink()) {
69
+ try {
70
+ fs.unlinkSync(fullPath);
71
+ console.log("deleted symlink", fullPath);
72
+ } catch (e) {
73
+ console.log("failed delete symlink", fullPath, e && e.message);
74
+ }
75
+ return;
76
+ }
77
+ if (stat.isDirectory()) {
78
+ const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
79
+ for (let i = 0; i < subdir.length; i++) {
80
+ del(subdir[i]);
81
+ }
82
+ try {
83
+ fs.rmdirSync(fullPath);
84
+ console.log("deleted", fullPath);
85
+ } catch (_e) {
86
+ try {
87
+ fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
88
+ console.log("deleted", fullPath);
89
+ } catch (ee) {
90
+ console.log("failed delete", fullPath, ee && ee.message);
91
+ }
92
+ }
93
+ return;
94
+ }
95
+ try {
96
+ fs.unlinkSync(fullPath);
97
+ console.log("deleted", fullPath);
98
+ } catch (_e) {
99
+ try {
100
+ fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
101
+ console.log("deleted", fullPath);
102
+ } catch (ee) {
103
+ console.log("failed delete", fullPath, ee && ee.message);
104
+ }
105
+ }
106
+ } catch (err) {
107
+ console.log("failed delete", fullPath, err && err.message);
108
+ }
109
+ }
110
+ module2.exports.del = del;
111
+ function delStream(globStream) {
112
+ globStream.stream().on("data", (result) => {
113
+ const fullPath = path.resolve(process.cwd(), result);
114
+ try {
115
+ if (fs.existsSync(fullPath)) {
116
+ const stat = fs.lstatSync(fullPath);
117
+ if (stat.isSymbolicLink()) {
118
+ try {
119
+ fs.unlinkSync(fullPath);
120
+ console.log("deleted symlink", fullPath);
121
+ } catch (e) {
122
+ console.log("failed delete symlink", fullPath, e && e.message);
123
+ }
124
+ return;
125
+ }
126
+ if (stat.isDirectory()) {
127
+ const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
128
+ for (let i = 0; i < subdir.length; i++) {
129
+ del(subdir[i]);
130
+ }
131
+ }
132
+ }
133
+ del(fullPath);
134
+ } catch (err) {
135
+ console.log("failed processing", fullPath, err && err.message);
136
+ }
137
+ });
138
+ }
139
+ module2.exports.delStream = delStream;
140
+ function getFileTreeString(hashArray) {
141
+ const tree = {};
142
+ const hashMap = {};
143
+ for (const entry of hashArray) {
144
+ const [filePath, hash] = entry.split(" ");
145
+ hashMap[filePath] = hash;
146
+ const parts = filePath.split("/");
147
+ let current = tree;
148
+ for (let i = 0; i < parts.length; i++) {
149
+ const part = parts[i];
150
+ if (i === parts.length - 1) {
151
+ current[part] = null;
152
+ } else {
153
+ current[part] = current[part] || {};
154
+ current = current[part];
155
+ }
156
+ }
157
+ }
158
+ function printNode(node, prefix = "", parentPath = "") {
159
+ const keys = Object.keys(node).sort();
160
+ let lines = [];
161
+ keys.forEach((key, idx) => {
162
+ const isLast = idx === keys.length - 1;
163
+ const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
164
+ const currentPath = parentPath ? parentPath + "/" + key : key;
165
+ if (node[key] === null) {
166
+ lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
167
+ } else {
168
+ lines.push(prefix + branch + key + "/");
169
+ lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "\u2502 "), currentPath));
170
+ }
171
+ });
172
+ return lines;
173
+ }
174
+ return printNode(tree, "", "").join("\n");
175
+ }
176
+ module2.exports.getFileTreeString = getFileTreeString;
177
+ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
178
+ module2.exports.delay = delay;
179
+ }
180
+ });
181
+
15
182
  // src/utils/findEnvFiles.cjs
16
183
  var require_findEnvFiles = __commonJS({
17
184
  "src/utils/findEnvFiles.cjs"(exports2, module2) {
@@ -110,14 +277,14 @@ var require_findEnvFiles = __commonJS({
110
277
  // src/clean-github-actions-caches.cjs
111
278
  init_cjs_shims();
112
279
  var axios = require("axios");
113
- var minimist = require("minimist");
280
+ var { getArgs } = require_utils();
114
281
  var { findEnvWithToken } = require_findEnvFiles();
115
282
  require("dotenv").config({
116
283
  path: findEnvWithToken(),
117
284
  quiet: true,
118
285
  overwrite: true
119
286
  });
120
- var ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
287
+ var ACCESS_TOKEN = process.env.ACCESS_TOKEN || process.env.GITHUB_TOKEN;
121
288
  if (!ACCESS_TOKEN) {
122
289
  throw new Error(
123
290
  "Access token is not provided. Please set ACCESS_TOKEN or GITHUB_TOKEN in your environment variables."
@@ -140,6 +307,9 @@ Options:
140
307
  -r, --repo <repo> GitHub repository (owner/repo). If omitted, the tool will
141
308
  attempt to infer the repository from the current working
142
309
  directory's git remotes.
310
+ -p, --prefix-depth <n>
311
+ Number of leading cache key segments to use as the
312
+ grouping prefix when splitting on /[-_]/. Default: 3.
143
313
 
144
314
  Environment Variables:
145
315
  ACCESS_TOKEN GitHub access token (preferred)
@@ -156,22 +326,23 @@ Examples:
156
326
  clean-github-actions-caches --repo octocat/hello-world
157
327
 
158
328
  # Run via npx without installing
159
- npx -y binary-collections@https://raw.githubusercontent.com/dimaslanjaka/bin/master/releases/bin.tgz clean-github-actions-caches --repo owner/repo
329
+ npx --legacy-peer-deps -y binary-collections@https://raw.githubusercontent.com/dimaslanjaka/bin/master/releases/bin.tgz clean-github-actions-caches --repo owner/repo --prefix-depth 3
160
330
 
161
331
  # Run via yarn dlx
162
- yarn dlx binary-collections@https://raw.githubusercontent.com/dimaslanjaka/bin/master/releases/bin.tgz clean-github-actions-caches
332
+ yarn dlx binary-collections@https://raw.githubusercontent.com/dimaslanjaka/bin/master/releases/bin.tgz clean-github-actions-caches --prefix-depth 3
163
333
 
164
334
  Notes:
165
335
  - Ensure ACCESS_TOKEN or GITHUB_TOKEN is set and has permissions to manage Actions caches.
166
336
  - Intended for repository maintainers with appropriate permissions.
167
337
  `);
168
338
  }
169
- var argv = minimist(process.argv.slice(2), {
339
+ var argv = getArgs({
170
340
  alias: {
171
341
  h: "help",
342
+ p: "prefix-depth",
172
343
  r: "repo"
173
344
  },
174
- string: ["repo"],
345
+ string: ["prefix-depth", "repo"],
175
346
  boolean: ["help"]
176
347
  });
177
348
  if (argv.help) {
@@ -200,7 +371,53 @@ function deleteGitHubActionsCache(GH_REPO, cacheId) {
200
371
  });
201
372
  });
202
373
  }
203
- function get_caches(GH_REPO) {
374
+ function normalizePrefixDepth(prefixDepth) {
375
+ const parsed = Number(prefixDepth);
376
+ if (!Number.isFinite(parsed) || parsed < 1) {
377
+ return 3;
378
+ }
379
+ return Math.floor(parsed);
380
+ }
381
+ function isChecksumSegment(segment) {
382
+ return /^[a-f0-9]{32,}$/i.test(segment);
383
+ }
384
+ function getMeaningfulCacheKeyParts(key) {
385
+ return String(key).split(/[-_]/).filter(Boolean).filter((segment) => !isChecksumSegment(segment));
386
+ }
387
+ function getCachePrefix(key, prefixDepth = 3) {
388
+ const normalizedDepth = normalizePrefixDepth(prefixDepth);
389
+ const parts = String(key).split(/[-_]/).filter(Boolean);
390
+ const meaningfulParts = getMeaningfulCacheKeyParts(key);
391
+ if (meaningfulParts.length !== parts.length) {
392
+ if (meaningfulParts.length < normalizedDepth) {
393
+ return `${meaningfulParts.join("-")}-`;
394
+ }
395
+ return meaningfulParts.join("-");
396
+ }
397
+ if (parts.length <= normalizedDepth) {
398
+ return parts.join("-");
399
+ }
400
+ return parts.slice(0, normalizedDepth).join("-");
401
+ }
402
+ function groupCachesByPrefix(caches, prefixDepth = 3) {
403
+ return caches.reduce(
404
+ /**
405
+ * @param {Record<string, Record<string, any>[]>} acc
406
+ * @param {Record<string, any>} item
407
+ * @returns {Record<string, Record<string, any>[]>}
408
+ */
409
+ (acc, item) => {
410
+ const prefix = getCachePrefix(item.key, prefixDepth);
411
+ if (!acc[prefix]) {
412
+ acc[prefix] = [];
413
+ }
414
+ acc[prefix].push(item);
415
+ return acc;
416
+ },
417
+ {}
418
+ );
419
+ }
420
+ function get_caches(GH_REPO, prefixDepth = 3) {
204
421
  const url = `https://api.github.com/repos/${GH_REPO}/actions/caches`;
205
422
  return new Promise((resolve, reject) => {
206
423
  axios.get(url, {
@@ -210,40 +427,19 @@ function get_caches(GH_REPO) {
210
427
  }
211
428
  }).then((response) => {
212
429
  const data = response.data.actions_caches;
213
- const getPrefix = (key) => {
214
- const split = key.split(/[-_]/);
215
- if (split.length === 3) {
216
- return `${split[0]}-${split[1]}`;
217
- }
218
- if (split.length > 3) {
219
- return `${split[0]}-${split[1]}-${split[2]}`;
220
- }
221
- return split[0];
222
- };
223
- const grouped = data.reduce(
224
- /**
225
- * @param {Record<string, Record<string, any>[]>} acc
226
- * @param {Record<string, any>} item
227
- * @returns {Record<string, Record<string, any>[]>}
228
- */
229
- (acc, item) => {
230
- const prefix = getPrefix(item.key);
231
- if (!acc[prefix]) {
232
- acc[prefix] = [];
233
- }
234
- acc[prefix].push(item);
235
- return acc;
236
- },
237
- {}
238
- );
430
+ const grouped = groupCachesByPrefix(data, prefixDepth);
239
431
  resolve(grouped);
240
432
  }).catch((error) => {
241
- console.error("Error fetching data:", error);
242
433
  reject(error);
243
434
  });
244
435
  });
245
436
  }
246
437
  module.exports = {
247
438
  deleteGitHubActionsCache,
248
- get_caches
439
+ getCachePrefix,
440
+ getMeaningfulCacheKeyParts,
441
+ get_caches,
442
+ groupCachesByPrefix,
443
+ isChecksumSegment,
444
+ normalizePrefixDepth
249
445
  };
@@ -6,10 +6,48 @@
6
6
  * @returns {Promise<any>} Promise resolving with GitHub API response.
7
7
  */
8
8
  export function deleteGitHubActionsCache(GH_REPO: string, cacheId: string | number): Promise<any>;
9
+ /**
10
+ * Extract the grouping prefix from a cache key.
11
+ *
12
+ * @param {string} key
13
+ * @param {number} [prefixDepth=3]
14
+ * @returns {string}
15
+ */
16
+ export function getCachePrefix(key: string, prefixDepth?: number): string;
17
+ /**
18
+ * Remove checksum-like segments from a cache key.
19
+ *
20
+ * @param {string} key
21
+ * @returns {string[]}
22
+ */
23
+ export function getMeaningfulCacheKeyParts(key: string): string[];
9
24
  /**
10
25
  * List GitHub Actions caches grouped by cache key prefix.
11
26
  *
12
27
  * @param {string} GH_REPO GitHub repository in format `owner/repo`.
28
+ * @param {number} [prefixDepth=3]
13
29
  * @returns {Promise<Record<string, Record<string, any>[]>>}
14
30
  */
15
- export function get_caches(GH_REPO: string): Promise<Record<string, Record<string, any>[]>>;
31
+ export function get_caches(GH_REPO: string, prefixDepth?: number): Promise<Record<string, Record<string, any>[]>>;
32
+ /**
33
+ * Group GitHub Actions caches by their derived prefix.
34
+ *
35
+ * @param {Record<string, any>[]} caches
36
+ * @param {number} [prefixDepth=3]
37
+ * @returns {Record<string, Record<string, any>[]>}
38
+ */
39
+ export function groupCachesByPrefix(caches: Record<string, any>[], prefixDepth?: number): Record<string, Record<string, any>[]>;
40
+ /**
41
+ * Detect cache-key segments that look like checksum hashes.
42
+ *
43
+ * @param {string} segment
44
+ * @returns {boolean}
45
+ */
46
+ export function isChecksumSegment(segment: string): boolean;
47
+ /**
48
+ * Normalize the number of cache key segments to use for grouping.
49
+ *
50
+ * @param {unknown} prefixDepth
51
+ * @returns {number}
52
+ */
53
+ export function normalizePrefixDepth(prefixDepth: unknown): number;
@@ -1,7 +1,8 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_clean_github_actions_caches
4
- } from "./chunk-FB2WKVJD.mjs";
4
+ } from "./chunk-CD3HF3LK.mjs";
5
5
  import "./chunk-H44UWUFY.mjs";
6
+ import "./chunk-6RK5UCTP.mjs";
6
7
  import "./chunk-QQ4A6DLD.mjs";
7
8
  export default require_clean_github_actions_caches();
@@ -32,7 +32,7 @@ __export(command_exports, {
32
32
  commandConvert: () => commandConvert
33
33
  });
34
34
  module.exports = __toCommonJS(command_exports);
35
- var import_path = __toESM(require("path"), 1);
35
+ var import_upath = __toESM(require("upath"), 1);
36
36
 
37
37
  // src/utils/isWindows.js
38
38
  function isWindows() {
@@ -55,7 +55,7 @@ function commandConvert(command, env, normalize = false) {
55
55
  const varName = $1 || $2;
56
56
  return env[varName] ? `%${varName}%` : "";
57
57
  });
58
- return normalize === true ? import_path.default.normalize(convertedCmd) : convertedCmd;
58
+ return normalize === true ? import_upath.default.normalize(convertedCmd) : convertedCmd;
59
59
  }
60
60
  // Annotate the CommonJS export names for ESM import in node:
61
61
  0 && (module.exports = {
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.commandConvert = commandConvert;
7
- const path_1 = __importDefault(require("path"));
7
+ const upath_1 = __importDefault(require("upath"));
8
8
  const isWindows_js_1 = require("../utils/isWindows.js");
9
9
  /**
10
10
  * Converts an environment variable usage to be appropriate for the current OS
@@ -41,5 +41,5 @@ function commandConvert(command, env, normalize = false) {
41
41
  // For example, `./cmd.bat`. See kentcdodds/cross-env#127
42
42
  // However, it should not be done for command arguments.
43
43
  // See https://github.com/kentcdodds/cross-env/pull/130#issuecomment-319887970
44
- return normalize === true ? path_1.default.normalize(convertedCmd) : convertedCmd;
44
+ return normalize === true ? upath_1.default.normalize(convertedCmd) : convertedCmd;
45
45
  }
@@ -1,8 +1,8 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  commandConvert
4
- } from "../chunk-C6D2TTYU.mjs";
5
- import "../chunk-XPJGCDOD.mjs";
4
+ } from "../chunk-OBXLTXFJ.mjs";
5
+ import "../chunk-QII2EKCS.mjs";
6
6
  import "../chunk-QQ4A6DLD.mjs";
7
7
  export {
8
8
  commandConvert
@@ -35,7 +35,7 @@ module.exports = __toCommonJS(cross_env_exports);
35
35
  var import_cross_spawn = require("cross-spawn");
36
36
 
37
37
  // src/cross-env/command.ts
38
- var import_path = __toESM(require("path"), 1);
38
+ var import_upath = __toESM(require("upath"), 1);
39
39
 
40
40
  // src/utils/isWindows.js
41
41
  function isWindows() {
@@ -58,7 +58,7 @@ function commandConvert(command, env, normalize = false) {
58
58
  const varName = $1 || $2;
59
59
  return env[varName] ? `%${varName}%` : "";
60
60
  });
61
- return normalize === true ? import_path.default.normalize(convertedCmd) : convertedCmd;
61
+ return normalize === true ? import_upath.default.normalize(convertedCmd) : convertedCmd;
62
62
  }
63
63
 
64
64
  // src/cross-env/variable.ts
@@ -1,11 +1,11 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  commandConvert
4
- } from "../chunk-C6D2TTYU.mjs";
4
+ } from "../chunk-OBXLTXFJ.mjs";
5
5
  import {
6
6
  varValueConvert
7
- } from "../chunk-V2IBPCEV.mjs";
8
- import "../chunk-XPJGCDOD.mjs";
7
+ } from "../chunk-6C7KTYGZ.mjs";
8
+ import "../chunk-QII2EKCS.mjs";
9
9
  import {
10
10
  init_esm_shims
11
11
  } from "../chunk-QQ4A6DLD.mjs";
@@ -1,8 +1,8 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  varValueConvert
4
- } from "../chunk-V2IBPCEV.mjs";
5
- import "../chunk-XPJGCDOD.mjs";
4
+ } from "../chunk-6C7KTYGZ.mjs";
5
+ import "../chunk-QII2EKCS.mjs";
6
6
  import "../chunk-QQ4A6DLD.mjs";
7
7
  export {
8
8
  varValueConvert
@@ -19,9 +19,9 @@ var require_utils = __commonJS({
19
19
  init_cjs_shims();
20
20
  var fs = 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 getArgs(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 getArgs() {
67
62
  return argv;
68
63
  }
69
64
  module2.exports.getArgs = getArgs;
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_utils
4
- } from "./chunk-5RTXZVCW.mjs";
4
+ } from "./chunk-6RK5UCTP.mjs";
5
5
  import {
6
6
  __require,
7
7
  init_esm_shims