tsc
All checks were successful
Distribution check / Generated files check (push) Successful in -2m2s
NPM Audit Check / Check NPM audit (push) Successful in -2m10s
Unit tests / Unit tests (latest) (push) Successful in -2m1s
Unit tests / Unit tests (lts/*) (push) Successful in -2m1s
Unit tests / Unit tests (lts/hydrogen) (push) Successful in -2m0s

This commit is contained in:
2025-11-06 00:36:58 -05:00
parent b0bb95a5e9
commit e2e5a99d85
4 changed files with 56 additions and 6 deletions

View File

@@ -6,7 +6,7 @@ async function parse(previous, current) {
const actions = curr?.actions; const actions = curr?.actions;
const result = { const result = {
build: false, build: false,
move: false, move: [],
delete: [], delete: [],
actions, actions,
}; };
@@ -14,10 +14,9 @@ async function parse(previous, current) {
const repo = prev.repos[actions.removeRepo]; const repo = prev.repos[actions.removeRepo];
result.delete.push(...parseRepoContents(repo, actions.removeRepo)); result.delete.push(...parseRepoContents(repo, actions.removeRepo));
} }
else if (prev && (result.move = isMove(actions))) { else if (prev && isMove(actions)) {
const moving = parseRepoContents(curr.repos[actions.addRepo], actions.removeRepo); const moving = result.move = parseRepoContents(curr.repos[actions.addRepo], actions.removeRepo);
result.delete.push(...getDropped(parseRepoContents(prev.repos[actions.addRepo], actions.addRepo), moving)); result.delete.push(...getDropped(parseRepoContents(prev.repos[actions.addRepo], actions.addRepo), moving));
result.delete.push(...moving);
} }
else if ((result.build = isAdd(actions)) && prev) { else if ((result.build = isAdd(actions)) && prev) {
result.delete.push(...getDropped(parseRepoContents(prev.repos[actions.addRepo], actions.addRepo), parseRepoContents(curr.repos[actions.addRepo], actions.addRepo))); result.delete.push(...getDropped(parseRepoContents(prev.repos[actions.addRepo], actions.addRepo), parseRepoContents(curr.repos[actions.addRepo], actions.addRepo)));
@@ -55,5 +54,5 @@ async function tryRead(file) {
return null; return null;
} }
} }
export { parse }; export { parse, tryRead };
//# sourceMappingURL=pkgbase.js.map //# sourceMappingURL=pkgbase.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,50 @@
import * as core from '@actions/core';
import { context } from '@actions/github';
import ky from 'ky';
import { parse } from './pkgbase.js';
;
async function main() {
const mode = core.getInput('mode', { required: true }).toLocaleLowerCase();
if (mode === 'parse') {
await doParse();
return;
}
const parsedData = JSON.parse(core.getInput('parsed-data', { required: true }));
const username = core.getInput('username', { required: true });
const token = core.getInput('token', { required: true });
const headers = {
Authorization: `Basic ${btoa(`${username}:${token}`)}`
};
if (mode === 'move') {
for (const pkg of parsedData.move) {
const filename = getFilename(pkg);
const files = await ky.get(`${context.serverUrl}/api/v1/packages/${context.repo.owner}/arch/${pkg.package}/${pkg.version}/files`).json();
const match = files.filter(f => f.name === filename);
if (match.length !== 1) {
throw new Error(`Expected one matching package, found ${match.length}`);
}
const packageUrl = `${context.serverUrl}/${context.repo.owner}/-/packages/arch/${pkg.package}/${pkg.version}/files/${match[0].id}`;
// const req = (await ky.get(packageUrl)).body.pipeThrough;
}
parsedData.delete.push(...parsedData.move);
}
for (const pkg of parsedData.delete) {
await ky.delete(`${context.serverUrl}/api/packages/${context.repo.owner}/arch/${pkg.repository}/${pkg.package}/${pkg.version}/${pkg.architecture}`, {
headers
});
}
}
function getFilename(pkg) {
return `${pkg.package}-${pkg.version}-${pkg.architecture}.pkg.tar.zst`;
}
function getCurrent() {
return core.getInput('current', { required: true });
}
async function doParse() {
const previous = core.getInput('previous', { required: true });
const current = getCurrent();
const diff = await parse(previous, current);
core.setOutput('parsed-data', JSON.stringify(diff));
}
export { main };
//# sourceMappingURL=router.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,KAAK,EAAiC,MAAM,cAAc,CAAC;AAYnE,CAAC;AAEF,KAAK,UAAU,IAAI;IACf,MAAM,IAAI,GAAG,IAAI,CAA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,IAAI,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,OAAO,EAAE,IAAI,EAAE,CAAC","sourcesContent":["import * as core from '@actions/core'\nimport { context } from '@actions/github'\nimport ky from 'ky';\nimport { parse, type Result, type PackageInfo } from './pkgbase.js';\n\ntype Mode = 'parse' | 'move' | 'delete';\n\ninterface PackageFile {\n id: number,\n size: number,\n name: string,\n md5: string,\n sha1: string,\n sha256: string,\n sha512: string\n};\n\nasync function main() {\n const mode = core.getInput('mode', { required: true }).toLocaleLowerCase() as Mode;\n\n if (mode === 'parse') {\n await doParse();\n return;\n }\n const parsedData: Result = JSON.parse(core.getInput('parsed-data', { required: true }));\n const username = core.getInput('username', { required: true });\n const token = core.getInput('token', { required: true });\n const headers = {\n Authorization: `Basic ${btoa(`${username}:${token}`)}`\n }\n if (mode === 'move') {\n for (const pkg of parsedData.move) {\n const filename = getFilename(pkg);\n const files = await ky.get(`${context.serverUrl}/api/v1/packages/${context.repo.owner}/arch/${pkg.package}/${pkg.version}/files`).json<PackageFile[]>();\n const match = files.filter(f => f.name === filename);\n if (match.length !== 1) {\n throw new Error(`Expected one matching package, found ${match.length}`);\n }\n const packageUrl = `${context.serverUrl}/${context.repo.owner}/-/packages/arch/${pkg.package}/${pkg.version}/files/${match[0].id}`;\n // const req = (await ky.get(packageUrl)).body.pipeThrough;\n }\n parsedData.delete.push(...parsedData.move);\n }\n\n for (const pkg of parsedData.delete) {\n await ky.delete(`${context.serverUrl}/api/packages/${context.repo.owner}/arch/${pkg.repository}/${pkg.package}/${pkg.version}/${pkg.architecture}`, {\n headers\n });\n }\n}\n\nfunction getFilename(pkg: PackageInfo) {\n return `${pkg.package}-${pkg.version}-${pkg.architecture}.pkg.tar.zst`;\n}\n\nfunction getCurrent(): string {\n return core.getInput('current', { required: true });\n}\n\nasync function doParse() {\n const previous = core.getInput('previous', { required: true });\n const current = getCurrent();\n const diff = await parse(previous, current);\n core.setOutput('parsed-data', JSON.stringify(diff));\n}\n\nexport { main };\n"]}