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
+
1
9
'use strict' ;
2
10
3
11
// THIS CHECK SHOULD BE THE FIRST THING IN THIS FILE
@@ -13,28 +21,31 @@ const os = require('os');
13
21
14
22
// clang-format entry points
15
23
const 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} ' ,
21
29
'!tools/public_api_guard/**/*.d.ts' ,
30
+ './*.{js,ts}' ,
31
+ '!shims_for_IE.js' ,
22
32
] ;
23
33
24
34
// Check source code for formatting errors (clang-format)
25
35
gulp . task ( 'format:enforce' , ( ) => {
26
36
const format = require ( 'gulp-clang-format' ) ;
27
37
const clangFormat = require ( 'clang-format' ) ;
28
38
return gulp . src ( srcsToFmt ) . pipe (
29
- format . checkFormat ( 'file' , clangFormat , { verbose : true , fail : true } ) ) ;
39
+ format . checkFormat ( 'file' , clangFormat , { verbose : true , fail : true } ) ) ;
30
40
} ) ;
31
41
32
42
// Format the source code with clang-format (see .clang-format)
33
43
gulp . task ( 'format' , ( ) => {
34
44
const format = require ( 'gulp-clang-format' ) ;
35
45
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 ( '.' ) ) ;
38
49
} ) ;
39
50
40
51
const entrypoints = [
@@ -62,12 +73,18 @@ const entrypoints = [
62
73
] ;
63
74
const publicApiDir = path . normalize ( 'tools/public_api_guard' ) ;
64
75
const 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' ,
71
88
] . concat ( entrypoints ) ;
72
89
73
90
// Build angular
@@ -83,38 +100,42 @@ gulp.task('public-api:enforce', (done) => {
83
100
const childProcess = require ( 'child_process' ) ;
84
101
85
102
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
+ } ) ;
97
114
} ) ;
98
115
99
116
// Generate the public API golden files
100
117
gulp . task ( 'public-api:update' , [ 'build.sh' ] , ( done ) => {
101
118
const childProcess = require ( 'child_process' ) ;
102
119
103
120
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 ) ;
108
125
} ) ;
109
126
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.
112
131
gulp . task ( 'check-tests' , function ( ) {
113
132
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 } ) ) ;
118
139
} ) ;
119
140
120
141
// Check the coding standards and programming errors
@@ -123,14 +144,21 @@ gulp.task('lint', ['check-tests', 'format:enforce', 'tools:build'], () => {
123
144
// Built-in rules are at
124
145
// https://github.com/palantir/tslint#supported-rules
125
146
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 } ) ) ;
134
162
} ) ;
135
163
136
164
gulp . task ( 'tools:build' , ( done ) => { tsc ( 'tools/' , done ) ; } ) ;
@@ -142,7 +170,7 @@ gulp.task('check-cycle', (done) => {
142
170
const dependencyObject = madge ( [ 'dist/all/' ] , {
143
171
format : 'cjs' ,
144
172
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, '//' ) ; }
146
174
} ) ;
147
175
const circularDependencies = dependencyObject . circular ( ) . getArray ( ) ;
148
176
if ( circularDependencies . length > 0 ) {
@@ -173,11 +201,11 @@ gulp.task('serve-examples', () => {
173
201
const cors = require ( 'cors' ) ;
174
202
175
203
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 ( ) ] ,
181
209
} ) ;
182
210
} ) ;
183
211
@@ -187,16 +215,13 @@ gulp.task('changelog', () => {
187
215
const conventionalChangelog = require ( 'gulp-conventional-changelog' ) ;
188
216
189
217
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 ( './' ) ) ;
200
225
} ) ;
201
226
202
227
function tsc ( projectPath , done ) {
@@ -205,8 +230,7 @@ function tsc(projectPath, done) {
205
230
childProcess
206
231
. spawn (
207
232
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' } )
210
234
. on ( 'close' , done ) ;
211
235
}
212
236
0 commit comments