feat(dev-infra): run buildifier formatting and linting via ng-dev (#36842)

In an effort to centralize formatting and linting enforcement into one
location, buildifier is being added as a formatter for ng-dev's format
command.  Allowing for format enforcement for all .bzl, .bazel, WORKSPACE
and BUILD files.

PR Close #36842
This commit is contained in:
Joey Perrott
2020-04-24 16:29:53 -07:00
committed by Alex Rickabaugh
parent 0f3831b105
commit 2cb5f59acc
11 changed files with 354 additions and 110 deletions

View File

@ -34,9 +34,36 @@ export function buildFormatParser(localYargs: yargs.Argv) {
const executionCmd = check ? checkFiles : formatFiles;
executionCmd(allChangedFilesSince(sha));
})
.command('files <files..>', 'Run the formatter on provided files', {}, ({check, files}) => {
const executionCmd = check ? checkFiles : formatFiles;
executionCmd(files);
.command(
'files <files..>', 'Run the formatter on provided files', {},
({check, files}) => {
const executionCmd = check ? checkFiles : formatFiles;
executionCmd(files);
})
// TODO(josephperrott): remove this hidden command after deprecation period.
.command('deprecation-warning [originalCommand]', false, {}, ({originalCommand}) => {
console.warn(`\`yarn ${
originalCommand}\` is deprecated in favor of running the formatter via ng-dev`);
console.warn();
console.warn(`As a replacement of \`yarn ${originalCommand}\`, run:`);
switch (originalCommand) {
case 'bazel:format':
case 'bazel:lint-fix':
console.warn(` yarn ng-dev format all`);
break;
case 'bazel:lint':
console.warn(` yarn ng-dev format all --check`);
break;
default:
console.warn(`Error: Unrecognized previous command.`);
}
console.warn();
console.warn(`You can find more usage information by running:`);
console.warn(` yarn ng-dev format --help`);
console.warn();
console.warn(`For more on the rationale and effects of this deprecation visit:`);
// TODO(josephperrott): Update this PR to the correct URL.
console.warn(` https://github.com/angular/angular/pull/36842#issue-410321447`);
});
}