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