Skip to content
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

#612: fixes mcdev init for joining an existing project #613

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/dist/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5346,13 +5346,13 @@ Central class for loading and validating properties from config and auth
**Kind**: global constant

* [config](#config)
* [.getProperties([silent])](#config.getProperties) ⇒ <code>Promise.&lt;TYPE.Mcdevrc&gt;</code>
* [.getProperties([silent], [isInit])](#config.getProperties) ⇒ <code>Promise.&lt;TYPE.Mcdevrc&gt;</code>
* [.checkProperties(properties, [silent])](#config.checkProperties) ⇒ <code>Promise.&lt;(boolean\|Array.&lt;string&gt;)&gt;</code>
* [.getDefaultProperties()](#config.getDefaultProperties) ⇒ <code>Promise.&lt;TYPE.Mcdevrc&gt;</code>

<a name="config.getProperties"></a>

### config.getProperties([silent]) ⇒ <code>Promise.&lt;TYPE.Mcdevrc&gt;</code>
### config.getProperties([silent], [isInit]) ⇒ <code>Promise.&lt;TYPE.Mcdevrc&gt;</code>
loads central properties from config file

**Kind**: static method of [<code>config</code>](#config)
Expand All @@ -5361,6 +5361,7 @@ loads central properties from config file
| Param | Type | Description |
| --- | --- | --- |
| [silent] | <code>boolean</code> | omit throwing errors and print messages; assuming not silent if not set |
| [isInit] | <code>boolean</code> | don't tell the user to run init |

<a name="config.checkProperties"></a>

Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
5 changes: 3 additions & 2 deletions lib/util/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.<TYPE.Mcdevrc>} central properties object
*/
async getProperties(silent) {
async getProperties(silent, isInit) {
if (config.properties) {
return config.properties;
}
Expand Down Expand Up @@ -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.`
);
Expand Down
6 changes: 3 additions & 3 deletions lib/util/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down