storyblok 3.25.3 → 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.
@@ -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"
@@ -12,7 +12,7 @@ jobs:
12
12
  - uses: actions/checkout@v3
13
13
  - uses: actions/setup-node@v3
14
14
  with:
15
- node-version: 18
15
+ node-version: 20.11
16
16
  cache: 'yarn'
17
17
  - name: Install dependencies
18
18
  run: yarn
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`: region you would like to work in. Please keep in mind that the region must match the region of your space. You can use `us`, `cn` or `eu`, if left empty, default is `eu`. This region flag will be used for the other cli's commands.
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:
@@ -1,5 +1,4 @@
1
- const { LOGIN_URL, SIGNUP_URL } = require('../src/constants')
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
@@ -9,7 +8,7 @@ const axios = {
9
8
  post: jest.fn((path, data) => {
10
9
  const { email, password } = data || {}
11
10
 
12
- if (path === LOGIN_URL && isCredCorrects(email, password)) {
11
+ if (path === USERS_ROUTES.LOGIN && isCredCorrects(email, password)) {
13
12
  return Promise.resolve({
14
13
  data: {
15
14
  access_token: TOKEN_TEST
@@ -17,7 +16,7 @@ const axios = {
17
16
  })
18
17
  }
19
18
 
20
- if (path === SIGNUP_URL && isCredCorrects(email, password)) {
19
+ if (path === USERS_ROUTES.SIGNUP && isCredCorrects(email, password)) {
21
20
  return Promise.resolve({
22
21
  data: {
23
22
  access_token: TOKEN_TEST
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storyblok",
3
- "version": "3.25.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 enviroments')
43
- .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. You can use us, cn or eu, if left empty, default is eu. This region flag will be used for the other cli\'s commands')
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)
@@ -492,29 +499,29 @@ program
492
499
  }
493
500
  })
494
501
 
495
- // delete-datasources
502
+ // delete-datasources
496
503
  program
497
- .command(COMMANDS.DELETE_DATASOURCES)
498
- .requiredOption('--space-id <SPACE_ID>', 'Space id')
499
- .option('--by-slug <SLUG>', 'Delete datasources by slug')
500
- .option('--by-name <name>', 'Delete datasources by name')
501
- .action(async (options) => {
502
- console.log(`${chalk.blue('-')} Executing ${COMMANDS.DELETE_DATASOURCES} task`)
503
-
504
- const { spaceId, bySlug, byName } = options
505
-
506
- try {
507
- if (!api.isAuthorized()) {
508
- await api.processLogin()
509
- }
504
+ .command(COMMANDS.DELETE_DATASOURCES)
505
+ .requiredOption('--space-id <SPACE_ID>', 'Space id')
506
+ .option('--by-slug <SLUG>', 'Delete datasources by slug')
507
+ .option('--by-name <name>', 'Delete datasources by name')
508
+ .action(async (options) => {
509
+ console.log(`${chalk.blue('-')} Executing ${COMMANDS.DELETE_DATASOURCES} task`)
510
510
 
511
- api.setSpaceId(spaceId)
511
+ const { spaceId, bySlug, byName } = options
512
512
 
513
- await tasks.deleteDatasources(api, { byName, bySlug })
514
- } catch (e) {
515
- errorHandler(e, COMMANDS.DELETE_DATASOURCES)
516
- }
517
- })
513
+ try {
514
+ if (!api.isAuthorized()) {
515
+ await api.processLogin()
516
+ }
517
+
518
+ api.setSpaceId(spaceId)
519
+
520
+ await tasks.deleteDatasources(api, { byName, bySlug })
521
+ } catch (e) {
522
+ errorHandler(e, COMMANDS.DELETE_DATASOURCES)
523
+ }
524
+ })
518
525
 
519
526
  program.parse(process.argv)
520
527
 
@@ -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
- console.log(chalk.yellow('/!\\') + ' If your space was created under US or CN region, you must provide the region us or cn upon login.')
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,16 +1,4 @@
1
- const API_URL = 'https://api.storyblok.com/v1/'
2
- const US_API_URL = 'https://api-us.storyblok.com/v1/'
3
- const CN_API_URL = 'https://app.storyblokchina.cn/v1/'
4
- const LOGIN_URL = `${API_URL}users/login`
5
- const SIGNUP_URL = `${API_URL}users/signup`
6
-
7
- const SYNC_TYPES = [
8
- 'folders',
9
- 'components',
10
- 'roles',
11
- 'stories',
12
- 'datasources'
13
- ]
1
+ const SYNC_TYPES = ['folders', 'components', 'roles', 'stories', 'datasources']
14
2
 
15
3
  const COMMANDS = {
16
4
  GENERATE_MIGRATION: 'generate-migration',
@@ -35,12 +23,7 @@ const DEFAULT_AGENT = {
35
23
  }
36
24
 
37
25
  module.exports = {
38
- LOGIN_URL,
39
- SIGNUP_URL,
40
- API_URL,
41
26
  SYNC_TYPES,
42
- US_API_URL,
43
- CN_API_URL,
44
27
  COMMANDS,
45
28
  DEFAULT_AGENT
46
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))
@@ -1,4 +1,5 @@
1
1
  const chalk = require('chalk')
2
+ const { ALL_REGIONS, getRegionName, CN_CODE } = require('@storyblok/region-helper')
2
3
  /**
3
4
  * @method listSpaces
4
5
  * @param api - Pass the api instance as a parameter
@@ -6,11 +7,8 @@ const chalk = require('chalk')
6
7
  */
7
8
 
8
9
  const listSpaces = async (api, currentRegion) => {
9
- const isChinaEnv = currentRegion === 'cn'
10
- const regionOptions = {
11
- eu: 'Europe',
12
- us: 'United States'
13
- }
10
+ const isChinaEnv = currentRegion === CN_CODE
11
+
14
12
  console.log()
15
13
  console.log(chalk.green('✓') + ' Loading spaces...')
16
14
 
@@ -36,7 +34,8 @@ const listSpaces = async (api, currentRegion) => {
36
34
  return spaces
37
35
  } else {
38
36
  const spacesList = []
39
- for (const key in regionOptions) {
37
+ for (const key of ALL_REGIONS) {
38
+ if (key === CN_CODE) continue
40
39
  spacesList.push(await api.getAllSpacesByRegion(key)
41
40
  .then((res) => {
42
41
  return {
@@ -52,7 +51,7 @@ const listSpaces = async (api, currentRegion) => {
52
51
  }
53
52
  spacesList.forEach(region => {
54
53
  console.log()
55
- console.log(`${chalk.blue(' -')} Spaces From ${regionOptions[region.key]} region:`)
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
- if (sourceSchemaItem?.type === 'bloks' || sourceSchemaItem?.type === 'richtext') {
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 { SIGNUP_URL, API_URL, US_API_URL, CN_API_URL, DEFAULT_AGENT } = require('../constants')
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 } = content
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 = 'eu') {
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 = 'eu') {
172
- return axios.post(SIGNUP_URL, {
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,12 +311,6 @@ module.exports = {
310
311
  },
311
312
 
312
313
  apiSwitcher (region) {
313
- const apiList = {
314
- us: US_API_URL,
315
- cn: CN_API_URL,
316
- eu: API_URL
317
- }
318
-
319
- return region ? apiList[region] : apiList[this.region]
314
+ return region ? getRegionApiEndpoint(region) : getRegionApiEndpoint(this.region)
320
315
  }
321
316
  }
@@ -1,3 +1,5 @@
1
+ const { ALL_REGIONS, EU_CODE } = require('@storyblok/region-helper')
2
+
1
3
  const getOptions = (subCommand, argv = {}, api = {}) => {
2
4
  let email = ''
3
5
  const moreOptions = [
@@ -9,14 +11,14 @@ const getOptions = (subCommand, argv = {}, api = {}) => {
9
11
  const regionInput = {
10
12
  type: 'input',
11
13
  name: 'region',
12
- message: 'Please enter the region you would like to work in (us, eu or cn) - if not set, default is eu:',
14
+ message: `Please enter the region you would like to work in (${ALL_REGIONS}):`,
15
+ default: EU_CODE,
13
16
  validate: function (value) {
14
- const flagList = ['us', 'cn', 'eu']
15
- if (flagList.indexOf(value) > -1) {
17
+ if (ALL_REGIONS.indexOf(value) > -1) {
16
18
  return true
17
19
  }
18
20
 
19
- return 'Please enter a valid region: us, eu or cn'
21
+ return `Please enter a valid region: ${ALL_REGIONS}`
20
22
  }
21
23
  }
22
24
 
@@ -6,5 +6,6 @@ module.exports = {
6
6
  capitalize: require('./capitalize'),
7
7
  findByProperty: require('./find-by-property'),
8
8
  parseError: require('./parse-error'),
9
+ region: require('./region'),
9
10
  saveFileFactory: require('./save-file-factory')
10
11
  }
@@ -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'))
@@ -0,0 +1,7 @@
1
+ const { getRegionBaseUrl } = require('@storyblok/region-helper')
2
+
3
+ const getRegionApiEndpoint = (region) => `${getRegionBaseUrl(region)}/v1/`
4
+
5
+ module.exports = {
6
+ getRegionApiEndpoint
7
+ }
@@ -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 = 'eu'
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,11 +1,6 @@
1
1
  const { listSpaces } = require('../../src/tasks/')
2
2
  const { FAKE_SPACES } = require('../constants')
3
-
4
- const REGION_FLAGS = {
5
- UNITED_STATES: 'us',
6
- EUROPE: 'eu',
7
- CHINA: 'cn'
8
- }
3
+ const { EU_CODE, US_CODE, AP_CODE, CA_CODE, CN_CODE } = require('@storyblok/region-helper')
9
4
 
10
5
  describe('Test spaces method', () => {
11
6
  it('Testing list-spaces funtion without api instance', async () => {
@@ -22,28 +17,36 @@ describe('Test spaces method', () => {
22
17
  getAllSpacesByRegion: jest.fn(() => Promise.resolve(FAKE_SPACES()))
23
18
  }
24
19
  expect(
25
- await listSpaces(FAKE_API, REGION_FLAGS.CHINA)
20
+ await listSpaces(FAKE_API, CN_CODE)
26
21
  ).toEqual(FAKE_SPACES())
27
22
  expect(FAKE_API.getAllSpacesByRegion).toHaveBeenCalled()
28
23
  })
29
24
 
30
- it('Testing list-spaces funtion for Europe and United States regions', async () => {
25
+ it('Testing list-spaces funtion for all regions', async () => {
31
26
  const FAKE_API = {
32
27
  getAllSpacesByRegion: jest.fn(() => Promise.resolve(FAKE_SPACES()))
33
28
  }
34
29
  const response = [
35
30
  {
36
- key: REGION_FLAGS.EUROPE,
31
+ key: EU_CODE,
32
+ res: [...FAKE_SPACES()]
33
+ },
34
+ {
35
+ key: US_CODE,
36
+ res: [...FAKE_SPACES()]
37
+ },
38
+ {
39
+ key: CA_CODE,
37
40
  res: [...FAKE_SPACES()]
38
41
  },
39
42
  {
40
- key: REGION_FLAGS.UNITED_STATES,
43
+ key: AP_CODE,
41
44
  res: [...FAKE_SPACES()]
42
45
  }
43
46
  ]
44
47
 
45
48
  expect(
46
- await listSpaces(FAKE_API, REGION_FLAGS.EUROPE)
49
+ await listSpaces(FAKE_API, EU_CODE)
47
50
  ).toEqual(response)
48
51
  })
49
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 { API_URL } = require('../../src/constants')
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
- }, API_URL)
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 { API_URL } = require('../../src/constants')
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
- }, API_URL)
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 { API_URL } = require('../../src/constants')
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
- }, API_URL)
16
+ }, getRegionApiEndpoint(EU_CODE))
16
17
 
17
18
  try {
18
19
  const path = `spaces/${process.env.STORYBLOK_SPACE}/components`
@@ -1,6 +1,7 @@
1
1
  const sync = require('../../src/tasks/sync')
2
2
  const Storyblok = require('storyblok-js-client')
3
- const { API_URL } = require('../../src/constants')
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
- }, API_URL)
36
+ }, getRegionApiEndpoint(EU_CODE))
36
37
 
37
38
  const sourceStories = await getData(
38
39
  client,