v3.accords-library.com/scripts/download-payload-sdk.ts

15 lines
441 B
TypeScript
Raw Normal View History

2024-02-17 22:11:17 +00:00
import { writeFileSync } from "fs";
const PAYLOAD_FOLDER = `${process.cwd()}/src/shared/payload`;
const sdk = await fetch(`${import.meta.env.PAYLOAD_API_URL}/sdk`);
if (!sdk.ok) {
console.error("Failed to get the sdk", sdk.status, sdk.statusText);
} else {
2024-03-13 02:11:21 +00:00
const sdkFile = (await sdk.text()).replaceAll("process.env.", "import.meta.env.");
2024-02-17 22:11:17 +00:00
writeFileSync(`${PAYLOAD_FOLDER}/payload-sdk.ts`, sdkFile, {
encoding: "utf-8",
});
}