diff --git a/commands/clone.js b/commands/clone.js index 64562fa..0a31bdd 100644 --- a/commands/clone.js +++ b/commands/clone.js @@ -17,6 +17,7 @@ module.exports = function(program, next) { .option('-p, --project ', 'The project ID that you wish to clone from one database to another.') .option('--forms ', 'A comma-separated value of all the Form ID\'s you wish to clone. If included, then only the provided forms will be cloned.', false) .option('--exclude ', 'A comma-separated value of all the Form ID\'s you wish to exclude in the clone process.', false) + .option('--start-with ', 'The form ID to start cloning from.') .option('-u, --update-existing', 'Update existing Projects and Forms instead of cloning (No OSS).', true) .option('--update-existing-submissions', 'Update existing Submissions when found in the destination (slows down the clone process if set).', false) .option('--src-ca ', 'The TLS certificate authority for the source mongo url') diff --git a/src/Cloner.js b/src/Cloner.js index 8ce82fe..763fd8e 100644 --- a/src/Cloner.js +++ b/src/Cloner.js @@ -905,6 +905,10 @@ class Cloner { process.stdout.write('\n'); process.stdout.write(' - Forms:'); let compsWithEncryptedData = []; + let started = true; + if (this.options.startWith) { + started = false; + } await this.upsertAll('forms', this.formQuery(srcProject), (form) => { process.stdout.write('\n'); process.stdout.write(`- Form: ${form.title} (${form._id})`); @@ -912,7 +916,6 @@ class Cloner { if (this.options.submissionsOnly) { return false; } - await eachComponentAsync(update.components, async(component, path) => { if (component.encrypted) { compsWithEncryptedData.push(path); @@ -923,6 +926,12 @@ class Cloner { update.project = destProject._id; this.migrateFormAccess(src, update); }, async(srcForm, destForm) => { + if (!started && this.options.startWith && srcForm._id.toString() === this.options.startWith) { + started = true; + } + if (!started) { + return false; + } if (this.options.deleteSubmissions) { console.log(`Deleting submissions from ${destForm.title}`); await this.dest.submissions.deleteMany(this.itemQuery({