|
1 | 1 | import {spawn} from 'child_process';
|
2 |
| -import {existsSync, statSync, copySync} from 'fs-extra'; |
| 2 | +import {existsSync, statSync, copySync, writeFileSync} from 'fs-extra'; |
3 | 3 | import {join} from 'path';
|
4 | 4 | import {task, src, dest} from 'gulp';
|
5 | 5 | import {execTask, sequenceTask} from '../util/task_helpers';
|
6 |
| -import {DIST_RELEASE, DIST_BUNDLES, DIST_MATERIAL, COMPONENTS_DIR} from '../constants'; |
| 6 | +import { |
| 7 | + DIST_RELEASE, DIST_BUNDLES, DIST_MATERIAL, COMPONENTS_DIR, LICENSE_BANNER |
| 8 | +} from '../constants'; |
7 | 9 | import * as minimist from 'minimist';
|
8 | 10 |
|
9 | 11 | /** Parse command-line arguments for release task. */
|
10 | 12 | const argv = minimist(process.argv.slice(3));
|
11 | 13 |
|
12 |
| -// Capture all d.ts files output by typescript compilation except for the |
13 |
| -// special files generated by ngc. |
14 |
| -const typingsGlob = [ |
15 |
| - join(DIST_MATERIAL, '**', '*.d.ts'), |
16 |
| - `!${join(DIST_MATERIAL, 'index.d.ts')}`, |
17 |
| - `!${join(DIST_MATERIAL, 'public_api.d.ts')}`, |
18 |
| -]; |
| 14 | +// Capture all d.ts files output by typescript compilation. |
| 15 | +const typingsGlob = join(DIST_MATERIAL, '**', '*.d.ts'); |
19 | 16 |
|
20 | 17 | const assetsGlob = join(COMPONENTS_DIR, '+(package.json|README.md)');
|
21 | 18 |
|
@@ -43,29 +40,38 @@ task(':package:release', [
|
43 | 40 | /** Copy metatadata.json and associated d.ts files to the root of the package structure. */
|
44 | 41 | task(':package:metadata', () => {
|
45 | 42 | // See: https://github.com/angular/angular/blob/master/build.sh#L293-L294
|
46 |
| - copySync(join(DIST_MATERIAL, 'public_api.d.ts'), join(DIST_RELEASE, 'public_api.d.ts')); |
47 |
| - copySync(join(DIST_MATERIAL, 'index.d.ts'), join(DIST_RELEASE, 'material.d.ts')); |
48 | 43 | copySync(join(DIST_MATERIAL, 'index.metadata.json'),
|
49 | 44 | join(DIST_RELEASE, 'material.metadata.json'));
|
50 | 45 | });
|
51 | 46 |
|
52 | 47 | task(':package:assets', () => src(assetsGlob).pipe(dest(DIST_RELEASE)));
|
53 | 48 |
|
54 | 49 | /** Copy all d.ts except the special flat typings from ngc to typings/ in the release package. */
|
55 |
| -task(':package:typings', () => src(typingsGlob).pipe(dest(join(DIST_RELEASE, 'typings')))); |
| 50 | +task(':package:typings', () => { |
| 51 | + return src(typingsGlob) |
| 52 | + .pipe(dest(join(DIST_RELEASE, 'typings'))) |
| 53 | + .on('end', () => createTypingFile()); |
| 54 | +}); |
56 | 55 |
|
57 | 56 | /** Copy umd bundles to the root of the release package. */
|
58 | 57 | task(':package:umd', () => src(umdGlob).pipe((dest(join(DIST_RELEASE, 'bundles')))));
|
59 | 58 |
|
60 |
| -/** Copy fesm bundles to @angular/material in the release package */ |
61 |
| -task(':package:fesm', () => src(fesmGlob).pipe(dest(join(DIST_RELEASE, '@angular', 'material')))); |
| 59 | +/** Copy primary entry-point FESM bundles to the @angular/ directory. */ |
| 60 | +task(':package:fesm', () => src(fesmGlob).pipe(dest(join(DIST_RELEASE, '@angular')))); |
62 | 61 |
|
63 | 62 | /** Make sure we're logged in. */
|
64 | 63 | task(':publish:whoami', execTask('npm', ['whoami'], {
|
65 | 64 | silent: true,
|
66 | 65 | errMessage: 'You must be logged in to publish.'
|
67 | 66 | }));
|
68 | 67 |
|
| 68 | +/** Create a typing file that links to the bundled definitions of NGC. */ |
| 69 | +function createTypingFile() { |
| 70 | + writeFileSync(join(DIST_RELEASE, 'material.d.ts'), |
| 71 | + LICENSE_BANNER + '\nexport * from "./typings/index";' |
| 72 | + ); |
| 73 | +} |
| 74 | + |
69 | 75 | task(':publish:logout', execTask('npm', ['logout']));
|
70 | 76 |
|
71 | 77 |
|
|
0 commit comments