Skip to content

Commit

Permalink
add input sanitization for components-full-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
christianzoppi committed Apr 29, 2024
1 parent 5bc907f commit 5dc5938
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ $ storyblok sync --type <COMMAND> --source <SPACE_ID> --target <SPACE_ID>
* `filter`: sync stories based on the given filter. Required Options: Required options: `--keys`, `--operations`, `--values`
* `keys`: Multiple keys should be separated by comma. Example: `--keys key1,key2`, `--keys key1`
* `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.
* `components-full-sync`: If used, the CLI will override the full component object when synching across spaces.

#### Examples

Expand Down
3 changes: 2 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ program
} = options;

const _componentsGroups = componentsGroups ? componentsGroups.split(",") : null;
const _componentsFullSync = !!componentsFullSync;
const filterQuery = filter ? buildFilterQuery(keys, operations, values) : undefined
const token = creds.get().token || null;

Expand All @@ -345,7 +346,7 @@ program
startsWith,
filterQuery,
_componentsGroups,
componentsFullSync,
_componentsFullSync,
});

console.log("\n" + chalk.green("✓") + " Sync data between spaces successfully completed");
Expand Down
1 change: 1 addition & 0 deletions src/tasks/sync-commands/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class SyncComponents {

mergeComponents (sourceComponent, targetComponent = {}) {
const data = this.componentsFullSync ? {
// This should be the default behavior in a major future version
...sourceComponent
} : {
...sourceComponent,
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const SyncSpaces = {
this.targetSpaceId = options.target
this.oauthToken = options.token
this.componentsGroups = options._componentsGroups
this.componentsFullSync = options.componentsFullSync
this.componentsFullSync = options._componentsFullSync
this.startsWith = options.startsWith
this.filterQuery = options.filterQuery
},
Expand Down

0 comments on commit 5dc5938

Please sign in to comment.