1- /**
2- * @license
3- * Copyright Google Inc. All Rights Reserved.
4- *
5- * Use of this source code is governed by an MIT-style license that can be
6- * found in the LICENSE file at https://angular.io/license
7- */
8-
91'use strict' ;
102
113// THIS CHECK SHOULD BE THE FIRST THING IN THIS FILE
@@ -21,30 +13,28 @@ const os = require('os');
2113
2214// clang-format entry points
2315const srcsToFmt = [
24- 'modules/@angular/**/*.{js,ts} ' ,
25- 'modules/benchmarks/**/*.{js,ts} ' ,
26- 'modules/e2e_util/**/*.{js,ts} ' ,
27- 'modules/playground/**/*.{js,ts} ' ,
28- 'tools/**/*.{js,ts} ' ,
16+ 'modules/@angular/**/*.ts ' ,
17+ 'modules/benchmarks/**/*.ts ' ,
18+ 'modules/e2e_util/**/*.ts ' ,
19+ 'modules/playground/**/*.ts ' ,
20+ 'tools/**/*.ts ' ,
2921 '!tools/public_api_guard/**/*.d.ts' ,
30- './*.{js,ts}' ,
3122] ;
3223
3324// Check source code for formatting errors (clang-format)
3425gulp . task ( 'format:enforce' , ( ) => {
3526 const format = require ( 'gulp-clang-format' ) ;
3627 const clangFormat = require ( 'clang-format' ) ;
3728 return gulp . src ( srcsToFmt ) . pipe (
38- format . checkFormat ( 'file' , clangFormat , { verbose : true , fail : true } ) ) ;
29+ format . checkFormat ( 'file' , clangFormat , { verbose : true , fail : true } ) ) ;
3930} ) ;
4031
4132// Format the source code with clang-format (see .clang-format)
4233gulp . task ( 'format' , ( ) => {
4334 const format = require ( 'gulp-clang-format' ) ;
4435 const clangFormat = require ( 'clang-format' ) ;
45- return gulp . src ( srcsToFmt , { base : '.' } )
46- . pipe ( format . format ( 'file' , clangFormat ) )
47- . pipe ( gulp . dest ( '.' ) ) ;
36+ return gulp . src ( srcsToFmt , { base : '.' } ) . pipe (
37+ format . format ( 'file' , clangFormat ) ) . pipe ( gulp . dest ( '.' ) ) ;
4838} ) ;
4939
5040const entrypoints = [
@@ -72,18 +62,12 @@ const entrypoints = [
7262] ;
7363const publicApiDir = path . normalize ( 'tools/public_api_guard' ) ;
7464const publicApiArgs = [
75- '--rootDir' ,
76- 'dist/packages-dist' ,
77- '--stripExportPattern' ,
78- '^__' ,
79- '--allowModuleIdentifiers' ,
80- 'jasmine' ,
81- '--allowModuleIdentifiers' ,
82- 'protractor' ,
83- '--allowModuleIdentifiers' ,
84- 'angular' ,
85- '--onStabilityMissing' ,
86- 'error' ,
65+ '--rootDir' , 'dist/packages-dist' ,
66+ '--stripExportPattern' , '^__' ,
67+ '--allowModuleIdentifiers' , 'jasmine' ,
68+ '--allowModuleIdentifiers' , 'protractor' ,
69+ '--allowModuleIdentifiers' , 'angular' ,
70+ '--onStabilityMissing' , 'error' ,
8771] . concat ( entrypoints ) ;
8872
8973// Build angular
@@ -99,42 +83,38 @@ gulp.task('public-api:enforce', (done) => {
9983 const childProcess = require ( 'child_process' ) ;
10084
10185 childProcess
102- . spawn (
103- path . join ( __dirname , platformScriptPath ( `/node_modules/.bin/ts-api-guardian` ) ) ,
104- [ '--verifyDir' , publicApiDir ] . concat ( publicApiArgs ) , { stdio : 'inherit' } )
105- . on ( 'close' , ( errorCode ) => {
106- if ( errorCode !== 0 ) {
107- done ( new Error (
108- 'Public API differs from golden file. Please run `gulp public-api:update`.' ) ) ;
109- } else {
110- done ( ) ;
111- }
112- } ) ;
86+ . spawn (
87+ path . join ( __dirname , platformScriptPath ( `/node_modules/.bin/ts-api-guardian` ) ) ,
88+ [ '--verifyDir' , publicApiDir ] . concat ( publicApiArgs ) , { stdio : 'inherit' } )
89+ . on ( 'close' , ( errorCode ) => {
90+ if ( errorCode !== 0 ) {
91+ done ( new Error (
92+ 'Public API differs from golden file. Please run `gulp public-api:update`.' ) ) ;
93+ } else {
94+ done ( ) ;
95+ }
96+ } ) ;
11397} ) ;
11498
11599// Generate the public API golden files
116100gulp . task ( 'public-api:update' , [ 'build.sh' ] , ( done ) => {
117101 const childProcess = require ( 'child_process' ) ;
118102
119103 childProcess
120- . spawn (
121- path . join ( __dirname , platformScriptPath ( `/node_modules/.bin/ts-api-guardian` ) ) ,
122- [ '--outDir' , publicApiDir ] . concat ( publicApiArgs ) , { stdio : 'inherit' } )
123- . on ( 'close' , done ) ;
104+ . spawn (
105+ path . join ( __dirname , platformScriptPath ( `/node_modules/.bin/ts-api-guardian` ) ) ,
106+ [ '--outDir' , publicApiDir ] . concat ( publicApiArgs ) , { stdio : 'inherit' } )
107+ . on ( 'close' , done ) ;
124108} ) ;
125109
126- // Checks tests for presence of ddescribe, fdescribe, fit, iit and fails the build if one of the
127- // focused tests is found.
128- // Currently xdescribe and xit are _not_ reported as errors since there are a couple of excluded
129- // tests in our code base.
110+ // Checks tests for presence of ddescribe, fdescribe, fit, iit and fails the build if one of the focused tests is found.
111+ // Currently xdescribe and xit are _not_ reported as errors since there are a couple of excluded tests in our code base.
130112gulp . task ( 'check-tests' , function ( ) {
131113 const ddescribeIit = require ( 'gulp-ddescribe-iit' ) ;
132- return gulp
133- . src ( [
134- 'modules/**/*.spec.ts' ,
135- 'modules/**/*_spec.ts' ,
136- ] )
137- . pipe ( ddescribeIit ( { allowDisabledTests : true } ) ) ;
114+ return gulp . src ( [
115+ 'modules/**/*.spec.ts' ,
116+ 'modules/**/*_spec.ts' ,
117+ ] ) . pipe ( ddescribeIit ( { allowDisabledTests : true } ) ) ;
138118} ) ;
139119
140120// Check the coding standards and programming errors
@@ -143,21 +123,14 @@ gulp.task('lint', ['check-tests', 'format:enforce', 'tools:build'], () => {
143123 // Built-in rules are at
144124 // https://github.com/palantir/tslint#supported-rules
145125 const tslintConfig = require ( './tslint.json' ) ;
146- return gulp
147- . src ( [
148- // todo(vicb): add .js files when supported
149- // see https://github.com/palantir/tslint/pull/1515
150- 'modules/@angular/**/*.ts' ,
151- 'modules/benchpress/**/*.ts' ,
152- './*.ts' ,
153- ] )
154- . pipe ( tslint ( {
155- tslint : require ( 'tslint' ) . default ,
156- configuration : tslintConfig ,
157- rulesDirectory : 'dist/tools/tslint' ,
158- formatter : 'prose' ,
159- } ) )
160- . pipe ( tslint . report ( { emitError : true } ) ) ;
126+ return gulp . src ( [ 'modules/@angular/**/*.ts' , 'modules/benchpress/**/*.ts' ] )
127+ . pipe ( tslint ( {
128+ tslint : require ( 'tslint' ) . default ,
129+ configuration : tslintConfig ,
130+ rulesDirectory : 'dist/tools/tslint' ,
131+ formatter : 'prose' ,
132+ } ) )
133+ . pipe ( tslint . report ( { emitError : true } ) ) ;
161134} ) ;
162135
163136gulp . task ( 'tools:build' , ( done ) => { tsc ( 'tools/' , done ) ; } ) ;
@@ -169,7 +142,7 @@ gulp.task('check-cycle', (done) => {
169142 const dependencyObject = madge ( [ 'dist/all/' ] , {
170143 format : 'cjs' ,
171144 extensions : [ '.js' ] ,
172- onParseFile : function ( data ) { data . src = data . src . replace ( / \/ \* c i r c u l a r \* \/ / g, '//' ) ; }
145+ onParseFile : function ( data ) { data . src = data . src . replace ( / \/ \* c i r c u l a r \* \/ / g, "//" ) ; }
173146 } ) ;
174147 const circularDependencies = dependencyObject . circular ( ) . getArray ( ) ;
175148 if ( circularDependencies . length > 0 ) {
@@ -200,11 +173,11 @@ gulp.task('serve-examples', () => {
200173 const cors = require ( 'cors' ) ;
201174
202175 connect . server ( {
203- root : `${ __dirname } /dist/examples` ,
204- port : 8001 ,
205- livereload : false ,
206- open : false ,
207- middleware : ( connect , opt ) => [ cors ( ) ] ,
176+ root : `${ __dirname } /dist/examples` ,
177+ port : 8001 ,
178+ livereload : false ,
179+ open : false ,
180+ middleware : ( connect , opt ) => [ cors ( ) ] ,
208181 } ) ;
209182} ) ;
210183
@@ -214,13 +187,16 @@ gulp.task('changelog', () => {
214187 const conventionalChangelog = require ( 'gulp-conventional-changelog' ) ;
215188
216189 return gulp . src ( 'CHANGELOG.md' )
217- . pipe ( conventionalChangelog ( { preset : 'angular' , releaseCount : 1 } , {
218- // Conventional Changelog Context
219- // We have to manually set version number so it doesn't get prefixed with `v`
220- // See https://github.com/conventional-changelog/conventional-changelog-core/issues/10
221- currentTag : require ( './package.json' ) . version
222- } ) )
223- . pipe ( gulp . dest ( './' ) ) ;
190+ . pipe ( conventionalChangelog ( {
191+ preset : 'angular' ,
192+ releaseCount : 1
193+ } , {
194+ // Conventional Changelog Context
195+ // We have to manually set version number so it doesn't get prefixed with `v`
196+ // See https://github.com/conventional-changelog/conventional-changelog-core/issues/10
197+ currentTag : require ( './package.json' ) . version
198+ } ) )
199+ . pipe ( gulp . dest ( './' ) ) ;
224200} ) ;
225201
226202function tsc ( projectPath , done ) {
@@ -229,7 +205,8 @@ function tsc(projectPath, done) {
229205 childProcess
230206 . spawn (
231207 path . normalize ( platformScriptPath ( `${ __dirname } /node_modules/.bin/tsc` ) ) ,
232- [ '-p' , path . join ( __dirname , projectPath ) ] , { stdio : 'inherit' } )
208+ [ '-p' , path . join ( __dirname , projectPath ) ] ,
209+ { stdio : 'inherit' } )
233210 . on ( 'close' , done ) ;
234211}
235212
0 commit comments