Implement RPC contract validation baseline
This commit is contained in:
38
scripts/copy-packages.mjs
Executable file
38
scripts/copy-packages.mjs
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const rootDir = join(__dirname, "..");
|
||||
|
||||
// Package configs to copy and transform
|
||||
const packages = [
|
||||
{ name: "contracts", src: "packages/contracts/package.json" },
|
||||
{ name: "shared", src: "packages/shared/package.json" },
|
||||
];
|
||||
|
||||
for (const pkg of packages) {
|
||||
const srcPath = join(rootDir, pkg.src);
|
||||
const destDir = join(rootDir, "dist-electron", "packages", pkg.name);
|
||||
const destPath = join(destDir, "package.json");
|
||||
|
||||
mkdirSync(destDir, { recursive: true });
|
||||
|
||||
const pkgJson = JSON.parse(readFileSync(srcPath, "utf-8"));
|
||||
|
||||
// Transform exports to use .js instead of .ts for import
|
||||
if (pkgJson.exports) {
|
||||
for (const [key, value] of Object.entries(pkgJson.exports)) {
|
||||
if (value?.import && typeof value.import === "string") {
|
||||
value.import = value.import.replace(/\.ts$/, ".js");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writeFileSync(destPath, JSON.stringify(pkgJson, null, 2));
|
||||
console.log(`[copy-packages] Copied and transformed ${pkg.name}/package.json`);
|
||||
}
|
||||
|
||||
console.log("[copy-packages] Done!");
|
||||
Reference in New Issue
Block a user