@@ -2,54 +2,55 @@ import {spawn} from 'child_process';
2
2
import { existsSync , statSync , copySync } from 'fs-extra' ;
3
3
import { join } from 'path' ;
4
4
import { task , src , dest } from 'gulp' ;
5
- import { execTask } from '../util/task_helpers' ;
6
- import { DIST_RELEASE , DIST_BUNDLES , DIST_MATERIAL } from '../constants' ;
7
-
8
- // There are no type definitions available for these imports.
9
- import gulpRunSequence = require( 'run-sequence' ) ;
10
- import minimist = require( 'minimist' ) ;
5
+ import { execTask , sequenceTask } from '../util/task_helpers' ;
6
+ import { DIST_RELEASE , DIST_BUNDLES , DIST_MATERIAL , COMPONENTS_DIR } from '../constants' ;
7
+ import * as minimist from 'minimist' ;
11
8
9
+ /** Parse command-line arguments for release task. */
12
10
const argv = minimist ( process . argv . slice ( 3 ) ) ;
13
11
14
- // Capture all d.ts files output by typescript compilation except for the special files
15
- // generated by ngc.
12
+ // Capture all d.ts files output by typescript compilation except for the
13
+ // special files generated by ngc.
16
14
const typingsGlob = [
17
15
join ( DIST_MATERIAL , '**' , '*.d.ts' ) ,
18
16
`!${ join ( DIST_MATERIAL , 'index.d.ts' ) } ` ,
19
17
`!${ join ( DIST_MATERIAL , 'public_api.d.ts' ) } ` ,
20
18
] ;
21
19
20
+ const assetsGlob = join ( COMPONENTS_DIR , '+(package.json|README.md)' ) ;
21
+
22
22
// Capture all UMD bundles.
23
23
const umdGlob = join ( DIST_BUNDLES , '*.umd.*' ) ;
24
24
25
25
// Capture all flat ESM bunldes (e.g., "material.js" and "material.es5.js")
26
- const fesmGlob = [ join ( DIST_BUNDLES , "*.js" ) , `!${ umdGlob } ` ] ;
27
-
28
- task ( 'build:release' , function ( done : ( ) => void ) {
29
- gulpRunSequence (
30
- 'library:build' ,
31
- ':package:release' ,
32
- done
33
- ) ;
34
- } ) ;
26
+ const fesmGlob = [ join ( DIST_BUNDLES , '*.js' ) , `!${ umdGlob } ` ] ;
27
+
28
+ task ( 'build:release' , sequenceTask (
29
+ 'library:build' ,
30
+ ':package:release' ,
31
+ ) ) ;
35
32
36
33
/** Task that combines intermediate build artifacts into the release package structure. */
37
34
task ( ':package:release' , [
38
35
':package:metadata' ,
39
36
':package:typings' ,
40
37
':package:umd' ,
41
38
':package:fesm' ,
39
+ ':package:assets'
42
40
] ) ;
43
41
42
+
44
43
/** Copy metatadata.json and associated d.ts files to the root of the package structure. */
45
44
task ( ':package:metadata' , ( ) => {
46
- // https://github.com/angular/angular/blob/master/build.sh#L293-L294
45
+ // See: https://github.com/angular/angular/blob/master/build.sh#L293-L294
47
46
copySync ( join ( DIST_MATERIAL , 'public_api.d.ts' ) , join ( DIST_RELEASE , 'public_api.d.ts' ) ) ;
48
47
copySync ( join ( DIST_MATERIAL , 'index.d.ts' ) , join ( DIST_RELEASE , 'material.d.ts' ) ) ;
49
48
copySync ( join ( DIST_MATERIAL , 'index.metadata.json' ) ,
50
49
join ( DIST_RELEASE , 'material.metadata.json' ) ) ;
51
50
} ) ;
52
51
52
+ task ( ':package:assets' , ( ) => src ( assetsGlob ) . pipe ( dest ( DIST_RELEASE ) ) ) ;
53
+
53
54
/** Copy all d.ts except the special flat typings from ngc to typings/ in the release package. */
54
55
task ( ':package:typings' , ( ) => src ( typingsGlob ) . pipe ( dest ( join ( DIST_RELEASE , 'typings' ) ) ) ) ;
55
56
@@ -131,12 +132,9 @@ task(':publish', function(done: (err?: any) => void) {
131
132
. then ( ( ) => process . chdir ( currentDir ) ) ;
132
133
} ) ;
133
134
134
- task ( 'publish' , function ( done : ( ) => void ) {
135
- gulpRunSequence (
136
- ':publish:whoami' ,
137
- 'build:release' ,
138
- ':publish' ,
139
- ':publish:logout' ,
140
- done
141
- ) ;
142
- } ) ;
135
+ task ( 'publish' , sequenceTask (
136
+ ':publish:whoami' ,
137
+ 'build:release' ,
138
+ ':publish' ,
139
+ ':publish:logout' ,
140
+ ) ) ;
0 commit comments