forked from switchboard-xyz/solana-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.js
70 lines (59 loc) · 2.29 KB
/
esbuild.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* eslint node/no-unpublished-require: 0 */
/* eslint no-unused-vars: 0 */
import * as utils from "@switchboard-xyz/common/esm-utils";
import { execSync } from "child_process";
import { build } from "esbuild";
import fs from "fs";
import fsPromises from "fs/promises";
import path from "path";
import shell from "shelljs";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const buildFiles = ["tsconfig.tsbuildinfo"];
const outDir = path.join(__dirname, "lib");
async function main() {
await Promise.all([
fsPromises.rm(outDir, { recursive: true, force: true }),
fsPromises.rm(path.join(__dirname, "lib-cjs"), {
recursive: true,
force: true,
}),
buildFiles.map((f) => fsPromises.rm(f, { force: true })),
]);
fs.mkdirSync(outDir, { recursive: true });
execSync(`pnpm exec tsc --outDir lib`, { encoding: "utf-8" });
execSync(`pnpm exec tsc --outDir lib-cjs -p tsconfig.cjs.json`, {
encoding: "utf-8",
});
await utils
.moveCjsFilesAsync("lib-cjs", "lib")
.then(() => fsPromises.rm("lib-cjs", { recursive: true, force: true }));
console.log(`Generating entrypoints ...`);
utils.generateEntrypoints(__dirname, "lib", {
index: "index",
SwitchboardProgram: "SwitchboardProgram",
TransactionObject: "TransactionObject",
AggregatorAccount: "accounts/AggregatorAccount",
generated: "generated/index",
runner: "runner/index",
"generated/accounts": "generated/accounts",
"generated/instructions": "generated/instructions",
"generated/types": "generated/types",
"generated/oracle": "generated/oracle-program/index",
"generated/oracle/accounts": "generated/oracle-program/accounts/index",
"generated/oracle/instructions":
"generated/oracle-program/instructions/index",
"generated/oracle/types": "generated/oracle-program/types/index",
"generated/attestation": "generated/attestation-program/index",
"generated/attestation/accounts":
"generated/attestation-program/accounts/index",
"generated/attestation/instructions":
"generated/attestation-program/instructions/index",
"generated/attestation/types": "generated/attestation-program/types/index",
});
}
main().catch((error) => {
console.error(error);
throw error;
});