|
1 | 1 | import {spawn} from 'child_process'; |
2 | 2 | import {existsSync, statSync, copySync} from 'fs-extra'; |
3 | 3 | import {join} from 'path'; |
4 | | -import {task} from 'gulp'; |
| 4 | +import {task, src, dest} from 'gulp'; |
5 | 5 | import {execTask} from '../util/task_helpers'; |
6 | | -import {DIST_RELEASE, DIST_BUNDLES} from '../constants'; |
| 6 | +import {DIST_RELEASE, DIST_BUNDLES, DIST_MATERIAL} from '../constants'; |
7 | 7 |
|
8 | 8 | // There are no type definitions available for these imports. |
9 | 9 | import gulpRunSequence = require('run-sequence'); |
10 | 10 | import minimist = require('minimist'); |
11 | 11 |
|
12 | 12 | const argv = minimist(process.argv.slice(3)); |
13 | 13 |
|
| 14 | +// Capture all d.ts files output by typescript compilation except for the special files |
| 15 | +// generated by ngc. |
| 16 | +const typingsGlob = [ |
| 17 | + join(DIST_MATERIAL, '**', '*.d.ts'), |
| 18 | + `!${join(DIST_MATERIAL, 'index.d.ts')}`, |
| 19 | + `!${join(DIST_MATERIAL, 'public_api.d.ts')}`, |
| 20 | +]; |
| 21 | + |
| 22 | +// Capture all UMD bundles. |
| 23 | +const umdGlob = join(DIST_BUNDLES, '*.umd.*'); |
| 24 | + |
| 25 | +// Capture all flat ESM bunldes (e.g., "material.js" and "material.es5.js") |
| 26 | +const fesmGlob = [join(DIST_BUNDLES, "*.js"), `!${umdGlob}`]; |
| 27 | + |
14 | 28 | task('build:release', function(done: () => void) { |
15 | 29 | gulpRunSequence( |
16 | 30 | 'library:build', |
17 | | - ':build:release:copy', |
| 31 | + ':package:release', |
18 | 32 | done |
19 | 33 | ); |
20 | 34 | }); |
21 | 35 |
|
22 | | -/** Task that merges the different bundles and outputs into the release folder. */ |
23 | | -task(':build:release:copy', () => { |
| 36 | +/** Task that combines intermediate build artifacts into the release package structure. */ |
| 37 | +task(':package:release', [ |
| 38 | + ':package:metadata', |
| 39 | + ':package:typings', |
| 40 | + ':package:umd', |
| 41 | + ':package:fesm', |
| 42 | +]); |
| 43 | + |
| 44 | +/** Copy metatadata.json and associated d.ts files to the root of the package structure. */ |
| 45 | +task(':package:metadata', () => { |
24 | 46 | // https://github.com/angular/angular/blob/master/build.sh#L293-L294 |
25 | | - copySync(join(DIST_BUNDLES, 'index.d.ts'), join(DIST_RELEASE, 'material.d.ts')); |
26 | | - copySync(join(DIST_BUNDLES, 'index.metadata.json'), join(DIST_RELEASE, 'material.metadata.json')); |
| 47 | + copySync(join(DIST_MATERIAL, 'public_api.d.ts'), join(DIST_RELEASE, 'public_api.d.ts')); |
| 48 | + copySync(join(DIST_MATERIAL, 'index.d.ts'), join(DIST_RELEASE, 'material.d.ts')); |
| 49 | + copySync(join(DIST_MATERIAL, 'index.metadata.json'), |
| 50 | + join(DIST_RELEASE, 'material.metadata.json')); |
| 51 | +}); |
27 | 52 |
|
| 53 | +/** Copy all d.ts except the special flat typings from ngc to typings/ in the release package. */ |
| 54 | +task(':package:typings', () => src(typingsGlob).pipe(dest(join(DIST_RELEASE, 'typings')))); |
28 | 55 |
|
29 | | -}); |
| 56 | +/** Copy umd bundles to the root of the release package. */ |
| 57 | +task(':package:umd', () => src(umdGlob).pipe((dest(join(DIST_RELEASE, 'bundles'))))); |
| 58 | + |
| 59 | +/** Copy fesm bundles to @angular/material in the release package */ |
| 60 | +task(':package:fesm', () => src(fesmGlob).pipe(dest(join(DIST_RELEASE, '@angular', 'material')))); |
30 | 61 |
|
31 | 62 | /** Make sure we're logged in. */ |
32 | 63 | task(':publish:whoami', execTask('npm', ['whoami'], { |
|
0 commit comments