@@ -2,54 +2,55 @@ import {spawn} from 'child_process';
22import { existsSync , statSync , copySync } from 'fs-extra' ;
33import { join } from 'path' ;
44import { 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' ;
118
9+ /** Parse command-line arguments for release task. */
1210const argv = minimist ( process . argv . slice ( 3 ) ) ;
1311
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.
1614const typingsGlob = [
1715 join ( DIST_MATERIAL , '**' , '*.d.ts' ) ,
1816 `!${ join ( DIST_MATERIAL , 'index.d.ts' ) } ` ,
1917 `!${ join ( DIST_MATERIAL , 'public_api.d.ts' ) } ` ,
2018] ;
2119
20+ const assetsGlob = join ( COMPONENTS_DIR , '+(package.json|README.md)' ) ;
21+
2222// Capture all UMD bundles.
2323const umdGlob = join ( DIST_BUNDLES , '*.umd.*' ) ;
2424
2525// 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+ ) ) ;
3532
3633/** Task that combines intermediate build artifacts into the release package structure. */
3734task ( ':package:release' , [
3835 ':package:metadata' ,
3936 ':package:typings' ,
4037 ':package:umd' ,
4138 ':package:fesm' ,
39+ ':package:assets'
4240] ) ;
4341
42+
4443/** Copy metatadata.json and associated d.ts files to the root of the package structure. */
4544task ( ':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
4746 copySync ( join ( DIST_MATERIAL , 'public_api.d.ts' ) , join ( DIST_RELEASE , 'public_api.d.ts' ) ) ;
4847 copySync ( join ( DIST_MATERIAL , 'index.d.ts' ) , join ( DIST_RELEASE , 'material.d.ts' ) ) ;
4948 copySync ( join ( DIST_MATERIAL , 'index.metadata.json' ) ,
5049 join ( DIST_RELEASE , 'material.metadata.json' ) ) ;
5150} ) ;
5251
52+ task ( ':package:assets' , ( ) => src ( assetsGlob ) . pipe ( dest ( DIST_RELEASE ) ) ) ;
53+
5354/** Copy all d.ts except the special flat typings from ngc to typings/ in the release package. */
5455task ( ':package:typings' , ( ) => src ( typingsGlob ) . pipe ( dest ( join ( DIST_RELEASE , 'typings' ) ) ) ) ;
5556
@@ -131,12 +132,9 @@ task(':publish', function(done: (err?: any) => void) {
131132 . then ( ( ) => process . chdir ( currentDir ) ) ;
132133} ) ;
133134
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