// Provide output expressing which files are failing formatting.
info.group('\nThe following files are out of format:');
for(constfileoffailures){
info(` - ${file}`);
}
info.groupEnd();
info();
// If the command is run in a non-CI environment, prompt to format the files immediately.
letrunFormatter=false;
if(!process.env['CI']){
runFormatter=yieldpromptConfirm('Format the files now?',true);
}
if(runFormatter){
// Format the failing files as requested.
yieldformatFiles(failures);
process.exit(0);
}
else{
// Inform user how to format files in the future.
info();
info(`To format the failing file run the following command:`);
info(` yarn ng-dev format files ${failures.join(' ')}`);
process.exit(1);
}
}
else{
info('√ All files correctly formatted.');
process.exit(0);
}
});
}
/** Build the parser for the format commands. */
functionbuildFormatParser(localYargs){
returnlocalYargs.help()
.strict()
.demandCommand()
.option('check',{
type:'boolean',
default:process.env['CI']?true:false,
description:'Run the formatter to check formatting rather than updating code format'
})
.command('all','Run the formatter on all files in the repository',args=>args,({check})=>{
constexecutionCmd=check?checkFiles:formatFiles;
executionCmd(allFiles());
})
.command('changed [shaOrRef]','Run the formatter on files changed since the provided sha/ref',args=>args.positional('shaOrRef',{type:'string'}),({shaOrRef,check})=>{
constsha=shaOrRef||'master';
constexecutionCmd=check?checkFiles:formatFiles;
executionCmd(allChangedFilesSince(sha));
})
.command('staged','Run the formatter on all staged files',args=>args,({check})=>{
constexecutionCmd=check?checkFiles:formatFiles;
executionCmd(allStagedFiles());
})
.command('files <files..>','Run the formatter on provided files',args=>args.positional('files',{array:true,type:'string'}),({check,files})=>{
.command('discover-new-conflicts <pr-number>','Check if a pending PR causes new conflicts for other pending PRs',buildDiscoverNewConflictsCommand,handleDiscoverNewConflictsCommand)
.command('rebase <pr-number>','Rebase a pending PR and push the rebased commits back to Github',buildRebaseCommand,handleRebaseCommand)
constpullRequest=yieldthis.pushChangesToForkAndCreatePullRequest(pullRequestBaseBranch,`release-stage-${newVersion}`,`Bump version to "v${newVersion}" with changelog.`);
info(green(' ✓ Release staging pull request has been created.'));
info(yellow(` Please ask team members to review: ${pullRequest.url}.`));
error(yellow(` ✘ Could not cherry-pick release notes for v${newVersion}.`));
error(yellow(` Please copy the release notes manually into the "${nextBranch}" branch.`));
returnfalse;
}
// Create a cherry-pick pull request that should be merged by the caretaker.
const{url}=yieldthis.pushChangesToForkAndCreatePullRequest(nextBranch,`changelog-cherry-pick-${newVersion}`,commitMessage,`Cherry-picks the changelog from the "${stagingBranch}" branch to the next `+
`branch (${nextBranch}).`);
info(green(` ✓ Pull request for cherry-picking the changelog into "${nextBranch}" `+
'has been created.'));
info(yellow(` Please ask team members to review: ${url}.`));
nextPullRequestMessage+=`\n\nAlso this PR cherry-picks the changelog for `+
`v${newVersion} into the ${nextBranch} branch so that the changelog is up to date.`;
}
else{
error(yellow(` ✘ Could not cherry-pick release notes for v${newVersion}.`));
error(yellow(` Please copy the release note manually into "${nextBranch}".`));
}
constnextUpdatePullRequest=yieldthis.pushChangesToForkAndCreatePullRequest(nextBranch,`next-release-train-${newNextVersion}`,`Update next branch to reflect new release-train "v${newNextVersion}".`,nextPullRequestMessage);
info(green(` ✓ Pull request for updating the "${nextBranch}" branch has been created.`));
info(yellow(` Please ask team members to review: ${nextUpdatePullRequest.url}.`));