@@ -344,15 +344,15 @@ const getConfirmation = async () => {
344344 if (!cliConfig.force) {
345345 async function fixConfirmation() {
346346 const answers = await inquirer.prompt(questionPushChangesConfirmation);
347- if(answers.changes !== 'YES' && answers.changes !== 'NO') {
347+ if (answers.changes !== 'YES' && answers.changes !== 'NO') {
348348 return await fixConfirmation();
349349 }
350350
351351 return answers.changes;
352352 }
353353
354354 let answers = await inquirer.prompt(questionPushChanges);
355- if(answers.changes !== 'YES' && answers.changes !== 'NO') {
355+ if (answers.changes !== 'YES' && answers.changes !== 'NO') {
356356 answers.changes = await fixConfirmation();
357357 }
358358
@@ -412,7 +412,7 @@ const approveChanges = async (resource, resourceGetFunction, keys, resourceName,
412412 }
413413
414414 drawTable(changes);
415- if((await getConfirmation()) === true) {
415+ if ((await getConfirmation()) === true) {
416416 return true;
417417 }
418418
@@ -688,6 +688,20 @@ const deleteAttribute = async (collection, attribute, isIndex = false) => {
688688 });
689689}
690690
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+
691705
692706/**
693707 * Check if attribute non-changeable fields has been changed
@@ -715,11 +729,7 @@ const checkAttributeChanges = (remote, local, collection, recraeting = true) =>
715729
716730 if (changeableKeys.includes(key)) {
717731 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)
723733 }
724734 continue;
725735 }
@@ -728,15 +738,7 @@ const checkAttributeChanges = (remote, local, collection, recraeting = true) =>
728738 continue;
729739 }
730740
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)
740742 }
741743
742744 return reason === '' ? undefined : { key: keyName, attribute, reason, action };
@@ -793,7 +795,7 @@ const attributesToCreate = async (remoteAttributes, localAttributes, collection,
793795 log(`Attribute recreation will cause ${chalk.red('loss of data')}`);
794796 }
795797
796- if((await getConfirmation()) !== true) {
798+ if ((await getConfirmation()) !== true) {
797799 return changedAttributes;
798800 }
799801 }
@@ -915,7 +917,7 @@ const pushSettings = async () => {
915917
916918 if (changes.length > 0) {
917919 drawTable(changes);
918- if((await getConfirmation()) !== true) {
920+ if ((await getConfirmation()) !== true) {
919921 success(`Successfully pushed 0 project settings.`);
920922 return;
921923 }
0 commit comments