binary-collections 2.0.14 → 2.0.15

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 (145) hide show
  1. package/.opencode/plugins/opencode-request-logger/README.md +44 -0
  2. package/.venv/Lib/site-packages/pyarrow/tests/data/orc/README.md +22 -0
  3. package/docs-src/install-opencode-plugins.md +86 -0
  4. package/docs-src/opencode-cli.md +38 -10
  5. package/lib/binary-collections/config-types.cjs +17 -0
  6. package/lib/binary-collections/config-types.d.ts +12 -0
  7. package/lib/binary-collections/config-types.js +2 -0
  8. package/lib/binary-collections/config-types.mjs +7 -0
  9. package/lib/binary-collections/config.cjs +16 -8
  10. package/lib/binary-collections/config.d.cts +18 -10
  11. package/lib/binary-collections/config.mjs +1 -1
  12. package/lib/binary-collections/findScript.cjs +8 -6
  13. package/lib/binary-collections/findScript.mjs +2 -2
  14. package/lib/binary-collections/listScript.cjs +8 -6
  15. package/lib/binary-collections/listScript.mjs +2 -2
  16. package/lib/binary-collections.cjs +8 -6
  17. package/lib/binary-collections.mjs +3 -3
  18. package/lib/changelog.cjs +142 -4
  19. package/lib/changelog.mjs +9 -5
  20. package/lib/{chunk-SARIXFHP.mjs → chunk-3T6AMFI3.mjs} +16 -8
  21. package/lib/{chunk-3F6EIHYG.mjs → chunk-3ZF2QMDK.mjs} +3 -3
  22. package/lib/chunk-B77D3SR4.mjs +28 -0
  23. package/lib/chunk-BPED62FN.mjs +115 -0
  24. package/lib/{chunk-XI67TI46.mjs → chunk-DHFRWM2W.mjs} +1 -1
  25. package/lib/{chunk-2SJKVOTN.mjs → chunk-DPEE3FBB.mjs} +1 -1
  26. package/lib/{chunk-UYNBNLV5.mjs → chunk-H7AE4IO3.mjs} +1 -1
  27. package/lib/{chunk-YWSLMAQ7.mjs → chunk-KCJYREA2.mjs} +14 -12
  28. package/lib/{chunk-JK3MG2KF.mjs → chunk-NHD4HLSU.mjs} +1 -1
  29. package/lib/{chunk-I3O5ZRYU.mjs → chunk-OWNVMKAA.mjs} +1 -1
  30. package/lib/chunk-SKVF4TMD.mjs +59 -0
  31. package/lib/{chunk-SJYP66BO.mjs → chunk-TDUUOAQD.mjs} +1 -1
  32. package/lib/{chunk-D42YBRZW.mjs → chunk-UAEKSLAX.mjs} +1 -1
  33. package/lib/chunk-V6PTSDW5.mjs +82 -0
  34. package/lib/{chunk-AJ3OIYYP.mjs → chunk-WNUEY6VJ.mjs} +8 -6
  35. package/lib/{chunk-YLV4QATP.mjs → chunk-Z53IUBUN.mjs} +6 -5
  36. package/lib/{chunk-JMUFQSPE.mjs → chunk-Z7RM46Q4.mjs} +1 -1
  37. package/lib/cross-env/index.mjs +3 -3
  38. package/lib/git/git-diff-cli.cjs +16 -8
  39. package/lib/git/git-diff-cli.mjs +3 -3
  40. package/lib/git/git-diff.cjs +16 -8
  41. package/lib/git/git-diff.mjs +3 -3
  42. package/lib/git/git-fix.cjs +16 -8
  43. package/lib/git/git-fix.mjs +2 -2
  44. package/lib/git/user-config.cjs +16 -8
  45. package/lib/git/user-config.mjs +2 -2
  46. package/lib/github-workflows/clean-github-actions-caches-cli.cjs +16 -8
  47. package/lib/github-workflows/clean-github-actions-caches-cli.mjs +2 -2
  48. package/lib/github-workflows/clean-github-actions-caches.cjs +16 -8
  49. package/lib/github-workflows/clean-github-actions-caches.mjs +2 -2
  50. package/lib/github-workflows/get-latest-workflow-status-cli.cjs +16 -8
  51. package/lib/github-workflows/get-latest-workflow-status-cli.mjs +2 -2
  52. package/lib/github-workflows/utils.cjs +16 -8
  53. package/lib/github-workflows/utils.mjs +2 -2
  54. package/lib/github-workflows/workflow-badge-cli.cjs +16 -8
  55. package/lib/github-workflows/workflow-badge-cli.mjs +4 -4
  56. package/lib/node-cache-cleaner-cli.mjs +3 -3
  57. package/lib/opencode/cli/auth-rotate.cjs +343 -28
  58. package/lib/opencode/cli/auth-rotate.d.ts +3 -1
  59. package/lib/opencode/cli/auth-rotate.js +10 -15
  60. package/lib/opencode/cli/auth-rotate.mjs +6 -2
  61. package/lib/opencode/cli/auth-rotate.runner.cjs +454 -0
  62. package/lib/opencode/cli/auth-rotate.runner.d.ts +1 -0
  63. package/lib/opencode/cli/auth-rotate.runner.js +8 -0
  64. package/lib/opencode/cli/auth-rotate.runner.mjs +21 -0
  65. package/lib/opencode/install-opencode-plugins-cli.cjs +82 -0
  66. package/lib/opencode/install-opencode-plugins-cli.d.ts +1 -0
  67. package/lib/opencode/install-opencode-plugins-cli.js +78 -0
  68. package/lib/opencode/install-opencode-plugins-cli.mjs +65 -0
  69. package/lib/opencode/utils/check-api.cjs +332 -18
  70. package/lib/opencode/utils/check-api.d.ts +5 -1
  71. package/lib/opencode/utils/check-api.js +101 -15
  72. package/lib/opencode/utils/check-api.mjs +5 -1
  73. package/lib/opencode/utils/check-api.runner.cjs +0 -0
  74. package/lib/opencode/utils/check-api.runner.d.ts +0 -0
  75. package/lib/opencode/utils/check-api.runner.js +1 -0
  76. package/lib/opencode/utils/check-api.runner.mjs +7 -0
  77. package/lib/opencode-cli.cjs +352 -29
  78. package/lib/opencode-cli.js +3 -2
  79. package/lib/opencode-cli.mjs +11 -6
  80. package/lib/package-resolutions-updater-cli.cjs +16 -8
  81. package/lib/package-resolutions-updater-cli.mjs +2 -2
  82. package/lib/package-resolutions-updater.cjs +16 -8
  83. package/lib/package-resolutions-updater.mjs +2 -2
  84. package/lib/print-directory-tree.cjs +16 -8
  85. package/lib/print-directory-tree.mjs +1 -1
  86. package/lib/print-tarball-tree-cli.cjs +305 -0
  87. package/lib/print-tarball-tree-cli.d.mts +2 -0
  88. package/lib/print-tarball-tree-cli.mjs +54 -0
  89. package/lib/print-tarball-tree.cjs +43 -216
  90. package/lib/print-tarball-tree.d.mts +4 -1
  91. package/lib/print-tarball-tree.mjs +12 -66
  92. package/lib/rmpath-cli.cjs +16 -8
  93. package/lib/rmpath-cli.mjs +2 -2
  94. package/lib/rmpath.cjs +16 -8
  95. package/lib/rmpath.mjs +2 -2
  96. package/lib/run-by-checksum/hash.cjs +45 -67
  97. package/lib/run-by-checksum/{hash.d.ts → hash.d.cts} +9 -2
  98. package/lib/run-by-checksum/hash.mjs +3 -7
  99. package/lib/run-by-checksum/run.cjs +95 -58
  100. package/lib/run-by-checksum/run.js +3 -3
  101. package/lib/run-by-checksum/run.mjs +2 -2
  102. package/lib/run-by-checksum-cli.cjs +96 -74
  103. package/lib/run-by-checksum-cli.mjs +2 -2
  104. package/lib/submodule-install.cjs +16 -8
  105. package/lib/submodule-install.mjs +1 -1
  106. package/lib/submodule-remove-cli.cjs +16 -8
  107. package/lib/submodule-remove-cli.mjs +2 -2
  108. package/lib/submodule-remove.cjs +16 -8
  109. package/lib/submodule-remove.mjs +2 -2
  110. package/lib/utils/isDebug.cjs +13 -0
  111. package/lib/utils/isDebug.d.cts +9 -0
  112. package/lib/utils/isDebug.mjs +6 -0
  113. package/package.json +9 -7
  114. package/readme.md +63 -0
  115. package/releases/readme.md +1 -1
  116. package/lib/chunk-546KAIYT.mjs +0 -113
  117. package/lib/chunk-5WAOOOGZ.mjs +0 -77
  118. package/lib/chunk-72XTQ3CK.mjs +0 -45
  119. package/lib/chunk-7Q6YEUQF.mjs +0 -246
  120. package/lib/chunk-AQZ7LMFS.mjs +0 -100
  121. package/lib/chunk-BDCMTOZI.mjs +0 -246
  122. package/lib/chunk-BEUM4LH4.mjs +0 -184
  123. package/lib/chunk-BO4TZS4Q.mjs +0 -246
  124. package/lib/chunk-BZWVHODJ.mjs +0 -62
  125. package/lib/chunk-CM3IC5YC.mjs +0 -226
  126. package/lib/chunk-FR3DMHJC.mjs +0 -146
  127. package/lib/chunk-H44UWUFY.mjs +0 -105
  128. package/lib/chunk-JVMLKHD2.mjs +0 -62
  129. package/lib/chunk-KAT2JNLZ.mjs +0 -146
  130. package/lib/chunk-KRCPFWIF.mjs +0 -193
  131. package/lib/chunk-LVSPEFU2.mjs +0 -86
  132. package/lib/chunk-MCCMMZSM.mjs +0 -60
  133. package/lib/chunk-MGPYPKIE.mjs +0 -109
  134. package/lib/chunk-OA2RKEY3.mjs +0 -162
  135. package/lib/chunk-PAZH45HS.mjs +0 -41
  136. package/lib/chunk-QZMGBDSA.mjs +0 -32
  137. package/lib/chunk-RDGDLSPD.mjs +0 -76
  138. package/lib/chunk-RKPIBGKE.mjs +0 -61
  139. package/lib/chunk-SWUAEY4H.mjs +0 -44
  140. package/lib/chunk-UAIF5VIA.mjs +0 -89
  141. package/lib/chunk-UHPFLJXH.mjs +0 -227
  142. package/lib/chunk-WOC4FZ6F.mjs +0 -164
  143. package/lib/chunk-WSHVPGNM.mjs +0 -44
  144. package/lib/run-by-checksum/hash.js +0 -119
  145. package/readme.html +0 -784
@@ -1,105 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import {
3
- __commonJS,
4
- __require,
5
- init_esm_shims
6
- } from "./chunk-QQ4A6DLD.mjs";
7
-
8
- // src/utils/findEnvFiles.cjs
9
- var require_findEnvFiles = __commonJS({
10
- "src/utils/findEnvFiles.cjs"(exports, module) {
11
- init_esm_shims();
12
- var fs = __require("fs");
13
- var path = __require("path");
14
- var glob = __require("glob");
15
- var DEFAULT_IGNORES = [
16
- "**/node_modules/**",
17
- "**/.git/**",
18
- "**/.yarn/**",
19
- "**/.pnpm/**",
20
- "**/dist/**",
21
- "**/build/**",
22
- "**/coverage/**",
23
- "**/vendor/**",
24
- "**/tmp/**",
25
- "**/.cache/**",
26
- "**/assets/**",
27
- "**/logs/**",
28
- "**/output/**",
29
- "**/public/**",
30
- "**/static/**",
31
- "**/temp/**",
32
- "**/backup/**",
33
- "**/backups/**",
34
- "**/examples/**",
35
- "**/docs/**",
36
- "**/tests/**",
37
- "**/__tests__/**",
38
- "**/spec/**",
39
- "**/__specs__/**",
40
- "**/scripts/**",
41
- "**/bin/**",
42
- "**/hooks/**",
43
- "**/config/**",
44
- "**/configs/**",
45
- "**/settings/**",
46
- "**/.vscode/**",
47
- "**/.idea/**"
48
- ];
49
- function findEnvFiles(startDir = process.cwd(), filter) {
50
- const found = /* @__PURE__ */ new Set();
51
- function addFile(file) {
52
- const normalized = path.normalize(file);
53
- if (typeof filter === "function" && !filter(normalized)) {
54
- return;
55
- }
56
- found.add(normalized);
57
- }
58
- let current = path.resolve(startDir);
59
- while (true) {
60
- const envPath = path.join(current, ".env");
61
- if (fs.existsSync(envPath)) {
62
- addFile(envPath);
63
- }
64
- const parent = path.dirname(current);
65
- if (parent === current) {
66
- break;
67
- }
68
- current = parent;
69
- }
70
- const files = glob.globSync("**/.env*", {
71
- cwd: startDir,
72
- absolute: true,
73
- nodir: true,
74
- ignore: DEFAULT_IGNORES
75
- });
76
- for (const file of files) {
77
- addFile(file);
78
- }
79
- return [...found];
80
- }
81
- function findEnvWithToken(startDir = process.cwd(), tokenName = "GITHUB_TOKEN") {
82
- const envFiles = findEnvFiles(startDir);
83
- return envFiles.find((file) => {
84
- try {
85
- const content = fs.readFileSync(file, "utf-8");
86
- const regex = new RegExp(`^\\s*${tokenName}\\s*=`, "m");
87
- return regex.test(content);
88
- } catch (err) {
89
- console.warn(`Failed to read ${file}: ${err instanceof Error ? err.message : String(err)}`);
90
- return false;
91
- }
92
- });
93
- }
94
- module.exports = {
95
- DEFAULT_IGNORES,
96
- findEnvFiles,
97
- findEnvWithToken,
98
- default: findEnvFiles
99
- };
100
- }
101
- });
102
-
103
- export {
104
- require_findEnvFiles
105
- };
@@ -1,62 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import {
3
- require_config
4
- } from "./chunk-SARIXFHP.mjs";
5
- import {
6
- __commonJS,
7
- __require,
8
- init_esm_shims
9
- } from "./chunk-QQ4A6DLD.mjs";
10
-
11
- // src/submodule-remove.cjs
12
- var require_submodule_remove = __commonJS({
13
- "src/submodule-remove.cjs"(exports, module) {
14
- init_esm_shims();
15
- var { spawnAsync } = __require("cross-spawn");
16
- var path = __require("upath");
17
- var fs = __require("fs-extra");
18
- var { loadDotenv } = require_config();
19
- loadDotenv();
20
- async function removeSubmodule(submodulePath) {
21
- try {
22
- await spawnAsync("git", ["submodule", "deinit", "-f", submodulePath], { stdio: "inherit" });
23
- } catch (error) {
24
- console.warn(`Warning: Could not deinitialize submodule "${submodulePath}". It may not exist.`);
25
- console.warn(error.message);
26
- }
27
- try {
28
- await spawnAsync("git", ["config", "--remove-section", `submodule.${submodulePath}`], { stdio: "inherit" });
29
- } catch (error) {
30
- console.warn(`Warning: Could not remove git config section for submodule "${submodulePath}". It may not exist.`);
31
- console.warn(error.message);
32
- }
33
- const gitModulesPath = path.resolve(".git", "modules", submodulePath);
34
- if (fs.existsSync(gitModulesPath)) {
35
- fs.rmSync(gitModulesPath, { recursive: true, force: true });
36
- console.log(`Removed .git/modules entry for submodule "${submodulePath}".`);
37
- } else {
38
- console.warn(`Warning: The path "${gitModulesPath}" does not exist. Skipping removal of .git/modules entry.`);
39
- }
40
- const gitmodulesPath = path.resolve(".gitmodules");
41
- if (fs.existsSync(gitmodulesPath)) {
42
- let gitmodulesContent = fs.readFileSync(gitmodulesPath, "utf-8");
43
- const submoduleSectionRegex = new RegExp(
44
- `\\[submodule "${submodulePath.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}"]([\\s\\S]*?)(?=\\[|$)`,
45
- "g"
46
- );
47
- gitmodulesContent = gitmodulesContent.replace(submoduleSectionRegex, "").trim();
48
- fs.writeFileSync(gitmodulesPath, gitmodulesContent);
49
- console.log(`Removed submodule "${submodulePath}" from .gitmodules.`);
50
- } else {
51
- console.warn(`Warning: The .gitmodules file does not exist. Skipping removal of submodule "${submodulePath}".`);
52
- }
53
- fs.rmSync(path.resolve(submodulePath), { recursive: true, force: true });
54
- console.log(`Submodule "${submodulePath}" has been removed.`);
55
- }
56
- module.exports = removeSubmodule;
57
- }
58
- });
59
-
60
- export {
61
- require_submodule_remove
62
- };
@@ -1,146 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import {
3
- require_config
4
- } from "./chunk-SARIXFHP.mjs";
5
- import {
6
- __commonJS,
7
- __require,
8
- init_esm_shims
9
- } from "./chunk-QQ4A6DLD.mjs";
10
-
11
- // src/github-workflows/utils.cjs
12
- var require_utils = __commonJS({
13
- "src/github-workflows/utils.cjs"(exports, module) {
14
- init_esm_shims();
15
- var axios = __require("axios");
16
- var { spawn } = __require("cross-spawn");
17
- var { GITHUB_ACCESS_TOKEN: TOKEN } = require_config();
18
- if (!TOKEN) {
19
- console.error("Missing env var: ACCESS_TOKEN or GITHUB_TOKEN");
20
- process.exit(1);
21
- }
22
- var BASE = "https://api.github.com";
23
- var HEADERS = {
24
- Authorization: `Bearer ${TOKEN}`,
25
- Accept: "application/vnd.github+json",
26
- "X-GitHub-Api-Version": "2022-11-28"
27
- };
28
- async function request(url) {
29
- try {
30
- const res = await axios.get(url, { headers: HEADERS });
31
- return res.data;
32
- } catch (err) {
33
- if (err == null ? void 0 : err.response) {
34
- const statusText = err.response.statusText || "Request failed";
35
- const responseText = typeof err.response.data === "string" ? err.response.data : JSON.stringify(err.response.data);
36
- throw new Error(`${err.response.status} ${statusText}
37
- ${responseText}`);
38
- }
39
- throw err;
40
- }
41
- }
42
- function runGit(args) {
43
- return new Promise((resolve, reject) => {
44
- var _a, _b;
45
- const child = spawn("git", args, {
46
- cwd: process.cwd(),
47
- stdio: ["ignore", "pipe", "pipe"]
48
- });
49
- let stdout = "";
50
- let stderr = "";
51
- (_a = child.stdout) == null ? void 0 : _a.on("data", (chunk) => {
52
- stdout += chunk.toString();
53
- });
54
- (_b = child.stderr) == null ? void 0 : _b.on("data", (chunk) => {
55
- stderr += chunk.toString();
56
- });
57
- child.on("error", reject);
58
- child.on("close", (code) => {
59
- if (code === 0) return resolve(stdout.trim());
60
- reject(new Error(stderr.trim() || `git ${args.join(" ")} exited with code ${code}`));
61
- });
62
- });
63
- }
64
- function parseOwnerFromUrl(remoteUrl) {
65
- const normalized = remoteUrl.trim().replace(/\.git$/i, "");
66
- const match = normalized.match(/github\.com[:/](?<owner>[^/]+)\/(?<repo>[^/]+)$/i);
67
- return (match == null ? void 0 : match.groups) || null;
68
- }
69
- function getOwnerFromRemoteUrl(remoteUrl) {
70
- const parsed = parseOwnerFromUrl(remoteUrl);
71
- return (parsed == null ? void 0 : parsed.owner) || null;
72
- }
73
- function getRepoFromRemoteUrl(remoteUrl) {
74
- const parsed = parseOwnerFromUrl(remoteUrl);
75
- return (parsed == null ? void 0 : parsed.repo) || null;
76
- }
77
- async function getCurrentOwner() {
78
- const commands = [
79
- ["config", "--local", "--get", "remote.origin.url"],
80
- ["remote", "get-url", "origin"]
81
- ];
82
- for (const args of commands) {
83
- try {
84
- const remoteUrl = await runGit(args);
85
- const owner = getOwnerFromRemoteUrl(remoteUrl);
86
- if (owner) return owner;
87
- } catch {
88
- }
89
- }
90
- throw new Error("Unable to determine repository owner from git remote.origin.url");
91
- }
92
- async function getCurrentRepo() {
93
- const commands = [
94
- ["config", "--local", "--get", "remote.origin.url"],
95
- ["remote", "get-url", "origin"]
96
- ];
97
- for (const args of commands) {
98
- try {
99
- const remoteUrl = await runGit(args);
100
- const repo = getRepoFromRemoteUrl(remoteUrl);
101
- if (repo) return repo;
102
- } catch {
103
- }
104
- }
105
- throw new Error("Unable to determine repository name from git remote.origin.url");
106
- }
107
- async function getOwnerRepo() {
108
- const owner = await getCurrentOwner();
109
- const repo = await getCurrentRepo();
110
- return { owner, repo };
111
- }
112
- async function getLatestRun(owner, repo, workflowId) {
113
- var _a;
114
- let url;
115
- if (workflowId) {
116
- url = `${BASE}/repos/${owner}/${repo}/actions/workflows/${encodeURIComponent(workflowId)}/runs?per_page=1`;
117
- } else {
118
- url = `${BASE}/repos/${owner}/${repo}/actions/runs?per_page=1`;
119
- }
120
- const data = await request(url);
121
- return (_a = data.workflow_runs) == null ? void 0 : _a[0];
122
- }
123
- async function getJobs(owner, repo, runId) {
124
- const data = await request(`${BASE}/repos/${owner}/${repo}/actions/runs/${runId}/jobs`);
125
- return data.jobs || [];
126
- }
127
- module.exports = {
128
- BASE,
129
- HEADERS,
130
- request,
131
- runGit,
132
- parseOwnerFromUrl,
133
- getOwnerFromRemoteUrl,
134
- getRepoFromRemoteUrl,
135
- getCurrentOwner,
136
- getCurrentRepo,
137
- getOwnerRepo,
138
- getLatestRun,
139
- getJobs
140
- };
141
- }
142
- });
143
-
144
- export {
145
- require_utils
146
- };
@@ -1,193 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import {
3
- require_config
4
- } from "./chunk-PAZH45HS.mjs";
5
- import {
6
- require_findEnvFiles
7
- } from "./chunk-H44UWUFY.mjs";
8
- import {
9
- require_utils
10
- } from "./chunk-6RK5UCTP.mjs";
11
- import {
12
- __commonJS,
13
- __require,
14
- init_esm_shims
15
- } from "./chunk-QQ4A6DLD.mjs";
16
-
17
- // src/github-workflows/clean-github-actions-caches.cjs
18
- var require_clean_github_actions_caches = __commonJS({
19
- "src/github-workflows/clean-github-actions-caches.cjs"(exports, module) {
20
- init_esm_shims();
21
- var axios = __require("axios");
22
- var { getArgs } = require_utils();
23
- var { GITHUB_ACCESS_TOKEN: ACCESS_TOKEN } = require_config();
24
- var { findEnvWithToken } = require_findEnvFiles();
25
- __require("dotenv").config({
26
- path: findEnvWithToken(),
27
- quiet: true,
28
- overwrite: true
29
- });
30
- if (!ACCESS_TOKEN) {
31
- throw new Error(
32
- "Access token is not provided. Please set ACCESS_TOKEN or GITHUB_TOKEN in your environment variables."
33
- );
34
- }
35
- function printHelp() {
36
- console.log(`
37
- GitHub Actions Cache Cleaner
38
-
39
- Description:
40
- Removes outdated GitHub Actions caches for a repository, keeping only the newest
41
- cache for each cache-key prefix. Authenticates via ACCESS_TOKEN or GITHUB_TOKEN
42
- from your environment or .env file.
43
-
44
- Usage:
45
- clean-github-actions-caches [options]
46
-
47
- Options:
48
- -h, --help Show this help message
49
- -r, --repo <repo> GitHub repository (owner/repo). If omitted, the tool will
50
- attempt to infer the repository from the current working
51
- directory's git remotes.
52
- -p, --prefix-depth <n>
53
- Number of leading cache key segments to use as the
54
- grouping prefix when splitting on /[-_]/. Default: 3.
55
-
56
- Environment Variables:
57
- ACCESS_TOKEN GitHub access token (preferred)
58
- GITHUB_TOKEN GitHub access token (fallback)
59
-
60
- Behavior & Safety:
61
- - Groups caches by a derived prefix from the cache key and keeps the most
62
- recently created cache for each group.
63
- - Deletes only caches older than the latest per prefix to reduce risk of
64
- removing needed artifacts.
65
-
66
- Examples:
67
- # Run against a specific repo (owner/repo)
68
- clean-github-actions-caches --repo octocat/hello-world
69
-
70
- # Run via npx without installing
71
- 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
72
-
73
- # Run via yarn dlx
74
- yarn dlx binary-collections@https://raw.githubusercontent.com/dimaslanjaka/bin/master/releases/bin.tgz clean-github-actions-caches --prefix-depth 3
75
-
76
- Notes:
77
- - Ensure ACCESS_TOKEN or GITHUB_TOKEN is set and has permissions to manage Actions caches.
78
- - Intended for repository maintainers with appropriate permissions.
79
- `);
80
- }
81
- var argv = getArgs({
82
- alias: {
83
- h: "help",
84
- p: "prefix-depth",
85
- r: "repo"
86
- },
87
- string: ["prefix-depth", "repo"],
88
- boolean: ["help"]
89
- });
90
- if (argv.help) {
91
- printHelp();
92
- process.exit(0);
93
- }
94
- function deleteGitHubActionsCache(GH_REPO, cacheId) {
95
- return new Promise((resolve, reject) => {
96
- const url = `https://api.github.com/repos/${GH_REPO}/actions/caches/${cacheId}`;
97
- const token = ACCESS_TOKEN;
98
- if (!token) {
99
- return reject(new Error("Access token is not provided"));
100
- }
101
- axios.delete(url, {
102
- headers: {
103
- Authorization: `token ${token}`,
104
- Accept: "application/vnd.github.v3+json"
105
- }
106
- }).then((response) => {
107
- console.log(`Cache (${cacheId}) deleted successfully`, response.data);
108
- resolve(response.data);
109
- }).catch((error) => {
110
- var _a;
111
- console.error("Error deleting cache:", ((_a = error.response) == null ? void 0 : _a.data) || error.message || "Unknown error");
112
- reject(error);
113
- });
114
- });
115
- }
116
- function normalizePrefixDepth(prefixDepth) {
117
- const parsed = Number(prefixDepth);
118
- if (!Number.isFinite(parsed) || parsed < 1) {
119
- return 3;
120
- }
121
- return Math.floor(parsed);
122
- }
123
- function isChecksumSegment(segment) {
124
- return /^[a-f0-9]{32,}$/i.test(segment);
125
- }
126
- function getMeaningfulCacheKeyParts(key) {
127
- return String(key).split(/[-_]/).filter(Boolean).filter((segment) => !isChecksumSegment(segment));
128
- }
129
- function getCachePrefix(key, prefixDepth = 3) {
130
- const normalizedDepth = normalizePrefixDepth(prefixDepth);
131
- const parts = String(key).split(/[-_]/).filter(Boolean);
132
- const meaningfulParts = getMeaningfulCacheKeyParts(key);
133
- if (meaningfulParts.length !== parts.length) {
134
- if (meaningfulParts.length < normalizedDepth) {
135
- return `${meaningfulParts.join("-")}-`;
136
- }
137
- return meaningfulParts.join("-");
138
- }
139
- if (parts.length <= normalizedDepth) {
140
- return parts.join("-");
141
- }
142
- return parts.slice(0, normalizedDepth).join("-");
143
- }
144
- function groupCachesByPrefix(caches, prefixDepth = 3) {
145
- return caches.reduce(
146
- /**
147
- * @param {Record<string, Record<string, any>[]>} acc
148
- * @param {Record<string, any>} item
149
- * @returns {Record<string, Record<string, any>[]>}
150
- */
151
- (acc, item) => {
152
- const prefix = getCachePrefix(item.key, prefixDepth);
153
- if (!acc[prefix]) {
154
- acc[prefix] = [];
155
- }
156
- acc[prefix].push(item);
157
- return acc;
158
- },
159
- {}
160
- );
161
- }
162
- function get_caches(GH_REPO, prefixDepth = 3) {
163
- const url = `https://api.github.com/repos/${GH_REPO}/actions/caches`;
164
- return new Promise((resolve, reject) => {
165
- axios.get(url, {
166
- headers: {
167
- Accept: "application/vnd.github.v3+json",
168
- Authorization: `token ${ACCESS_TOKEN}`
169
- }
170
- }).then((response) => {
171
- const data = response.data.actions_caches;
172
- const grouped = groupCachesByPrefix(data, prefixDepth);
173
- resolve(grouped);
174
- }).catch((error) => {
175
- reject(error);
176
- });
177
- });
178
- }
179
- module.exports = {
180
- deleteGitHubActionsCache,
181
- getCachePrefix,
182
- getMeaningfulCacheKeyParts,
183
- get_caches,
184
- groupCachesByPrefix,
185
- isChecksumSegment,
186
- normalizePrefixDepth
187
- };
188
- }
189
- });
190
-
191
- export {
192
- require_clean_github_actions_caches
193
- };
@@ -1,86 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import {
3
- getCacheFile,
4
- loadCache,
5
- saveCache
6
- } from "./chunk-QD4T255Z.mjs";
7
- import {
8
- buildChecksum,
9
- getAllFiles
10
- } from "./chunk-WSHVPGNM.mjs";
11
- import {
12
- init_esm_shims
13
- } from "./chunk-QQ4A6DLD.mjs";
14
-
15
- // src/run-by-checksum/run.js
16
- init_esm_shims();
17
- import { spawn } from "child_process";
18
- async function runChecksum({
19
- patterns = [],
20
- ignore = [],
21
- exec,
22
- cwd = process.env.INIT_CWD || process.cwd(),
23
- dryRun = false
24
- }) {
25
- if (!patterns.length && !exec) {
26
- console.log("No patterns or command provided, skipping checksum runner.");
27
- process.exit(1);
28
- }
29
- if (!exec) {
30
- console.log("No command provided, skipping checksum runner.");
31
- process.exit(1);
32
- }
33
- if (!patterns.length) {
34
- console.log("No patterns provided, skipping checksum runner.");
35
- process.exit(1);
36
- }
37
- const files = getAllFiles({ patterns, ignore, cwd });
38
- const checksum = buildChecksum(files);
39
- const cacheFile = getCacheFile({ patterns, ignore, cwd });
40
- const cache = loadCache(cacheFile);
41
- if ((cache == null ? void 0 : cache.checksum) === checksum) {
42
- return {
43
- changed: false,
44
- cacheFile,
45
- files
46
- };
47
- }
48
- if (dryRun) {
49
- return {
50
- changed: true,
51
- cacheFile,
52
- files,
53
- skipped: true
54
- };
55
- }
56
- await runCommand(exec, cwd);
57
- saveCache(cacheFile, {
58
- checksum,
59
- files,
60
- patterns,
61
- ignore,
62
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
63
- });
64
- return {
65
- changed: true,
66
- cacheFile,
67
- files
68
- };
69
- }
70
- function runCommand(command, cwd) {
71
- return new Promise((resolve, reject) => {
72
- const child = spawn(command, {
73
- shell: true,
74
- stdio: "inherit",
75
- cwd
76
- });
77
- child.on("exit", (code) => {
78
- if (code === 0 || code === null) resolve();
79
- else reject(new Error(`Command failed: ${code}`));
80
- });
81
- });
82
- }
83
-
84
- export {
85
- runChecksum
86
- };
@@ -1,60 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import {
3
- init_esm_shims
4
- } from "./chunk-QQ4A6DLD.mjs";
5
-
6
- // src/run-by-checksum/hash.js
7
- init_esm_shims();
8
- import fs from "fs-extra";
9
- import * as glob from "glob";
10
- import upath from "upath";
11
- import path from "upath";
12
- import crypto from "crypto";
13
- function getAllFiles({ patterns, ignore, cwd }) {
14
- const files = /* @__PURE__ */ new Set();
15
- const root = cwd || process.cwd();
16
- for (const pattern of patterns) {
17
- const matched = glob.sync(pattern, {
18
- cwd: root,
19
- nodir: true,
20
- ignore
21
- });
22
- for (const f of matched) {
23
- files.add(upath.normalize(path.resolve(root, f)));
24
- }
25
- }
26
- return [...files].sort();
27
- }
28
- function isBinaryFile(filePath, bytesToCheck = 8e3) {
29
- const buffer = fs.readFileSync(filePath, { length: bytesToCheck });
30
- for (let i = 0; i < buffer.length; i++) {
31
- if (buffer[i] === 0) {
32
- return true;
33
- }
34
- }
35
- return false;
36
- }
37
- function hashFile(file) {
38
- const isBin = isBinaryFile(file);
39
- if (!isBin) {
40
- const content = fs.readFileSync(file, { encoding: "utf-8" });
41
- const normalized = content.toString().replace(/\s+/g, " ").trim();
42
- return crypto.createHash("sha256").update(normalized).digest("hex");
43
- } else {
44
- const stats = fs.statSync(file);
45
- return crypto.createHash("sha256").update(file).update(String(stats.size)).digest("hex");
46
- }
47
- }
48
- function buildChecksum(files) {
49
- const hash = crypto.createHash("sha256");
50
- for (const file of files) {
51
- hash.update(file);
52
- hash.update(hashFile(file));
53
- }
54
- return hash.digest("hex");
55
- }
56
-
57
- export {
58
- getAllFiles,
59
- buildChecksum
60
- };