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.
- package/binaries/binary-executor.cjs +89 -13
- package/binaries/clean-nodemodule.cjs +89 -13
- package/binaries/clean-nodemodules.cjs +89 -13
- package/binaries/dev.cjs +89 -13
- package/binaries/empty.cjs +89 -13
- package/binaries/git-reduce-size.cjs +89 -13
- package/binaries/javakill.cjs +89 -13
- package/binaries/kill-process.cjs +89 -13
- package/binaries/nodekill.cjs +89 -13
- package/binaries/prod.cjs +89 -13
- package/binaries/py.cjs +89 -13
- package/binaries/rmfind.cjs +89 -13
- package/binaries/rmx.cjs +89 -13
- package/binaries/submodule-token.cjs +89 -13
- package/binaries/test-cjs.cjs +89 -13
- package/binaries/test-esm.cjs +89 -13
- package/binaries/yarn-clean.cjs +89 -13
- package/binaries/yc +22 -1
- package/binaries/yc.cjs +89 -13
- package/binaries/ycw +256 -0
- package/binaries/ycw.cjs +254 -0
- package/docs-src/binary-collections.md +34 -0
- package/docs-src/changelog.md +26 -0
- package/docs-src/clean-github-actions-caches.md +115 -0
- package/docs-src/copy-move-file.md +59 -0
- package/docs-src/del-gradle.md +17 -0
- package/docs-src/del-ps.md +28 -0
- package/docs-src/downloader.md +62 -0
- package/docs-src/env-helpers.md +29 -0
- package/docs-src/find-node-modules.md +17 -0
- package/docs-src/free-chatgpt.md +26 -0
- package/docs-src/git-diff.md +33 -0
- package/docs-src/git-fix.md +34 -0
- package/docs-src/git-purge.md +17 -0
- package/docs-src/git-reduce-size.md +17 -0
- package/docs-src/git-undo.md +21 -0
- package/docs-src/kill-night-crows.md +26 -0
- package/docs-src/node-cache-cleaner.md +182 -0
- package/docs-src/node-executor.md +50 -0
- package/docs-src/node-package-packer.md +48 -0
- package/docs-src/npm-run-series.md +43 -0
- package/docs-src/package-resolutions-updater.md +22 -0
- package/docs-src/php-cs-fixer-staged.md +19 -0
- package/docs-src/print-directory-tree.md +35 -0
- package/docs-src/print-tarball-tree.md +55 -0
- package/docs-src/py.md +19 -0
- package/docs-src/remove-module.md +32 -0
- package/docs-src/rmfind-rmx.md +21 -0
- package/docs-src/rmpath.md +38 -0
- package/docs-src/run-by-checksum.md +87 -0
- package/docs-src/submodule-install.md +31 -0
- package/docs-src/submodule-remove.md +22 -0
- package/docs-src/submodule-token.md +17 -0
- package/docs-src/test-runners.md +21 -0
- package/docs-src/yarn-install.md +31 -0
- package/docs-src/yarn-reinstall.md +27 -0
- package/lib/binary-collections/config.cjs +1 -1
- package/lib/binary-collections/config.mjs +1 -1
- package/lib/binary-collections/findScript.cjs +35 -10
- package/lib/binary-collections/findScript.mjs +2 -2
- package/lib/binary-collections/listScript.cjs +35 -10
- package/lib/binary-collections/listScript.mjs +2 -2
- package/lib/binary-collections.cjs +45 -25
- package/lib/binary-collections.mjs +11 -11
- package/lib/changelog.cjs +7 -12
- package/lib/changelog.mjs +2 -2
- package/lib/{chunk-SPTECFE5.mjs → chunk-2MN4VPV2.mjs} +86 -20
- package/lib/{chunk-V2IBPCEV.mjs → chunk-6C7KTYGZ.mjs} +3 -1
- package/lib/{chunk-5RTXZVCW.mjs → chunk-6RK5UCTP.mjs} +5 -10
- package/lib/{chunk-FB2WKVJD.mjs → chunk-CD3HF3LK.mjs} +67 -35
- package/lib/{chunk-6PU7BAHB.mjs → chunk-FLYSZFLW.mjs} +1 -1
- package/lib/chunk-KLKAIFKI.mjs +40 -0
- package/lib/chunk-LVSPEFU2.mjs +86 -0
- package/lib/{chunk-2LSRSEXF.mjs → chunk-MGPYPKIE.mjs} +2 -2
- package/lib/{chunk-ZOWVMII3.mjs → chunk-NQXUYO67.mjs} +35 -10
- package/lib/{chunk-C6D2TTYU.mjs → chunk-OBXLTXFJ.mjs} +4 -2
- package/lib/chunk-QD4T255Z.mjs +40 -0
- package/lib/{chunk-XPJGCDOD.mjs → chunk-QII2EKCS.mjs} +14 -2
- package/lib/chunk-RDGDLSPD.mjs +76 -0
- package/lib/{chunk-NCZPTKDV.mjs → chunk-RDN6HF5Z.mjs} +1 -1
- package/lib/chunk-RJKTSUAX.mjs +123 -0
- package/lib/{chunk-66KDU4TX.mjs → chunk-TBWXE7ST.mjs} +36 -61
- package/lib/{chunk-M3YIYRHT.mjs → chunk-UY5VUEA3.mjs} +1 -1
- package/lib/chunk-WSHVPGNM.mjs +44 -0
- package/lib/{chunk-G5UUEWUO.mjs → chunk-X2B3X7D4.mjs} +1 -1
- package/lib/clean-github-actions-caches-cli.cjs +255 -213
- package/lib/clean-github-actions-caches-cli.mjs +25 -7
- package/lib/clean-github-actions-caches.cjs +231 -35
- package/lib/clean-github-actions-caches.d.cts +39 -1
- package/lib/clean-github-actions-caches.mjs +2 -1
- package/lib/cross-env/command.cjs +2 -2
- package/lib/cross-env/command.js +2 -2
- package/lib/cross-env/command.mjs +2 -2
- package/lib/cross-env/index.cjs +2 -2
- package/lib/cross-env/index.mjs +3 -3
- package/lib/cross-env/variable.mjs +2 -2
- package/lib/del-gradle.cjs +6 -11
- package/lib/del-gradle.mjs +1 -1
- package/lib/del-node-modules.cjs +185 -3
- package/lib/del-node-modules.js +3 -3
- package/lib/del-node-modules.mjs +6 -3
- package/lib/{del-ps.cjs → del-ps-cli.cjs} +36 -41
- package/lib/del-ps-cli.mjs +44 -0
- package/lib/del-yarn-caches.cjs +6 -11
- package/lib/del-yarn-caches.mjs +1 -1
- package/lib/downloader-cli.cjs +256 -0
- package/lib/downloader-cli.d.cts +2 -0
- package/lib/downloader-cli.mjs +90 -0
- package/lib/file/copy-cli.cjs +183 -2
- package/lib/file/copy-cli.mjs +6 -2
- package/lib/file/move-cli.cjs +183 -2
- package/lib/file/move-cli.mjs +6 -2
- package/lib/find-node-modules-cli.cjs +1 -1
- package/lib/find-node-modules-cli.mjs +1 -1
- package/lib/find-node-modules.cjs +1 -1
- package/lib/find-node-modules.mjs +1 -1
- package/lib/free-chatgpt.cjs +6 -11
- package/lib/free-chatgpt.mjs +1 -1
- package/lib/git/user-config.cjs +7 -12
- package/lib/git/user-config.mjs +2 -2
- package/lib/git-diff-cli.cjs +91 -30
- package/lib/git-diff-cli.mjs +3 -3
- package/lib/git-diff.cjs +91 -30
- package/lib/git-diff.js +85 -28
- package/lib/git-diff.mjs +3 -3
- package/lib/git-fix.cjs +7 -12
- package/lib/git-fix.mjs +2 -2
- package/lib/git-purge.cjs +7 -12
- package/lib/git-purge.mjs +2 -2
- package/lib/index.cjs +1 -1
- package/lib/index.mjs +1 -1
- package/lib/node-cache-cleaner-cli.cjs +185 -2
- package/lib/node-cache-cleaner-cli.js +2 -5
- package/lib/node-cache-cleaner-cli.mjs +8 -4
- package/lib/node-executor.cjs +183 -2
- package/lib/node-executor.mjs +5 -2
- package/lib/node-package-packer/build-readme.cjs +150 -0
- package/lib/node-package-packer/build-readme.d.mts +10 -0
- package/lib/node-package-packer/build-readme.mjs +10 -0
- package/lib/node-package-packer/build-tarball.cjs +495 -0
- package/lib/node-package-packer/build-tarball.d.mts +33 -0
- package/lib/node-package-packer/build-tarball.mjs +175 -0
- package/lib/node-package-packer-cli.cjs +525 -0
- package/lib/node-package-packer-cli.d.mts +1 -0
- package/lib/node-package-packer-cli.mjs +34 -0
- package/lib/npm-run-series.cjs +7 -12
- package/lib/npm-run-series.mjs +2 -2
- package/lib/package-resolutions-updater-cli.cjs +73 -76
- package/lib/package-resolutions-updater-cli.mjs +4 -3
- package/lib/package-resolutions-updater.cjs +71 -74
- package/lib/package-resolutions-updater.d.mts +34 -0
- package/lib/package-resolutions-updater.mjs +3 -2
- package/lib/php-cs-fixer-staged.cjs +1 -1
- package/lib/php-cs-fixer-staged.mjs +1 -1
- package/lib/print-directory-tree.cjs +16 -18
- package/lib/print-directory-tree.mjs +11 -8
- package/lib/print-tarball-tree.cjs +262 -0
- package/lib/print-tarball-tree.d.mts +1 -0
- package/lib/print-tarball-tree.mjs +68 -0
- package/lib/ps/index.cjs +10 -10
- package/lib/ps/index.mjs +4 -4
- package/lib/ps/table-parser.d.ts +3 -4
- package/lib/ps/table-parser.js +9 -16
- package/lib/remove-module.cjs +17 -22
- package/lib/remove-module.mjs +2 -2
- package/lib/rm-node-module-cli.cjs +171 -4
- package/lib/rm-node-module-cli.mjs +7 -4
- package/lib/rmpath-cli.cjs +285 -0
- package/lib/rmpath-cli.d.mts +1 -0
- package/lib/rmpath-cli.mjs +23 -0
- package/lib/rmpath.cjs +6 -217
- package/lib/rmpath.mjs +5 -101
- package/lib/run-by-checksum/cache.cjs +69 -0
- package/lib/run-by-checksum/cache.d.ts +19 -0
- package/lib/run-by-checksum/cache.js +50 -0
- package/lib/run-by-checksum/cache.mjs +12 -0
- package/lib/run-by-checksum/hash.cjs +72 -0
- package/lib/run-by-checksum/hash.d.ts +14 -0
- package/lib/run-by-checksum/hash.js +85 -0
- package/lib/{ps/isWin.mjs → run-by-checksum/hash.mjs} +5 -5
- package/lib/run-by-checksum/run.cjs +169 -0
- package/lib/run-by-checksum/run.d.ts +22 -0
- package/lib/run-by-checksum/run.js +93 -0
- package/lib/run-by-checksum/run.mjs +10 -0
- package/lib/run-by-checksum-cli.cjs +382 -0
- package/lib/run-by-checksum-cli.d.ts +2 -0
- package/lib/run-by-checksum-cli.js +43 -0
- package/lib/run-by-checksum-cli.mjs +56 -0
- package/lib/submodule-install.cjs +8 -13
- package/lib/submodule-install.mjs +3 -3
- package/lib/submodule-remove-cli.cjs +169 -2
- package/lib/submodule-remove-cli.js +2 -2
- package/lib/submodule-remove-cli.mjs +5 -2
- package/lib/utils/fetchResponse.cjs +24 -0
- package/lib/utils/fetchResponse.d.cts +25 -0
- package/lib/utils/fetchResponse.mjs +6 -0
- package/lib/utils/index.cjs +5 -10
- package/lib/utils/index.d.cts +2 -9
- package/lib/utils/index.mjs +1 -1
- package/lib/utils/isWindows.mjs +3 -1
- package/lib/utils/runBash.cjs +1 -1
- package/lib/utils/runBash.mjs +1 -1
- package/lib/yarn-per-branch-lock-installer.cjs +202 -11
- package/lib/yarn-per-branch-lock-installer.mjs +24 -11
- package/lib/yarn-reinstall.cjs +6 -11
- package/lib/yarn-reinstall.mjs +1 -1
- package/package.json +35 -10
- package/readme.html +2 -2
- package/readme.md +5 -5
- package/releases/readme.md +6 -3
- package/tmp/test-repo-runChecksum/test-complex-glob/README.md +1 -0
- package/tmp/test-repo-runChecksum/test-mixed-args/README.md +1 -0
- package/.opencode/package.json +0 -5
- package/lib/chunk-6S4NXESK.mjs +0 -26
- package/lib/del-ps.js +0 -32
- package/lib/del-ps.mjs +0 -43
- package/lib/ps/isWin.cjs +0 -26
- package/lib/ps/isWin.d.ts +0 -2
- package/lib/ps/isWin.js +0 -4
- package/test/package.json +0 -20
- package/test-project/package.json +0 -22
- package/test-project/workspaces/workspace-a/package.json +0 -135
- package/test-project/workspaces/workspace-a/test/demo/package.json +0 -25
- package/test-project/workspaces/workspace-b/package.json +0 -139
- package/test-project/workspaces/workspace-b/test/sample-project/package.json +0 -7
- package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/package.json +0 -96
- package/tmp/rm-node-modules-test-project/package.json +0 -17
- package/tmp/rm-node-modules-test-project/packages/workspace-a/package.json +0 -16
- package/tmp/rm-node-modules-test-project/packages/workspace-b/package.json +0 -16
- package/tmp/test-repo/package.json +0 -17
- /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
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
|
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
|
|
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
|
-
|
|
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-
|
|
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
|
|
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 ?
|
|
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 = {
|
package/lib/cross-env/command.js
CHANGED
|
@@ -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
|
|
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 ?
|
|
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-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-OBXLTXFJ.mjs";
|
|
5
|
+
import "../chunk-QII2EKCS.mjs";
|
|
6
6
|
import "../chunk-QQ4A6DLD.mjs";
|
|
7
7
|
export {
|
|
8
8
|
commandConvert
|
package/lib/cross-env/index.cjs
CHANGED
|
@@ -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
|
|
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 ?
|
|
61
|
+
return normalize === true ? import_upath.default.normalize(convertedCmd) : convertedCmd;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
// src/cross-env/variable.ts
|
package/lib/cross-env/index.mjs
CHANGED
|
@@ -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-
|
|
4
|
+
} from "../chunk-OBXLTXFJ.mjs";
|
|
5
5
|
import {
|
|
6
6
|
varValueConvert
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
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-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-6C7KTYGZ.mjs";
|
|
5
|
+
import "../chunk-QII2EKCS.mjs";
|
|
6
6
|
import "../chunk-QQ4A6DLD.mjs";
|
|
7
7
|
export {
|
|
8
8
|
varValueConvert
|
package/lib/del-gradle.cjs
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
59
|
-
|
|
60
|
-
|
|
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;
|