diff --git a/docs/dist/documentation.md b/docs/dist/documentation.md index d459f97fb..b223cc782 100644 --- a/docs/dist/documentation.md +++ b/docs/dist/documentation.md @@ -5346,13 +5346,13 @@ Central class for loading and validating properties from config and auth **Kind**: global constant * [config](#config) - * [.getProperties([silent])](#config.getProperties) ⇒ Promise.<TYPE.Mcdevrc> + * [.getProperties([silent], [isInit])](#config.getProperties) ⇒ Promise.<TYPE.Mcdevrc> * [.checkProperties(properties, [silent])](#config.checkProperties) ⇒ Promise.<(boolean\|Array.<string>)> * [.getDefaultProperties()](#config.getDefaultProperties) ⇒ Promise.<TYPE.Mcdevrc> -### config.getProperties([silent]) ⇒ Promise.<TYPE.Mcdevrc> +### config.getProperties([silent], [isInit]) ⇒ Promise.<TYPE.Mcdevrc> loads central properties from config file **Kind**: static method of [config](#config) @@ -5361,6 +5361,7 @@ loads central properties from config file | Param | Type | Description | | --- | --- | --- | | [silent] | boolean | omit throwing errors and print messages; assuming not silent if not set | +| [isInit] | boolean | don't tell the user to run init | diff --git a/lib/index.js b/lib/index.js index d115fbe32..ee98a608a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -290,7 +290,7 @@ class Mcdev { */ static async initProject(credentialsName) { Util.logger.info('mcdev:: Setting up project'); - const properties = await config.getProperties(!!credentialsName); + const properties = await config.getProperties(!!credentialsName, true); await Init.initProject(properties, credentialsName); } diff --git a/lib/util/config.js b/lib/util/config.js index de2bda103..cab81b61c 100644 --- a/lib/util/config.js +++ b/lib/util/config.js @@ -14,9 +14,10 @@ const config = { * loads central properties from config file * * @param {boolean} [silent] omit throwing errors and print messages; assuming not silent if not set + * @param {boolean} [isInit] don't tell the user to run init * @returns {Promise.} central properties object */ - async getProperties(silent) { + async getProperties(silent, isInit) { if (config.properties) { return config.properties; } @@ -65,7 +66,7 @@ const config = { return; } } - } else if (!silent) { + } else if (!silent && !isInit) { Util.logger.error( `${Util.authFileName} not found. Please run 'mcdev init' to provide the missing credential details.` ); diff --git a/lib/util/init.js b/lib/util/init.js index 368c8b3b5..43980a3ba 100644 --- a/lib/util/init.js +++ b/lib/util/init.js @@ -341,9 +341,9 @@ const Init = { let auth; try { auth = File.readJsonSync(Util.authFileName); - } catch (ex) { - Util.logger.error(`${ex.code}: ${ex.message}`); - return; + } catch { + // file not found + auth = []; } // walk through config credentials and check if the matching credential in the auth file is missing something missingCredentials = Object.keys(properties.credentials).filter( diff --git a/package-lock.json b/package-lock.json index a9f9efff3..379d1b3af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mcdev", - "version": "4.2.0", + "version": "4.2.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mcdev", - "version": "4.2.0", + "version": "4.2.1", "license": "MIT", "dependencies": { "beauty-amp-core": "0.3.7", diff --git a/package.json b/package.json index c6bc4400c..60f770a40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mcdev", - "version": "4.2.0", + "version": "4.2.1", "description": "Accenture Salesforce Marketing Cloud DevTools", "author": "Accenture: joern.berkefeld, douglas.midgley, robert.zimmermann, maciej.barnas", "license": "MIT",