Files
next-ai-draw-io/packages/mcp-server/scripts/check-package.mjs
T
Dayuan Jiang 7fccf68edf fix(mcp-server): read npm 12's pack output in the package check (#952)
The publish workflow installs the latest npm, and npm 12 prints
`npm pack --json` as an object keyed by package name instead of a list,
so check-package failed and 0.3.0 was not published. Accept both.
2026-10-05 22:58:56 +09:00

26 lines
902 B
JavaScript

// Fail if the npm package would miss files the server reads at runtime.
// Tests run from src/ (tsx) and cannot notice a broken dist/ copy step.
// Run after `npm run build`.
import { execSync } from "node:child_process"
const REQUIRED = [
"dist/index.js",
"dist/shape-libraries/aws4.md",
"dist/preview/index.html",
"dist/preview/preview.css",
"dist/preview/preview.js",
]
const output = JSON.parse(
execSync("npm pack --dry-run --json", { encoding: "utf8" }),
)
// npm 11 prints a list, npm 12 an object keyed by package name
const pack = Array.isArray(output) ? output[0] : Object.values(output)[0]
const files = new Set(pack.files.map((f) => f.path))
const missing = REQUIRED.filter((f) => !files.has(f))
if (missing.length > 0) {
console.error(`npm package is missing: ${missing.join(", ")}`)
process.exit(1)
}
console.log(`npm package OK (${files.size} files)`)