storyblok 3.20.0 → 3.22.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/README.md +6 -3
- package/package.json +1 -1
- package/src/cli.js +8 -3
- package/src/tasks/sync-commands/components.js +9 -0
- package/src/tasks/sync.js +3 -1
- package/src/utils/get-questions.js +1 -1
package/README.md
CHANGED
|
@@ -37,17 +37,20 @@ $ storyblok login
|
|
|
37
37
|
* `password`: your user's password
|
|
38
38
|
|
|
39
39
|
##### Options for Login with token (Recomended to SSO user's but works with all user accounts)
|
|
40
|
-
* `token`: your access token
|
|
40
|
+
* `token`: your personal access token
|
|
41
|
+
|
|
42
|
+
**Get your personal access token**
|
|
43
|
+
* Go to [https://app.storyblok.com/#/me/account?tab=token](https://app.storyblok.com/#/me/account?tab=token) and click on Generate new token.
|
|
41
44
|
|
|
42
45
|
**For Both login options you nedd to pass the region**
|
|
43
46
|
|
|
44
|
-
* `region`:
|
|
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.
|
|
45
48
|
|
|
46
49
|
#### Login with token flag
|
|
47
50
|
You can also add the token directly from the login’s command, like the example below:
|
|
48
51
|
|
|
49
52
|
```sh
|
|
50
|
-
$ storyblok login --token <
|
|
53
|
+
$ storyblok login --token <PERSONAL_ACCESS_TOKEN> --region eu
|
|
51
54
|
```
|
|
52
55
|
|
|
53
56
|
### logout
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -40,7 +40,7 @@ program
|
|
|
40
40
|
.command(COMMANDS.LOGIN)
|
|
41
41
|
.description('Login to the Storyblok cli')
|
|
42
42
|
.option('-t, --token <token>', 'Token to login directly without questions, like for CI enviroments')
|
|
43
|
-
.option('-r, --region <region>', '
|
|
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
44
|
.action(async (options) => {
|
|
45
45
|
const { token, region } = options
|
|
46
46
|
|
|
@@ -273,6 +273,7 @@ program
|
|
|
273
273
|
.option('--keys <KEYS>', 'Field names in your story object which should be used for filtering. Multiple keys should separated by comma.')
|
|
274
274
|
.option('--operations <OPERATIONS>', 'Operations to be used for filtering. Can be: is, in, not_in, like, not_like, any_in_array, all_in_array, gt_date, lt_date, gt_int, lt_int, gt_float, lt_float. Multiple operations should be separated by comma.')
|
|
275
275
|
.option('--values <VALUES>', 'Values to be used for filtering. Any string or number. If you want to use multiple values, separate them with a comma. Multiple values should be separated by comma.')
|
|
276
|
+
.option('--components-groups <UUIDs>', 'Synchronize components based on their group UUIDs separated by commas')
|
|
276
277
|
.action(async (options) => {
|
|
277
278
|
console.log(`${chalk.blue('-')} Sync data between spaces\n`)
|
|
278
279
|
|
|
@@ -289,9 +290,12 @@ program
|
|
|
289
290
|
filter,
|
|
290
291
|
keys,
|
|
291
292
|
operations,
|
|
292
|
-
values
|
|
293
|
+
values,
|
|
294
|
+
componentsGroups
|
|
293
295
|
} = options
|
|
294
296
|
|
|
297
|
+
const _componentsGroups = componentsGroups ? componentsGroups.split(',') : null
|
|
298
|
+
|
|
295
299
|
const _types = type.split(',') || []
|
|
296
300
|
_types.forEach(_type => {
|
|
297
301
|
if (!SYNC_TYPES.includes(_type)) {
|
|
@@ -308,7 +312,8 @@ program
|
|
|
308
312
|
source,
|
|
309
313
|
target,
|
|
310
314
|
startsWith,
|
|
311
|
-
filterQuery
|
|
315
|
+
filterQuery,
|
|
316
|
+
_componentsGroups
|
|
312
317
|
})
|
|
313
318
|
|
|
314
319
|
console.log('\n' + chalk.green('✓') + ' Sync data between spaces successfully completed')
|
|
@@ -18,6 +18,7 @@ class SyncComponents {
|
|
|
18
18
|
this.oauthToken = options.oauthToken
|
|
19
19
|
this.client = api.getClient()
|
|
20
20
|
this.presetsLib = new PresetsLib({ oauthToken: options.oauthToken, targetSpaceId: this.targetSpaceId })
|
|
21
|
+
this.componentsGroups = options.componentsGroups
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
async sync () {
|
|
@@ -70,6 +71,14 @@ class SyncComponents {
|
|
|
70
71
|
|
|
71
72
|
const sourceGroupUuid = component.component_group_uuid
|
|
72
73
|
|
|
74
|
+
if (this.componentsGroups && !this.componentsGroups.includes(sourceGroupUuid)) {
|
|
75
|
+
console.log(
|
|
76
|
+
chalk.yellow("-") +
|
|
77
|
+
` Component ${component.name} does not belong to the ${this.componentsGroups} group(s).`
|
|
78
|
+
);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
|
|
73
82
|
// if the component belongs to a group
|
|
74
83
|
if (sourceGroupUuid) {
|
|
75
84
|
const sourceGroup = findByProperty(
|
package/src/tasks/sync.js
CHANGED
|
@@ -18,6 +18,7 @@ const SyncSpaces = {
|
|
|
18
18
|
this.startsWith = options.startsWith
|
|
19
19
|
this.filterQuery = options.filterQuery
|
|
20
20
|
this.client = api.getClient()
|
|
21
|
+
this.componentsGroups = options._componentsGroups
|
|
21
22
|
},
|
|
22
23
|
|
|
23
24
|
async getStoryWithTranslatedSlugs (sourceStory, targetStory) {
|
|
@@ -231,7 +232,8 @@ const SyncSpaces = {
|
|
|
231
232
|
const syncComponentsInstance = new SyncComponents({
|
|
232
233
|
sourceSpaceId: this.sourceSpaceId,
|
|
233
234
|
targetSpaceId: this.targetSpaceId,
|
|
234
|
-
oauthToken: this.oauthToken
|
|
235
|
+
oauthToken: this.oauthToken,
|
|
236
|
+
componentsGroups: this.componentsGroups
|
|
235
237
|
})
|
|
236
238
|
|
|
237
239
|
try {
|
|
@@ -9,7 +9,7 @@ const getOptions = (subCommand, argv = {}, api = {}) => {
|
|
|
9
9
|
const regionInput = {
|
|
10
10
|
type: 'input',
|
|
11
11
|
name: 'region',
|
|
12
|
-
message: '
|
|
12
|
+
message: 'Please enter the region you would like to work in (us, eu or cn) - if not set, default is eu:',
|
|
13
13
|
validate: function (value) {
|
|
14
14
|
const flagList = ['us', 'cn', 'eu']
|
|
15
15
|
if (flagList.indexOf(value) > -1) {
|