storyblok 3.30.0 → 3.31.1
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 +1 -0
- package/dist/cli.mjs +39 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -254,6 +254,7 @@ $ storyblok sync --type <COMMAND> --source <SPACE_ID> --target <SPACE_ID>
|
|
|
254
254
|
* `filter`: sync stories based on the given filter. Required Options: Required options: `--keys`, `--operations`, `--values`
|
|
255
255
|
* `keys`: Multiple keys should be separated by comma. Example: `--keys key1,key2`, `--keys key1`
|
|
256
256
|
* `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.
|
|
257
|
+
* `components-full-sync`: If used, the CLI will override the full component object when synching across spaces.
|
|
257
258
|
|
|
258
259
|
#### Examples
|
|
259
260
|
|
package/dist/cli.mjs
CHANGED
|
@@ -525,21 +525,31 @@ const api = {
|
|
|
525
525
|
oauthToken: "",
|
|
526
526
|
spaceId: null,
|
|
527
527
|
region: "",
|
|
528
|
-
getClient() {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
528
|
+
getClient: /* @__PURE__ */ function() {
|
|
529
|
+
let client, accessToken, oauthToken, region, credsRegion;
|
|
530
|
+
return function getClient() {
|
|
531
|
+
const { region: _credsRegion } = creds.get();
|
|
532
|
+
if (client && accessToken === this.accessToken && oauthToken === this.oauthToken && region === this.region && credsRegion === _credsRegion) {
|
|
533
|
+
return client;
|
|
534
|
+
}
|
|
535
|
+
accessToken = this.accessToken;
|
|
536
|
+
oauthToken = this.oauthToken;
|
|
537
|
+
region = this.region;
|
|
538
|
+
credsRegion = _credsRegion;
|
|
539
|
+
try {
|
|
540
|
+
return client = new Storyblok({
|
|
541
|
+
accessToken,
|
|
542
|
+
oauthToken,
|
|
543
|
+
region,
|
|
544
|
+
headers: {
|
|
545
|
+
...DEFAULT_AGENT
|
|
546
|
+
}
|
|
547
|
+
}, this.apiSwitcher(credsRegion));
|
|
548
|
+
} catch (error) {
|
|
549
|
+
throw new Error(error);
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
}(),
|
|
543
553
|
getPath(path) {
|
|
544
554
|
if (this.spaceId) {
|
|
545
555
|
return `spaces/${this.spaceId}/${path}`;
|
|
@@ -1039,6 +1049,7 @@ class SyncComponents {
|
|
|
1039
1049
|
this.client = api.getClient();
|
|
1040
1050
|
this.presetsLib = new PresetsLib({ oauthToken: options.oauthToken, targetSpaceId: this.targetSpaceId });
|
|
1041
1051
|
this.componentsGroups = options.componentsGroups;
|
|
1052
|
+
this.componentsFullSync = options.componentsFullSync;
|
|
1042
1053
|
}
|
|
1043
1054
|
async sync() {
|
|
1044
1055
|
const syncComponentGroupsInstance = new SyncComponentGroups({
|
|
@@ -1171,7 +1182,10 @@ class SyncComponents {
|
|
|
1171
1182
|
return this.client.put(`spaces/${spaceId}/components/${componentId}`, payload);
|
|
1172
1183
|
}
|
|
1173
1184
|
mergeComponents(sourceComponent, targetComponent = {}) {
|
|
1174
|
-
const data = {
|
|
1185
|
+
const data = this.componentsFullSync ? {
|
|
1186
|
+
// This should be the default behavior in a major future version
|
|
1187
|
+
...sourceComponent
|
|
1188
|
+
} : {
|
|
1175
1189
|
...sourceComponent,
|
|
1176
1190
|
...targetComponent
|
|
1177
1191
|
};
|
|
@@ -1490,6 +1504,7 @@ const SyncSpaces = {
|
|
|
1490
1504
|
this.targetSpaceId = options.target;
|
|
1491
1505
|
this.oauthToken = options.token;
|
|
1492
1506
|
this.componentsGroups = options._componentsGroups;
|
|
1507
|
+
this.componentsFullSync = options._componentsFullSync;
|
|
1493
1508
|
this.startsWith = options.startsWith;
|
|
1494
1509
|
this.filterQuery = options.filterQuery;
|
|
1495
1510
|
},
|
|
@@ -1670,7 +1685,8 @@ const SyncSpaces = {
|
|
|
1670
1685
|
sourceSpaceId: this.sourceSpaceId,
|
|
1671
1686
|
targetSpaceId: this.targetSpaceId,
|
|
1672
1687
|
oauthToken: this.oauthToken,
|
|
1673
|
-
componentsGroups: this.componentsGroups
|
|
1688
|
+
componentsGroups: this.componentsGroups,
|
|
1689
|
+
componentsFullSync: this.componentsFullSync
|
|
1674
1690
|
});
|
|
1675
1691
|
try {
|
|
1676
1692
|
await syncComponentsInstance.sync();
|
|
@@ -3677,7 +3693,7 @@ program.command(COMMANDS.SELECT).description("Usage to kickstart a boilerplate,
|
|
|
3677
3693
|
program.command(COMMANDS.SYNC).description("Sync schemas, roles, folders and stories between spaces").requiredOption(
|
|
3678
3694
|
"--type <TYPE>",
|
|
3679
3695
|
"Define what will be sync. Can be components, folders, stories, datasources or roles"
|
|
3680
|
-
).requiredOption("--source <SPACE_ID>", "Source space id").requiredOption("--target <SPACE_ID>", "Target space id").option("--starts-with <STARTS_WITH>", "Sync only stories that starts with the given string").option("--filter", "Enable filter options to sync only stories that match the given filter. Required options: --keys; --operations; --values").option("--keys <KEYS>", "Field names in your story object which should be used for filtering. Multiple keys should separated by comma.").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.").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.").option("--components-groups <UUIDs>", "Synchronize components based on their group UUIDs separated by commas").action(async (options) => {
|
|
3696
|
+
).requiredOption("--source <SPACE_ID>", "Source space id").requiredOption("--target <SPACE_ID>", "Target space id").option("--starts-with <STARTS_WITH>", "Sync only stories that starts with the given string").option("--filter", "Enable filter options to sync only stories that match the given filter. Required options: --keys; --operations; --values").option("--keys <KEYS>", "Field names in your story object which should be used for filtering. Multiple keys should separated by comma.").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.").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.").option("--components-groups <UUIDs>", "Synchronize components based on their group UUIDs separated by commas").option("--components-full-sync", "Synchronize components by overriding any property from source to target").action(async (options) => {
|
|
3681
3697
|
console.log(`${chalk.blue("-")} Sync data between spaces
|
|
3682
3698
|
`);
|
|
3683
3699
|
try {
|
|
@@ -3693,9 +3709,11 @@ program.command(COMMANDS.SYNC).description("Sync schemas, roles, folders and sto
|
|
|
3693
3709
|
keys,
|
|
3694
3710
|
operations,
|
|
3695
3711
|
values,
|
|
3696
|
-
componentsGroups
|
|
3712
|
+
componentsGroups,
|
|
3713
|
+
componentsFullSync
|
|
3697
3714
|
} = options;
|
|
3698
3715
|
const _componentsGroups = componentsGroups ? componentsGroups.split(",") : null;
|
|
3716
|
+
const _componentsFullSync = !!componentsFullSync;
|
|
3699
3717
|
const filterQuery = filter ? buildFilterQuery(keys, operations, values) : void 0;
|
|
3700
3718
|
const token = creds.get().token || null;
|
|
3701
3719
|
const _types = type.split(",") || [];
|
|
@@ -3711,7 +3729,8 @@ program.command(COMMANDS.SYNC).description("Sync schemas, roles, folders and sto
|
|
|
3711
3729
|
source,
|
|
3712
3730
|
startsWith,
|
|
3713
3731
|
filterQuery,
|
|
3714
|
-
_componentsGroups
|
|
3732
|
+
_componentsGroups,
|
|
3733
|
+
_componentsFullSync
|
|
3715
3734
|
});
|
|
3716
3735
|
console.log("\n" + chalk.green("\u2713") + " Sync data between spaces successfully completed");
|
|
3717
3736
|
} catch (e) {
|