chore: import upstream snapshot with attribution
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Waiting to run
Test and Publish Multi-arch Docker Image / test (push) Waiting to run
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Blocked by required conditions
Validate Renovate Config / Validate Renovate Configuration (push) Waiting to run
CI / Shell Format Check (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / CI Config (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:24:08 +08:00
commit 0d3cb498a3
5438 changed files with 1316560 additions and 0 deletions
+111
View File
@@ -0,0 +1,111 @@
import { execFileSync } from 'node:child_process';
import path from 'node:path';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import ts from 'typescript';
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
const repoRoot = path.resolve(scriptDir, '..');
const rootOwnedPrefixes = ['src/', 'test/', 'scripts/'];
const externalProjectPrefixes = ['src/app/', 'test/code-scan-action/'];
function normalizePath(filePath: string): string {
return filePath.split(path.sep).join('/');
}
function isTypeScriptFile(filePath: string): boolean {
return (
filePath.endsWith('.ts') ||
filePath.endsWith('.tsx') ||
filePath.endsWith('.mts') ||
filePath.endsWith('.cts')
);
}
function hasPrefix(filePath: string, prefixes: string[]): boolean {
return prefixes.some((prefix) => filePath.startsWith(prefix));
}
function isRootOwnedTypeScriptFile(filePath: string): boolean {
return !filePath.includes('/') || hasPrefix(filePath, rootOwnedPrefixes);
}
export function getTrackedTypeScriptFiles(): string[] {
return execFileSync('git', ['ls-files'], {
cwd: repoRoot,
encoding: 'utf8',
})
.split('\n')
.map((filePath) => filePath.trim())
.filter(Boolean)
.map(normalizePath)
.filter(
(filePath) =>
isTypeScriptFile(filePath) &&
isRootOwnedTypeScriptFile(filePath) &&
!hasPrefix(filePath, externalProjectPrefixes),
)
.sort();
}
export function getRootProjectFiles(): Set<string> {
const configPath = ts.findConfigFile(repoRoot, ts.sys.fileExists, 'tsconfig.json');
if (!configPath) {
throw new Error('Could not find root tsconfig.json');
}
const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
if (configFile.error) {
throw new Error(ts.flattenDiagnosticMessageText(configFile.error.messageText, '\n'));
}
const parsedConfig = ts.parseJsonConfigFileContent(
configFile.config,
ts.sys,
path.dirname(configPath),
);
if (parsedConfig.errors.length > 0) {
const message = parsedConfig.errors
.map((error) => ts.flattenDiagnosticMessageText(error.messageText, '\n'))
.join('\n');
throw new Error(message);
}
return new Set(
parsedConfig.fileNames.map((filePath) => normalizePath(path.relative(repoRoot, filePath))),
);
}
export function findMissingRootTypeScriptFiles(): string[] {
const projectFiles = getRootProjectFiles();
return getTrackedTypeScriptFiles().filter((filePath) => !projectFiles.has(filePath));
}
export function runTypeScriptCoverageCheck(): number {
const missingFiles = findMissingRootTypeScriptFiles();
if (missingFiles.length === 0) {
return 0;
}
console.error('Root tsconfig.json is not type-checking these tracked TypeScript files:');
for (const filePath of missingFiles) {
console.error(`- ${filePath}`);
}
console.error(
'Add them to the root project, or add the owning subtree to externalProjectPrefixes with a separate typecheck.',
);
return 1;
}
if (process.argv[1] === fileURLToPath(import.meta.url)) {
try {
process.exitCode = runTypeScriptCoverageCheck();
} catch (error) {
console.error(
`Failed to verify root TypeScript coverage: ${error instanceof Error ? error.message : String(error)}`,
);
process.exitCode = 1;
}
}