forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.js
More file actions
22 lines (19 loc) · 675 Bytes
/
setup.js
File metadata and controls
22 lines (19 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const spaceImport = require("contentful-import");
const exportFile = require("./export.json");
const { CONTENTFUL_SPACE_ID, CONTENTFUL_MANAGEMENT_TOKEN } = process.env;
if (!CONTENTFUL_SPACE_ID || !CONTENTFUL_MANAGEMENT_TOKEN) {
throw new Error(
[
"Parameters missing...",
"Please run the setup command as follows",
"CONTENTFUL_SPACE_ID=XXX CONTENTFUL_MANAGEMENT_TOKEN=CFPAT-XXX npm run setup",
].join("\n"),
);
}
spaceImport({
spaceId: CONTENTFUL_SPACE_ID,
managementToken: CONTENTFUL_MANAGEMENT_TOKEN,
content: exportFile,
})
.then(() => console.log("The content model of your space is set up!"))
.catch((e) => console.error(e));