build(plugin-sdk): enforce export sync in check
This commit is contained in:
parent
39aba198f1
commit
2b57d3bb34
@ -226,7 +226,7 @@
|
|||||||
"build:plugin-sdk:dts": "tsc -p tsconfig.plugin-sdk.dts.json || true",
|
"build:plugin-sdk:dts": "tsc -p tsconfig.plugin-sdk.dts.json || true",
|
||||||
"build:strict-smoke": "pnpm canvas:a2ui:bundle && node scripts/tsdown-build.mjs && node scripts/runtime-postbuild.mjs && pnpm build:plugin-sdk:dts",
|
"build:strict-smoke": "pnpm canvas:a2ui:bundle && node scripts/tsdown-build.mjs && node scripts/runtime-postbuild.mjs && pnpm build:plugin-sdk:dts",
|
||||||
"canvas:a2ui:bundle": "bash scripts/bundle-a2ui.sh",
|
"canvas:a2ui:bundle": "bash scripts/bundle-a2ui.sh",
|
||||||
"check": "pnpm check:host-env-policy:swift && pnpm format:check && pnpm tsgo && pnpm lint && pnpm lint:tmp:no-random-messaging && pnpm lint:tmp:channel-agnostic-boundaries && pnpm lint:tmp:no-raw-channel-fetch && pnpm lint:agent:ingress-owner && pnpm lint:plugins:no-register-http-handler && pnpm lint:plugins:no-monolithic-plugin-sdk-entry-imports && pnpm lint:webhook:no-low-level-body-read && pnpm lint:auth:no-pairing-store-group && pnpm lint:auth:pairing-account-scope",
|
"check": "pnpm check:host-env-policy:swift && pnpm format:check && pnpm tsgo && pnpm plugin-sdk:check-exports && pnpm lint && pnpm lint:tmp:no-random-messaging && pnpm lint:tmp:channel-agnostic-boundaries && pnpm lint:tmp:no-raw-channel-fetch && pnpm lint:agent:ingress-owner && pnpm lint:plugins:no-register-http-handler && pnpm lint:plugins:no-monolithic-plugin-sdk-entry-imports && pnpm lint:webhook:no-low-level-body-read && pnpm lint:auth:no-pairing-store-group && pnpm lint:auth:pairing-account-scope",
|
||||||
"check:docs": "pnpm format:docs:check && pnpm lint:docs && pnpm docs:check-i18n-glossary && pnpm docs:check-links",
|
"check:docs": "pnpm format:docs:check && pnpm lint:docs && pnpm docs:check-i18n-glossary && pnpm docs:check-links",
|
||||||
"check:host-env-policy:swift": "node scripts/generate-host-env-security-policy-swift.mjs --check",
|
"check:host-env-policy:swift": "node scripts/generate-host-env-security-policy-swift.mjs --check",
|
||||||
"check:loc": "node --import tsx scripts/check-ts-max-loc.ts --max 500",
|
"check:loc": "node --import tsx scripts/check-ts-max-loc.ts --max 500",
|
||||||
@ -292,6 +292,7 @@
|
|||||||
"moltbot:rpc": "node scripts/run-node.mjs agent --mode rpc --json",
|
"moltbot:rpc": "node scripts/run-node.mjs agent --mode rpc --json",
|
||||||
"openclaw": "node scripts/run-node.mjs",
|
"openclaw": "node scripts/run-node.mjs",
|
||||||
"openclaw:rpc": "node scripts/run-node.mjs agent --mode rpc --json",
|
"openclaw:rpc": "node scripts/run-node.mjs agent --mode rpc --json",
|
||||||
|
"plugin-sdk:check-exports": "node scripts/sync-plugin-sdk-exports.mjs --check",
|
||||||
"plugin-sdk:sync-exports": "node scripts/sync-plugin-sdk-exports.mjs",
|
"plugin-sdk:sync-exports": "node scripts/sync-plugin-sdk-exports.mjs",
|
||||||
"plugins:sync": "node --import tsx scripts/sync-plugin-versions.ts",
|
"plugins:sync": "node --import tsx scripts/sync-plugin-versions.ts",
|
||||||
"prepack": "pnpm build && pnpm ui:build",
|
"prepack": "pnpm build && pnpm ui:build",
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import fs from "node:fs";
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { buildPluginSdkPackageExports } from "./lib/plugin-sdk-entries.mjs";
|
import { buildPluginSdkPackageExports } from "./lib/plugin-sdk-entries.mjs";
|
||||||
|
|
||||||
|
const checkOnly = process.argv.includes("--check");
|
||||||
const packageJsonPath = path.join(process.cwd(), "package.json");
|
const packageJsonPath = path.join(process.cwd(), "package.json");
|
||||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
||||||
const currentExports = packageJson.exports ?? {};
|
const currentExports = packageJson.exports ?? {};
|
||||||
@ -30,5 +31,16 @@ if (!insertedPluginSdkExports) {
|
|||||||
Object.assign(nextExports, syncedPluginSdkExports);
|
Object.assign(nextExports, syncedPluginSdkExports);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const nextExportsJson = JSON.stringify(nextExports);
|
||||||
|
const currentExportsJson = JSON.stringify(currentExports);
|
||||||
|
if (checkOnly) {
|
||||||
|
if (currentExportsJson !== nextExportsJson) {
|
||||||
|
console.error("plugin-sdk exports out of sync. Run `pnpm plugin-sdk:sync-exports`.");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
console.log("plugin-sdk exports synced.");
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
packageJson.exports = nextExports;
|
packageJson.exports = nextExports;
|
||||||
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, "utf8");
|
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, "utf8");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user