Repository: Accenture/sfmc-devtools
Pull request #507 (2022-11-03 16:47:10)

4.1.6
release


Patch:
diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml
index 25e6dd22..3faaba98 100644
--- a/.github/ISSUE_TEMPLATE/bug.yml
+++ b/.github/ISSUE_TEMPLATE/bug.yml
@@ -39,6 +39,7 @@ body:
           label: Version
           description: What version of our software are you running? (mcdev --version)
           options:
+              - 4.1.6
               - 4.1.5
               - 4.1.4
               - 4.1.3
diff --git a/README.md b/README.md
index 549f148c..cfc7c416 100644
--- a/README.md
+++ b/README.md
@@ -123,7 +123,7 @@ If you experience issues installing Accenture SFMC DevTools, please check out th
 1. Install Accenture SFMC DevTools by running `npm install -g mcdev` (prefix with `sudo` on MacOS)
    - If you get an error, please see the below troubleshooting section.
 
-When completed run `mcdev --version` and it will show you which version you installed (e.g. `4.1.5`).
+When completed run `mcdev --version` and it will show you which version you installed (e.g. `4.1.6`).
 
 > **_Side note for proud nerds_:**
 >
@@ -277,10 +277,10 @@ _Note: Regardless of which tag or branch you install_
 **Install specific version (using a version tag on npm):**
 
 ```bash
-npm install -g mcdev@4.1.5
+npm install -g mcdev@4.1.6
 ```
 
-**Warning**: When you used the above method to install Accenture SFMC DevTools for a specific version or tag, trying to [update Accenture SFMC DevTools](#updating-mcdev) might not download the most recently published official version but instead stay on the version or branch you previously selected (in the above examples: develop, 4.1.5)!
+**Warning**: When you used the above method to install Accenture SFMC DevTools for a specific version or tag, trying to [update Accenture SFMC DevTools](#updating-mcdev) might not download the most recently published official version but instead stay on the version or branch you previously selected (in the above examples: develop, 4.1.6)!
 
 > **Note**: The version is currently _not_ updated on the developer branch until a new release is published. Hence, you will not see a change if you run `mcdev --version`.
 
@@ -1493,7 +1493,7 @@ Assuming you cloned Accenture SFMC DevTools into `C:\repos\sfmc-devtools\` (or `
 
 This should tell npm to create a symlink to your cloned local directoty, allowing you to see updates you make in your mcdev repo instantly.
 
-To test your new **global** developer setup, run `mcdev --version` in CLI which should return the current version (e.g. `4.1.5`). Then, go into your mcdev repo and update the version with the suffix `-dev`, e.g. to `4.1.5-dev` and then run `mcdev --version` again to verify that your change propagates instantly.
+To test your new **global** developer setup, run `mcdev --version` in CLI which should return the current version (e.g. `4.1.6`). Then, go into your mcdev repo and update the version with the suffix `-dev`, e.g. to `4.1.6-dev` and then run `mcdev --version` again to verify that your change propagates instantly.
 
 > **Not recommended:** Alternatively, you can install it locally only by opening a terminal in your project directory and executing `npm install --save-dev "C:\repos\sfmc-devtools"`
 > To run the local version you need to prepend "npx" before your commands, e.g. `npx mcdev --version`
@@ -1531,7 +1531,7 @@ The following explains how you _could_ install it locally for certain edge cases
 4. Afterwards, install Accenture SFMC DevTools by running `npm install --save-dev mcdev`
    - If you get an error, please see the below troubleshooting section.
 
-When completed run `mcdev --version` and it will show you which version you installed (e.g. `4.1.5`).
+When completed run `mcdev --version` and it will show you which version you installed (e.g. `4.1.6`).
 
 ### 9.3. NPM Scripts
 
diff --git a/docs/dist/documentation.md b/docs/dist/documentation.md
index 10354a14..e1c98e31 100644
--- a/docs/dist/documentation.md
+++ b/docs/dist/documentation.md
@@ -4790,7 +4790,8 @@ CLI helper class
 
 * [Cli](#Cli)
     * [.initMcdevConfig()](#Cli.initMcdevConfig) ⇒ <code>Promise.&lt;boolean&gt;</code>
-    * [.addExtraCredential(properties)](#Cli.addExtraCredential) ⇒ <code>Promise.&lt;void&gt;</code>
+    * [.addExtraCredential(properties)](#Cli.addExtraCredential) ⇒ <code>Promise.&lt;(boolean\|string)&gt;</code>
+    * [.logExistingCredentials(properties)](#Cli.logExistingCredentials) ⇒ <code>void</code>
     * [.updateCredential(properties, credName)](#Cli.updateCredential) ⇒ <code>Promise.&lt;boolean&gt;</code>
     * [.getCredentialObject(properties, target, [isCredentialOnly], [allowAll])](#Cli.getCredentialObject) ⇒ <code>Promise.&lt;TYPE.BuObject&gt;</code>
     * [._selectBU(properties, [credential], [isCredentialOnly], [allowAll])](#Cli._selectBU) ⇒ <code>Promise.&lt;Array&gt;</code>
@@ -4810,11 +4811,22 @@ loads default config and adds first credential
 **Returns**: <code>Promise.&lt;boolean&gt;</code> - success of init  
 <a name="Cli.addExtraCredential"></a>
 
-### Cli.addExtraCredential(properties) ⇒ <code>Promise.&lt;void&gt;</code>
+### Cli.addExtraCredential(properties) ⇒ <code>Promise.&lt;(boolean\|string)&gt;</code>
 Extends template file for properties.json
 
 **Kind**: static method of [<code>Cli</code>](#Cli)  
-**Returns**: <code>Promise.&lt;void&gt;</code> - -  
+**Returns**: <code>Promise.&lt;(boolean\|string)&gt;</code> - status  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| properties | <code>TYPE.Mcdevrc</code> | config file's json |
+
+<a name="Cli.logExistingCredentials"></a>
+
+### Cli.logExistingCredentials(properties) ⇒ <code>void</code>
+helper that logs to cli which credentials are already existing in our config file
+
+**Kind**: static method of [<code>Cli</code>](#Cli)  
 
 | Param | Type | Description |
 | --- | --- | --- |
diff --git a/lib/util/cli.js b/lib/util/cli.js
index 358d04b2..78be773d 100644
--- a/lib/util/cli.js
+++ b/lib/util/cli.js
@@ -33,7 +33,7 @@ const Cli = {
      * Extends template file for properties.json
      *
      * @param {TYPE.Mcdevrc} properties config file's json
-     * @returns {Promise.<void>} -
+     * @returns {Promise.<boolean | string>} status
      */
     async addExtraCredential(properties) {
         const skipInteraction = Util.skipInteraction;
@@ -41,21 +41,31 @@ const Cli = {
             // return null here to avoid seeing 2 error messages for the same issue
             return null;
         } else {
-            Util.logger.info('Found the following credentials in your config file:');
-            for (const cred in properties.credentials) {
-                if (Object.prototype.hasOwnProperty.call(properties.credentials, cred)) {
-                    Util.logger.info(` - ${cred}`);
-                }
-            }
+            this.logExistingCredentials(properties);
             Util.logger.info('\nPlease enter your new credentials');
             if (skipInteraction && properties.credentials[skipInteraction.credentialName]) {
                 Util.logger.error(
                     `Credential '${skipInteraction.credentialName}' already existing. If you tried updating please provide run 'mcdev init ${skipInteraction.credentialName}'`
                 );
+                return null;
             }
             return this._setCredential(properties, null);
         }
     },
+    /**
+     * helper that logs to cli which credentials are already existing in our config file
+     *
+     * @param {TYPE.Mcdevrc} properties config file's json
+     * @returns {void}
+     */
+    logExistingCredentials(properties) {
+        Util.logger.info('Found the following credentials in your config file:');
+        for (const cred in properties.credentials) {
+            if (Object.prototype.hasOwnProperty.call(properties.credentials, cred)) {
+                Util.logger.info(` - ${cred}`);
+            }
+        }
+    },
     /**
      * Extends template file for properties.json
      * update credentials
@@ -245,7 +255,7 @@ const Cli = {
                     inputData = skipInteraction;
                 } else {
                     throw new Error(
-                        '--skipInteraction flag found but missing required input for client_id,client_secret,auth_url,account_id,credentialName'
+                        '--skipInteraction flag found but not defined for all required inputs: client_id,client_secret,auth_url,account_id,credentialName'
                     );
                 }
             } else {
diff --git a/lib/util/init.git.js b/lib/util/init.git.js
index eb1cbb96..c7a251d9 100644
--- a/lib/util/init.git.js
+++ b/lib/util/init.git.js
@@ -100,7 +100,7 @@ const Init = {
                     `Your remote Git repository is still empty and ready to store your initial backup. Hint: This is the server version of the repo which you share with your team.`
                 );
                 let responses;
-                if (!skipInteraction || !skipInteraction.gitPush !== 'yes') {
+                if (!skipInteraction) {
                     responses = await inquirer.prompt([
                         {
                             type: 'confirm',
diff --git a/lib/util/init.js b/lib/util/init.js
index a7b3cddc..29ce500f 100644
--- a/lib/util/init.js
+++ b/lib/util/init.js
@@ -31,13 +31,19 @@ const Init = {
         if ((await File.pathExists(Util.configFileName)) && properties) {
             // config exists
             if (credentialName) {
-                Util.logger.info(`Updating credential '${credentialName}'`);
                 // update-credential mode
                 if (!properties.credentials[credentialName]) {
-                    Util.logger.error(`Could not find credential '${credentialName}'`);
+                    Util.logger.error(
+                        `Could not update credential '${credentialName}' because it was not found in your config. Please check your spelling and try again.`
+                    );
+                    Cli.logExistingCredentials(properties);
+                    if (skipInteraction) {
+                        return;
+                    }
                     const response = await Cli._selectBU(properties, null, true);
                     credentialName = response.credential;
                 }
+                Util.logger.info(`Updating existing credential '${credentialName}'`);
                 let error;
                 do {
                     error = false;
@@ -48,8 +54,14 @@ const Init = {
                         } else {
                             error = true;
                         }
-                    } catch {
-                        error = true;
+                    } catch (ex) {
+                        if (skipInteraction) {
+                            Util.logger.error(ex.message);
+                            return;
+                        } else {
+                            // retry
+                            error = true;
+                        }
                     }
                 } while (error && !skipInteraction);
                 Util.logger.debug('reloading config');
@@ -180,7 +192,7 @@ const Init = {
     async _downloadAllBUs(bu, gitStatus) {
         const skipInteraction = Util.skipInteraction;
         let responses;
-        if (!skipInteraction || skipInteraction.backupBUs !== 'yes') {
+        if (!skipInteraction) {
             responses = await inquirer.prompt([
                 {
                     type: 'confirm',
diff --git a/package-lock.json b/package-lock.json
index 251caf35..e25a1173 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
 {
     "name": "mcdev",
-    "version": "4.1.5",
+    "version": "4.1.6",
     "lockfileVersion": 2,
     "requires": true,
     "packages": {
         "": {
             "name": "mcdev",
-            "version": "4.1.5",
+            "version": "4.1.6",
             "license": "MIT",
             "dependencies": {
                 "cli-progress": "3.11.2",
@@ -47,7 +47,7 @@
                 "jsdoc-to-markdown": "7.1.1",
                 "lint-staged": "13.0.3",
                 "mocha": "10.1.0",
-                "mock-fs": "5.1.4",
+                "mock-fs": "5.2.0",
                 "npm-check": "6.0.1",
                 "npm-run-all": "4.1.5",
                 "prettier-eslint": "15.0.1"
@@ -5696,9 +5696,9 @@
             }
         },
         "node_modules/mock-fs": {
-            "version": "5.1.4",
-            "resolved": "https://registry.npmjs.org/mock-fs/-/mock-fs-5.1.4.tgz",
-            "integrity": "sha512-sudhLjCjX37qWIcAlIv1OnAxB2wI4EmXByVuUjILh1rKGNGpGU8GNnzw+EAbrhdpBe0TL/KONbK1y3RXZk8SxQ==",
+            "version": "5.2.0",
+            "resolved": "https://registry.npmjs.org/mock-fs/-/mock-fs-5.2.0.tgz",
+            "integrity": "sha512-2dF2R6YMSZbpip1V1WHKGLNjr/k48uQClqMVb5H3MOvwc9qhYis3/IWbj02qIg/Y8MDXKFF4c5v0rxx2o6xTZw==",
             "dev": true,
             "engines": {
                 "node": ">=12.0.0"
@@ -12935,9 +12935,9 @@
             }
         },
         "mock-fs": {
-            "version": "5.1.4",
-            "resolved": "https://registry.npmjs.org/mock-fs/-/mock-fs-5.1.4.tgz",
-            "integrity": "sha512-sudhLjCjX37qWIcAlIv1OnAxB2wI4EmXByVuUjILh1rKGNGpGU8GNnzw+EAbrhdpBe0TL/KONbK1y3RXZk8SxQ==",
+            "version": "5.2.0",
+            "resolved": "https://registry.npmjs.org/mock-fs/-/mock-fs-5.2.0.tgz",
+            "integrity": "sha512-2dF2R6YMSZbpip1V1WHKGLNjr/k48uQClqMVb5H3MOvwc9qhYis3/IWbj02qIg/Y8MDXKFF4c5v0rxx2o6xTZw==",
             "dev": true
         },
         "moo": {
diff --git a/package.json b/package.json
index c3e262e9..16658673 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "mcdev",
-    "version": "4.1.5",
+    "version": "4.1.6",
     "description": "Accenture Salesforce Marketing Cloud DevTools",
     "author": "Accenture: joern.berkefeld, douglas.midgley, robert.zimmermann, maciej.barnas",
     "license": "MIT",
@@ -75,7 +75,7 @@
         "jsdoc-to-markdown": "7.1.1",
         "lint-staged": "13.0.3",
         "mocha": "10.1.0",
-        "mock-fs": "5.1.4",
+        "mock-fs": "5.2.0",
         "npm-check": "6.0.1",
         "npm-run-all": "4.1.5",
         "prettier-eslint": "15.0.1"


Test patch:
diff --git a/test/mockRoot/.mcdevrc.json b/test/mockRoot/.mcdevrc.json
index 7546e065..2d8149b4 100644
--- a/test/mockRoot/.mcdevrc.json
+++ b/test/mockRoot/.mcdevrc.json
@@ -63,5 +63,5 @@
             "triggeredSendDefinition"
         ]
     },
-    "version": "4.1.5"
+    "version": "4.1.6"
 }