angular-cli/scripts/validate.ts
Hans Larsen 7eb4bab00f build: add validation for "DO NOT SUBMIT" strings
This makes sure that messages that should not be submitted (or
comments) fail validation on CI.
2019-03-11 13:38:00 -07:00

68 lines
2.0 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 validateDoNotSubmit from './validate-do-not-submit';
import validateLicenses from './validate-licenses';
export default async function (options: { verbose: boolean }, logger: logging.Logger) {
let error = false;
if (execSync(`git status --porcelain`).toString()) {
logger.error('There are local changes.');
if (!options.verbose) {
return 101;
}
error = true;
}
logger.info('Running templates validation...');
const templateLogger = logger.createChild('templates');
await 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...');
error = await validateCommits({}, logger.createChild('validate-commits')) != 0
|| error;
logger.info('');
logger.info(`Running DO_NOT${''}_SUBMIT validation...`);
error = await validateDoNotSubmit({}, logger.createChild('validate-do-not-submit')) != 0
|| error;
logger.info('');
logger.info('Running license validation...');
error = await validateLicenses({}, logger.createChild('validate-commits')) != 0
|| error;
logger.info('');
logger.info('Running BUILD files validation...');
error = await validateBuildFiles({}, logger.createChild('validate-build-files')) != 0
|| error;
if (error) {
return 101;
}
return 0;
}