-
Notifications
You must be signed in to change notification settings - Fork 147
fix: Fixing issues with commands introduced in #403 #440
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,8 @@ | |
|
|
||
| const path = require('path') | ||
| const yargs = require('yargs/yargs') | ||
| const YoctoColors = require('yoctocolors') | ||
| const {hideBin} = require('yargs/helpers') | ||
| const chalk = require('chalk') | ||
| const inquirer = require('inquirer') | ||
|
|
||
| const init = require('./init') | ||
|
|
@@ -70,14 +70,11 @@ function startGeneration(argv) { | |
| } | ||
|
|
||
| async function addContribution(argv) { | ||
| // ensure the config file exists | ||
| await util.configFile.readConfig(argv.config) | ||
|
|
||
| const username = argv._[1] === undefined ? undefined : String(argv._[1]) | ||
| const contributions = argv._[2] | ||
|
|
||
| // Add or update contributor in the config file | ||
| const data = updateContributors(argv, username, contributions) | ||
| const data = await updateContributors(argv, username, contributions) | ||
|
|
||
| argv.contributors = data.contributors | ||
|
|
||
|
|
@@ -90,22 +87,20 @@ async function addContribution(argv) { | |
| } | ||
|
|
||
| async function checkContributors(argv) { | ||
| const configData = await util.configFile.readConfig(argv.config) | ||
|
|
||
| return repo | ||
| .getContributors( | ||
| configData.projectOwner, | ||
| configData.projectName, | ||
| configData.repoType, | ||
| configData.repoHost, | ||
| argv.projectOwner, | ||
| argv.projectName, | ||
| argv.repoType, | ||
| argv.repoHost, | ||
| ) | ||
| .then(repoContributors => { | ||
| const checkKey = repo.getCheckKey(configData.repoType) | ||
| const knownContributions = configData.contributors.reduce((obj, item) => { | ||
| const checkKey = repo.getCheckKey(argv.repoType) | ||
| const knownContributions = argv.contributors.reduce((obj, item) => { | ||
| obj[item[checkKey]] = item.contributions | ||
| return obj | ||
| }, {}) | ||
| const knownContributors = configData.contributors.map( | ||
| const knownContributors = argv.contributors.map( | ||
| contributor => contributor[checkKey], | ||
| ) | ||
|
|
||
|
|
@@ -122,14 +117,17 @@ async function checkContributors(argv) { | |
|
|
||
| if (missingInConfig.length) { | ||
| process.stdout.write( | ||
| chalk.bold('Missing contributors in .all-contributorsrc:\n'), | ||
| YoctoColors.bold('Missing contributors in .all-contributorsrc:\n'), | ||
| ) | ||
| process.stdout.write(` ${missingInConfig.join(', ')}\n`) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We were indenting missing members, but not unknown members. It looked weird, so i removed the indent |
||
| process.stdout.write(`${missingInConfig.join(', ')}\n`) | ||
| } | ||
|
|
||
| if (missingFromRepo.length) { | ||
| process.stdout.write('\n') | ||
| process.stdout.write( | ||
| chalk.bold('Unknown contributors found in .all-contributorsrc:\n'), | ||
| YoctoColors.bold( | ||
| 'Unknown contributors found in .all-contributorsrc:\n', | ||
| ), | ||
| ) | ||
| process.stdout.write(`${missingFromRepo.join(', ')}\n`) | ||
| } | ||
|
|
@@ -169,6 +167,18 @@ function promptForCommand(argv) { | |
| async function run() { | ||
| try { | ||
| const argv = getArgs() | ||
|
|
||
| // Load and merge config file data into argv | ||
| try { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Secondary issue
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tldr; Original PR removed the .config prop of the yargs method because the docs mentioned it didnt support async functions. What i forgot to do apparently, it replace it properly, so the config wasnt loaded like it should have been. This change fixes that correctly by loading the config on execution of the cli command. |
||
| const configData = await util.configFile.readConfig(argv.config) | ||
| Object.assign(argv, configData) | ||
| } catch (error) { | ||
| if (error instanceof SyntaxError || argv.config !== defaultRCFile) { | ||
| throw error | ||
| } | ||
| // If default config file doesn't exist, that's okay | ||
| } | ||
|
|
||
| const command = await promptForCommand(argv) | ||
|
|
||
| switch (command) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Primary issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also another thing i missed in that original PR. I forgot the await here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh perfect. Justin, we can merge this FIRST, and then I'll rebase my tests pr against it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats what i was thinking!