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+
19'use strict' ;
210
311// THIS CHECK SHOULD BE THE FIRST THING IN THIS FILE
@@ -13,28 +21,30 @@ const os = require('os');
1321
1422// clang-format entry points
1523const srcsToFmt = [
16- 'modules/@angular/**/*.ts ' ,
17- 'modules/benchmarks/**/*.ts ' ,
18- 'modules/e2e_util/**/*.ts ' ,
19- 'modules/playground/**/*.ts ' ,
20- 'tools/**/*.ts ' ,
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} ' ,
2129 '!tools/public_api_guard/**/*.d.ts' ,
30+ './*.{js,ts}' ,
2231] ;
2332
2433// Check source code for formatting errors (clang-format)
2534gulp . task ( 'format:enforce' , ( ) => {
2635 const format = require ( 'gulp-clang-format' ) ;
2736 const clangFormat = require ( 'clang-format' ) ;
2837 return gulp . src ( srcsToFmt ) . pipe (
29- format . checkFormat ( 'file' , clangFormat , { verbose : true , fail : true } ) ) ;
38+ format . checkFormat ( 'file' , clangFormat , { verbose : true , fail : true } ) ) ;
3039} ) ;
3140
3241// Format the source code with clang-format (see .clang-format)
3342gulp . task ( 'format' , ( ) => {
3443 const format = require ( 'gulp-clang-format' ) ;
3544 const clangFormat = require ( 'clang-format' ) ;
36- return gulp . src ( srcsToFmt , { base : '.' } ) . pipe (
37- format . format ( 'file' , clangFormat ) ) . pipe ( gulp . dest ( '.' ) ) ;
45+ return gulp . src ( srcsToFmt , { base : '.' } )
46+ . pipe ( format . format ( 'file' , clangFormat ) )
47+ . pipe ( gulp . dest ( '.' ) ) ;
3848} ) ;
3949
4050const entrypoints = [
@@ -62,12 +72,18 @@ const entrypoints = [
6272] ;
6373const publicApiDir = path . normalize ( 'tools/public_api_guard' ) ;
6474const publicApiArgs = [
65- '--rootDir' , 'dist/packages-dist' ,
66- '--stripExportPattern' , '^__' ,
67- '--allowModuleIdentifiers' , 'jasmine' ,
68- '--allowModuleIdentifiers' , 'protractor' ,
69- '--allowModuleIdentifiers' , 'angular' ,
70- '--onStabilityMissing' , 'error' ,
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' ,
7187] . concat ( entrypoints ) ;
7288
7389// Build angular
@@ -83,38 +99,42 @@ gulp.task('public-api:enforce', (done) => {
8399 const childProcess = require ( 'child_process' ) ;
84100
85101 childProcess
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- } ) ;
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+ } ) ;
97113} ) ;
98114
99115// Generate the public API golden files
100116gulp . task ( 'public-api:update' , [ 'build.sh' ] , ( done ) => {
101117 const childProcess = require ( 'child_process' ) ;
102118
103119 childProcess
104- . spawn (
105- path . join ( __dirname , platformScriptPath ( `/node_modules/.bin/ts-api-guardian` ) ) ,
106- [ '--outDir' , publicApiDir ] . concat ( publicApiArgs ) , { stdio : 'inherit' } )
107- . on ( 'close' , done ) ;
120+ . spawn (
121+ path . join ( __dirname , platformScriptPath ( `/node_modules/.bin/ts-api-guardian` ) ) ,
122+ [ '--outDir' , publicApiDir ] . concat ( publicApiArgs ) , { stdio : 'inherit' } )
123+ . on ( 'close' , done ) ;
108124} ) ;
109125
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.
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.
112130gulp . task ( 'check-tests' , function ( ) {
113131 const ddescribeIit = require ( 'gulp-ddescribe-iit' ) ;
114- return gulp . src ( [
115- 'modules/**/*.spec.ts' ,
116- 'modules/**/*_spec.ts' ,
117- ] ) . pipe ( ddescribeIit ( { allowDisabledTests : true } ) ) ;
132+ return gulp
133+ . src ( [
134+ 'modules/**/*.spec.ts' ,
135+ 'modules/**/*_spec.ts' ,
136+ ] )
137+ . pipe ( ddescribeIit ( { allowDisabledTests : true } ) ) ;
118138} ) ;
119139
120140// Check the coding standards and programming errors
@@ -123,14 +143,21 @@ gulp.task('lint', ['check-tests', 'format:enforce', 'tools:build'], () => {
123143 // Built-in rules are at
124144 // https://github.com/palantir/tslint#supported-rules
125145 const tslintConfig = require ( './tslint.json' ) ;
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 } ) ) ;
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 } ) ) ;
134161} ) ;
135162
136163gulp . task ( 'tools:build' , ( done ) => { tsc ( 'tools/' , done ) ; } ) ;
@@ -142,7 +169,7 @@ gulp.task('check-cycle', (done) => {
142169 const dependencyObject = madge ( [ 'dist/all/' ] , {
143170 format : 'cjs' ,
144171 extensions : [ '.js' ] ,
145- onParseFile : function ( data ) { data . src = data . src . replace ( / \/ \* c i r c u l a r \* \/ / g, "//" ) ; }
172+ onParseFile : function ( data ) { data . src = data . src . replace ( / \/ \* c i r c u l a r \* \/ / g, '//' ) ; }
146173 } ) ;
147174 const circularDependencies = dependencyObject . circular ( ) . getArray ( ) ;
148175 if ( circularDependencies . length > 0 ) {
@@ -173,11 +200,11 @@ gulp.task('serve-examples', () => {
173200 const cors = require ( 'cors' ) ;
174201
175202 connect . server ( {
176- root : `${ __dirname } /dist/examples` ,
177- port : 8001 ,
178- livereload : false ,
179- open : false ,
180- middleware : ( connect , opt ) => [ cors ( ) ] ,
203+ root : `${ __dirname } /dist/examples` ,
204+ port : 8001 ,
205+ livereload : false ,
206+ open : false ,
207+ middleware : ( connect , opt ) => [ cors ( ) ] ,
181208 } ) ;
182209} ) ;
183210
@@ -187,16 +214,13 @@ gulp.task('changelog', () => {
187214 const conventionalChangelog = require ( 'gulp-conventional-changelog' ) ;
188215
189216 return gulp . src ( 'CHANGELOG.md' )
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 ( './' ) ) ;
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 ( './' ) ) ;
200224} ) ;
201225
202226function tsc ( projectPath , done ) {
@@ -205,8 +229,7 @@ function tsc(projectPath, done) {
205229 childProcess
206230 . spawn (
207231 path . normalize ( platformScriptPath ( `${ __dirname } /node_modules/.bin/tsc` ) ) ,
208- [ '-p' , path . join ( __dirname , projectPath ) ] ,
209- { stdio : 'inherit' } )
232+ [ '-p' , path . join ( __dirname , projectPath ) ] , { stdio : 'inherit' } )
210233 . on ( 'close' , done ) ;
211234}
212235
0 commit comments