- test(e2e): add playwright harness and test stack - test(e2e): add core flow - fix(ui): preserve same-origin browser form submissions - fix(ui): offer reload inside stale edit dialogs - test(e2e): add persona session and accessibility suites - test(e2e): preserve per-run artifacts and clean pulled images - test(e2e): verify import and audit state across navigation - test(e2e): tighten verification helpers and persona checks - test(e2e): bound response body reads of the browser observer - test: recover review compatibility assertions - test: stabilize audit and user flow assertions
61 lines
2.4 KiB
TypeScript
61 lines
2.4 KiB
TypeScript
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
// Copyright (C) 2026 Bryan Joshua Pedini
|
|
|
|
import { COMPOSE_FILE, containerName, project, RESOURCE_PREFIX, RUN_LABEL } from './env';
|
|
import { run, runOk, type ProcOptions, type ProcResult } from './proc';
|
|
|
|
export function docker(args: readonly string[], opts: ProcOptions = {}): Promise<ProcResult> {
|
|
return run('docker', args, opts);
|
|
}
|
|
|
|
export function dockerOk(args: readonly string[], opts: ProcOptions = {}): Promise<ProcResult> {
|
|
return runOk('docker', args, opts);
|
|
}
|
|
|
|
export function compose(args: readonly string[], opts: ProcOptions = {}): Promise<ProcResult> {
|
|
return runOk('docker', ['compose', '--project-name', project(), '--file', COMPOSE_FILE, ...args], opts);
|
|
}
|
|
|
|
export function runnerContainer(): string {
|
|
return containerName('runner');
|
|
}
|
|
|
|
function lines(s: string): string[] {
|
|
return s
|
|
.split('\n')
|
|
.map((l) => l.trim())
|
|
.filter(Boolean);
|
|
}
|
|
|
|
export interface ProjectResources {
|
|
containers: string[];
|
|
volumes: string[];
|
|
networks: string[];
|
|
}
|
|
|
|
export async function projectResources(): Promise<ProjectResources> {
|
|
const p = project();
|
|
const byLabel = await dockerOk(['ps', '-a', '--filter', `label=${RUN_LABEL}=${p}`, '--format', '{{.Names}}']);
|
|
const byName = await dockerOk(['ps', '-a', '--filter', `name=^${p}`, '--format', '{{.Names}}']);
|
|
const byCompose = await dockerOk(['ps', '-a', '--filter', `label=com.docker.compose.project=${p}`, '--format', '{{.Names}}']);
|
|
const self = new Set([runnerContainer()]);
|
|
const containers = [...new Set([...lines(byLabel.stdout), ...lines(byName.stdout), ...lines(byCompose.stdout)])].filter(
|
|
(n) => !self.has(n) && !/^.+-runner-run-[0-9a-f]+$/.test(n),
|
|
);
|
|
const volumes = new Set<string>();
|
|
for (const filter of [`label=${RUN_LABEL}=${p}`, `label=com.docker.compose.project=${p}`, `name=${p}`]) {
|
|
const r = await dockerOk(['volume', 'ls', '-q', '--filter', filter]);
|
|
for (const v of lines(r.stdout)) volumes.add(v);
|
|
}
|
|
const networks = new Set<string>();
|
|
for (const filter of [`label=${RUN_LABEL}=${p}`, `name=${p}`]) {
|
|
const r = await dockerOk(['network', 'ls', '--format', '{{.Name}}', '--filter', filter]);
|
|
for (const n of lines(r.stdout)) networks.add(n);
|
|
}
|
|
return { containers, volumes: [...volumes], networks: [...networks] };
|
|
}
|
|
|
|
export function isOwnedName(name: string): boolean {
|
|
return name.startsWith(RESOURCE_PREFIX);
|
|
}
|