Files
nexu-io--open-design/tools/pack/tests/internal-packages-coverage.test.ts
wehub-resource-sync 070959e133
landing-page-staging / Deploy landing page to staging (push) Has been skipped
landing-page-ci / Validate landing page (push) Failing after 4s
visual-baseline / Capture visual baselines (push) Has been cancelled
bake-plugin-previews / Bake plugin previews (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:00:47 +08:00

52 lines
1.8 KiB
TypeScript

import { readFileSync } from "node:fs";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
const ROOT = join(fileURLToPath(import.meta.url), "..", "..", "..", "..");
type PackageJson = {
dependencies?: Record<string, string>;
};
function readPackageJson(relativePath: string): PackageJson {
return JSON.parse(readFileSync(join(ROOT, relativePath, "package.json"), "utf8")) as PackageJson;
}
function collectWorkspaceRuntimeDeps(relativePath: string): string[] {
const pkg = readPackageJson(relativePath);
if (pkg.dependencies == null) return [];
return Object.keys(pkg.dependencies).filter((name) => name.startsWith("@open-design/"));
}
function loadInternalPackageNames(modulePath: string): string[] {
const source = readFileSync(join(ROOT, modulePath), "utf8");
const matches = source.matchAll(/name:\s*"(@open-design\/[^"]+)"/g);
return [...matches].map((m) => m[1]!);
}
const PACKAGED_APPS = ["apps/desktop", "apps/web", "apps/packaged", "apps/daemon"];
const PACK_LANES = [
{ lane: "linux", file: "tools/pack/src/linux.ts" },
{ lane: "mac", file: "tools/pack/src/mac/constants.ts" },
{ lane: "win", file: "tools/pack/src/win/constants.ts" },
];
describe("INTERNAL_PACKAGES covers all workspace runtime deps", () => {
const requiredPackages = new Set<string>();
for (const app of PACKAGED_APPS) {
for (const dep of collectWorkspaceRuntimeDeps(app)) {
requiredPackages.add(dep);
}
}
for (const { lane, file } of PACK_LANES) {
it(`${lane} lane includes all required workspace packages`, () => {
const declared = new Set(loadInternalPackageNames(file));
const missing = [...requiredPackages].filter((pkg) => !declared.has(pkg));
expect(missing, `${lane} INTERNAL_PACKAGES is missing: ${missing.join(", ")}`).toEqual([]);
});
}
});