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,31 @@ 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}' ,
31+ '!shims_for_IE.js' ,
2232] ;
2333
2434// Check source code for formatting errors (clang-format)
2535gulp . task ( 'format:enforce' , ( ) => {
2636 const format = require ( 'gulp-clang-format' ) ;
2737 const clangFormat = require ( 'clang-format' ) ;
2838 return gulp . src ( srcsToFmt ) . pipe (
29- format . checkFormat ( 'file' , clangFormat , { verbose : true , fail : true } ) ) ;
39+ format . checkFormat ( 'file' , clangFormat , { verbose : true , fail : true } ) ) ;
3040} ) ;
3141
3242// Format the source code with clang-format (see .clang-format)
3343gulp . task ( 'format' , ( ) => {
3444 const format = require ( 'gulp-clang-format' ) ;
3545 const clangFormat = require ( 'clang-format' ) ;
36- return gulp . src ( srcsToFmt , { base : '.' } ) . pipe (
37- format . format ( 'file' , clangFormat ) ) . pipe ( gulp . dest ( '.' ) ) ;
46+ return gulp . src ( srcsToFmt , { base : '.' } )
47+ . pipe ( format . format ( 'file' , clangFormat ) )
48+ . pipe ( gulp . dest ( '.' ) ) ;
3849} ) ;
3950
4051const entrypoints = [
@@ -62,12 +73,18 @@ const entrypoints = [
6273] ;
6374const publicApiDir = path . normalize ( 'tools/public_api_guard' ) ;
6475const publicApiArgs = [
65- '--rootDir' , 'dist/packages-dist' ,
66- '--stripExportPattern' , '^__' ,
67- '--allowModuleIdentifiers' , 'jasmine' ,
68- '--allowModuleIdentifiers' , 'protractor' ,
69- '--allowModuleIdentifiers' , 'angular' ,
70- '--onStabilityMissing' , 'error' ,
76+ '--rootDir' ,
77+ 'dist/packages-dist' ,
78+ '--stripExportPattern' ,
79+ '^__' ,
80+ '--allowModuleIdentifiers' ,
81+ 'jasmine' ,
82+ '--allowModuleIdentifiers' ,
83+ 'protractor' ,
84+ '--allowModuleIdentifiers' ,
85+ 'angular' ,
86+ '--onStabilityMissing' ,
87+ 'error' ,
7188] . concat ( entrypoints ) ;
7289
7390// Build angular
@@ -83,38 +100,42 @@ gulp.task('public-api:enforce', (done) => {
83100 const childProcess = require ( 'child_process' ) ;
84101
85102 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- } ) ;
103+ . spawn (
104+ path . join ( __dirname , platformScriptPath ( `/node_modules/.bin/ts-api-guardian` ) ) ,
105+ [ '--verifyDir' , publicApiDir ] . concat ( publicApiArgs ) , { stdio : 'inherit' } )
106+ . on ( 'close' , ( errorCode ) => {
107+ if ( errorCode !== 0 ) {
108+ done ( new Error (
109+ 'Public API differs from golden file. Please run `gulp public-api:update`.' ) ) ;
110+ } else {
111+ done ( ) ;
112+ }
113+ } ) ;
97114} ) ;
98115
99116// Generate the public API golden files
100117gulp . task ( 'public-api:update' , [ 'build.sh' ] , ( done ) => {
101118 const childProcess = require ( 'child_process' ) ;
102119
103120 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 ) ;
121+ . spawn (
122+ path . join ( __dirname , platformScriptPath ( `/node_modules/.bin/ts-api-guardian` ) ) ,
123+ [ '--outDir' , publicApiDir ] . concat ( publicApiArgs ) , { stdio : 'inherit' } )
124+ . on ( 'close' , done ) ;
108125} ) ;
109126
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.
127+ // Checks tests for presence of ddescribe, fdescribe, fit, iit and fails the build if one of the
128+ // focused tests is found.
129+ // Currently xdescribe and xit are _not_ reported as errors since there are a couple of excluded
130+ // tests in our code base.
112131gulp . task ( 'check-tests' , function ( ) {
113132 const ddescribeIit = require ( 'gulp-ddescribe-iit' ) ;
114- return gulp . src ( [
115- 'modules/**/*.spec.ts' ,
116- 'modules/**/*_spec.ts' ,
117- ] ) . pipe ( ddescribeIit ( { allowDisabledTests : true } ) ) ;
133+ return gulp
134+ . src ( [
135+ 'modules/**/*.spec.ts' ,
136+ 'modules/**/*_spec.ts' ,
137+ ] )
138+ . pipe ( ddescribeIit ( { allowDisabledTests : true } ) ) ;
118139} ) ;
119140
120141// Check the coding standards and programming errors
@@ -123,14 +144,21 @@ gulp.task('lint', ['check-tests', 'format:enforce', 'tools:build'], () => {
123144 // Built-in rules are at
124145 // https://github.com/palantir/tslint#supported-rules
125146 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 } ) ) ;
147+ return gulp
148+ . src ( [
149+ // todo(vicb): add .js files when supported
150+ // see https://github.com/palantir/tslint/pull/1515
151+ 'modules/@angular/**/*.ts' ,
152+ 'modules/benchpress/**/*.ts' ,
153+ './*.ts' ,
154+ ] )
155+ . pipe ( tslint ( {
156+ tslint : require ( 'tslint' ) . default ,
157+ configuration : tslintConfig ,
158+ rulesDirectory : 'dist/tools/tslint' ,
159+ formatter : 'prose' ,
160+ } ) )
161+ . pipe ( tslint . report ( { emitError : true } ) ) ;
134162} ) ;
135163
136164gulp . task ( 'tools:build' , ( done ) => { tsc ( 'tools/' , done ) ; } ) ;
@@ -142,7 +170,7 @@ gulp.task('check-cycle', (done) => {
142170 const dependencyObject = madge ( [ 'dist/all/' ] , {
143171 format : 'cjs' ,
144172 extensions : [ '.js' ] ,
145- onParseFile : function ( data ) { data . src = data . src . replace ( / \/ \* c i r c u l a r \* \/ / g, "//" ) ; }
173+ onParseFile : function ( data ) { data . src = data . src . replace ( / \/ \* c i r c u l a r \* \/ / g, '//' ) ; }
146174 } ) ;
147175 const circularDependencies = dependencyObject . circular ( ) . getArray ( ) ;
148176 if ( circularDependencies . length > 0 ) {
@@ -173,11 +201,11 @@ gulp.task('serve-examples', () => {
173201 const cors = require ( 'cors' ) ;
174202
175203 connect . server ( {
176- root : `${ __dirname } /dist/examples` ,
177- port : 8001 ,
178- livereload : false ,
179- open : false ,
180- middleware : ( connect , opt ) => [ cors ( ) ] ,
204+ root : `${ __dirname } /dist/examples` ,
205+ port : 8001 ,
206+ livereload : false ,
207+ open : false ,
208+ middleware : ( connect , opt ) => [ cors ( ) ] ,
181209 } ) ;
182210} ) ;
183211
@@ -187,16 +215,13 @@ gulp.task('changelog', () => {
187215 const conventionalChangelog = require ( 'gulp-conventional-changelog' ) ;
188216
189217 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 ( './' ) ) ;
218+ . pipe ( conventionalChangelog ( { preset : 'angular' , releaseCount : 1 } , {
219+ // Conventional Changelog Context
220+ // We have to manually set version number so it doesn't get prefixed with `v`
221+ // See https://github.com/conventional-changelog/conventional-changelog-core/issues/10
222+ currentTag : require ( './package.json' ) . version
223+ } ) )
224+ . pipe ( gulp . dest ( './' ) ) ;
200225} ) ;
201226
202227function tsc ( projectPath , done ) {
@@ -205,8 +230,7 @@ function tsc(projectPath, done) {
205230 childProcess
206231 . spawn (
207232 path . normalize ( platformScriptPath ( `${ __dirname } /node_modules/.bin/tsc` ) ) ,
208- [ '-p' , path . join ( __dirname , projectPath ) ] ,
209- { stdio : 'inherit' } )
233+ [ '-p' , path . join ( __dirname , projectPath ) ] , { stdio : 'inherit' } )
210234 . on ( 'close' , done ) ;
211235}
212236
0 commit comments