storyblok 3.30.0 → 3.31.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 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
@@ -1039,6 +1039,7 @@ class SyncComponents {
1039
1039
  this.client = api.getClient();
1040
1040
  this.presetsLib = new PresetsLib({ oauthToken: options.oauthToken, targetSpaceId: this.targetSpaceId });
1041
1041
  this.componentsGroups = options.componentsGroups;
1042
+ this.componentsFullSync = options.componentsFullSync;
1042
1043
  }
1043
1044
  async sync() {
1044
1045
  const syncComponentGroupsInstance = new SyncComponentGroups({
@@ -1171,7 +1172,10 @@ class SyncComponents {
1171
1172
  return this.client.put(`spaces/${spaceId}/components/${componentId}`, payload);
1172
1173
  }
1173
1174
  mergeComponents(sourceComponent, targetComponent = {}) {
1174
- const data = {
1175
+ const data = this.componentsFullSync ? {
1176
+ // This should be the default behavior in a major future version
1177
+ ...sourceComponent
1178
+ } : {
1175
1179
  ...sourceComponent,
1176
1180
  ...targetComponent
1177
1181
  };
@@ -1490,6 +1494,7 @@ const SyncSpaces = {
1490
1494
  this.targetSpaceId = options.target;
1491
1495
  this.oauthToken = options.token;
1492
1496
  this.componentsGroups = options._componentsGroups;
1497
+ this.componentsFullSync = options._componentsFullSync;
1493
1498
  this.startsWith = options.startsWith;
1494
1499
  this.filterQuery = options.filterQuery;
1495
1500
  },
@@ -1670,7 +1675,8 @@ const SyncSpaces = {
1670
1675
  sourceSpaceId: this.sourceSpaceId,
1671
1676
  targetSpaceId: this.targetSpaceId,
1672
1677
  oauthToken: this.oauthToken,
1673
- componentsGroups: this.componentsGroups
1678
+ componentsGroups: this.componentsGroups,
1679
+ componentsFullSync: this.componentsFullSync
1674
1680
  });
1675
1681
  try {
1676
1682
  await syncComponentsInstance.sync();
@@ -3677,7 +3683,7 @@ program.command(COMMANDS.SELECT).description("Usage to kickstart a boilerplate,
3677
3683
  program.command(COMMANDS.SYNC).description("Sync schemas, roles, folders and stories between spaces").requiredOption(
3678
3684
  "--type <TYPE>",
3679
3685
  "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) => {
3686
+ ).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
3687
  console.log(`${chalk.blue("-")} Sync data between spaces
3682
3688
  `);
3683
3689
  try {
@@ -3693,9 +3699,11 @@ program.command(COMMANDS.SYNC).description("Sync schemas, roles, folders and sto
3693
3699
  keys,
3694
3700
  operations,
3695
3701
  values,
3696
- componentsGroups
3702
+ componentsGroups,
3703
+ componentsFullSync
3697
3704
  } = options;
3698
3705
  const _componentsGroups = componentsGroups ? componentsGroups.split(",") : null;
3706
+ const _componentsFullSync = !!componentsFullSync;
3699
3707
  const filterQuery = filter ? buildFilterQuery(keys, operations, values) : void 0;
3700
3708
  const token = creds.get().token || null;
3701
3709
  const _types = type.split(",") || [];
@@ -3711,7 +3719,8 @@ program.command(COMMANDS.SYNC).description("Sync schemas, roles, folders and sto
3711
3719
  source,
3712
3720
  startsWith,
3713
3721
  filterQuery,
3714
- _componentsGroups
3722
+ _componentsGroups,
3723
+ _componentsFullSync
3715
3724
  });
3716
3725
  console.log("\n" + chalk.green("\u2713") + " Sync data between spaces successfully completed");
3717
3726
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storyblok",
3
- "version": "3.30.0",
3
+ "version": "3.31.0",
4
4
  "description": "A simple CLI to start Storyblok from your command line.",
5
5
  "repository": {
6
6
  "type": "git",