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.
- package/.opencode/plugins/opencode-request-logger/README.md +44 -0
- package/.venv/Lib/site-packages/pyarrow/tests/data/orc/README.md +22 -0
- package/docs-src/install-opencode-plugins.md +86 -0
- package/docs-src/opencode-cli.md +38 -10
- package/lib/binary-collections/config-types.cjs +17 -0
- package/lib/binary-collections/config-types.d.ts +12 -0
- package/lib/binary-collections/config-types.js +2 -0
- package/lib/binary-collections/config-types.mjs +7 -0
- package/lib/binary-collections/config.cjs +16 -8
- package/lib/binary-collections/config.d.cts +18 -10
- package/lib/binary-collections/config.mjs +1 -1
- package/lib/binary-collections/findScript.cjs +8 -6
- package/lib/binary-collections/findScript.mjs +2 -2
- package/lib/binary-collections/listScript.cjs +8 -6
- package/lib/binary-collections/listScript.mjs +2 -2
- package/lib/binary-collections.cjs +8 -6
- package/lib/binary-collections.mjs +3 -3
- package/lib/changelog.cjs +142 -4
- package/lib/changelog.mjs +9 -5
- package/lib/{chunk-SARIXFHP.mjs → chunk-3T6AMFI3.mjs} +16 -8
- package/lib/{chunk-3F6EIHYG.mjs → chunk-3ZF2QMDK.mjs} +3 -3
- package/lib/chunk-B77D3SR4.mjs +28 -0
- package/lib/chunk-BPED62FN.mjs +115 -0
- package/lib/{chunk-XI67TI46.mjs → chunk-DHFRWM2W.mjs} +1 -1
- package/lib/{chunk-2SJKVOTN.mjs → chunk-DPEE3FBB.mjs} +1 -1
- package/lib/{chunk-UYNBNLV5.mjs → chunk-H7AE4IO3.mjs} +1 -1
- package/lib/{chunk-YWSLMAQ7.mjs → chunk-KCJYREA2.mjs} +14 -12
- package/lib/{chunk-JK3MG2KF.mjs → chunk-NHD4HLSU.mjs} +1 -1
- package/lib/{chunk-I3O5ZRYU.mjs → chunk-OWNVMKAA.mjs} +1 -1
- package/lib/chunk-SKVF4TMD.mjs +59 -0
- package/lib/{chunk-SJYP66BO.mjs → chunk-TDUUOAQD.mjs} +1 -1
- package/lib/{chunk-D42YBRZW.mjs → chunk-UAEKSLAX.mjs} +1 -1
- package/lib/chunk-V6PTSDW5.mjs +82 -0
- package/lib/{chunk-AJ3OIYYP.mjs → chunk-WNUEY6VJ.mjs} +8 -6
- package/lib/{chunk-YLV4QATP.mjs → chunk-Z53IUBUN.mjs} +6 -5
- package/lib/{chunk-JMUFQSPE.mjs → chunk-Z7RM46Q4.mjs} +1 -1
- package/lib/cross-env/index.mjs +3 -3
- package/lib/git/git-diff-cli.cjs +16 -8
- package/lib/git/git-diff-cli.mjs +3 -3
- package/lib/git/git-diff.cjs +16 -8
- package/lib/git/git-diff.mjs +3 -3
- package/lib/git/git-fix.cjs +16 -8
- package/lib/git/git-fix.mjs +2 -2
- package/lib/git/user-config.cjs +16 -8
- package/lib/git/user-config.mjs +2 -2
- package/lib/github-workflows/clean-github-actions-caches-cli.cjs +16 -8
- package/lib/github-workflows/clean-github-actions-caches-cli.mjs +2 -2
- package/lib/github-workflows/clean-github-actions-caches.cjs +16 -8
- package/lib/github-workflows/clean-github-actions-caches.mjs +2 -2
- package/lib/github-workflows/get-latest-workflow-status-cli.cjs +16 -8
- package/lib/github-workflows/get-latest-workflow-status-cli.mjs +2 -2
- package/lib/github-workflows/utils.cjs +16 -8
- package/lib/github-workflows/utils.mjs +2 -2
- package/lib/github-workflows/workflow-badge-cli.cjs +16 -8
- package/lib/github-workflows/workflow-badge-cli.mjs +4 -4
- package/lib/node-cache-cleaner-cli.mjs +3 -3
- package/lib/opencode/cli/auth-rotate.cjs +343 -28
- package/lib/opencode/cli/auth-rotate.d.ts +3 -1
- package/lib/opencode/cli/auth-rotate.js +10 -15
- package/lib/opencode/cli/auth-rotate.mjs +6 -2
- package/lib/opencode/cli/auth-rotate.runner.cjs +454 -0
- package/lib/opencode/cli/auth-rotate.runner.d.ts +1 -0
- package/lib/opencode/cli/auth-rotate.runner.js +8 -0
- package/lib/opencode/cli/auth-rotate.runner.mjs +21 -0
- package/lib/opencode/install-opencode-plugins-cli.cjs +82 -0
- package/lib/opencode/install-opencode-plugins-cli.d.ts +1 -0
- package/lib/opencode/install-opencode-plugins-cli.js +78 -0
- package/lib/opencode/install-opencode-plugins-cli.mjs +65 -0
- package/lib/opencode/utils/check-api.cjs +332 -18
- package/lib/opencode/utils/check-api.d.ts +5 -1
- package/lib/opencode/utils/check-api.js +101 -15
- package/lib/opencode/utils/check-api.mjs +5 -1
- package/lib/opencode/utils/check-api.runner.cjs +0 -0
- package/lib/opencode/utils/check-api.runner.d.ts +0 -0
- package/lib/opencode/utils/check-api.runner.js +1 -0
- package/lib/opencode/utils/check-api.runner.mjs +7 -0
- package/lib/opencode-cli.cjs +352 -29
- package/lib/opencode-cli.js +3 -2
- package/lib/opencode-cli.mjs +11 -6
- package/lib/package-resolutions-updater-cli.cjs +16 -8
- package/lib/package-resolutions-updater-cli.mjs +2 -2
- package/lib/package-resolutions-updater.cjs +16 -8
- package/lib/package-resolutions-updater.mjs +2 -2
- package/lib/print-directory-tree.cjs +16 -8
- package/lib/print-directory-tree.mjs +1 -1
- package/lib/print-tarball-tree-cli.cjs +305 -0
- package/lib/print-tarball-tree-cli.d.mts +2 -0
- package/lib/print-tarball-tree-cli.mjs +54 -0
- package/lib/print-tarball-tree.cjs +43 -216
- package/lib/print-tarball-tree.d.mts +4 -1
- package/lib/print-tarball-tree.mjs +12 -66
- package/lib/rmpath-cli.cjs +16 -8
- package/lib/rmpath-cli.mjs +2 -2
- package/lib/rmpath.cjs +16 -8
- package/lib/rmpath.mjs +2 -2
- package/lib/run-by-checksum/hash.cjs +45 -67
- package/lib/run-by-checksum/{hash.d.ts → hash.d.cts} +9 -2
- package/lib/run-by-checksum/hash.mjs +3 -7
- package/lib/run-by-checksum/run.cjs +95 -58
- package/lib/run-by-checksum/run.js +3 -3
- package/lib/run-by-checksum/run.mjs +2 -2
- package/lib/run-by-checksum-cli.cjs +96 -74
- package/lib/run-by-checksum-cli.mjs +2 -2
- package/lib/submodule-install.cjs +16 -8
- package/lib/submodule-install.mjs +1 -1
- package/lib/submodule-remove-cli.cjs +16 -8
- package/lib/submodule-remove-cli.mjs +2 -2
- package/lib/submodule-remove.cjs +16 -8
- package/lib/submodule-remove.mjs +2 -2
- package/lib/utils/isDebug.cjs +13 -0
- package/lib/utils/isDebug.d.cts +9 -0
- package/lib/utils/isDebug.mjs +6 -0
- package/package.json +9 -7
- package/readme.md +63 -0
- package/releases/readme.md +1 -1
- package/lib/chunk-546KAIYT.mjs +0 -113
- package/lib/chunk-5WAOOOGZ.mjs +0 -77
- package/lib/chunk-72XTQ3CK.mjs +0 -45
- package/lib/chunk-7Q6YEUQF.mjs +0 -246
- package/lib/chunk-AQZ7LMFS.mjs +0 -100
- package/lib/chunk-BDCMTOZI.mjs +0 -246
- package/lib/chunk-BEUM4LH4.mjs +0 -184
- package/lib/chunk-BO4TZS4Q.mjs +0 -246
- package/lib/chunk-BZWVHODJ.mjs +0 -62
- package/lib/chunk-CM3IC5YC.mjs +0 -226
- package/lib/chunk-FR3DMHJC.mjs +0 -146
- package/lib/chunk-H44UWUFY.mjs +0 -105
- package/lib/chunk-JVMLKHD2.mjs +0 -62
- package/lib/chunk-KAT2JNLZ.mjs +0 -146
- package/lib/chunk-KRCPFWIF.mjs +0 -193
- package/lib/chunk-LVSPEFU2.mjs +0 -86
- package/lib/chunk-MCCMMZSM.mjs +0 -60
- package/lib/chunk-MGPYPKIE.mjs +0 -109
- package/lib/chunk-OA2RKEY3.mjs +0 -162
- package/lib/chunk-PAZH45HS.mjs +0 -41
- package/lib/chunk-QZMGBDSA.mjs +0 -32
- package/lib/chunk-RDGDLSPD.mjs +0 -76
- package/lib/chunk-RKPIBGKE.mjs +0 -61
- package/lib/chunk-SWUAEY4H.mjs +0 -44
- package/lib/chunk-UAIF5VIA.mjs +0 -89
- package/lib/chunk-UHPFLJXH.mjs +0 -227
- package/lib/chunk-WOC4FZ6F.mjs +0 -164
- package/lib/chunk-WSHVPGNM.mjs +0 -44
- package/lib/run-by-checksum/hash.js +0 -119
- package/readme.html +0 -784
package/lib/chunk-UHPFLJXH.mjs
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
require_fetchResponse
|
|
4
|
-
} from "./chunk-KLKAIFKI.mjs";
|
|
5
|
-
import {
|
|
6
|
-
require_config
|
|
7
|
-
} from "./chunk-SWUAEY4H.mjs";
|
|
8
|
-
import {
|
|
9
|
-
require_utils
|
|
10
|
-
} from "./chunk-6RK5UCTP.mjs";
|
|
11
|
-
import {
|
|
12
|
-
__toESM,
|
|
13
|
-
init_esm_shims
|
|
14
|
-
} from "./chunk-QQ4A6DLD.mjs";
|
|
15
|
-
|
|
16
|
-
// src/package-resolutions-updater.mjs
|
|
17
|
-
init_esm_shims();
|
|
18
|
-
var utils = __toESM(require_utils(), 1);
|
|
19
|
-
var import_config = __toESM(require_config(), 1);
|
|
20
|
-
var import_fetchResponse = __toESM(require_fetchResponse(), 1);
|
|
21
|
-
import fs from "fs";
|
|
22
|
-
import os from "os";
|
|
23
|
-
import path from "upath";
|
|
24
|
-
import { parseGitHubUrl } from "git-command-helper";
|
|
25
|
-
(0, import_config.loadDotenv)();
|
|
26
|
-
var args = utils.getArgs();
|
|
27
|
-
if (args.help || args.h) {
|
|
28
|
-
showHelp();
|
|
29
|
-
}
|
|
30
|
-
function showHelp() {
|
|
31
|
-
const helpText = `
|
|
32
|
-
GitHub Package Resolutions Updater
|
|
33
|
-
Usage:
|
|
34
|
-
node src/package-resolutions-updater.mjs [options]
|
|
35
|
-
Options:
|
|
36
|
-
--help, -h Show this help message
|
|
37
|
-
Description:
|
|
38
|
-
Updates the commit hashes in package.json's 'resolutions' field for GitHub tarball URLs to point to the latest commit SHA of the corresponding repository and branch.
|
|
39
|
-
Features:
|
|
40
|
-
- Parses GitHub URLs to extract repository owner, name, and branch.
|
|
41
|
-
- Fetches the latest commit SHA across all branches using GitHub's API.
|
|
42
|
-
- Replaces the old branch or commit in the URL with the latest SHA.
|
|
43
|
-
- Overwrites package.json with the updated URLs.
|
|
44
|
-
Requirements:
|
|
45
|
-
- GitHub Personal Access Token (GITHUB_TOKEN) via .env
|
|
46
|
-
- ESM support (type: "module" in package.json)
|
|
47
|
-
- Node.js v18+ recommended
|
|
48
|
-
Dependencies:
|
|
49
|
-
- ansi-colors \u2013 for styled terminal output
|
|
50
|
-
Examples:
|
|
51
|
-
node src/package-resolutions-updater.mjs
|
|
52
|
-
node src/package-resolutions-updater.mjs --help
|
|
53
|
-
|
|
54
|
-
`;
|
|
55
|
-
console.log(helpText);
|
|
56
|
-
process.exit(0);
|
|
57
|
-
}
|
|
58
|
-
var GITHUB_USER_AGENTS = [
|
|
59
|
-
"octokit-rest.js/19.0.7",
|
|
60
|
-
"GitHub CLI/2.40.0",
|
|
61
|
-
"Mozilla/5.0 (compatible; GitHubCopilot/1.0)",
|
|
62
|
-
"PostmanRuntime/7.32.3",
|
|
63
|
-
"binary-collections-resolver/1.0 (+https://github.com/dimaslanjaka/bin)"
|
|
64
|
-
];
|
|
65
|
-
var userAgentDir = path.join(os.tmpdir(), "nodejs");
|
|
66
|
-
var userAgentFile = path.join(userAgentDir, "useragent.txt");
|
|
67
|
-
var selectedUserAgent;
|
|
68
|
-
try {
|
|
69
|
-
if (!fs.existsSync(userAgentDir)) fs.mkdirSync(userAgentDir, { recursive: true });
|
|
70
|
-
if (fs.existsSync(userAgentFile)) {
|
|
71
|
-
const fileAgent = fs.readFileSync(userAgentFile, "utf-8").trim();
|
|
72
|
-
if (GITHUB_USER_AGENTS.includes(fileAgent)) {
|
|
73
|
-
selectedUserAgent = fileAgent;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (!selectedUserAgent) {
|
|
77
|
-
selectedUserAgent = GITHUB_USER_AGENTS[Math.floor(Math.random() * GITHUB_USER_AGENTS.length)];
|
|
78
|
-
fs.writeFileSync(userAgentFile, selectedUserAgent, "utf-8");
|
|
79
|
-
}
|
|
80
|
-
} catch (_e) {
|
|
81
|
-
selectedUserAgent = GITHUB_USER_AGENTS[Math.floor(Math.random() * GITHUB_USER_AGENTS.length)];
|
|
82
|
-
}
|
|
83
|
-
async function fetchJson(url) {
|
|
84
|
-
var _a;
|
|
85
|
-
const response = await (0, import_fetchResponse.default)(url, {
|
|
86
|
-
headers: {
|
|
87
|
-
"User-Agent": selectedUserAgent,
|
|
88
|
-
Accept: "application/vnd.github.v3+json",
|
|
89
|
-
"X-GitHub-Api-Version": "2022-11-28",
|
|
90
|
-
...import_config.GITHUB_ACCESS_TOKEN ? { Authorization: `token ${import_config.GITHUB_ACCESS_TOKEN}` } : {}
|
|
91
|
-
},
|
|
92
|
-
responseType: "json"
|
|
93
|
-
});
|
|
94
|
-
if (response.status < 200 || response.status >= 300) {
|
|
95
|
-
const message = ((_a = response.data) == null ? void 0 : _a.message) || "Unknown error";
|
|
96
|
-
throw new Error(`GitHub API Error ${response.status}: ${message}
|
|
97
|
-
URL: ${url}`);
|
|
98
|
-
}
|
|
99
|
-
return response.data;
|
|
100
|
-
}
|
|
101
|
-
async function getLatestCommit(owner, repo, branch = "main") {
|
|
102
|
-
var _a, _b, _c, _d;
|
|
103
|
-
const url = `https://api.github.com/repos/${owner}/${repo}/commits/${branch}`;
|
|
104
|
-
const json = await fetchJson(url);
|
|
105
|
-
const sha = json.sha;
|
|
106
|
-
const dateStr = ((_b = (_a = json.commit) == null ? void 0 : _a.committer) == null ? void 0 : _b.date) || ((_d = (_c = json.commit) == null ? void 0 : _c.author) == null ? void 0 : _d.date);
|
|
107
|
-
if (!sha || !dateStr) {
|
|
108
|
-
console.log(json);
|
|
109
|
-
throw new Error(`Missing SHA or date for ${owner}/${repo}@${branch}`);
|
|
110
|
-
}
|
|
111
|
-
return {
|
|
112
|
-
owner,
|
|
113
|
-
repo,
|
|
114
|
-
branch,
|
|
115
|
-
sha,
|
|
116
|
-
date: new Date(dateStr).toISOString()
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
async function getLatestCommitAcrossBranches(owner, repo) {
|
|
120
|
-
const branches = await fetchJson(`https://api.github.com/repos/${owner}/${repo}/branches`);
|
|
121
|
-
const commits = await Promise.all(
|
|
122
|
-
branches.map(async ({ name, commit }) => {
|
|
123
|
-
var _a, _b, _c, _d;
|
|
124
|
-
const commitSha = commit == null ? void 0 : commit.sha;
|
|
125
|
-
if (!commitSha) {
|
|
126
|
-
console.warn(`No commit SHA for '${owner}/${repo}' branch: ${name}`);
|
|
127
|
-
return { branch: name, sha: "", date: /* @__PURE__ */ new Date(0) };
|
|
128
|
-
}
|
|
129
|
-
try {
|
|
130
|
-
const commitData = await fetchJson(`https://api.github.com/repos/${owner}/${repo}/commits/${commitSha}`);
|
|
131
|
-
const dateStr = ((_b = (_a = commitData.commit) == null ? void 0 : _a.committer) == null ? void 0 : _b.date) || ((_d = (_c = commitData.commit) == null ? void 0 : _c.author) == null ? void 0 : _d.date);
|
|
132
|
-
const date = dateStr ? new Date(dateStr) : /* @__PURE__ */ new Date(0);
|
|
133
|
-
return { branch: name, sha: commitData.sha, date };
|
|
134
|
-
} catch (e) {
|
|
135
|
-
console.warn(`Failed to fetch commit for ${name}: ${e.message}`);
|
|
136
|
-
return { branch: name, sha: commitSha, date: /* @__PURE__ */ new Date(0) };
|
|
137
|
-
}
|
|
138
|
-
})
|
|
139
|
-
);
|
|
140
|
-
const latest = commits.reduce((a, b) => a.date > b.date ? a : b, { date: /* @__PURE__ */ new Date(0) });
|
|
141
|
-
return {
|
|
142
|
-
owner,
|
|
143
|
-
repo,
|
|
144
|
-
branch: latest.branch,
|
|
145
|
-
sha: latest.sha,
|
|
146
|
-
date: latest.date.toISOString()
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
function replaceRawWithLatestHash(url, latestHash) {
|
|
150
|
-
const parsed = parseGitHubUrl(url);
|
|
151
|
-
if (!parsed || !parsed.owner || !parsed.repo || !parsed.branch) {
|
|
152
|
-
throw new Error("Invalid GitHub raw URL");
|
|
153
|
-
}
|
|
154
|
-
const branchPrefix = `${parsed.branch}/`;
|
|
155
|
-
const rawPrefix = parsed.host === "github.com" ? `raw/${branchPrefix}` : branchPrefix;
|
|
156
|
-
const refsPrefix = `refs/heads/${branchPrefix}`;
|
|
157
|
-
const path2 = parsed.path.startsWith(rawPrefix) ? parsed.path.slice(rawPrefix.length) : parsed.path.startsWith(refsPrefix) ? parsed.path.slice(refsPrefix.length) : parsed.path.startsWith(branchPrefix) ? parsed.path.slice(branchPrefix.length) : parsed.path;
|
|
158
|
-
if (parsed.host === "github.com") {
|
|
159
|
-
return `https://github.com/${parsed.owner}/${parsed.repo}/raw/${latestHash}/${path2}`;
|
|
160
|
-
}
|
|
161
|
-
if (parsed.host === "raw.githubusercontent.com") {
|
|
162
|
-
return `https://raw.githubusercontent.com/${parsed.owner}/${parsed.repo}/${latestHash}/${path2}`;
|
|
163
|
-
}
|
|
164
|
-
throw new Error("Invalid GitHub raw URL");
|
|
165
|
-
}
|
|
166
|
-
async function resolvePackageResolutionUpdates(resolutions, specialPackageOverrides = []) {
|
|
167
|
-
const updates = [];
|
|
168
|
-
for (const [currentPkgName, url] of Object.entries(resolutions || {})) {
|
|
169
|
-
let repo;
|
|
170
|
-
try {
|
|
171
|
-
repo = parseGitHubUrl(url);
|
|
172
|
-
} catch (error) {
|
|
173
|
-
updates.push({
|
|
174
|
-
skipped: true,
|
|
175
|
-
currentPkgName,
|
|
176
|
-
url,
|
|
177
|
-
error
|
|
178
|
-
});
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
181
|
-
try {
|
|
182
|
-
const override = specialPackageOverrides.find((p) => p.pkg === currentPkgName);
|
|
183
|
-
const latest = override ? await getLatestCommit(override.owner, override.repo, override.branch) : await getLatestCommitAcrossBranches(repo.owner, repo.repo);
|
|
184
|
-
const new_url = replaceRawWithLatestHash(url, latest.sha);
|
|
185
|
-
const response = await (0, import_fetchResponse.default)(new_url);
|
|
186
|
-
if (response.status < 200 || response.status >= 300) {
|
|
187
|
-
updates.push({
|
|
188
|
-
failed: true,
|
|
189
|
-
currentPkgName,
|
|
190
|
-
url,
|
|
191
|
-
new_url,
|
|
192
|
-
repo,
|
|
193
|
-
latest,
|
|
194
|
-
error: new Error(`New URL not accessible (status ${response.status}).
|
|
195
|
-
original: ${url}
|
|
196
|
-
new: ${new_url}`)
|
|
197
|
-
});
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
updates.push({
|
|
201
|
-
currentPkgName,
|
|
202
|
-
url,
|
|
203
|
-
new_url,
|
|
204
|
-
repo,
|
|
205
|
-
latest
|
|
206
|
-
});
|
|
207
|
-
} catch (error) {
|
|
208
|
-
updates.push({
|
|
209
|
-
failed: true,
|
|
210
|
-
currentPkgName,
|
|
211
|
-
url,
|
|
212
|
-
repo,
|
|
213
|
-
error
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return updates;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export {
|
|
221
|
-
parseGitHubUrl,
|
|
222
|
-
fetchJson,
|
|
223
|
-
getLatestCommit,
|
|
224
|
-
getLatestCommitAcrossBranches,
|
|
225
|
-
replaceRawWithLatestHash,
|
|
226
|
-
resolvePackageResolutionUpdates
|
|
227
|
-
};
|
package/lib/chunk-WOC4FZ6F.mjs
DELETED
|
@@ -1,164 +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
|
-
__toESM,
|
|
7
|
-
init_esm_shims
|
|
8
|
-
} from "./chunk-QQ4A6DLD.mjs";
|
|
9
|
-
|
|
10
|
-
// src/github-workflows/get-latest-workflow-status.mjs
|
|
11
|
-
init_esm_shims();
|
|
12
|
-
var import_config = __toESM(require_config(), 1);
|
|
13
|
-
import axios from "axios";
|
|
14
|
-
import { spawn } from "cross-spawn";
|
|
15
|
-
if (!import_config.GITHUB_ACCESS_TOKEN) {
|
|
16
|
-
console.error("Missing env var: ACCESS_TOKEN or GITHUB_TOKEN");
|
|
17
|
-
process.exit(1);
|
|
18
|
-
}
|
|
19
|
-
var BASE = "https://api.github.com";
|
|
20
|
-
var headers = {
|
|
21
|
-
Authorization: `Bearer ${import_config.GITHUB_ACCESS_TOKEN}`,
|
|
22
|
-
Accept: "application/vnd.github+json",
|
|
23
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
24
|
-
};
|
|
25
|
-
async function request(url) {
|
|
26
|
-
try {
|
|
27
|
-
const res = await axios.get(url, { headers });
|
|
28
|
-
return res.data;
|
|
29
|
-
} catch (err) {
|
|
30
|
-
if (err == null ? void 0 : err.response) {
|
|
31
|
-
const statusText = err.response.statusText || "Request failed";
|
|
32
|
-
const responseText = typeof err.response.data === "string" ? err.response.data : JSON.stringify(err.response.data);
|
|
33
|
-
throw new Error(`${err.response.status} ${statusText}
|
|
34
|
-
${responseText}`);
|
|
35
|
-
}
|
|
36
|
-
throw err;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function runGit(args) {
|
|
40
|
-
return new Promise((resolve, reject) => {
|
|
41
|
-
var _a, _b;
|
|
42
|
-
const child = spawn("git", args, {
|
|
43
|
-
cwd: process.cwd(),
|
|
44
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
45
|
-
});
|
|
46
|
-
let stdout = "";
|
|
47
|
-
let stderr = "";
|
|
48
|
-
(_a = child.stdout) == null ? void 0 : _a.on("data", (chunk) => {
|
|
49
|
-
stdout += chunk.toString();
|
|
50
|
-
});
|
|
51
|
-
(_b = child.stderr) == null ? void 0 : _b.on("data", (chunk) => {
|
|
52
|
-
stderr += chunk.toString();
|
|
53
|
-
});
|
|
54
|
-
child.on("error", reject);
|
|
55
|
-
child.on("close", (code) => {
|
|
56
|
-
if (code === 0) {
|
|
57
|
-
resolve(stdout.trim());
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
reject(new Error(stderr.trim() || `git ${args.join(" ")} exited with code ${code}`));
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function getOwnerFromRemoteUrl(remoteUrl) {
|
|
65
|
-
var _a;
|
|
66
|
-
const normalized = remoteUrl.trim().replace(/\.git$/i, "");
|
|
67
|
-
const match = normalized.match(/github\.com[:/](?<owner>[^/]+)\/(?<repo>[^/]+)$/i);
|
|
68
|
-
return ((_a = match == null ? void 0 : match.groups) == null ? void 0 : _a.owner) || null;
|
|
69
|
-
}
|
|
70
|
-
function getRepoFromRemoteUrl(remoteUrl) {
|
|
71
|
-
var _a;
|
|
72
|
-
const normalized = remoteUrl.trim().replace(/\.git$/i, "");
|
|
73
|
-
const match = normalized.match(/github\.com[:/](?<owner>[^/]+)\/(?<repo>[^/]+)$/i);
|
|
74
|
-
return ((_a = match == null ? void 0 : match.groups) == null ? void 0 : _a.repo) || null;
|
|
75
|
-
}
|
|
76
|
-
async function getCurrentOwner() {
|
|
77
|
-
const commands = [
|
|
78
|
-
["config", "--local", "--get", "remote.origin.url"],
|
|
79
|
-
["remote", "get-url", "origin"]
|
|
80
|
-
];
|
|
81
|
-
for (const args of commands) {
|
|
82
|
-
try {
|
|
83
|
-
const remoteUrl = await runGit(args);
|
|
84
|
-
const owner = getOwnerFromRemoteUrl(remoteUrl);
|
|
85
|
-
if (owner) {
|
|
86
|
-
return owner;
|
|
87
|
-
}
|
|
88
|
-
} catch {
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
throw new Error("Unable to determine repository owner from git remote.origin.url");
|
|
92
|
-
}
|
|
93
|
-
async function getCurrentRepo() {
|
|
94
|
-
const commands = [
|
|
95
|
-
["config", "--local", "--get", "remote.origin.url"],
|
|
96
|
-
["remote", "get-url", "origin"]
|
|
97
|
-
];
|
|
98
|
-
for (const args of commands) {
|
|
99
|
-
try {
|
|
100
|
-
const remoteUrl = await runGit(args);
|
|
101
|
-
const repo = getRepoFromRemoteUrl(remoteUrl);
|
|
102
|
-
if (repo) {
|
|
103
|
-
return repo;
|
|
104
|
-
}
|
|
105
|
-
} catch {
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
throw new Error("Unable to determine repository name from git remote.origin.url");
|
|
109
|
-
}
|
|
110
|
-
async function getLatestRun(owner, repo, workflowId) {
|
|
111
|
-
var _a;
|
|
112
|
-
let url;
|
|
113
|
-
if (workflowId) {
|
|
114
|
-
url = `${BASE}/repos/${owner}/${repo}/actions/workflows/${encodeURIComponent(workflowId)}/runs?per_page=1`;
|
|
115
|
-
} else {
|
|
116
|
-
url = `${BASE}/repos/${owner}/${repo}/actions/runs?per_page=1`;
|
|
117
|
-
}
|
|
118
|
-
const data = await request(url);
|
|
119
|
-
return (_a = data.workflow_runs) == null ? void 0 : _a[0];
|
|
120
|
-
}
|
|
121
|
-
async function getJobs(owner, repo, runId) {
|
|
122
|
-
const url = `${BASE}/repos/${owner}/${repo}/actions/runs/${runId}/jobs`;
|
|
123
|
-
const data = await request(url);
|
|
124
|
-
return data.jobs || [];
|
|
125
|
-
}
|
|
126
|
-
function printReport(run, jobs) {
|
|
127
|
-
var _a;
|
|
128
|
-
console.log("\n==============================");
|
|
129
|
-
console.log("\u{1F680} Latest Workflow Run");
|
|
130
|
-
console.log("==============================");
|
|
131
|
-
console.log(`Name : ${run.name}`);
|
|
132
|
-
console.log(`Status : ${run.status}`);
|
|
133
|
-
console.log(`Conclusion: ${run.conclusion}`);
|
|
134
|
-
console.log(`Branch : ${run.head_branch}`);
|
|
135
|
-
console.log(`Run ID : ${run.id}`);
|
|
136
|
-
console.log(`URL : ${run.html_url}`);
|
|
137
|
-
console.log("\n==============================");
|
|
138
|
-
console.log("\u{1F9E9} Jobs & Steps");
|
|
139
|
-
console.log("==============================\n");
|
|
140
|
-
for (const job of jobs) {
|
|
141
|
-
console.log(`\u{1F9F1} Job: ${job.name}`);
|
|
142
|
-
console.log(` Status: ${job.status} | Conclusion: ${job.conclusion}`);
|
|
143
|
-
if (!((_a = job.steps) == null ? void 0 : _a.length)) {
|
|
144
|
-
console.log(" (no steps found)\n");
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
for (const step of job.steps) {
|
|
148
|
-
const icon = step.conclusion === "success" ? "\u2705" : step.conclusion === "failure" ? "\u274C" : step.conclusion === "skipped" ? "\u23ED\uFE0F" : "\u26AA";
|
|
149
|
-
console.log(` ${icon} ${step.name} -> ${step.conclusion} (${step.status})`);
|
|
150
|
-
}
|
|
151
|
-
console.log("");
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export {
|
|
156
|
-
request,
|
|
157
|
-
getOwnerFromRemoteUrl,
|
|
158
|
-
getRepoFromRemoteUrl,
|
|
159
|
-
getCurrentOwner,
|
|
160
|
-
getCurrentRepo,
|
|
161
|
-
getLatestRun,
|
|
162
|
-
getJobs,
|
|
163
|
-
printReport
|
|
164
|
-
};
|
package/lib/chunk-WSHVPGNM.mjs
DELETED
|
@@ -1,44 +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 hashFile(file) {
|
|
29
|
-
const content = fs.readFileSync(file);
|
|
30
|
-
return crypto.createHash("sha256").update(content).digest("hex");
|
|
31
|
-
}
|
|
32
|
-
function buildChecksum(files) {
|
|
33
|
-
const hash = crypto.createHash("sha256");
|
|
34
|
-
for (const file of files) {
|
|
35
|
-
hash.update(file);
|
|
36
|
-
hash.update(hashFile(file));
|
|
37
|
-
}
|
|
38
|
-
return hash.digest("hex");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export {
|
|
42
|
-
getAllFiles,
|
|
43
|
-
buildChecksum
|
|
44
|
-
};
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.getAllFiles = getAllFiles;
|
|
40
|
-
exports.buildChecksum = buildChecksum;
|
|
41
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
42
|
-
const glob = __importStar(require("glob"));
|
|
43
|
-
const upath_1 = __importDefault(require("upath"));
|
|
44
|
-
const upath_2 = __importDefault(require("upath"));
|
|
45
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
46
|
-
/**
|
|
47
|
-
* Get all files matching the given glob patterns, ignoring specified paths.
|
|
48
|
-
* @param {{ patterns: string[], ignore: string[], cwd?: string }} options
|
|
49
|
-
* @returns {string[]}
|
|
50
|
-
*/
|
|
51
|
-
function getAllFiles({ patterns, ignore, cwd }) {
|
|
52
|
-
const files = new Set();
|
|
53
|
-
const root = cwd || process.cwd();
|
|
54
|
-
for (const pattern of patterns) {
|
|
55
|
-
const matched = glob.sync(pattern, {
|
|
56
|
-
cwd: root,
|
|
57
|
-
nodir: true,
|
|
58
|
-
ignore
|
|
59
|
-
});
|
|
60
|
-
for (const f of matched) {
|
|
61
|
-
// Resolve to absolute path for consistent hashing
|
|
62
|
-
files.add(upath_1.default.normalize(upath_2.default.resolve(root, f)));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return [...files].sort();
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Check if a file is binary by scanning for null bytes in the first N bytes.
|
|
69
|
-
* @param {string} filePath - Absolute path to the file
|
|
70
|
-
* @param {number} [bytesToCheck=8000] - Number of bytes to scan from the start
|
|
71
|
-
* @returns {boolean}
|
|
72
|
-
*/
|
|
73
|
-
function isBinaryFile(filePath, bytesToCheck = 8000) {
|
|
74
|
-
const buffer = fs_extra_1.default.readFileSync(filePath, { length: bytesToCheck });
|
|
75
|
-
for (let i = 0; i < buffer.length; i++) {
|
|
76
|
-
if (buffer[i] === 0) {
|
|
77
|
-
// Null byte is a strong indicator of binary
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
// Optionally, check if it decodes as UTF-8
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Compute a SHA-256 hex digest for a file. For text files, the content is
|
|
86
|
-
* normalized (whitespace collapsed) before hashing. For binary files, the path
|
|
87
|
-
* and size are hashed instead of content.
|
|
88
|
-
* @private
|
|
89
|
-
* @param {string} file - Absolute path to the file
|
|
90
|
-
* @returns {string}
|
|
91
|
-
*/
|
|
92
|
-
function hashFile(file) {
|
|
93
|
-
const isBin = isBinaryFile(file);
|
|
94
|
-
if (!isBin) {
|
|
95
|
-
const content = fs_extra_1.default.readFileSync(file, { encoding: 'utf-8' });
|
|
96
|
-
// remove whitespaces and newlines for text files to avoid irrelevant changes affecting the checksum
|
|
97
|
-
const normalized = content.toString().replace(/\s+/g, ' ').trim();
|
|
98
|
-
return crypto_1.default.createHash('sha256').update(normalized).digest('hex');
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
// For binary files, hash the file path and size instead of content
|
|
102
|
-
const stats = fs_extra_1.default.statSync(file);
|
|
103
|
-
return crypto_1.default.createHash('sha256').update(file).update(String(stats.size)).digest('hex');
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Build a combined SHA-256 checksum from an ordered list of files.
|
|
108
|
-
* For each file, both its path and content hash are fed into the digest.
|
|
109
|
-
* @param {string[]} files - Ordered list of absolute file paths
|
|
110
|
-
* @returns {string}
|
|
111
|
-
*/
|
|
112
|
-
function buildChecksum(files) {
|
|
113
|
-
const hash = crypto_1.default.createHash('sha256');
|
|
114
|
-
for (const file of files) {
|
|
115
|
-
hash.update(file);
|
|
116
|
-
hash.update(hashFile(file));
|
|
117
|
-
}
|
|
118
|
-
return hash.digest('hex');
|
|
119
|
-
}
|