chore: remove legacy SSR checks and consolidate migration maintenance

This commit is contained in:
maoyingjie
2026-10-26 10:32:22 +08:00
parent 52a0bef851
commit 60af6ee40b
169 changed files with 958 additions and 8422 deletions
+128
View File
@@ -0,0 +1,128 @@
import fs from "node:fs";
import path from "node:path";
import os from "node:os";
import { spawnSync } from "node:child_process";
const root = path.resolve(import.meta.dirname, "..");
const fixtures = path.join(root, "tests/package");
const args = process.argv.slice(2);
const offline = args.includes("--offline");
const ids = args.filter((arg) => arg !== "--offline");
const specs = JSON.parse(
fs.readFileSync(path.join(fixtures, "client-checks.json"), "utf8"),
);
if (!ids.length || ids.some((id) => !Object.hasOwn(specs, id))) {
console.error(
`Usage: node scripts/check-package.mjs <${Object.keys(specs).join("|")}> [...] [--offline]`,
);
process.exit(1);
}
// Every run consumes final tarballs outside the workspace: no source paths/alias.
// Keep this directory for optional browser checks; never start a server here.
const consumer = fs.realpathSync(
fs.mkdtempSync(path.join(os.tmpdir(), "heroui-client-package-")),
);
console.log(`Independent consumer: ${consumer}`);
function run(bin, argv, cwd = root) {
const result = spawnSync(bin, argv, { cwd, stdio: "inherit", shell: false });
if (result.error) throw result.error;
if (result.status !== 0) throw new Error(`${bin} exited ${result.status}`);
}
run("pnpm", ["build"]);
const tarballs = {};
for (const pkg of ["styles", "vue"]) {
run(
"pnpm",
["pack", "--pack-destination", consumer],
path.join(root, "packages", pkg),
);
const manifest = JSON.parse(
fs.readFileSync(path.join(root, "packages", pkg, "package.json"), "utf8"),
);
tarballs[manifest.name] =
`file:./${manifest.name.replace(/^@/, "").replaceAll("/", "-")}-${manifest.version}.tgz`;
}
const installedVersion = (pkg) =>
JSON.parse(
fs.readFileSync(
path.join(root, "node_modules", pkg, "package.json"),
"utf8",
),
).version;
fs.writeFileSync(
path.join(consumer, "package.json"),
JSON.stringify(
{
name: "heroui-client-consumer",
private: true,
type: "module",
dependencies: {
...tarballs,
vue: installedVersion("vue"),
"@internationalized/date": installedVersion("@internationalized/date"),
},
devDependencies: { typescript: installedVersion("typescript") },
},
null,
2,
),
);
fs.writeFileSync(
path.join(consumer, "pnpm-workspace.yaml"),
`overrides:\n "@heroui-vue/styles": ${JSON.stringify(tarballs["@heroui-vue/styles"])}\n`,
);
for (const name of ["check-client.mjs", "client-checks.json"])
fs.copyFileSync(path.join(fixtures, name), path.join(consumer, name));
const contracts = ids
.map((id) => `${id}-contract.ts`)
.filter((file) => fs.existsSync(path.join(fixtures, file)));
for (const file of contracts)
fs.copyFileSync(path.join(fixtures, file), path.join(consumer, file));
run("pnpm", ["install", ...(offline ? ["--offline"] : [])], consumer);
run(process.execPath, ["check-client.mjs", ...ids], consumer);
if (contracts.length) {
const tsc = path.join(consumer, "node_modules/typescript/bin/tsc");
for (const [module, resolution] of [
["nodenext", "nodenext"],
["esnext", "bundler"],
])
run(
process.execPath,
[
tsc,
"--noEmit",
"--strict",
"--skipLibCheck",
"--target",
"es2022",
"--module",
module,
"--moduleResolution",
resolution,
...contracts,
],
consumer,
);
}
const browser = ids.includes("b02-pickers")
? "b02"
: ids.includes("b01-menu-dropdown")
? "b01"
: null;
if (browser) {
for (const file of ["index.html", "main.js", "style.css"])
fs.copyFileSync(
path.join(fixtures, `${browser}-consumer-app`, file),
path.join(consumer, file),
);
fs.copyFileSync(
path.join(fixtures, "b02-consumer-app", "vite.config.js"),
path.join(consumer, "vite.config.js"),
);
console.log(
`${browser.toUpperCase()} browser fixture prepared. Optional: cd ${consumer} && ${path.join(root, "node_modules/.bin/vite")} --host 127.0.0.1 --port <free-port> --strictPort`,
);
}
console.log(
`Package checks passed: ${ids.join(", ")}. No SSR/hydration checks or server started.`,
);