-
Notifications
You must be signed in to change notification settings - Fork 2
frodo config import --compare-and-delete , --dry-run flag #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
e60ac69
fd786e2
763db1b
e17b69e
264a01d
7c049b9
aceffae
d9f547a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| //------------------ Modified file by Sean for test import/promote command-------------original file is in config-import-backup.ts | ||
|
|
||
| import { state } from '@rockcarver/frodo-lib'; | ||
| import { Option } from 'commander'; | ||
|
|
||
| import * as s from '../../help/SampleData'; | ||
| import { getTokens } from '../../ops/AuthenticateOps'; | ||
| import { | ||
| compareWithMasterDirectoryAndDeleteFromCloud, | ||
| compareWithMasterFileAndDeleteFromCloud, | ||
| importEntityfromFile, | ||
| importEverythingFromFile, | ||
| importEverythingFromFiles, | ||
|
|
@@ -55,6 +59,7 @@ export default function setup() { | |
| 'Import all scripts including the default scripts.' | ||
| ) | ||
| ) | ||
|
|
||
|
||
| .addOption( | ||
| new Option( | ||
| '--include-active-values', | ||
|
|
@@ -73,6 +78,18 @@ export default function setup() { | |
| 'Import global entity. Ignored with -a and -A.' | ||
| ) | ||
| ) | ||
| .addOption( | ||
| new Option( | ||
| '--delete-and-import', | ||
|
||
| 'Deletes whatever added to the current cloud after comparison from --compare flag. Then it imports master config file/directory back to cloud. Only run when --compare flag is on.' | ||
|
||
| ) | ||
| ) | ||
| .addOption( | ||
| new Option( | ||
| '--compare', | ||
| 'This export config data from the current tenant as an object, and it compares whatever changes between this object and the config data from the master file/directory.' | ||
|
||
| ) | ||
| ) | ||
| .addHelpText( | ||
| 'after', | ||
| `How Frodo handles secrets:\n`['brightGreen'] + | ||
|
|
@@ -112,8 +129,17 @@ export default function setup() { | |
| program.help(); | ||
| process.exitCode = 1; | ||
| } | ||
| if (options.deleteAndImport && !options.compare) { | ||
| printMessage( | ||
| '--compare flag is needed to run --delete-and-import', | ||
| 'error' | ||
| ); | ||
| program.help(); | ||
| process.exitCode = 1; | ||
| } | ||
|
|
||
| // --all -a | ||
skootrivir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| else if (options.all && (await getTokens())) { | ||
| else if (options.all && !options.compare && (await getTokens())) { | ||
| verboseMessage('Exporting everything from a single file...'); | ||
| const outcome = await importEverythingFromFile(options.file, { | ||
| reUuidJourneys: options.reUuidJourneys, | ||
|
|
@@ -125,6 +151,34 @@ export default function setup() { | |
| }); | ||
| if (!outcome) process.exitCode = 1; | ||
| } | ||
| // What I added single file, compare and delete | ||
| else if (options.all && options.compare && (await getTokens())) { | ||
| verboseMessage('compare and delete option in '); | ||
|
||
| const outcome = await compareWithMasterFileAndDeleteFromCloud( | ||
| options.file, // Master File | ||
| options.deleteAndImport, //what if | ||
| { | ||
| useStringArrays: false, | ||
| noDecode: undefined, | ||
| coords: false, // we are not going to get coords value in case master does not have coord values. | ||
| includeDefault: undefined, | ||
| includeActiveValues: false, //we are not going to get active values from tenant in comparison to be safe. | ||
| target: undefined, | ||
| includeReadOnly: undefined, | ||
| onlyRealm: undefined, | ||
| onlyGlobal: undefined, | ||
| }, | ||
| { | ||
| reUuidJourneys: options.reUuidJourneys, | ||
| reUuidScripts: options.reUuidScripts, | ||
| cleanServices: options.cleanServices, | ||
| includeDefault: options.default, | ||
| includeActiveValues: options.includeActiveValues, | ||
| source: options.source, | ||
| } | ||
| ); | ||
| if (!outcome) process.exitCode = 1; | ||
| } | ||
| // require --directory -D for all-separate function | ||
| else if (options.allSeparate && !state.getDirectory()) { | ||
| printMessage( | ||
|
|
@@ -135,7 +189,11 @@ export default function setup() { | |
| process.exitCode = 1; | ||
| } | ||
| // --all-separate -A | ||
| else if (options.allSeparate && (await getTokens())) { | ||
| else if ( | ||
| options.allSeparate && | ||
| !options.compare && | ||
| (await getTokens()) | ||
| ) { | ||
| verboseMessage('Importing everything from separate files...'); | ||
| const outcome = await importEverythingFromFiles({ | ||
| reUuidJourneys: options.reUuidJourneys, | ||
|
|
@@ -147,6 +205,39 @@ export default function setup() { | |
| }); | ||
| if (!outcome) process.exitCode = 1; | ||
| } | ||
| //what I added | ||
|
||
| else if ( | ||
| options.allSeparate && | ||
| options.compare && | ||
| (await getTokens()) | ||
| ) { | ||
| verboseMessage('Export-compare-delete-import option in ...'); | ||
|
||
| const outcome = await compareWithMasterDirectoryAndDeleteFromCloud( | ||
| options.deleteAndImport, //what-if | ||
| { | ||
| // export options | ||
| useStringArrays: false, | ||
| noDecode: false, | ||
| coords: false, // we are not going to get coords value in case master does not have coord values. | ||
| includeDefault: undefined, | ||
| includeActiveValues: false, //we are not going to get active values from tenant in comparison to be safe. | ||
| target: undefined, | ||
| includeReadOnly: undefined, | ||
| onlyRealm: undefined, | ||
| onlyGlobal: undefined, | ||
| }, | ||
| { | ||
| //import options | ||
| reUuidJourneys: options.reUuidJourneys, | ||
| reUuidScripts: options.reUuidScripts, | ||
| cleanServices: options.cleanServices, | ||
| includeDefault: options.default, | ||
| includeActiveValues: options.includeActiveValues, | ||
| source: options.source, | ||
| } | ||
| ); | ||
| if (!outcome) process.exitCode = 1; | ||
| } | ||
| // Import entity from file | ||
| else if (options.file && (await getTokens())) { | ||
| verboseMessage('Importing config entity from file...'); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.