refactor: separate plugin repositories and release-based catalog

This commit is contained in:
2026-09-11 10:06:30 +08:00
parent 07174e35ab
commit 07cf38b1a4
148 changed files with 377 additions and 19048 deletions
+3 -10
View File
@@ -3,7 +3,7 @@ export function appendRelease(catalog, manifest, artifact, releasedAt) {
const next = structuredClone(catalog);
let curio = next.curios.find(item => item.id === manifest.id);
if (!curio) {
curio = { id: manifest.id, name: manifest.name, description: manifest.description ?? '', versions: [] };
curio = { id: manifest.id, name: manifest.name, description: manifest.description ?? '', ...(manifest.icon ? { icon: manifest.icon } : {}), versions: [] };
next.curios.push(curio);
}
let version = curio.versions.find(item => item.version === manifest.version);
@@ -22,16 +22,9 @@ export function appendRelease(catalog, manifest, artifact, releasedAt) {
curio.versions.unshift(version);
curio.name = manifest.name;
curio.description = manifest.description ?? '';
if (manifest.icon) curio.icon = manifest.icon;
}
version.artifacts.push(structuredClone(artifact));
next.generatedAt = releasedAt;
next.generatedAt = next.generatedAt > releasedAt ? next.generatedAt : releasedAt;
return next;
}
export function artifactPath(manifest, target) {
// Validate path components before they become a publication path.
if (!/^[a-z0-9][a-z0-9.-]*[a-z0-9]$/.test(manifest.id)) throw new Error('Invalid Curio ID');
if (!/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(manifest.version)) throw new Error('Invalid plugin version');
if (!['any', 'aarch64-apple-darwin', 'x86_64-apple-darwin'].includes(target)) throw new Error('Unsupported artifact target');
return `packages/${manifest.id}/${manifest.version}/${target}.curio`;
}