mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-18 19:30:27 +08:00
- Add release read API to httpd as cargo feature enabled by default - Add Releases and Release views to the UI - Filter out redacted artifacts and mark delegate authors - Degrade releases UI gracefully with older radicle-httpd versions - Hide fully redacted releases - Skip releases in the list endpoint when every artifact was redacted by its author or a delegate, so no empty release entries are shown - Keep them reachable with showRedacted=true and by release id - Add e2e tests for the release routes Co-Authored-By: Rūdolfs Ošiņš <rudolfs@osins.org>
78 lines
2.3 KiB
TypeScript
78 lines
2.3 KiB
TypeScript
import type { Options } from "execa";
|
|
|
|
import { execa } from "execa";
|
|
import * as Crypto from "node:crypto";
|
|
import { fileURLToPath } from "node:url";
|
|
import * as Path from "node:path";
|
|
import * as Fs from "node:fs/promises";
|
|
|
|
// Generate string of 12 random characters with 8 bits of entropy.
|
|
export function randomTag(): string {
|
|
return Crypto.randomBytes(8).toString("hex");
|
|
}
|
|
|
|
export function createOptions(repoFolder: string, days: number): Options {
|
|
return {
|
|
cwd: repoFolder,
|
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
env: { RAD_LOCAL_TIME: (1671211684 + days * 86400).toString() },
|
|
};
|
|
}
|
|
|
|
const filename = fileURLToPath(import.meta.url);
|
|
export const supportDir = Path.dirname(filename);
|
|
export const tmpDir = Path.resolve(supportDir, "..", "./tmp");
|
|
export const fixturesDir = Path.resolve(supportDir, "..", "./fixtures");
|
|
const workspacePaths = [Path.join(tmpDir, "peers"), Path.join(tmpDir, "repos")];
|
|
|
|
export const heartwoodRelease = (
|
|
await Fs.readFile(`${supportDir}/heartwood-release`, "utf8")
|
|
).trim();
|
|
|
|
export const radicleHttpdRelease = (
|
|
await Fs.readFile(`${supportDir}/radicle-httpd-release`, "utf8")
|
|
).trim();
|
|
|
|
export const radicleArtifactRelease = (
|
|
await Fs.readFile(`${supportDir}/radicle-artifact-release`, "utf8")
|
|
).trim();
|
|
|
|
export const useLocalHttpd = process.env.USE_LOCAL_HTTPD === "true";
|
|
|
|
export const releaseApiOnlyLocal =
|
|
"the release read API only exists in the local httpd build";
|
|
|
|
// Assert that binaries are installed and are the correct version.
|
|
export async function assertBinariesInstalled(
|
|
binary: string,
|
|
expectedVersion: string,
|
|
expectedPath: string,
|
|
): Promise<void> {
|
|
let which: string;
|
|
try {
|
|
({ stdout: which } = await execa("which", [binary]));
|
|
} catch {
|
|
throw new Error(`${binary} is not installed`);
|
|
}
|
|
if (Path.dirname(which) !== expectedPath) {
|
|
throw new Error(
|
|
`${binary} path doesn't match used ${binary} binary: ${expectedPath} !== ${which}`,
|
|
);
|
|
}
|
|
const { stdout: version } = await execa(binary, ["--version"]);
|
|
if (!version.includes(expectedVersion)) {
|
|
throw new Error(
|
|
`${binary} version ${version} does not satisfy ${expectedVersion}`,
|
|
);
|
|
}
|
|
}
|
|
|
|
export async function removeWorkspace(): Promise<void> {
|
|
for (const path of workspacePaths) {
|
|
await Fs.rm(path, {
|
|
recursive: true,
|
|
force: true,
|
|
});
|
|
}
|
|
}
|