binary-collections 2.0.11 → 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 +15 -1
- package/binaries/rmx.cjs +89 -13
- package/binaries/rmx.cmd +12 -0
- package/binaries/submodule-token.cjs +89 -13
- package/binaries/test-cjs +9 -1
- package/binaries/test-cjs.cjs +89 -13
- package/binaries/test-cjs.cmd +16 -1
- package/binaries/test-esm +16 -0
- package/binaries/test-esm.cjs +254 -0
- package/binaries/test-esm.cmd +23 -0
- package/binaries/yarn-clean +1 -1
- package/binaries/yarn-clean.cjs +89 -13
- package/binaries/yarn-clean.cmd +1 -1
- package/binaries/yarn-clean.py +33 -15
- package/binaries/yc +131 -0
- package/binaries/yc.cjs +254 -0
- 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 +91 -2
- 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/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 +126 -0
- package/lib/binary-collections/config.mjs +7 -0
- package/lib/binary-collections/executeScript.cjs +19 -0
- package/lib/binary-collections/executeScript.d.cts +12 -0
- package/lib/binary-collections/executeScript.mjs +6 -0
- package/lib/binary-collections/findScript.cjs +309 -0
- package/lib/binary-collections/findScript.d.cts +12 -0
- package/lib/binary-collections/findScript.mjs +7 -0
- package/lib/binary-collections/listScript.cjs +291 -0
- package/lib/binary-collections/listScript.d.cts +19 -0
- package/lib/binary-collections/listScript.mjs +7 -0
- package/lib/binary-collections.cjs +264 -157
- package/lib/binary-collections.mjs +26 -286
- package/lib/changelog.cjs +9 -14
- package/lib/changelog.mjs +2 -2
- package/lib/chunk-2MN4VPV2.mjs +246 -0
- package/lib/chunk-6C7KTYGZ.mjs +41 -0
- package/lib/{chunk-Z6JLYU2J.mjs → chunk-6RK5UCTP.mjs} +7 -12
- package/lib/chunk-CD3HF3LK.mjs +190 -0
- package/lib/chunk-FLYSZFLW.mjs +61 -0
- package/lib/{chunk-N436BNBK.mjs → chunk-GAGABICI.mjs} +19 -13
- package/lib/chunk-H44UWUFY.mjs +105 -0
- package/lib/chunk-KLKAIFKI.mjs +40 -0
- package/lib/chunk-LVSPEFU2.mjs +86 -0
- package/lib/{chunk-RWLXRTYP.mjs → chunk-MGPYPKIE.mjs} +2 -2
- package/lib/chunk-NGFK3EYW.mjs +28 -0
- package/lib/chunk-NQXUYO67.mjs +253 -0
- package/lib/chunk-NVEG3LEZ.mjs +143 -0
- package/lib/chunk-OBXLTXFJ.mjs +34 -0
- package/lib/chunk-OGXVGBRI.mjs +29 -0
- package/lib/chunk-OXV52GD5.mjs +62 -0
- package/lib/chunk-PXBMHE7O.mjs +35 -0
- package/lib/chunk-QD4T255Z.mjs +40 -0
- package/lib/chunk-QII2EKCS.mjs +26 -0
- package/lib/chunk-R5FJOR63.mjs +47 -0
- package/lib/chunk-RDGDLSPD.mjs +76 -0
- package/lib/chunk-RDN6HF5Z.mjs +79 -0
- package/lib/chunk-RJKTSUAX.mjs +123 -0
- package/lib/{chunk-XA3SNBPA.mjs → chunk-TBWXE7ST.mjs} +97 -38
- package/lib/chunk-UXCFNAR6.mjs +55 -0
- package/lib/{chunk-M3YIYRHT.mjs → chunk-UY5VUEA3.mjs} +1 -1
- package/lib/chunk-WSHVPGNM.mjs +44 -0
- package/lib/{chunk-66PAU5PS.mjs → chunk-X2B3X7D4.mjs} +10 -6
- package/lib/clean-github-actions-caches-cli.cjs +507 -0
- package/lib/clean-github-actions-caches-cli.mjs +74 -0
- package/lib/clean-github-actions-caches.cjs +246 -106
- package/lib/clean-github-actions-caches.d.cts +53 -1
- package/lib/clean-github-actions-caches.mjs +5 -130
- package/lib/cross-env/command.cjs +63 -0
- package/lib/cross-env/command.d.ts +8 -0
- package/lib/cross-env/command.js +45 -0
- package/lib/{ps/isWin.mjs → cross-env/command.mjs} +4 -5
- package/lib/cross-env/index.cjs +178 -0
- package/lib/cross-env/index.d.ts +8 -0
- package/lib/cross-env/index.js +102 -0
- package/lib/cross-env/index.mjs +101 -0
- package/lib/cross-env/variable.cjs +60 -0
- package/lib/cross-env/variable.d.ts +7 -0
- package/lib/cross-env/variable.js +59 -0
- package/lib/cross-env/variable.mjs +9 -0
- package/lib/del-gradle.cjs +8 -13
- package/lib/del-gradle.js +8 -8
- package/lib/del-gradle.mjs +1 -1
- package/lib/del-node-modules.cjs +185 -3
- package/lib/del-node-modules.js +25 -25
- package/lib/del-node-modules.mjs +6 -3
- package/lib/{del-ps.cjs → del-ps-cli.cjs} +38 -43
- package/lib/del-ps-cli.d.mts +1 -0
- package/lib/del-ps-cli.mjs +44 -0
- package/lib/del-yarn-caches.cjs +8 -13
- package/lib/del-yarn-caches.js +2 -2
- 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 +273 -0
- package/lib/file/copy-cli.d.mts +1 -0
- package/lib/file/copy-cli.mjs +59 -0
- package/lib/file/copy.cjs +56 -0
- package/lib/file/copy.d.mts +1 -0
- package/lib/file/copy.mjs +8 -0
- package/lib/file/move-cli.cjs +272 -0
- package/lib/file/move-cli.d.mts +1 -0
- package/lib/file/move-cli.mjs +59 -0
- package/lib/file/move.cjs +55 -0
- package/lib/file/move.d.mts +1 -0
- package/lib/file/move.mjs +8 -0
- package/lib/find-node-modules-cli.cjs +1 -1
- package/lib/find-node-modules-cli.js +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 +27 -26
- package/lib/free-chatgpt.js +10 -10
- package/lib/free-chatgpt.mjs +2 -2
- package/lib/git/user-config.cjs +9 -14
- package/lib/git/user-config.mjs +2 -2
- package/lib/git-diff-cli.cjs +273 -66
- package/lib/git-diff-cli.mjs +5 -4
- package/lib/git-diff.cjs +273 -66
- package/lib/git-diff.d.ts +2 -1
- package/lib/git-diff.js +153 -39
- package/lib/git-diff.mjs +5 -4
- package/lib/git-fix.cjs +9 -14
- package/lib/git-fix.mjs +2 -2
- package/lib/git-purge.cjs +9 -14
- package/lib/git-purge.mjs +2 -2
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.mjs +1 -1
- package/lib/kill-night-crows.cjs +7 -7
- package/lib/kill-night-crows.mjs +7 -7
- package/lib/node-cache-cleaner/npm.cjs +65 -0
- package/lib/node-cache-cleaner/npm.d.ts +2 -0
- package/lib/node-cache-cleaner/npm.js +41 -0
- package/lib/node-cache-cleaner/npm.mjs +10 -0
- package/lib/node-cache-cleaner/npx.cjs +89 -0
- package/lib/node-cache-cleaner/npx.d.ts +4 -0
- package/lib/node-cache-cleaner/npx.js +82 -0
- package/lib/{ps/index.d.mjs → node-cache-cleaner/npx.mjs} +6 -5
- package/lib/node-cache-cleaner/yarn.cjs +73 -0
- package/lib/node-cache-cleaner/yarn.d.ts +2 -0
- package/lib/node-cache-cleaner/yarn.js +62 -0
- package/lib/node-cache-cleaner/yarn.mjs +10 -0
- package/lib/node-cache-cleaner-cli.cjs +365 -0
- package/lib/node-cache-cleaner-cli.d.ts +2 -0
- package/lib/node-cache-cleaner-cli.js +57 -0
- package/lib/node-cache-cleaner-cli.mjs +60 -0
- package/lib/node-executor.cjs +272 -0
- package/lib/node-executor.d.cts +2 -0
- package/lib/node-executor.mjs +106 -0
- 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 +28 -40
- package/lib/npm-run-series.mjs +21 -7
- package/lib/package-resolutions-updater-cli.cjs +255 -173
- package/lib/package-resolutions-updater-cli.mjs +19 -40
- package/lib/package-resolutions-updater.cjs +244 -141
- package/lib/package-resolutions-updater.d.mts +54 -1
- package/lib/package-resolutions-updater.mjs +8 -5
- package/lib/php-cs-fixer-staged.cjs +1 -1
- package/lib/php-cs-fixer-staged.mjs +1 -1
- package/lib/print-directory-tree.cjs +18 -20
- 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/connected-domain.js +10 -10
- package/lib/ps/index.cjs +11 -11
- package/lib/ps/index.mjs +180 -174
- package/lib/ps/table-parser.d.ts +3 -4
- package/lib/ps/table-parser.js +15 -22
- package/lib/remove-module.cjs +19 -24
- package/lib/remove-module.mjs +2 -2
- package/lib/rm-node-module-cli.cjs +389 -0
- package/lib/rm-node-module-cli.d.cts +1 -0
- package/lib/rm-node-module-cli.mjs +92 -0
- package/lib/rm-node-modules.cjs +127 -0
- package/lib/rm-node-modules.d.cts +35 -0
- package/lib/{binary-collections-config.mjs → rm-node-modules.mjs} +3 -3
- 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/run-by-checksum/hash.mjs +10 -0
- 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 +55 -47
- package/lib/submodule-install.mjs +48 -35
- package/lib/submodule-remove-cli.cjs +170 -4
- package/lib/submodule-remove-cli.js +5 -5
- package/lib/submodule-remove-cli.mjs +6 -4
- package/lib/utils/chatgpt.cjs +19 -13
- package/lib/utils/chatgpt.js +94 -94
- package/lib/utils/chatgpt.mjs +1 -1
- 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/findEnvFiles.cjs +28 -46
- package/lib/utils/findEnvFiles.d.cts +19 -0
- package/lib/utils/findEnvFiles.mjs +3 -5
- package/lib/utils/findWorkspaceRoot.js +4 -4
- package/lib/utils/index.cjs +7 -12
- package/lib/utils/index.d.cts +2 -9
- package/lib/utils/index.mjs +1 -1
- package/lib/utils/isGithubTokenValid.js +7 -7
- package/lib/{ps/isWin.cjs → utils/isWindows.cjs} +12 -7
- package/lib/utils/isWindows.d.ts +5 -0
- package/lib/utils/isWindows.js +10 -0
- package/lib/utils/isWindows.mjs +10 -0
- package/lib/utils/runBash.cjs +53 -0
- package/lib/utils/runBash.d.cts +12 -0
- package/lib/utils/runBash.mjs +66 -0
- package/lib/yarn-per-branch-lock-installer.cjs +288 -0
- package/lib/yarn-per-branch-lock-installer.d.cts +2 -0
- package/lib/yarn-per-branch-lock-installer.mjs +122 -0
- package/lib/yarn-reinstall.cjs +8 -13
- package/lib/yarn-reinstall.mjs +1 -1
- package/package.json +91 -57
- package/readme.html +784 -0
- package/readme.md +107 -219
- package/releases/readme.md +6 -3
- package/test/README.md +2 -2
- package/test-project/workspaces/workspace-a/readme.md +20 -0
- package/test-project/workspaces/workspace-a/release/readme.md +42 -0
- package/test-project/workspaces/workspace-a/test/readme.md +12 -0
- package/test-project/workspaces/workspace-b/readme.md +94 -0
- package/test-project/workspaces/workspace-b/requirements.txt +1 -0
- package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/readme.md +156 -0
- package/tmp/test-repo/README.md +2 -35
- 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/lib/binary-collections-config.cjs +0 -15
- package/lib/chunk-2CBJCW7E.mjs +0 -81
- package/lib/chunk-4UHL4WVN.mjs +0 -136
- package/lib/chunk-6HHJRKFB.mjs +0 -59
- package/lib/chunk-6S4NXESK.mjs +0 -26
- package/lib/chunk-7XTEJHOE.mjs +0 -193
- package/lib/chunk-AJDD5DZM.mjs +0 -109
- package/lib/chunk-FCDQGYBF.mjs +0 -136
- package/lib/chunk-GEYA2USY.mjs +0 -207
- package/lib/chunk-GJTGHXRA.mjs +0 -356
- package/lib/chunk-ID2WBTE2.mjs +0 -80
- package/lib/chunk-JXFOHKDM.mjs +0 -239
- package/lib/chunk-NCXAP7AA.mjs +0 -31
- package/lib/chunk-PDSXF5HY.mjs +0 -187
- package/lib/chunk-TOIVAQF7.mjs +0 -136
- package/lib/chunk-V5SKYJUB.mjs +0 -136
- package/lib/chunk-WSRETQCA.mjs +0 -59
- package/lib/chunk-YYLIQQKF.mjs +0 -31
- package/lib/del-ps.js +0 -32
- package/lib/del-ps.mjs +0 -43
- package/lib/ps/index.d.cjs +0 -17
- package/lib/ps/index.d.ts +0 -2
- package/lib/ps/index.js +0 -254
- package/lib/ps/isWin.d.ts +0 -2
- package/lib/ps/isWin.js +0 -4
- package/lib/utils/findEnvFiles.d.ts +0 -8
- package/lib/utils/findEnvFiles.js +0 -121
- package/test/package.json +0 -20
- package/test-project/package.json +0 -16
- package/tmp/test-repo/package.json +0 -7
- package/tmp/typedoc/readme.md +0 -320
- /package/lib/{binary-collections-config.d.cts → binary-collections/config.d.cts} +0 -0
- /package/lib/{del-ps.d.ts → clean-github-actions-caches-cli.d.cts} +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
2
|
var __esm = (fn, res) => function __init() {
|
|
4
3
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
@@ -17,14 +16,14 @@ var init_cjs_shims = __esm({
|
|
|
17
16
|
var require_utils = __commonJS({
|
|
18
17
|
"src/utils/index.cjs"(exports2, module2) {
|
|
19
18
|
init_cjs_shims();
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
var
|
|
19
|
+
var fs = require("fs");
|
|
20
|
+
var path = require("upath");
|
|
21
|
+
var minimistLib = require("minimist");
|
|
22
|
+
var argv2 = minimistLib(process.argv.slice(2));
|
|
23
23
|
var { exec } = require("child_process");
|
|
24
|
-
var { URL: URL2 } = require("url");
|
|
25
24
|
var { promisify } = require("util");
|
|
26
25
|
var execAsync = promisify(exec);
|
|
27
|
-
async function
|
|
26
|
+
async function parseGitRemotes() {
|
|
28
27
|
try {
|
|
29
28
|
const { stdout } = await execAsync("git remote -v");
|
|
30
29
|
const lines = stdout.split("\n");
|
|
@@ -34,7 +33,7 @@ var require_utils = __commonJS({
|
|
|
34
33
|
if (name && url) {
|
|
35
34
|
const [repoUrl] = url.split(" ");
|
|
36
35
|
try {
|
|
37
|
-
const parsedUrl = new
|
|
36
|
+
const parsedUrl = new URL(repoUrl);
|
|
38
37
|
const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
|
|
39
38
|
if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
|
|
40
39
|
let repoPath = pathParts.join("/");
|
|
@@ -54,26 +53,21 @@ var require_utils = __commonJS({
|
|
|
54
53
|
return {};
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
|
-
module2.exports.parseGitRemotes =
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
|
|
56
|
+
module2.exports.parseGitRemotes = parseGitRemotes;
|
|
57
|
+
function getArgs2(opts) {
|
|
58
|
+
if (opts) {
|
|
59
|
+
return minimistLib(process.argv.slice(2), opts);
|
|
62
60
|
}
|
|
63
|
-
return
|
|
61
|
+
return argv2;
|
|
64
62
|
}
|
|
65
|
-
module2.exports.
|
|
66
|
-
function getArgs() {
|
|
67
|
-
return argv;
|
|
68
|
-
}
|
|
69
|
-
module2.exports.getArgs = getArgs;
|
|
63
|
+
module2.exports.getArgs = getArgs2;
|
|
70
64
|
function del(fullPath) {
|
|
71
65
|
try {
|
|
72
|
-
if (!
|
|
73
|
-
const stat =
|
|
66
|
+
if (!fs.existsSync(fullPath)) return;
|
|
67
|
+
const stat = fs.lstatSync(fullPath);
|
|
74
68
|
if (stat.isSymbolicLink()) {
|
|
75
69
|
try {
|
|
76
|
-
|
|
70
|
+
fs.unlinkSync(fullPath);
|
|
77
71
|
console.log("deleted symlink", fullPath);
|
|
78
72
|
} catch (e) {
|
|
79
73
|
console.log("failed delete symlink", fullPath, e && e.message);
|
|
@@ -81,16 +75,16 @@ var require_utils = __commonJS({
|
|
|
81
75
|
return;
|
|
82
76
|
}
|
|
83
77
|
if (stat.isDirectory()) {
|
|
84
|
-
const subdir =
|
|
78
|
+
const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
|
|
85
79
|
for (let i = 0; i < subdir.length; i++) {
|
|
86
80
|
del(subdir[i]);
|
|
87
81
|
}
|
|
88
82
|
try {
|
|
89
|
-
|
|
83
|
+
fs.rmdirSync(fullPath);
|
|
90
84
|
console.log("deleted", fullPath);
|
|
91
|
-
} catch (
|
|
85
|
+
} catch (_e) {
|
|
92
86
|
try {
|
|
93
|
-
|
|
87
|
+
fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
94
88
|
console.log("deleted", fullPath);
|
|
95
89
|
} catch (ee) {
|
|
96
90
|
console.log("failed delete", fullPath, ee && ee.message);
|
|
@@ -99,11 +93,11 @@ var require_utils = __commonJS({
|
|
|
99
93
|
return;
|
|
100
94
|
}
|
|
101
95
|
try {
|
|
102
|
-
|
|
96
|
+
fs.unlinkSync(fullPath);
|
|
103
97
|
console.log("deleted", fullPath);
|
|
104
|
-
} catch (
|
|
98
|
+
} catch (_e) {
|
|
105
99
|
try {
|
|
106
|
-
|
|
100
|
+
fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
107
101
|
console.log("deleted", fullPath);
|
|
108
102
|
} catch (ee) {
|
|
109
103
|
console.log("failed delete", fullPath, ee && ee.message);
|
|
@@ -116,13 +110,13 @@ var require_utils = __commonJS({
|
|
|
116
110
|
module2.exports.del = del;
|
|
117
111
|
function delStream(globStream) {
|
|
118
112
|
globStream.stream().on("data", (result) => {
|
|
119
|
-
const fullPath =
|
|
113
|
+
const fullPath = path.resolve(process.cwd(), result);
|
|
120
114
|
try {
|
|
121
|
-
if (
|
|
122
|
-
const stat =
|
|
115
|
+
if (fs.existsSync(fullPath)) {
|
|
116
|
+
const stat = fs.lstatSync(fullPath);
|
|
123
117
|
if (stat.isSymbolicLink()) {
|
|
124
118
|
try {
|
|
125
|
-
|
|
119
|
+
fs.unlinkSync(fullPath);
|
|
126
120
|
console.log("deleted symlink", fullPath);
|
|
127
121
|
} catch (e) {
|
|
128
122
|
console.log("failed delete symlink", fullPath, e && e.message);
|
|
@@ -130,7 +124,7 @@ var require_utils = __commonJS({
|
|
|
130
124
|
return;
|
|
131
125
|
}
|
|
132
126
|
if (stat.isDirectory()) {
|
|
133
|
-
const subdir =
|
|
127
|
+
const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
|
|
134
128
|
for (let i = 0; i < subdir.length; i++) {
|
|
135
129
|
del(subdir[i]);
|
|
136
130
|
}
|
|
@@ -185,26 +179,176 @@ var require_utils = __commonJS({
|
|
|
185
179
|
}
|
|
186
180
|
});
|
|
187
181
|
|
|
182
|
+
// src/utils/findEnvFiles.cjs
|
|
183
|
+
var require_findEnvFiles = __commonJS({
|
|
184
|
+
"src/utils/findEnvFiles.cjs"(exports2, module2) {
|
|
185
|
+
init_cjs_shims();
|
|
186
|
+
var fs = require("fs");
|
|
187
|
+
var path = require("path");
|
|
188
|
+
var glob = require("glob");
|
|
189
|
+
var DEFAULT_IGNORES = [
|
|
190
|
+
"**/node_modules/**",
|
|
191
|
+
"**/.git/**",
|
|
192
|
+
"**/.yarn/**",
|
|
193
|
+
"**/.pnpm/**",
|
|
194
|
+
"**/dist/**",
|
|
195
|
+
"**/build/**",
|
|
196
|
+
"**/coverage/**",
|
|
197
|
+
"**/vendor/**",
|
|
198
|
+
"**/tmp/**",
|
|
199
|
+
"**/.cache/**",
|
|
200
|
+
"**/assets/**",
|
|
201
|
+
"**/logs/**",
|
|
202
|
+
"**/output/**",
|
|
203
|
+
"**/public/**",
|
|
204
|
+
"**/static/**",
|
|
205
|
+
"**/temp/**",
|
|
206
|
+
"**/backup/**",
|
|
207
|
+
"**/backups/**",
|
|
208
|
+
"**/examples/**",
|
|
209
|
+
"**/docs/**",
|
|
210
|
+
"**/tests/**",
|
|
211
|
+
"**/__tests__/**",
|
|
212
|
+
"**/spec/**",
|
|
213
|
+
"**/__specs__/**",
|
|
214
|
+
"**/scripts/**",
|
|
215
|
+
"**/bin/**",
|
|
216
|
+
"**/hooks/**",
|
|
217
|
+
"**/config/**",
|
|
218
|
+
"**/configs/**",
|
|
219
|
+
"**/settings/**",
|
|
220
|
+
"**/.vscode/**",
|
|
221
|
+
"**/.idea/**"
|
|
222
|
+
];
|
|
223
|
+
function findEnvFiles(startDir = process.cwd(), filter) {
|
|
224
|
+
const found = /* @__PURE__ */ new Set();
|
|
225
|
+
function addFile(file) {
|
|
226
|
+
const normalized = path.normalize(file);
|
|
227
|
+
if (typeof filter === "function" && !filter(normalized)) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
found.add(normalized);
|
|
231
|
+
}
|
|
232
|
+
let current = path.resolve(startDir);
|
|
233
|
+
while (true) {
|
|
234
|
+
const envPath = path.join(current, ".env");
|
|
235
|
+
if (fs.existsSync(envPath)) {
|
|
236
|
+
addFile(envPath);
|
|
237
|
+
}
|
|
238
|
+
const parent = path.dirname(current);
|
|
239
|
+
if (parent === current) {
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
current = parent;
|
|
243
|
+
}
|
|
244
|
+
const files = glob.globSync("**/.env*", {
|
|
245
|
+
cwd: startDir,
|
|
246
|
+
absolute: true,
|
|
247
|
+
nodir: true,
|
|
248
|
+
ignore: DEFAULT_IGNORES
|
|
249
|
+
});
|
|
250
|
+
for (const file of files) {
|
|
251
|
+
addFile(file);
|
|
252
|
+
}
|
|
253
|
+
return [...found];
|
|
254
|
+
}
|
|
255
|
+
function findEnvWithToken2(startDir = process.cwd(), tokenName = "GITHUB_TOKEN") {
|
|
256
|
+
const envFiles = findEnvFiles(startDir);
|
|
257
|
+
return envFiles.find((file) => {
|
|
258
|
+
try {
|
|
259
|
+
const content = fs.readFileSync(file, "utf-8");
|
|
260
|
+
const regex = new RegExp(`^\\s*${tokenName}\\s*=`, "m");
|
|
261
|
+
return regex.test(content);
|
|
262
|
+
} catch (err) {
|
|
263
|
+
console.warn(`Failed to read ${file}: ${err instanceof Error ? err.message : String(err)}`);
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
module2.exports = {
|
|
269
|
+
DEFAULT_IGNORES,
|
|
270
|
+
findEnvFiles,
|
|
271
|
+
findEnvWithToken: findEnvWithToken2,
|
|
272
|
+
default: findEnvFiles
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
|
|
188
277
|
// src/clean-github-actions-caches.cjs
|
|
189
278
|
init_cjs_shims();
|
|
190
279
|
var axios = require("axios");
|
|
191
|
-
var {
|
|
192
|
-
var
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
console.warn(`.env file not found at ${envPath}`);
|
|
200
|
-
}
|
|
201
|
-
require("dotenv").config({ path: path.join(process.cwd(), ".env"), quiet: true });
|
|
202
|
-
var ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
|
|
280
|
+
var { getArgs } = require_utils();
|
|
281
|
+
var { findEnvWithToken } = require_findEnvFiles();
|
|
282
|
+
require("dotenv").config({
|
|
283
|
+
path: findEnvWithToken(),
|
|
284
|
+
quiet: true,
|
|
285
|
+
overwrite: true
|
|
286
|
+
});
|
|
287
|
+
var ACCESS_TOKEN = process.env.ACCESS_TOKEN || process.env.GITHUB_TOKEN;
|
|
203
288
|
if (!ACCESS_TOKEN) {
|
|
204
289
|
throw new Error(
|
|
205
290
|
"Access token is not provided. Please set ACCESS_TOKEN or GITHUB_TOKEN in your environment variables."
|
|
206
291
|
);
|
|
207
292
|
}
|
|
293
|
+
function printHelp() {
|
|
294
|
+
console.log(`
|
|
295
|
+
GitHub Actions Cache Cleaner
|
|
296
|
+
|
|
297
|
+
Description:
|
|
298
|
+
Removes outdated GitHub Actions caches for a repository, keeping only the newest
|
|
299
|
+
cache for each cache-key prefix. Authenticates via ACCESS_TOKEN or GITHUB_TOKEN
|
|
300
|
+
from your environment or .env file.
|
|
301
|
+
|
|
302
|
+
Usage:
|
|
303
|
+
clean-github-actions-caches [options]
|
|
304
|
+
|
|
305
|
+
Options:
|
|
306
|
+
-h, --help Show this help message
|
|
307
|
+
-r, --repo <repo> GitHub repository (owner/repo). If omitted, the tool will
|
|
308
|
+
attempt to infer the repository from the current working
|
|
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.
|
|
313
|
+
|
|
314
|
+
Environment Variables:
|
|
315
|
+
ACCESS_TOKEN GitHub access token (preferred)
|
|
316
|
+
GITHUB_TOKEN GitHub access token (fallback)
|
|
317
|
+
|
|
318
|
+
Behavior & Safety:
|
|
319
|
+
- Groups caches by a derived prefix from the cache key and keeps the most
|
|
320
|
+
recently created cache for each group.
|
|
321
|
+
- Deletes only caches older than the latest per prefix to reduce risk of
|
|
322
|
+
removing needed artifacts.
|
|
323
|
+
|
|
324
|
+
Examples:
|
|
325
|
+
# Run against a specific repo (owner/repo)
|
|
326
|
+
clean-github-actions-caches --repo octocat/hello-world
|
|
327
|
+
|
|
328
|
+
# Run via npx without installing
|
|
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
|
|
330
|
+
|
|
331
|
+
# Run via yarn dlx
|
|
332
|
+
yarn dlx binary-collections@https://raw.githubusercontent.com/dimaslanjaka/bin/master/releases/bin.tgz clean-github-actions-caches --prefix-depth 3
|
|
333
|
+
|
|
334
|
+
Notes:
|
|
335
|
+
- Ensure ACCESS_TOKEN or GITHUB_TOKEN is set and has permissions to manage Actions caches.
|
|
336
|
+
- Intended for repository maintainers with appropriate permissions.
|
|
337
|
+
`);
|
|
338
|
+
}
|
|
339
|
+
var argv = getArgs({
|
|
340
|
+
alias: {
|
|
341
|
+
h: "help",
|
|
342
|
+
p: "prefix-depth",
|
|
343
|
+
r: "repo"
|
|
344
|
+
},
|
|
345
|
+
string: ["prefix-depth", "repo"],
|
|
346
|
+
boolean: ["help"]
|
|
347
|
+
});
|
|
348
|
+
if (argv.help) {
|
|
349
|
+
printHelp();
|
|
350
|
+
process.exit(0);
|
|
351
|
+
}
|
|
208
352
|
function deleteGitHubActionsCache(GH_REPO, cacheId) {
|
|
209
353
|
return new Promise((resolve, reject) => {
|
|
210
354
|
const url = `https://api.github.com/repos/${GH_REPO}/actions/caches/${cacheId}`;
|
|
@@ -227,7 +371,53 @@ function deleteGitHubActionsCache(GH_REPO, cacheId) {
|
|
|
227
371
|
});
|
|
228
372
|
});
|
|
229
373
|
}
|
|
230
|
-
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) {
|
|
231
421
|
const url = `https://api.github.com/repos/${GH_REPO}/actions/caches`;
|
|
232
422
|
return new Promise((resolve, reject) => {
|
|
233
423
|
axios.get(url, {
|
|
@@ -237,69 +427,19 @@ function get_caches(GH_REPO) {
|
|
|
237
427
|
}
|
|
238
428
|
}).then((response) => {
|
|
239
429
|
const data = response.data.actions_caches;
|
|
240
|
-
const
|
|
241
|
-
const split = key.split(/[-_]/);
|
|
242
|
-
if (split.length == 3) {
|
|
243
|
-
return `${split[0]}-${split[1]}`;
|
|
244
|
-
} else if (split.length > 3) {
|
|
245
|
-
return `${split[0]}-${split[1]}-${split[2]}`;
|
|
246
|
-
}
|
|
247
|
-
return split[0];
|
|
248
|
-
};
|
|
249
|
-
const grouped = data.reduce(
|
|
250
|
-
/**
|
|
251
|
-
* @param {Record<string, Record<string, any>[]>} acc
|
|
252
|
-
* @param {Record<string, any>} item
|
|
253
|
-
* @returns {Record<string, Record<string, any>[]>}
|
|
254
|
-
*/
|
|
255
|
-
(acc, item) => {
|
|
256
|
-
const prefix = getPrefix(item.key);
|
|
257
|
-
if (!acc[prefix]) {
|
|
258
|
-
acc[prefix] = [];
|
|
259
|
-
}
|
|
260
|
-
acc[prefix].push(item);
|
|
261
|
-
return acc;
|
|
262
|
-
},
|
|
263
|
-
{}
|
|
264
|
-
);
|
|
430
|
+
const grouped = groupCachesByPrefix(data, prefixDepth);
|
|
265
431
|
resolve(grouped);
|
|
266
432
|
}).catch((error) => {
|
|
267
|
-
console.error("Error fetching data:", error);
|
|
268
433
|
reject(error);
|
|
269
434
|
});
|
|
270
435
|
});
|
|
271
436
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
human_readable_date: new Date(item.created_at).toLocaleString()
|
|
282
|
-
}));
|
|
283
|
-
if (items.length > 1) {
|
|
284
|
-
const ids = items.map((o) => o.id);
|
|
285
|
-
ids.shift();
|
|
286
|
-
if (ids.length > 0) {
|
|
287
|
-
for (const id of ids) {
|
|
288
|
-
try {
|
|
289
|
-
await deleteGitHubActionsCache(GH_REPO, id);
|
|
290
|
-
} catch (err) {
|
|
291
|
-
console.error(`Error deleting cache ${id}:`, err);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
} else {
|
|
295
|
-
console.log(`cache prefix ${key} no cache left`);
|
|
296
|
-
}
|
|
297
|
-
} else {
|
|
298
|
-
console.log(`cache prefix ${key} only have 1 cache`);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
} catch (e) {
|
|
303
|
-
console.error(`Error: ${e}`);
|
|
304
|
-
}
|
|
305
|
-
})();
|
|
437
|
+
module.exports = {
|
|
438
|
+
deleteGitHubActionsCache,
|
|
439
|
+
getCachePrefix,
|
|
440
|
+
getMeaningfulCacheKeyParts,
|
|
441
|
+
get_caches,
|
|
442
|
+
groupCachesByPrefix,
|
|
443
|
+
isChecksumSegment,
|
|
444
|
+
normalizePrefixDepth
|
|
445
|
+
};
|
|
@@ -1 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Deletes a GitHub Actions cache.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} GH_REPO - The GitHub repository in the format "owner/repo".
|
|
5
|
+
* @param {string|number} cacheId - The ID of the cache to delete.
|
|
6
|
+
* @returns {Promise<any>} Promise resolving with GitHub API response.
|
|
7
|
+
*/
|
|
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[];
|
|
24
|
+
/**
|
|
25
|
+
* List GitHub Actions caches grouped by cache key prefix.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} GH_REPO GitHub repository in format `owner/repo`.
|
|
28
|
+
* @param {number} [prefixDepth=3]
|
|
29
|
+
* @returns {Promise<Record<string, Record<string, any>[]>>}
|
|
30
|
+
*/
|
|
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,133 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
init_esm_shims
|
|
9
|
-
} from "./chunk-QQ4A6DLD.mjs";
|
|
10
|
-
|
|
11
|
-
// src/clean-github-actions-caches.cjs
|
|
12
|
-
var require_clean_github_actions_caches = __commonJS({
|
|
13
|
-
"src/clean-github-actions-caches.cjs"() {
|
|
14
|
-
init_esm_shims();
|
|
15
|
-
var axios = __require("axios");
|
|
16
|
-
var { parseGitRemotes } = require_utils();
|
|
17
|
-
var path = __require("upath");
|
|
18
|
-
var fs = __require("fs");
|
|
19
|
-
var projectDir = process.cwd();
|
|
20
|
-
var envPath = path.join(projectDir, ".env");
|
|
21
|
-
if (fs.existsSync(envPath)) {
|
|
22
|
-
__require("dotenv").config({ path: envPath, quiet: true });
|
|
23
|
-
} else {
|
|
24
|
-
console.warn(`.env file not found at ${envPath}`);
|
|
25
|
-
}
|
|
26
|
-
__require("dotenv").config({ path: path.join(process.cwd(), ".env"), quiet: true });
|
|
27
|
-
var ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
|
|
28
|
-
if (!ACCESS_TOKEN) {
|
|
29
|
-
throw new Error(
|
|
30
|
-
"Access token is not provided. Please set ACCESS_TOKEN or GITHUB_TOKEN in your environment variables."
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
function deleteGitHubActionsCache(GH_REPO, cacheId) {
|
|
34
|
-
return new Promise((resolve, reject) => {
|
|
35
|
-
const url = `https://api.github.com/repos/${GH_REPO}/actions/caches/${cacheId}`;
|
|
36
|
-
const token = ACCESS_TOKEN;
|
|
37
|
-
if (!token) {
|
|
38
|
-
return reject(new Error("Access token is not provided"));
|
|
39
|
-
}
|
|
40
|
-
axios.delete(url, {
|
|
41
|
-
headers: {
|
|
42
|
-
Authorization: `token ${token}`,
|
|
43
|
-
Accept: "application/vnd.github.v3+json"
|
|
44
|
-
}
|
|
45
|
-
}).then((response) => {
|
|
46
|
-
console.log(`Cache (${cacheId}) deleted successfully`, response.data);
|
|
47
|
-
resolve(response.data);
|
|
48
|
-
}).catch((error) => {
|
|
49
|
-
var _a;
|
|
50
|
-
console.error("Error deleting cache:", ((_a = error.response) == null ? void 0 : _a.data) || error.message || "Unknown error");
|
|
51
|
-
reject(error);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function get_caches(GH_REPO) {
|
|
56
|
-
const url = `https://api.github.com/repos/${GH_REPO}/actions/caches`;
|
|
57
|
-
return new Promise((resolve, reject) => {
|
|
58
|
-
axios.get(url, {
|
|
59
|
-
headers: {
|
|
60
|
-
Accept: "application/vnd.github.v3+json",
|
|
61
|
-
Authorization: `token ${ACCESS_TOKEN}`
|
|
62
|
-
}
|
|
63
|
-
}).then((response) => {
|
|
64
|
-
const data = response.data.actions_caches;
|
|
65
|
-
const getPrefix = (key) => {
|
|
66
|
-
const split = key.split(/[-_]/);
|
|
67
|
-
if (split.length == 3) {
|
|
68
|
-
return `${split[0]}-${split[1]}`;
|
|
69
|
-
} else if (split.length > 3) {
|
|
70
|
-
return `${split[0]}-${split[1]}-${split[2]}`;
|
|
71
|
-
}
|
|
72
|
-
return split[0];
|
|
73
|
-
};
|
|
74
|
-
const grouped = data.reduce(
|
|
75
|
-
/**
|
|
76
|
-
* @param {Record<string, Record<string, any>[]>} acc
|
|
77
|
-
* @param {Record<string, any>} item
|
|
78
|
-
* @returns {Record<string, Record<string, any>[]>}
|
|
79
|
-
*/
|
|
80
|
-
(acc, item) => {
|
|
81
|
-
const prefix = getPrefix(item.key);
|
|
82
|
-
if (!acc[prefix]) {
|
|
83
|
-
acc[prefix] = [];
|
|
84
|
-
}
|
|
85
|
-
acc[prefix].push(item);
|
|
86
|
-
return acc;
|
|
87
|
-
},
|
|
88
|
-
{}
|
|
89
|
-
);
|
|
90
|
-
resolve(grouped);
|
|
91
|
-
}).catch((error) => {
|
|
92
|
-
console.error("Error fetching data:", error);
|
|
93
|
-
reject(error);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
(async () => {
|
|
98
|
-
try {
|
|
99
|
-
const remotes = await parseGitRemotes();
|
|
100
|
-
const GH_REPO = remotes.origin;
|
|
101
|
-
const caches = await get_caches(GH_REPO);
|
|
102
|
-
for (const key in caches) {
|
|
103
|
-
if (Object.hasOwnProperty.call(caches, key)) {
|
|
104
|
-
const items = caches[key].sort((a, b) => new Date(b.created_at) - new Date(a.created_at)).map((item) => ({
|
|
105
|
-
...item,
|
|
106
|
-
human_readable_date: new Date(item.created_at).toLocaleString()
|
|
107
|
-
}));
|
|
108
|
-
if (items.length > 1) {
|
|
109
|
-
const ids = items.map((o) => o.id);
|
|
110
|
-
ids.shift();
|
|
111
|
-
if (ids.length > 0) {
|
|
112
|
-
for (const id of ids) {
|
|
113
|
-
try {
|
|
114
|
-
await deleteGitHubActionsCache(GH_REPO, id);
|
|
115
|
-
} catch (err) {
|
|
116
|
-
console.error(`Error deleting cache ${id}:`, err);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
console.log(`cache prefix ${key} no cache left`);
|
|
121
|
-
}
|
|
122
|
-
} else {
|
|
123
|
-
console.log(`cache prefix ${key} only have 1 cache`);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
} catch (e) {
|
|
128
|
-
console.error(`Error: ${e}`);
|
|
129
|
-
}
|
|
130
|
-
})();
|
|
131
|
-
}
|
|
132
|
-
});
|
|
3
|
+
require_clean_github_actions_caches
|
|
4
|
+
} from "./chunk-CD3HF3LK.mjs";
|
|
5
|
+
import "./chunk-H44UWUFY.mjs";
|
|
6
|
+
import "./chunk-6RK5UCTP.mjs";
|
|
7
|
+
import "./chunk-QQ4A6DLD.mjs";
|
|
133
8
|
export default require_clean_github_actions_caches();
|