Add runner ci (test)

This commit is contained in:
2026-03-10 23:56:53 +01:00
parent c3fbd7d4fe
commit f5bf18b739
21 changed files with 1372 additions and 39 deletions

View File

@@ -0,0 +1,58 @@
import fs from 'fs';
import path from 'path';
type PackagedProcess = NodeJS.Process & { pkg?: unknown };
function uniquePaths(paths: string[]): string[] {
return [...new Set(paths.map((candidate) => path.resolve(candidate)))];
}
export function isPackagedRuntime(): boolean {
return Boolean((process as PackagedProcess).pkg);
}
export function getRuntimeBaseDir(): string {
return isPackagedRuntime()
? path.dirname(process.execPath)
: process.cwd();
}
export function resolveRuntimePath(...segments: string[]): string {
return path.join(getRuntimeBaseDir(), ...segments);
}
export function resolveProjectRootPath(...segments: string[]): string {
return path.resolve(__dirname, '..', '..', ...segments);
}
export function findExistingPath(...candidates: string[]): string | null {
for (const candidate of uniquePaths(candidates)) {
if (fs.existsSync(candidate)) {
return candidate;
}
}
return null;
}
export function resolveEnvFilePath(): string {
if (isPackagedRuntime()) {
return resolveRuntimePath('.env');
}
return findExistingPath(
resolveRuntimePath('.env'),
resolveProjectRootPath('.env')
) ?? resolveProjectRootPath('.env');
}
export function resolveCertificateDirectory(): string {
if (isPackagedRuntime()) {
return resolveRuntimePath('.certs');
}
return findExistingPath(
resolveRuntimePath('.certs'),
resolveProjectRootPath('.certs')
) ?? resolveRuntimePath('.certs');
}