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