diff --git a/src/cli.ts b/src/cli.ts index 9173fe8..fa877ed 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -304,6 +304,7 @@ program .option('--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 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 ", "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) => { console.log(`${chalk.blue("-")} Sync data between spaces\n`); @@ -321,10 +322,12 @@ program keys, operations, values, - componentsGroups + componentsGroups, + componentsFullSync } = options; const _componentsGroups = componentsGroups ? componentsGroups.split(",") : null; + console.log(componentsFullSync) const filterQuery = filter ? buildFilterQuery(keys, operations, values) : undefined const token = creds.get().token || null; @@ -343,6 +346,7 @@ program startsWith, filterQuery, _componentsGroups, + componentsFullSync, }); console.log("\n" + chalk.green("✓") + " Sync data between spaces successfully completed"); diff --git a/src/tasks/sync-commands/components.js b/src/tasks/sync-commands/components.js index 5c9beed..487addb 100644 --- a/src/tasks/sync-commands/components.js +++ b/src/tasks/sync-commands/components.js @@ -20,6 +20,7 @@ class SyncComponents { this.client = api.getClient() this.presetsLib = new PresetsLib({ oauthToken: options.oauthToken, targetSpaceId: this.targetSpaceId }) this.componentsGroups = options.componentsGroups + this.componentsFullSync = options.componentsFullSync } async sync () { @@ -201,7 +202,10 @@ class SyncComponents { } mergeComponents (sourceComponent, targetComponent = {}) { - const data = { + console.log(this.componentsFullSync) + const data = this.componentsFullSync ? { + ...sourceComponent + } : { ...sourceComponent, ...targetComponent } diff --git a/src/tasks/sync.js b/src/tasks/sync.js index 95a39fb..7611d06 100644 --- a/src/tasks/sync.js +++ b/src/tasks/sync.js @@ -16,6 +16,7 @@ const SyncSpaces = { this.targetSpaceId = options.target this.oauthToken = options.token this.componentsGroups = options._componentsGroups + this.componentsFullSync = options.componentsFullSync this.startsWith = options.startsWith this.filterQuery = options.filterQuery }, @@ -232,7 +233,8 @@ const SyncSpaces = { sourceSpaceId: this.sourceSpaceId, targetSpaceId: this.targetSpaceId, oauthToken: this.oauthToken, - componentsGroups: this.componentsGroups + componentsGroups: this.componentsGroups, + componentsFullSync: this.componentsFullSync }) try {