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-05-16 13:10:31 +00:00
|
|
|
const sdkFile = await sdk.text();
|
2024-02-17 22:11:17 +00:00
|
|
|
writeFileSync(`${PAYLOAD_FOLDER}/payload-sdk.ts`, sdkFile, {
|
|
|
|
encoding: "utf-8",
|
|
|
|
});
|
|
|
|
}
|