Skip to content

Commit

Permalink
Add ability to extend reviewers in PR 👥
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrieanKhisbe committed Sep 17, 2024
1 parent 361aeb4 commit 197b7b8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/bump-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ const {syncGithub} = require('./core/github');
const {findLatest} = require('./core/node');
const {makeError, formatEventualSuffix} = require('./core/utils');

const parseArgvToArray = _.pipe(_.split(','), _.compact);

const bumpNodeVersion = async (latestNode, config) => {
process.stdout.write(c.bold.blue(`\n\n⬆️ About to bump node version:\n`));
const nodeVersion = _.trimCharsStart('v', latestNode.version);
Expand Down Expand Up @@ -95,8 +93,8 @@ const commitAndMakePullRequest = config => async options => {
body: _.get('body', pullRequest),
title: _.get('title', pullRequest),
label: config.label,
reviewers: _.pull(await currentUser(), parseArgvToArray(config.reviewers)),
team_reviewers: parseArgvToArray(config.teamReviewers)
reviewers: _.pull(await currentUser(), config.reviewers),
team_reviewers: config.teamReviewers
},
config.token,
config.forceFlag
Expand Down
13 changes: 13 additions & 0 deletions src/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const protocall = require('protocall');
const findUp = require('find-up');
const {command} = require('execa');
const Joi = require('joi');
const {parseArgvToArray} = require('./utils');

const RELEASE_TYPES = ['major', 'minor', 'patch', 'noop'];

Expand Down Expand Up @@ -85,6 +86,18 @@ const resolveConfig = async (config, configPath, argv) => {
base.packageContent = JSON.parse(fs.readFileSync(base.package));
base.local = argv.local;
base.token = await resolveGithubToken(argv);

// Combine reviewers config and extra args, removing leading @ for user, and potential specified orga for teams
base.reviewers = _.pipe(
parseArgvToArray,
_.map(_.trimCharsStart('@'))
)(`${argv.reviewers || ''},${_.join(',', base.reviewers)}`);

base.teamReviewers = _.pipe(
parseArgvToArray,
_.map(_.pipe(_.trimCharsStart('@'), _.split('/'), _.last))
)(`${argv.teamReviewers || ''},${_.join(',', base.teamReviewers)}`);

return base;
};

Expand Down
4 changes: 3 additions & 1 deletion src/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ const makeError = (message, options = {}) => {

const formatEventualSuffix = text => (_.isEmpty(text) ? '' : `\n\n\n-----\n${text}`);

module.exports = {makeError, formatEventualSuffix};
const parseArgvToArray = _.pipe(_.split(','), _.compact);

module.exports = {makeError, formatEventualSuffix, parseArgvToArray};
10 changes: 10 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ const yargs = require('yargs')
describe: 'Optional extra message to attach to the commit and pull request',
string: true,
alias: 'm'
},
reviewers: {
describe: 'Extra reviewers to add to the pull request',
string: true,
alias: 'r'
},
teamReviewers: {
describe: 'Extra team reviewers to add to the pull request',
string: true,
alias: 'R'
}
},
handler: setCommand(UPGRADE)
Expand Down

0 comments on commit 197b7b8

Please sign in to comment.