storyblok 3.26.0 → 3.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/.dependabot.yml +13 -0
- package/.github/workflows/release.yml +1 -1
- package/README.md +4 -1
- package/__mocks__/axios.js +1 -2
- package/package.json +2 -1
- package/src/cli.js +11 -3
- package/src/constants.js +2 -43
- package/src/tasks/delete-datasources.js +8 -9
- package/src/tasks/list-spaces.js +5 -6
- package/src/tasks/sync-commands/components.js +8 -5
- package/src/utils/api.js +8 -7
- package/src/utils/get-questions.js +6 -5
- package/src/utils/index.js +1 -0
- package/src/utils/last-step.js +1 -1
- package/src/utils/region.js +7 -0
- package/tests/constants.js +9 -1
- package/tests/units/list-spaces.spec.js +7 -7
- package/tests/units/push-components.spec.js +3 -2
- package/tests/units/quickstart.spec.js +3 -2
- package/tests/units/scaffold.spec.js +3 -2
- package/tests/units/sync.spec.js +3 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
2
|
+
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
|
3
|
+
|
|
4
|
+
version: 2
|
|
5
|
+
updates:
|
|
6
|
+
- package-ecosystem: "npm"
|
|
7
|
+
directory: "/"
|
|
8
|
+
schedule:
|
|
9
|
+
interval: "monthly"
|
|
10
|
+
allow:
|
|
11
|
+
- dependency-name: "@storyblok/region-helper"
|
|
12
|
+
reviewers:
|
|
13
|
+
- "storyblok/plugins-team"
|
package/README.md
CHANGED
|
@@ -44,7 +44,10 @@ $ storyblok login
|
|
|
44
44
|
|
|
45
45
|
**For Both login options you nedd to pass the region**
|
|
46
46
|
|
|
47
|
-
* `region
|
|
47
|
+
* `region` (default: `eu`): the region you would like to work in. All the supported regions can be found [here](https://www.storyblok.com/faq/define-specific-region-storyblok-api).
|
|
48
|
+
|
|
49
|
+
> [!NOTE]
|
|
50
|
+
> Please keep in mind that the region must match the region of your space, and also that it will be used for all future commands you may perform.
|
|
48
51
|
|
|
49
52
|
#### Login with token flag
|
|
50
53
|
You can also add the token directly from the login’s command, like the example below:
|
package/__mocks__/axios.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const { USERS_ROUTES } = require('../
|
|
2
|
-
const { EMAIL_TEST, PASSWORD_TEST, TOKEN_TEST } = require('../tests/constants')
|
|
1
|
+
const { USERS_ROUTES, EMAIL_TEST, PASSWORD_TEST, TOKEN_TEST } = require('../tests/constants')
|
|
3
2
|
|
|
4
3
|
const isCredCorrects = (email, pass) => {
|
|
5
4
|
return email === EMAIL_TEST && pass === PASSWORD_TEST
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storyblok",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.27.0",
|
|
4
4
|
"description": "A simple CLI to start Storyblok from your command line.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"author": "Dominik Angerer <dominikangerer1@gmail.com>, Alexander Feiglstorfer <delooks@gmail.com>",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@storyblok/region-helper": "^1.0.0",
|
|
28
29
|
"axios": "^0.27.2",
|
|
29
30
|
"chalk": "^4.1.0",
|
|
30
31
|
"clear": "0.1.0",
|
package/src/cli.js
CHANGED
|
@@ -7,6 +7,7 @@ const chalk = require('chalk')
|
|
|
7
7
|
const clear = require('clear')
|
|
8
8
|
const figlet = require('figlet')
|
|
9
9
|
const inquirer = require('inquirer')
|
|
10
|
+
const { ALL_REGIONS, EU_CODE, isRegion } = require('@storyblok/region-helper')
|
|
10
11
|
|
|
11
12
|
const updateNotifier = require('update-notifier')
|
|
12
13
|
const pkg = require('../package.json')
|
|
@@ -14,6 +15,7 @@ const pkg = require('../package.json')
|
|
|
14
15
|
const tasks = require('./tasks')
|
|
15
16
|
const { getQuestions, lastStep, api, creds } = require('./utils')
|
|
16
17
|
const { SYNC_TYPES, COMMANDS } = require('./constants')
|
|
18
|
+
const allRegionsText = ALL_REGIONS.join(', ')
|
|
17
19
|
|
|
18
20
|
clear()
|
|
19
21
|
console.log(chalk.cyan(figlet.textSync('storyblok')))
|
|
@@ -39,8 +41,8 @@ program
|
|
|
39
41
|
program
|
|
40
42
|
.command(COMMANDS.LOGIN)
|
|
41
43
|
.description('Login to the Storyblok cli')
|
|
42
|
-
.option('-t, --token <token>', 'Token to login directly without questions, like for CI
|
|
43
|
-
.option('-r, --region <region>',
|
|
44
|
+
.option('-t, --token <token>', 'Token to login directly without questions, like for CI environments')
|
|
45
|
+
.option('-r, --region <region>', `The region you would like to work in. Please keep in mind that the region must match the region of your space. This region flag will be used for the other cli's commands. You can use the values: ${allRegionsText}.`, EU_CODE)
|
|
44
46
|
.action(async (options) => {
|
|
45
47
|
const { token, region } = options
|
|
46
48
|
|
|
@@ -49,6 +51,11 @@ program
|
|
|
49
51
|
return
|
|
50
52
|
}
|
|
51
53
|
|
|
54
|
+
if (!isRegion(region)) {
|
|
55
|
+
console.log(chalk.red('X') + `The provided region ${region} is not valid. Please use one of the following: ${allRegionsText}`)
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
52
59
|
try {
|
|
53
60
|
await api.processLogin(token, region)
|
|
54
61
|
process.exit(0)
|
|
@@ -524,7 +531,8 @@ if (program.rawArgs.length <= 2) {
|
|
|
524
531
|
|
|
525
532
|
function errorHandler (e, command) {
|
|
526
533
|
if (/404/.test(e.message)) {
|
|
527
|
-
|
|
534
|
+
const allRegionsButDefault = ALL_REGIONS.filter(region => region !== EU_CODE).join(' ,')
|
|
535
|
+
console.log(chalk.yellow('/!\\') + ` If your space was not created under ${EU_CODE} region, you must provide the region (${allRegionsButDefault}) upon login.`)
|
|
528
536
|
} else {
|
|
529
537
|
console.log(chalk.red('X') + ' An error occurred when executing the ' + command + ' task: ' + e || e.message)
|
|
530
538
|
}
|
package/src/constants.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
const SYNC_TYPES = [
|
|
2
|
-
'folders',
|
|
3
|
-
'components',
|
|
4
|
-
'roles',
|
|
5
|
-
'stories',
|
|
6
|
-
'datasources'
|
|
7
|
-
]
|
|
1
|
+
const SYNC_TYPES = ['folders', 'components', 'roles', 'stories', 'datasources']
|
|
8
2
|
|
|
9
3
|
const COMMANDS = {
|
|
10
4
|
GENERATE_MIGRATION: 'generate-migration',
|
|
@@ -28,43 +22,8 @@ const DEFAULT_AGENT = {
|
|
|
28
22
|
SB_Agent_Version: process.env.npm_package_version || '3.0.0'
|
|
29
23
|
}
|
|
30
24
|
|
|
31
|
-
const REGIONS = {
|
|
32
|
-
cn: {
|
|
33
|
-
key: 'cn',
|
|
34
|
-
name: 'China',
|
|
35
|
-
apiEndpoint: 'https://app.storyblokchina.cn/v1/'
|
|
36
|
-
},
|
|
37
|
-
eu: {
|
|
38
|
-
key: 'eu',
|
|
39
|
-
name: 'Europe',
|
|
40
|
-
apiEndpoint: 'https://api.storyblok.com/v1/'
|
|
41
|
-
},
|
|
42
|
-
us: {
|
|
43
|
-
key: 'us',
|
|
44
|
-
name: 'United States',
|
|
45
|
-
apiEndpoint: 'https://api-us.storyblok.com/v1/'
|
|
46
|
-
},
|
|
47
|
-
ca: {
|
|
48
|
-
key: 'ca',
|
|
49
|
-
name: 'Canada',
|
|
50
|
-
apiEndpoint: 'https://api-ca.storyblok.com/v1/'
|
|
51
|
-
},
|
|
52
|
-
ap: {
|
|
53
|
-
key: 'ap',
|
|
54
|
-
name: 'Australia',
|
|
55
|
-
apiEndpoint: 'https://api-ap.storyblok.com/v1/'
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const USERS_ROUTES = {
|
|
60
|
-
LOGIN: `${REGIONS.eu.apiEndpoint}users/login`,
|
|
61
|
-
SIGNUP: `${REGIONS.eu.apiEndpoint}users/signup`
|
|
62
|
-
}
|
|
63
|
-
|
|
64
25
|
module.exports = {
|
|
65
26
|
SYNC_TYPES,
|
|
66
|
-
USERS_ROUTES,
|
|
67
27
|
COMMANDS,
|
|
68
|
-
DEFAULT_AGENT
|
|
69
|
-
REGIONS
|
|
28
|
+
DEFAULT_AGENT
|
|
70
29
|
}
|
|
@@ -13,26 +13,25 @@ const deleteDatasources = async (api, options) => {
|
|
|
13
13
|
let datasources = await api.getDatasources()
|
|
14
14
|
|
|
15
15
|
if (bySlug) {
|
|
16
|
-
datasources = datasources.filter(datasource => datasource.slug.toLowerCase().startsWith(bySlug.toLowerCase()))
|
|
17
|
-
const filteredSlugs = datasources.map(obj => obj.slug)
|
|
18
|
-
const formattedSlugs = filteredSlugs.join(', ')
|
|
16
|
+
datasources = datasources.filter(datasource => datasource.slug.toLowerCase().startsWith(bySlug.toLowerCase()))
|
|
17
|
+
const filteredSlugs = datasources.map(obj => obj.slug)
|
|
18
|
+
const formattedSlugs = filteredSlugs.join(', ')
|
|
19
19
|
|
|
20
|
-
console.log(`${chalk.blue('-')} Datasources where slug starts with ${bySlug}: ${formattedSlugs}`)
|
|
20
|
+
console.log(`${chalk.blue('-')} Datasources where slug starts with ${bySlug}: ${formattedSlugs}`)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
if (byName) {
|
|
24
|
-
datasources = datasources.filter(datasource => datasource.name.toLowerCase().startsWith(byName.toLowerCase()))
|
|
25
|
-
const filteredNames = datasources.map(obj => obj.name)
|
|
26
|
-
const formattedNames = filteredNames.join(', ')
|
|
24
|
+
datasources = datasources.filter(datasource => datasource.name.toLowerCase().startsWith(byName.toLowerCase()))
|
|
25
|
+
const filteredNames = datasources.map(obj => obj.name)
|
|
26
|
+
const formattedNames = filteredNames.join(', ')
|
|
27
27
|
|
|
28
|
-
console.log(`${chalk.blue('-')} Datasources where name starts with ${byName}: ${formattedNames}`)
|
|
28
|
+
console.log(`${chalk.blue('-')} Datasources where name starts with ${byName}: ${formattedNames}`)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
for (const datasource of datasources) {
|
|
32
32
|
console.log(`${chalk.blue('-')} Deleting ${datasource.name}`)
|
|
33
33
|
await api.deleteDatasource(datasource.id)
|
|
34
34
|
}
|
|
35
|
-
|
|
36
35
|
} catch (e) {
|
|
37
36
|
console.error(`${chalk.red('X')} An error ocurred in delete-components task when deleting a datasource`)
|
|
38
37
|
return Promise.reject(new Error(e))
|
package/src/tasks/list-spaces.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const chalk = require('chalk')
|
|
2
|
-
const {
|
|
2
|
+
const { ALL_REGIONS, getRegionName, CN_CODE } = require('@storyblok/region-helper')
|
|
3
3
|
/**
|
|
4
4
|
* @method listSpaces
|
|
5
5
|
* @param api - Pass the api instance as a parameter
|
|
@@ -7,7 +7,7 @@ const { REGIONS } = require('../constants')
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
const listSpaces = async (api, currentRegion) => {
|
|
10
|
-
const isChinaEnv = currentRegion ===
|
|
10
|
+
const isChinaEnv = currentRegion === CN_CODE
|
|
11
11
|
|
|
12
12
|
console.log()
|
|
13
13
|
console.log(chalk.green('✓') + ' Loading spaces...')
|
|
@@ -34,8 +34,8 @@ const listSpaces = async (api, currentRegion) => {
|
|
|
34
34
|
return spaces
|
|
35
35
|
} else {
|
|
36
36
|
const spacesList = []
|
|
37
|
-
for (const key
|
|
38
|
-
if (key ===
|
|
37
|
+
for (const key of ALL_REGIONS) {
|
|
38
|
+
if (key === CN_CODE) continue
|
|
39
39
|
spacesList.push(await api.getAllSpacesByRegion(key)
|
|
40
40
|
.then((res) => {
|
|
41
41
|
return {
|
|
@@ -50,9 +50,8 @@ const listSpaces = async (api, currentRegion) => {
|
|
|
50
50
|
return []
|
|
51
51
|
}
|
|
52
52
|
spacesList.forEach(region => {
|
|
53
|
-
const regionName = REGIONS[region.key].name
|
|
54
53
|
console.log()
|
|
55
|
-
console.log(`${chalk.blue(' -')} Spaces From ${
|
|
54
|
+
console.log(`${chalk.blue(' -')} Spaces From ${getRegionName(region.key)} region:`)
|
|
56
55
|
region.res.forEach((space) => {
|
|
57
56
|
console.log(` ${space.name} (id: ${space.id})`)
|
|
58
57
|
})
|
|
@@ -73,10 +73,10 @@ class SyncComponents {
|
|
|
73
73
|
|
|
74
74
|
if (this.componentsGroups && !this.componentsGroups.includes(sourceGroupUuid)) {
|
|
75
75
|
console.log(
|
|
76
|
-
chalk.yellow(
|
|
76
|
+
chalk.yellow('-') +
|
|
77
77
|
` Component ${component.name} does not belong to the ${this.componentsGroups} group(s).`
|
|
78
|
-
)
|
|
79
|
-
continue
|
|
78
|
+
)
|
|
79
|
+
continue
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// if the component belongs to a group
|
|
@@ -112,7 +112,7 @@ class SyncComponents {
|
|
|
112
112
|
await this.presetsLib.createPresets(componentPresets, componentCreated.id)
|
|
113
113
|
}
|
|
114
114
|
} catch (e) {
|
|
115
|
-
if (e.response && e.response.status || e.status === 422) {
|
|
115
|
+
if ((e.response && e.response.status) || e.status === 422) {
|
|
116
116
|
console.log(
|
|
117
117
|
`${chalk.yellow('-')} Component ${component.name} already exists, updating it...`
|
|
118
118
|
)
|
|
@@ -217,7 +217,10 @@ class SyncComponents {
|
|
|
217
217
|
return Object.keys(sourceSchema).reduce((acc, key) => {
|
|
218
218
|
// handle blocks separately
|
|
219
219
|
const sourceSchemaItem = sourceSchema[key]
|
|
220
|
-
|
|
220
|
+
const isBloksType = sourceSchemaItem && sourceSchemaItem.type === 'bloks'
|
|
221
|
+
const isRichtextType = sourceSchemaItem && sourceSchemaItem.type === 'richtext'
|
|
222
|
+
|
|
223
|
+
if (isBloksType || isRichtextType) {
|
|
221
224
|
acc[key] = this.mergeBloksSchema(sourceSchemaItem)
|
|
222
225
|
return acc
|
|
223
226
|
}
|
package/src/utils/api.js
CHANGED
|
@@ -5,7 +5,9 @@ const inquirer = require('inquirer')
|
|
|
5
5
|
|
|
6
6
|
const creds = require('./creds')
|
|
7
7
|
const getQuestions = require('./get-questions')
|
|
8
|
-
const {
|
|
8
|
+
const { DEFAULT_AGENT } = require('../constants')
|
|
9
|
+
const { getRegionApiEndpoint } = require('./region')
|
|
10
|
+
const { EU_CODE } = require('@storyblok/region-helper')
|
|
9
11
|
|
|
10
12
|
module.exports = {
|
|
11
13
|
accessToken: '',
|
|
@@ -39,7 +41,7 @@ module.exports = {
|
|
|
39
41
|
},
|
|
40
42
|
|
|
41
43
|
async login (content) {
|
|
42
|
-
const { email, password, region =
|
|
44
|
+
const { email, password, region = EU_CODE } = content
|
|
43
45
|
try {
|
|
44
46
|
const response = await axios.post(`${this.apiSwitcher(region)}users/login`, {
|
|
45
47
|
email: email,
|
|
@@ -96,7 +98,7 @@ module.exports = {
|
|
|
96
98
|
}
|
|
97
99
|
},
|
|
98
100
|
|
|
99
|
-
persistCredentials (email, token = null, region =
|
|
101
|
+
persistCredentials (email, token = null, region = EU_CODE) {
|
|
100
102
|
if (token) {
|
|
101
103
|
this.oauthToken = token
|
|
102
104
|
creds.set(email, token, region)
|
|
@@ -168,8 +170,8 @@ module.exports = {
|
|
|
168
170
|
creds.set(null)
|
|
169
171
|
},
|
|
170
172
|
|
|
171
|
-
signup (email, password, region =
|
|
172
|
-
return axios.post(
|
|
173
|
+
signup (email, password, region = EU_CODE) {
|
|
174
|
+
return axios.post(`${this.apiSwitcher(region)}users/signup`, {
|
|
173
175
|
email: email,
|
|
174
176
|
password: password,
|
|
175
177
|
region
|
|
@@ -255,7 +257,6 @@ module.exports = {
|
|
|
255
257
|
.catch(err => Promise.reject(err))
|
|
256
258
|
},
|
|
257
259
|
|
|
258
|
-
|
|
259
260
|
post (path, props) {
|
|
260
261
|
return this.sendRequest(path, 'post', props)
|
|
261
262
|
},
|
|
@@ -310,6 +311,6 @@ module.exports = {
|
|
|
310
311
|
},
|
|
311
312
|
|
|
312
313
|
apiSwitcher (region) {
|
|
313
|
-
return region ?
|
|
314
|
+
return region ? getRegionApiEndpoint(region) : getRegionApiEndpoint(this.region)
|
|
314
315
|
}
|
|
315
316
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { ALL_REGIONS, EU_CODE } = require('@storyblok/region-helper')
|
|
2
|
+
|
|
2
3
|
const getOptions = (subCommand, argv = {}, api = {}) => {
|
|
3
4
|
let email = ''
|
|
4
5
|
const moreOptions = [
|
|
@@ -7,17 +8,17 @@ const getOptions = (subCommand, argv = {}, api = {}) => {
|
|
|
7
8
|
'push-components',
|
|
8
9
|
'scaffold'
|
|
9
10
|
]
|
|
10
|
-
const regionsPrefixList = Object.keys(REGIONS)
|
|
11
11
|
const regionInput = {
|
|
12
12
|
type: 'input',
|
|
13
13
|
name: 'region',
|
|
14
|
-
message: `Please enter the region you would like to work in (${
|
|
14
|
+
message: `Please enter the region you would like to work in (${ALL_REGIONS}):`,
|
|
15
|
+
default: EU_CODE,
|
|
15
16
|
validate: function (value) {
|
|
16
|
-
if (
|
|
17
|
+
if (ALL_REGIONS.indexOf(value) > -1) {
|
|
17
18
|
return true
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
return `Please enter a valid region: ${
|
|
21
|
+
return `Please enter a valid region: ${ALL_REGIONS}`
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
package/src/utils/index.js
CHANGED
package/src/utils/last-step.js
CHANGED
|
@@ -49,7 +49,7 @@ const lastStep = answers => {
|
|
|
49
49
|
console.log(chalk.green('✓') + ' - The github repository ' + gitRepo + ' will be cloned now...')
|
|
50
50
|
|
|
51
51
|
ghdownload(gitRepo, outputDir, async (err) => {
|
|
52
|
-
if(err) {
|
|
52
|
+
if (err) {
|
|
53
53
|
if (err.code === 'ENOTEMPTY') {
|
|
54
54
|
console.log(chalk.red(' Oh Snap! It seems that you already have a project with the name: ' + name))
|
|
55
55
|
reject(new Error('This repository already has been cloned'))
|
package/tests/constants.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
const { getRegionApiEndpoint } = require('../src/utils/region')
|
|
2
|
+
const { EU_CODE } = require('@storyblok/region-helper')
|
|
1
3
|
const EMAIL_TEST = 'test@storyblok.com'
|
|
2
4
|
const PASSWORD_TEST = 'test'
|
|
3
5
|
const TOKEN_TEST = 'storyblok1234'
|
|
4
|
-
const REGION_TEST =
|
|
6
|
+
const REGION_TEST = EU_CODE
|
|
5
7
|
|
|
6
8
|
// use functions to always returns 'new' data
|
|
7
9
|
const FAKE_COMPONENTS = () => [
|
|
@@ -289,9 +291,15 @@ const FAKE_PRESET = () => ({
|
|
|
289
291
|
description: 'page preset'
|
|
290
292
|
})
|
|
291
293
|
|
|
294
|
+
const USERS_ROUTES = {
|
|
295
|
+
LOGIN: `${getRegionApiEndpoint(EU_CODE)}users/login`,
|
|
296
|
+
SIGNUP: `${getRegionApiEndpoint(EU_CODE)}users/signup`
|
|
297
|
+
}
|
|
298
|
+
|
|
292
299
|
module.exports = {
|
|
293
300
|
EMAIL_TEST,
|
|
294
301
|
TOKEN_TEST,
|
|
302
|
+
USERS_ROUTES,
|
|
295
303
|
FAKE_STORIES,
|
|
296
304
|
PASSWORD_TEST,
|
|
297
305
|
FAKE_COMPONENTS,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { listSpaces } = require('../../src/tasks/')
|
|
2
2
|
const { FAKE_SPACES } = require('../constants')
|
|
3
|
-
const {
|
|
3
|
+
const { EU_CODE, US_CODE, AP_CODE, CA_CODE, CN_CODE } = require('@storyblok/region-helper')
|
|
4
4
|
|
|
5
5
|
describe('Test spaces method', () => {
|
|
6
6
|
it('Testing list-spaces funtion without api instance', async () => {
|
|
@@ -17,7 +17,7 @@ describe('Test spaces method', () => {
|
|
|
17
17
|
getAllSpacesByRegion: jest.fn(() => Promise.resolve(FAKE_SPACES()))
|
|
18
18
|
}
|
|
19
19
|
expect(
|
|
20
|
-
await listSpaces(FAKE_API,
|
|
20
|
+
await listSpaces(FAKE_API, CN_CODE)
|
|
21
21
|
).toEqual(FAKE_SPACES())
|
|
22
22
|
expect(FAKE_API.getAllSpacesByRegion).toHaveBeenCalled()
|
|
23
23
|
})
|
|
@@ -28,25 +28,25 @@ describe('Test spaces method', () => {
|
|
|
28
28
|
}
|
|
29
29
|
const response = [
|
|
30
30
|
{
|
|
31
|
-
key:
|
|
31
|
+
key: EU_CODE,
|
|
32
32
|
res: [...FAKE_SPACES()]
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
|
-
key:
|
|
35
|
+
key: US_CODE,
|
|
36
36
|
res: [...FAKE_SPACES()]
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
|
-
key:
|
|
39
|
+
key: CA_CODE,
|
|
40
40
|
res: [...FAKE_SPACES()]
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
|
-
key:
|
|
43
|
+
key: AP_CODE,
|
|
44
44
|
res: [...FAKE_SPACES()]
|
|
45
45
|
}
|
|
46
46
|
]
|
|
47
47
|
|
|
48
48
|
expect(
|
|
49
|
-
await listSpaces(FAKE_API,
|
|
49
|
+
await listSpaces(FAKE_API, EU_CODE)
|
|
50
50
|
).toEqual(response)
|
|
51
51
|
})
|
|
52
52
|
})
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const pushComponents = require('../../src/tasks/push-components')
|
|
2
2
|
const Storyblok = require('storyblok-js-client')
|
|
3
3
|
const api = require('../../src/utils/api')
|
|
4
|
-
const {
|
|
4
|
+
const { getRegionApiEndpoint } = require('../../src/utils/region')
|
|
5
|
+
const { EU_CODE } = require('@storyblok/region-helper')
|
|
5
6
|
|
|
6
7
|
jest.mock('fs')
|
|
7
8
|
jest.unmock('axios')
|
|
@@ -10,7 +11,7 @@ const deleteDocComponent = async () => {
|
|
|
10
11
|
if (process.env.STORYBLOK_TOKEN) {
|
|
11
12
|
const client = new Storyblok({
|
|
12
13
|
oauthToken: process.env.STORYBLOK_TOKEN
|
|
13
|
-
},
|
|
14
|
+
}, getRegionApiEndpoint(EU_CODE))
|
|
14
15
|
|
|
15
16
|
try {
|
|
16
17
|
const path = `spaces/${process.env.STORYBLOK_SPACE}/components`
|
|
@@ -4,7 +4,8 @@ const path = require('path')
|
|
|
4
4
|
const quickstart = require('../../src/tasks/quickstart')
|
|
5
5
|
const Storyblok = require('storyblok-js-client')
|
|
6
6
|
const api = require('../../src/utils/api')
|
|
7
|
-
const {
|
|
7
|
+
const { getRegionApiEndpoint } = require('../../src/utils/region')
|
|
8
|
+
const { EU_CODE } = require('@storyblok/region-helper')
|
|
8
9
|
|
|
9
10
|
jest.unmock('fs')
|
|
10
11
|
jest.unmock('axios')
|
|
@@ -60,7 +61,7 @@ describe('testing quickstart()', () => {
|
|
|
60
61
|
|
|
61
62
|
const client = new Storyblok({
|
|
62
63
|
oauthToken: process.env.STORYBLOK_TOKEN
|
|
63
|
-
},
|
|
64
|
+
}, getRegionApiEndpoint(EU_CODE))
|
|
64
65
|
|
|
65
66
|
const response = await client.get('spaces')
|
|
66
67
|
const spaces = response.data.spaces
|
|
@@ -3,7 +3,8 @@ const fs = require('fs')
|
|
|
3
3
|
const scaffold = require('../../src/tasks/scaffold')
|
|
4
4
|
const Storyblok = require('storyblok-js-client')
|
|
5
5
|
const api = require('../../src/utils/api')
|
|
6
|
-
const {
|
|
6
|
+
const { getRegionApiEndpoint } = require('../../src/utils/region')
|
|
7
|
+
const { EU_CODE } = require('@storyblok/region-helper')
|
|
7
8
|
|
|
8
9
|
jest.mock('fs')
|
|
9
10
|
jest.unmock('axios')
|
|
@@ -12,7 +13,7 @@ const deleteTestComponent = async () => {
|
|
|
12
13
|
if (process.env.STORYBLOK_TOKEN) {
|
|
13
14
|
const client = new Storyblok({
|
|
14
15
|
oauthToken: process.env.STORYBLOK_TOKEN
|
|
15
|
-
},
|
|
16
|
+
}, getRegionApiEndpoint(EU_CODE))
|
|
16
17
|
|
|
17
18
|
try {
|
|
18
19
|
const path = `spaces/${process.env.STORYBLOK_SPACE}/components`
|
package/tests/units/sync.spec.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const sync = require('../../src/tasks/sync')
|
|
2
2
|
const Storyblok = require('storyblok-js-client')
|
|
3
|
-
const {
|
|
3
|
+
const { getRegionApiEndpoint } = require('../../src/utils/region')
|
|
4
|
+
const { EU_CODE } = require('@storyblok/region-helper')
|
|
4
5
|
|
|
5
6
|
jest.unmock('axios')
|
|
6
7
|
|
|
@@ -32,7 +33,7 @@ describe('testing sync function', () => {
|
|
|
32
33
|
|
|
33
34
|
const client = new Storyblok({
|
|
34
35
|
oauthToken: process.env.STORYBLOK_TOKEN
|
|
35
|
-
},
|
|
36
|
+
}, getRegionApiEndpoint(EU_CODE))
|
|
36
37
|
|
|
37
38
|
const sourceStories = await getData(
|
|
38
39
|
client,
|