2024-01-12 00:01:44 +01:00
|
|
|
const spaceImport = require("contentful-import");
|
|
|
|
const exportFile = require("./export.json");
|
2020-05-02 06:52:39 +02:00
|
|
|
|
2024-01-12 00:01:44 +01:00
|
|
|
const { CONTENTFUL_SPACE_ID, CONTENTFUL_MANAGEMENT_TOKEN } = process.env;
|
2020-05-02 06:52:39 +02:00
|
|
|
|
|
|
|
if (!CONTENTFUL_SPACE_ID || !CONTENTFUL_MANAGEMENT_TOKEN) {
|
|
|
|
throw new Error(
|
|
|
|
[
|
2024-01-12 00:01:44 +01:00
|
|
|
"Parameters missing...",
|
|
|
|
"Please run the setup command as follows",
|
|
|
|
"CONTENTFUL_SPACE_ID=XXX CONTENTFUL_MANAGEMENT_TOKEN=CFPAT-XXX npm run setup",
|
|
|
|
].join("\n"),
|
|
|
|
);
|
2020-05-02 06:52:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
spaceImport({
|
|
|
|
spaceId: CONTENTFUL_SPACE_ID,
|
|
|
|
managementToken: CONTENTFUL_MANAGEMENT_TOKEN,
|
|
|
|
content: exportFile,
|
|
|
|
})
|
2024-01-12 00:01:44 +01:00
|
|
|
.then(() => console.log("The content model of your space is set up!"))
|
|
|
|
.catch((e) => console.error(e));
|