Skip to content

Commit fac9371

Browse files
authored
Merge pull request #76 from ninetailed-inc/NT-665-sdk-fix-setup-and-export-scripts
feat: add new scripts for Contentful setup and export, and update pac…
2 parents c603273 + 0693000 commit fac9371

5 files changed

Lines changed: 925 additions & 34 deletions

File tree

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"test-all": "nx run-many --target=test --all --skip-nx-cache",
1414
"generate:doc": "ts-node -P ./tools/scripts/tsconfig.scripts.json ./tools/scripts/documentation/generate-documentation.ts",
1515
"prepare": "husky install",
16-
"license:add": "ts-node -P ./tools/scripts/tsconfig.scripts.json ./tools/scripts/add-license.ts"
16+
"license:add": "ts-node -P ./tools/scripts/tsconfig.scripts.json ./tools/scripts/add-license.ts",
17+
"setup": "PATH_TO_ENV_FILE=./packages/playgrounds/easy-hr/.env.local node ./packages/playgrounds/easy-hr/contentful/setup.js",
18+
"export": "PATH_TO_ENV_FILE=./packages/playgrounds/easy-hr/.env.local node ./packages/playgrounds/easy-hr/contentful/export.js"
1719
},
1820
"private": true,
1921
"dependencies": {
@@ -28,6 +30,10 @@
2830
"async-retry": "1.3.3",
2931
"classnames": "2.3.2",
3032
"contentful": "9.2.14",
33+
"contentful-export": "7.18.16",
34+
"contentful-import": "8.3.0",
35+
"contentful-management": "10.15.1",
36+
"contentful-typescript-codegen": "3.2.3",
3137
"core-js": "3.26.1",
3238
"diary": "0.4.4",
3339
"dot": "1.1.3",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
NEXT_PUBLIC_NINETAILED_CLIENT_ID=
2+
NEXT_PUBLIC_NINETAILED_ENVIRONMENT=
3+
4+
NEXT_PUBLIC_NINETAILED_MANAGEMENT_CLIENT_ID=
5+
NEXT_PUBLIC_NINETAILED_MANAGEMENT_SECRET=
6+
7+
NEXT_PUBLIC_GTM_ID=
8+
9+
CONTENTFUL_SPACE_ID=
10+
CONTENTFUL_ENVIRONMENT=
11+
NEXT_PUBLIC_CONTENTFUL_TOKEN=
12+
NEXT_PUBLIC_CONTENTFUL_PREVIEW_TOKEN=
13+
CONTENTFUL_PREVIEW_SECRET=
14+
15+
CONTENTFUL_MANAGEMENT_TOKEN=
16+
CONTENTFUL_SPACE_DATA_LOCATION=./packages/playgrounds/easy-hr/contentful/data/contentful-space-data.json

packages/playgrounds/easy-hr/contentful/export.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,26 @@ dotEnv.config({ path: `${process.env.PATH_TO_ENV_FILE}` });
99
* */
1010
const exportOptions = {
1111
spaceId: process.env.CONTENTFUL_SPACE_ID,
12-
environmentId: process.env.CONTENTFUL_ENVIRONMENT,
12+
environmentId: process.env.CONTENTFUL_ENVIRONMENT || 'master',
1313
managementToken: process.env.CONTENTFUL_MANAGEMENT_TOKEN,
14-
/* deliveryToken: process.env.CONTENTFUL_TOKEN, */
15-
contentFile: process.env.CONTENTFUL_SPACE_DATA_LOCATION,
14+
contentFile:
15+
process.env.CONTENTFUL_SPACE_DATA_LOCATION ||
16+
'./packages/playgrounds/easy-hr/contentful/data/contentful-space-data.json',
1617
includeDrafts: true,
18+
skipRoles: true,
19+
skipWebhooks: true,
1720
};
1821

1922
if (
2023
!process.env.CONTENTFUL_SPACE_ID ||
21-
!process.env.CONTENTFUL_MANAGEMENT_TOKEN ||
22-
!process.env.CONTENTFUL_SPACE_DATA_LOCATION
24+
!process.env.CONTENTFUL_MANAGEMENT_TOKEN
2325
) {
2426
throw new Error(
2527
[
2628
'Parameters missing...',
27-
'Please insert the following credentials into your .env.local.local file:',
29+
'Please insert the following credentials into your .env.local file:',
2830
'- CONTENTFUL_SPACE_ID=XXX',
2931
'- CONTENTFUL_MANAGEMENT_TOKEN=CFPAT-XXX',
30-
'- CONTENTFUL_SPACE_DATA_LOCATION="PATH TO STORAGE DIRECTORY"',
3132
'Afterwards run the export command as follows:',
3233
'"npm run export" or "yarn export"',
3334
].join('\n')

packages/playgrounds/easy-hr/contentful/setup.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const importOptions = {
1010
managementToken: process.env.CONTENTFUL_MANAGEMENT_TOKEN,
1111
contentFile:
1212
process.env.CONTENTFUL_SPACE_DATA_LOCATION ||
13-
'./contentful/data/contentful-space-data.json',
13+
'./packages/playgrounds/easy-hr/contentful/data/contentful-space-data.json',
1414
};
1515

1616
if (
@@ -20,10 +20,9 @@ if (
2020
throw new Error(
2121
[
2222
'Parameters missing...',
23-
'Please insert the following credentials into your .env.local.local file:',
23+
'Please insert the following credentials into your .env.local file:',
2424
'- CONTENTFUL_SPACE_ID=XXX',
2525
'- CONTENTFUL_MANAGEMENT_TOKEN=CFPAT-XXX',
26-
'- CONTENTFUL_SPACE_DATA_LOCATION="PATH TO STORAGE DIRECTORY"',
2726
'Afterwards run the setup command as follows:',
2827
'"npm run setup" or "yarn setup"',
2928
].join('\n')

0 commit comments

Comments
 (0)