@@ -344,15 +344,15 @@ const getConfirmation = async () => {
344
344
if (!cliConfig.force) {
345
345
async function fixConfirmation() {
346
346
const answers = await inquirer.prompt(questionPushChangesConfirmation);
347
- if(answers.changes !== 'YES' && answers.changes !== 'NO') {
347
+ if (answers.changes !== 'YES' && answers.changes !== 'NO') {
348
348
return await fixConfirmation();
349
349
}
350
350
351
351
return answers.changes;
352
352
}
353
353
354
354
let answers = await inquirer.prompt(questionPushChanges);
355
- if(answers.changes !== 'YES' && answers.changes !== 'NO') {
355
+ if (answers.changes !== 'YES' && answers.changes !== 'NO') {
356
356
answers.changes = await fixConfirmation();
357
357
}
358
358
@@ -412,7 +412,7 @@ const approveChanges = async (resource, resourceGetFunction, keys, resourceName,
412
412
}
413
413
414
414
drawTable(changes);
415
- if((await getConfirmation()) === true) {
415
+ if ((await getConfirmation()) === true) {
416
416
return true;
417
417
}
418
418
@@ -688,6 +688,20 @@ const deleteAttribute = async (collection, attribute, isIndex = false) => {
688
688
});
689
689
}
690
690
691
+ const compareAttribute = (remote, local, reason, key) => {
692
+ if (Array.isArray(remote) && Array.isArray(local)) {
693
+ if (JSON.stringify(remote) !== JSON.stringify(local)) {
694
+ const bol = reason === '' ? '' : '\n';
695
+ reason += `${bol}${key} changed from ${chalk.red(remote)} to ${chalk.green(local)}`;
696
+ }
697
+ } else if (remote !== local) {
698
+ const bol = reason === '' ? '' : '\n';
699
+ reason += `${bol}${key} changed from ${chalk.red(remote)} to ${chalk.green(local)}`;
700
+ }
701
+
702
+ return reason
703
+ }
704
+
691
705
692
706
/**
693
707
* Check if attribute non-changeable fields has been changed
@@ -715,11 +729,7 @@ const checkAttributeChanges = (remote, local, collection, recraeting = true) =>
715
729
716
730
if (changeableKeys.includes(key)) {
717
731
if (!recraeting) {
718
- if (remote[key] !== local[key]) {
719
- const bol = reason === '' ? '' : '\n';
720
- reason += `${bol}${key} changed from ${chalk.red(remote[key])} to ${chalk.green(local[key])}`;
721
- attribute = local;
722
- }
732
+ reason += compareAttribute(remote[key], local[key], reason, key)
723
733
}
724
734
continue;
725
735
}
@@ -728,15 +738,7 @@ const checkAttributeChanges = (remote, local, collection, recraeting = true) =>
728
738
continue;
729
739
}
730
740
731
- if (Array.isArray(remote[key]) && Array.isArray(local[key])) {
732
- if (JSON.stringify(remote[key]) !== JSON.stringify(local[key])) {
733
- const bol = reason === '' ? '' : '\n';
734
- reason += `${bol}${key} changed from ${chalk.red(remote[key])} to ${chalk.green(local[key])}`;
735
- }
736
- } else if (remote[key] !== local[key]) {
737
- const bol = reason === '' ? '' : '\n';
738
- reason += `${bol}${key} changed from ${chalk.red(remote[key])} to ${chalk.green(local[key])}`;
739
- }
741
+ reason += compareAttribute(remote[key], local[key], reason, key)
740
742
}
741
743
742
744
return reason === '' ? undefined : { key: keyName, attribute, reason, action };
@@ -793,7 +795,7 @@ const attributesToCreate = async (remoteAttributes, localAttributes, collection,
793
795
log(`Attribute recreation will cause ${chalk.red('loss of data')}`);
794
796
}
795
797
796
- if((await getConfirmation()) !== true) {
798
+ if ((await getConfirmation()) !== true) {
797
799
return changedAttributes;
798
800
}
799
801
}
@@ -915,7 +917,7 @@ const pushSettings = async () => {
915
917
916
918
if (changes.length > 0) {
917
919
drawTable(changes);
918
- if((await getConfirmation()) !== true) {
920
+ if ((await getConfirmation()) !== true) {
919
921
success(`Successfully pushed 0 project settings.`);
920
922
return;
921
923
}
0 commit comments