import { existsSync, readFileSync } from"node:fs";import { join, resolve } from"node:path";import { globSync } from"tinyglobby";import { parse } from"yaml";import { expect, it } from"vitest";const ROOT = resolve(__dirname, "../..");// Until step 5i the Rust workspace was a pnpm package (`packages/rust-core`)// and this guard held its `rust:verify` to the root script, so there was one// entry point. The flip moved the workspace to the root's `crates/`, OUTSIDE// pnpm's workspace, and its scripts became the root's. The guard keeps the// same property from the other side: no pnpm package carries a Cargo.toml,// and the one `rust:verify` is the root's.it("no pnpm workspace package carries a Cargo.toml — the Rust workspace is the root's crates/, and rust:verify is the root's script", () => {const workspace = parse(readFileSync(join(ROOT, "pnpm-workspace.yaml"), "utf8")) as { packages: string[]; };const packages = globSync(workspace.packages, { cwd: ROOT, onlyDirectories: true, expandDirectories: false, ignore: ["**/node_modules/**", "**/target/**"], }).map((pkg) => pkg.replace(/\/$/, "")); expect(packages.length, "workspace discovery found no packages").toBeGreaterThan(0);const rustPackages = packages.filter((pkg) => globSync("**/Cargo.toml", { cwd: join(ROOT, pkg), ignore: ["**/node_modules/**", "**/target/**"], }).length > 0); expect( rustPackages,"a pnpm package grew a Cargo.toml — the Rust workspace is crates/ at the root (step 5i), " +"and a package-level cargo script is a second entry point beside scripts/rust-verify.sh", ).toEqual([]); expect(existsSync(join(ROOT, "crates/Cargo.toml")), "crates/Cargo.toml is the Rust workspace's manifest").toBe(true);const root = JSON.parse(readFileSync(join(ROOT, "package.json"), "utf8")) as { scripts?: Record<string, string>; }; expect(root.scripts?.["rust:verify"], "the root's rust:verify runs the one script").toBe("bash scripts/rust-verify.sh");});