import {join} from 'path'; import {task, watch} from 'gulp'; import {buildConfig, sequenceTask} from 'material2-build-tools'; // There are no type definitions available for these imports. const runSequence = require('run-sequence'); const {packagesDir, projectDir} = buildConfig; /** Builds everything that is necessary for karma. */ task(':test:build', sequenceTask( 'clean', // Build ESM output of Material that also includes all test files. 'material:build-tests', )); /** * Runs the unit tests. Does not watch for changes. * This task should be used when running tests on the CI server. */ task('test:single-run', [':test:build'], (done: () => void) => { // Load karma not outside. Karma pollutes Promise with a different implementation. let karma = require('karma'); new karma.Server({ configFile: join(projectDir, 'test/karma.conf.js'), singleRun: true }, (exitCode: number) => { // Immediately exit the process if Karma reported errors, because due to // potential still running tunnel-browsers gulp won't exit properly. exitCode === 0 ? done() : process.exit(exitCode);
import {buildConfig, sequenceTask} from 'material2-build-tools'; const {packagesDir} = buildConfig; /** Path to the demo-app source directory. */ const demoAppSource = join(packagesDir, 'demo-app'); /** Path to the tsconfig file that builds the AOT files. */ const tsconfigFile = join(demoAppSource, 'tsconfig-aot.json'); /** Builds the demo-app assets and builds the required release packages. */ task('aot:deps', sequenceTask( [ 'cdk:build-release', 'material:build-release', 'material-experimental:build-release', 'material-moment-adapter:build-release' ], // Build the assets after the releases have been built, because the demo-app assets import // SCSS files from the release packages. [':build:devapp:assets', ':build:devapp:scss'], )); /** Build the demo-app and a release to confirm that the library is AOT-compatible. */ task('aot:build', sequenceTask('clean', 'aot:deps', 'aot:compiler-cli')); /** Build the demo-app and a release to confirm that the library is AOT-compatible. */ task('aot:compiler-cli', execNodeTask( '@angular/compiler-cli', 'ngc', ['-p', tsconfigFile] ));
import {join} from 'path'; import {task, watch} from 'gulp'; import {buildConfig, sequenceTask} from 'material2-build-tools'; // There are no type definitions available for these imports. const runSequence = require('run-sequence'); const {packagesDir, projectDir} = buildConfig; /** Builds everything that is necessary for karma. */ task(':test:build', sequenceTask( 'clean', // Build tests for all different packages by just building the tests of the moment-adapter // package. All dependencies of that package (material, cdk) will be built as well. 'material-moment-adapter:build-tests' )); /** * Runs the unit tests. Does not watch for changes. * This task should be used when running tests on the CI server. */ task('test:single-run', [':test:build'], (done: () => void) => { // Load karma not outside. Karma pollutes Promise with a different implementation. const karma = require('karma'); new karma.Server({ configFile: join(projectDir, 'test/karma.conf.js'), singleRun: true }, (exitCode: number) => { // Immediately exit the process if Karma reported errors, because due to // potential still running tunnel-browsers gulp won't exit properly.
const {packagesDir} = buildConfig; /** Path to the demo-app source directory. */ const demoAppSource = join(packagesDir, 'demo-app'); /** Path to the tsconfig file that builds the AOT files. */ const tsconfigFile = join(demoAppSource, 'tsconfig-aot.json'); /** * Build the demo-app wit the release output in order confirm that the library is * working with AOT compilation enabled. */ task('build-aot', sequenceTask( 'clean', ['build-aot:release-packages', 'build-aot:assets'], 'build-aot:compiler-cli' )); /** * Task that can be used to build the demo-app with AOT without building the * release output. This can be run if the release output is already built. */ task('build-aot:no-release-build', sequenceTask('build-aot:assets', 'build-aot:compiler-cli')); /** Builds the demo-app assets and builds the required release packages. */ task('build-aot:release-packages', sequenceTask( [ 'cdk:build-release', 'material:build-release', 'cdk-experimental:build-release',
/** Path to the directory where all releases are living. */ const releasesDir = join(outputDir, 'releases'); /** Path to the demo-app source directory. */ const demoAppSource = join(packagesDir, 'demo-app'); /** Path to the demo-app output directory. */ const demoAppOut = join(outputDir, 'packages', 'demo-app'); /** Path to the tsconfig file that builds the AOT files. */ const tsconfigFile = join(demoAppOut, 'tsconfig-aot.json'); /** Builds the demo-app and material. To be able to run NGC, apply the metadata workaround. */ task('aot:deps', sequenceTask( ['material:build-release', 'cdk:build-release', 'material-moment-adapter:build-release'], [':build:devapp:assets', ':build:devapp:scss', 'aot:copy-devapp', 'aot:copy-release'], )); // As a workaround for https://github.com/angular/angular/issues/12249, we need to // copy the Material and CDK ESM output inside of the demo-app output. task('aot:copy-release', () => { copySync(join(releasesDir, 'material'), join(demoAppOut, 'material')); copySync(join(releasesDir, 'cdk'), join(demoAppOut, 'cdk')); copySync( join(releasesDir, 'material-moment-adapter'), join(demoAppOut, 'material-moment-adapter')); }); // As a workaround for https://github.com/angular/angular/issues/12249, we need to // copy the demo-app sources to distribution and run the NGC inside of the dist folder. task('aot:copy-devapp', () => copySync(demoAppSource, demoAppOut));
// There are no type definitions available for these imports. const runSequence = require('run-sequence'); // Default Karma options. const defaultOptions = { configFile: join(buildConfig.projectDir, 'test/karma.conf.js'), autoWatch: false, singleRun: false }; /** Builds everything that is necessary for karma. */ task(':test:build', sequenceTask( 'clean', 'cdk:build-no-bundles', 'material:build-no-bundles', 'cdk-experimental:build-no-bundles', 'material-experimental:build-no-bundles', 'material-moment-adapter:build-no-bundles' )); /** * Runs the unit tests. Does not watch for changes. * This task should be used when running tests on the CI server. */ task('test:single-run', [':test:build'], (done: () => void) => { // Load karma not outside. Karma pollutes Promise with a different implementation. const karma = require('karma'); new karma.Server({...defaultOptions, singleRun: true}, (exitCode: number) => { // Immediately exit the process if Karma reported errors, because due to // potential still running tunnel-browsers gulp won't exit properly.
// highlight.js expects "typescript" written out, while Github supports "ts". let lang = language.toLowerCase() === 'ts' ? 'typescript' : language; return hljs.highlight(lang, code).value; } return code; } }; /** Generate all docs content. */ task('docs', sequenceTask( [ 'markdown-docs-material', 'markdown-docs-cdk', 'build-highlighted-examples', 'build-examples-module', 'api-docs', 'copy-stackblitz-examples' ], 'minify-html-files' )); /** Generates html files from the markdown overviews and guides for material. */ task('markdown-docs-material', () => { // Extend the renderer for custom heading anchor rendering markdown.marked.Renderer.prototype.heading = (text: string, level: number): string => { if (level === 3 || level === 4) { const escapedText = text.toLowerCase().replace(/[^\w]+/g, '-'); return ` <h${level} id="${escapedText}" class="docs-header-link"> <span header-link="${escapedText}"></span>
task(':build:devapp:ts', tsBuildTask(tsconfigPath)); task(':build:devapp:assets', copyTask(assetsGlob, outDir)); task(':build:devapp:scss', () => buildScssPipeline(appDir).pipe(dest(outDir))); task(':build:devapp:inline-resources', () => inlineResourcesForDirectory(outDir)); task(':serve:devapp', serverTask(outDir, true)); task('build:devapp', sequenceTask( 'cdk:build-no-bundles', 'material:build-no-bundles', 'cdk-experimental:build-no-bundles', 'material-experimental:build-no-bundles', 'material-moment-adapter:build-no-bundles', 'build-examples-module', // The examples module needs to be manually built before building examples package because // when using the `no-bundles` task, the package-specific pre-build tasks won't be executed. 'material-examples:build-no-bundles', [':build:devapp:assets', ':build:devapp:scss', ':build:devapp:ts'], // Inline all component resources because otherwise SystemJS tries to load HTML, CSS and // JavaScript files which makes loading the demo-app extremely slow. ':build:devapp:inline-resources', )); task('serve:devapp', ['build:devapp'], sequenceTask([':serve:devapp', ':watch:devapp'])); /* * Development App deployment tasks. These can be used to run the dev-app outside of our * serve task with a middleware. e.g. on Firebase hosting. */
// copied over. Rebuilt the theme CSS using the updated SCSS mixins. watch(join(materialOutPath, '**/*.css'), [':build:devapp:scss', triggerLivereload]); }); /** Path to the demo-app tsconfig file. */ const tsconfigPath = join(appDir, 'tsconfig-build.json'); task(':build:devapp:ts', tsBuildTask(tsconfigPath)); task(':build:devapp:scss', buildScssTask(outDir, appDir)); task(':build:devapp:assets', copyTask(appDir, outDir)); task('build:devapp', buildAppTask('devapp')); task(':serve:devapp', serverTask(outDir, true)); task('serve:devapp', ['build:devapp'], sequenceTask( [':serve:devapp', 'material:watch', ':watch:devapp'] )); /** Task that copies all vendors into the demo-app package. Allows hosting the app on firebase. */ task('stage-deploy:devapp', ['build:devapp'], () => { copyFiles(join(projectDir, 'node_modules'), vendorGlob, join(outDir, 'node_modules')); copyFiles(bundlesDir, '*.+(js|map)', join(outDir, 'dist/bundles')); copyFiles(materialOutPath, '**/prebuilt/*.+(css|map)', join(outDir, 'dist/packages/material')); }); /** * Task that deploys the demo-app to Firebase. Firebase project will be the one that is * set for project directory using the Firebase CLI. */ task('deploy:devapp', ['stage-deploy:devapp'], () => { return firebaseTools.deploy({cwd: projectDir, only: 'hosting'})
watchFiles(join(examplesPackage.sourceDir, '**/*'), ['material-examples:build-no-bundles']); }); /** Path to the demo-app tsconfig file. */ const tsconfigPath = join(appDir, 'tsconfig-build.json'); task(':build:devapp:ts', tsBuildTask(tsconfigPath)); task(':build:devapp:scss', buildScssTask(outDir, appDir)); task(':build:devapp:assets', copyTask(assetsGlob, outDir)); task(':serve:devapp', serverTask(outDir, true)); // The themes for the demo-app are built by using the SCSS mixins from Material. // Therefore when SCSS files have been changed, the custom theme needs to be rebuilt. task(':build:devapp:material-with-styles', sequenceTask( 'material:build-no-bundles', ':build:devapp:scss' )); task('build:devapp', sequenceTask( 'cdk:build-no-bundles', 'material:build-no-bundles', 'cdk-experimental:build-no-bundles', 'material-experimental:build-no-bundles', 'material-moment-adapter:build-no-bundles', 'build-examples-module', // The examples module needs to be built before building examples package 'material-examples:build-no-bundles', [':build:devapp:assets', ':build:devapp:scss', ':build:devapp:ts'] )); task('serve:devapp', ['build:devapp'], sequenceTask([':serve:devapp', ':watch:devapp']));