1
0
mirror of https://github.com/angular/angular-cli.git synced 2025-05-16 18:43:42 +08:00
Hans Larsen 483cbe2665 refactor: add tslint-sonarts and a lot of tslint rules
This should clean up the code a bit.

Note: at first I added the no-useless-cast rule, but after getting frustrated
with it (as it has many false positive), I decided to remove the rule but some
useless casts were removed so I let those in the PR.
2018-07-10 15:07:36 -07:00

60 lines
1.7 KiB
TypeScript

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// tslint:disable:no-implicit-dependencies
import { logging, tags } from '@angular-devkit/core';
import { execSync } from 'child_process';
import templates from './templates';
import validateBuildFiles from './validate-build-files';
import validateCommits from './validate-commits';
import validateLicenses from './validate-licenses';
export default async function (options: { verbose: boolean }, logger: logging.Logger) {
let error = false;
logger.info('Running templates validation...');
const templateLogger = logger.createChild('templates');
if (execSync(`git status --porcelain`).toString()) {
logger.error('There are local changes.');
if (!options.verbose) {
return 101;
}
error = true;
}
templates({}, templateLogger);
if (execSync(`git status --porcelain`).toString()) {
logger.error(tags.oneLine`
Running templates updated files... Please run "devkit-admin templates" before submitting
a PR.
`);
if (!options.verbose) {
process.exit(2);
}
error = true;
}
logger.info('');
logger.info('Running commit validation...');
validateCommits({}, logger.createChild('validate-commits'));
logger.info('');
logger.info('Running license validation...');
error = await validateLicenses({}, logger.createChild('validate-commits')) != 0
|| error;
logger.info('');
logger.info('Running BUILD files validation...');
validateBuildFiles({}, logger.createChild('validate-build-files'));
if (error) {
return 101;
}
return 0;
}