| 
									
										
										
										
											2015-04-25 14:45:08 -07:00
										 |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-14 08:10:31 -08:00
										 |  |  | // THIS CHECK SHOULD BE THE FIRST THING IN THIS FILE
 | 
					
						
							|  |  |  | // This is to ensure that we catch env issues before we error while requiring other dependencies.
 | 
					
						
							|  |  |  | require('./tools/check-environment')( | 
					
						
							| 
									
										
										
										
											2016-01-20 11:00:30 -08:00
										 |  |  |     {requiredNpmVersion: '>=3.5.3 <4.0.0', requiredNodeVersion: '>=5.4.1 <6.0.0'}); | 
					
						
							| 
									
										
										
										
											2015-11-14 08:10:31 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-02 21:49:10 -08:00
										 |  |  | var fse = require('fs-extra'); | 
					
						
							| 
									
										
										
										
											2014-10-28 11:45:48 +01:00
										 |  |  | var gulp = require('gulp'); | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | var gulpPlugins = require('gulp-load-plugins')(); | 
					
						
							|  |  |  | var merge = require('merge'); | 
					
						
							| 
									
										
										
										
											2015-04-24 15:59:13 -07:00
										 |  |  | var merge2 = require('merge2'); | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | var minimist = require('minimist'); | 
					
						
							|  |  |  | var os = require('os'); | 
					
						
							| 
									
										
										
										
											2015-03-18 00:43:30 +01:00
										 |  |  | var path = require('path'); | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | var runSequence = require('run-sequence'); | 
					
						
							|  |  |  | var shell = require('gulp-shell'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 17:43:30 -07:00
										 |  |  | var licenseWrap = require('./tools/build/licensewrap'); | 
					
						
							| 
									
										
										
										
											2015-10-11 02:23:05 -07:00
										 |  |  | var analytics = require('./tools/analytics/analytics'); | 
					
						
							| 
									
										
										
										
											2015-02-23 17:56:47 -08:00
										 |  |  | var pubget = require('./tools/build/pubget'); | 
					
						
							| 
									
										
										
										
											2015-02-11 11:40:29 -08:00
										 |  |  | var linknodemodules = require('./tools/build/linknodemodules'); | 
					
						
							| 
									
										
										
										
											2014-12-22 17:50:10 -08:00
										 |  |  | var pubbuild = require('./tools/build/pubbuild'); | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | var jsserve = require('./tools/build/jsserve'); | 
					
						
							|  |  |  | var pubserve = require('./tools/build/pubserve'); | 
					
						
							| 
									
										
										
										
											2015-02-20 17:44:23 -08:00
										 |  |  | var runServerDartTests = require('./tools/build/run_server_dart_tests'); | 
					
						
							| 
									
										
										
										
											2015-02-23 17:56:47 -08:00
										 |  |  | var util = require('./tools/build/util'); | 
					
						
							| 
									
										
										
										
											2015-08-20 13:19:34 -07:00
										 |  |  | var buildRouter = require('./modules/angular1_router/build'); | 
					
						
							| 
									
										
										
										
											2015-05-22 11:19:45 -04:00
										 |  |  | var shouldLog = require('./tools/build/logging'); | 
					
						
							| 
									
										
										
										
											2015-06-17 13:24:59 +02:00
										 |  |  | var dartSdk = require('./tools/build/dart'); | 
					
						
							| 
									
										
										
										
											2015-10-27 16:09:09 +01:00
										 |  |  | var browserProvidersConf = require('./browser-providers.conf.js'); | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-22 11:19:45 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-13 01:58:17 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | var cliArgs = minimist(process.argv.slice(2)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (cliArgs.projects) { | 
					
						
							|  |  |  |   // normalize for analytics
 | 
					
						
							|  |  |  |   cliArgs.projects.split(',').sort().join(','); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-16 11:11:20 -07:00
										 |  |  | // --projects=angular2 => {angular2: true}
 | 
					
						
							| 
									
										
										
										
											2015-11-13 01:58:17 -08:00
										 |  |  | var allProjects = | 
					
						
							| 
									
										
										
										
											2016-03-16 11:11:20 -07:00
										 |  |  |     'angular1_router,angular2,benchmarks,benchmarks_external,benchpress,playground,payload_tests,bundle_deps'; | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | var cliArgsProjects = (cliArgs.projects || allProjects) | 
					
						
							|  |  |  |                           .split(',') | 
					
						
							|  |  |  |                           .reduce((map, projectName) => { | 
					
						
							|  |  |  |                             map[projectName] = true; | 
					
						
							|  |  |  |                             return map; | 
					
						
							|  |  |  |                           }, {}); | 
					
						
							| 
									
										
										
										
											2015-11-16 16:18:59 -08:00
										 |  |  | var generateEs6 = !cliArgs.projects; | 
					
						
							| 
									
										
										
										
											2015-11-13 01:58:17 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | function printModulesWarning() { | 
					
						
							|  |  |  |   if (!cliArgs.projects && !process.env.CI) { | 
					
						
							|  |  |  |     // if users didn't specify projects to build, tell them why and how they should
 | 
					
						
							|  |  |  |     console.warn( | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |         "Pro Tip: Did you know that you can speed up your build by specifying project name(s)?"); | 
					
						
							|  |  |  |     console.warn("         It's like pressing the turbo button in the old days, but better!"); | 
					
						
							|  |  |  |     console.warn("         Examples: --project=angular2 or --project=angular2"); | 
					
						
							| 
									
										
										
										
											2015-11-13 01:58:17 -08:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-05 23:37:09 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-22 11:19:45 -04:00
										 |  |  | // Make it easy to quiet down portions of the build.
 | 
					
						
							|  |  |  | // --logs=all -> log everything (This is the default)
 | 
					
						
							|  |  |  | // --logs=quiet -> log nothing
 | 
					
						
							|  |  |  | // --logs=<comma-separated-list> -> log listed items.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Not all commands support optional logging, feel free
 | 
					
						
							|  |  |  | // to add support by adding a new key to this list,
 | 
					
						
							|  |  |  | // and toggling output from the command based on it.
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | var logs = {dartfmt: shouldLog('dartfmt')}; | 
					
						
							| 
									
										
										
										
											2015-04-26 00:31:53 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | // dynamic require in build.tools so we can bootstrap TypeScript compilation
 | 
					
						
							|  |  |  | function throwToolsBuildMissingError() { | 
					
						
							|  |  |  |   throw new Error('ERROR: build.tools task should have been run before using angularBuilder'); | 
					
						
							| 
									
										
										
										
											2015-04-13 09:52:02 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-04-26 00:31:53 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | var angularBuilder = { | 
					
						
							|  |  |  |   rebuildBrowserDevTree: throwToolsBuildMissingError, | 
					
						
							|  |  |  |   rebuildBrowserProdTree: throwToolsBuildMissingError, | 
					
						
							|  |  |  |   rebuildNodeTree: throwToolsBuildMissingError, | 
					
						
							|  |  |  |   rebuildDartTree: throwToolsBuildMissingError, | 
					
						
							| 
									
										
										
										
											2015-10-27 12:26:36 +01:00
										 |  |  |   uninitialized: true | 
					
						
							| 
									
										
										
										
											2015-04-26 00:31:53 -07:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2014-12-22 17:50:10 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 22:21:04 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-19 16:51:57 -07:00
										 |  |  | function sequenceComplete(done) { | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |   return function(err) { | 
					
						
							| 
									
										
										
										
											2015-05-19 16:51:57 -07:00
										 |  |  |     if (err) { | 
					
						
							|  |  |  |       var error = new Error('build sequence failed'); | 
					
						
							|  |  |  |       error.showStack = false; | 
					
						
							|  |  |  |       done(error); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       done(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 22:21:04 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | var treatTestErrorsAsFatal = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function runJasmineTests(globs, done) { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var fork = require('child_process').fork; | 
					
						
							| 
									
										
										
										
											2015-05-13 22:40:53 -04:00
										 |  |  |   var args = ['--'].concat(globs); | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-02 15:52:47 -06:00
										 |  |  |   fork('./dist/tools/cjs-jasmine', args, {stdio: 'inherit'}) | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |       .on('close', function jasmineCloseHandler(exitCode) { | 
					
						
							|  |  |  |         if (exitCode && treatTestErrorsAsFatal) { | 
					
						
							|  |  |  |           var err = new Error('Jasmine tests failed'); | 
					
						
							|  |  |  |           // Mark the error for gulp similar to how gulp-utils.PluginError does it.
 | 
					
						
							|  |  |  |           // The stack is not useful in this context.
 | 
					
						
							|  |  |  |           err.showStack = false; | 
					
						
							|  |  |  |           done(err); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |           done(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-05-13 22:21:04 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-05-07 22:37:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Note: when DART_SDK is not found, all gulp tasks ending with `.dart` will be skipped.
 | 
					
						
							| 
									
										
										
										
											2015-06-17 13:24:59 +02:00
										 |  |  | var DART_SDK = dartSdk.detect(gulp); | 
					
						
							| 
									
										
										
										
											2015-03-23 13:18:05 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | // -----------------------
 | 
					
						
							|  |  |  | // configuration
 | 
					
						
							| 
									
										
										
										
											2014-09-18 14:56:38 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | var CONFIG = { | 
					
						
							|  |  |  |   dest: { | 
					
						
							|  |  |  |     js: { | 
					
						
							|  |  |  |       all: 'dist/js', | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |       dev: {es6: 'dist/js/dev/es6', es5: 'dist/js/dev/es5'}, | 
					
						
							|  |  |  |       prod: {es6: 'dist/js/prod/es6', es5: 'dist/js/prod/es5'}, | 
					
						
							| 
									
										
										
										
											2015-02-11 11:40:29 -08:00
										 |  |  |       cjs: 'dist/js/cjs', | 
					
						
							| 
									
										
										
										
											2016-01-29 18:22:28 -08:00
										 |  |  |       dart2js: 'dist/js/dart2js', | 
					
						
							|  |  |  |       dart_dev_compiler: 'dist/js/ddc' | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2015-01-06 15:19:22 -08:00
										 |  |  |     dart: 'dist/dart', | 
					
						
							| 
									
										
										
										
											2015-06-19 19:04:41 +01:00
										 |  |  |     docs: 'dist/docs', | 
					
						
							| 
									
										
										
										
											2015-06-23 15:26:51 -07:00
										 |  |  |     docs_angular_io: 'dist/angular.io', | 
					
						
							| 
									
										
										
										
											2015-12-11 16:48:40 +01:00
										 |  |  |     bundles: {all: 'dist/build', benchpress: 'dist/build/benchpress_bundle/'} | 
					
						
							| 
									
										
										
										
											2014-11-17 20:47:05 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2014-10-08 16:15:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-10 16:04:07 +01:00
										 |  |  | var ANGULAR2_BUNDLE_CONFIG = [ | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   'angular2/common', | 
					
						
							|  |  |  |   'angular2/core', | 
					
						
							|  |  |  |   'angular2/compiler', | 
					
						
							|  |  |  |   'angular2/instrumentation', | 
					
						
							|  |  |  |   'angular2/platform/browser', | 
					
						
							|  |  |  |   'angular2/platform/common_dom' | 
					
						
							| 
									
										
										
										
											2015-12-10 16:04:07 +01:00
										 |  |  | ]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-14 23:19:18 +01:00
										 |  |  | var NG2_BUNDLE_CONTENT = ANGULAR2_BUNDLE_CONFIG.join(' + ') + ' - rxjs/*'; | 
					
						
							|  |  |  | var HTTP_BUNDLE_CONTENT = 'angular2/http - rxjs/* - ' + ANGULAR2_BUNDLE_CONFIG.join(' - '); | 
					
						
							|  |  |  | var ROUTER_BUNDLE_CONTENT = 'angular2/router + angular2/router/router_link_dsl - rxjs/* - ' + | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |                             ANGULAR2_BUNDLE_CONFIG.join(' - '); | 
					
						
							| 
									
										
										
										
											2016-04-29 18:05:36 -07:00
										 |  |  | var ALT_ROUTER_BUNDLE_CONTENT = | 
					
						
							|  |  |  |     'angular2/alt_router - rxjs/* - ' + ANGULAR2_BUNDLE_CONFIG.join(' - '); | 
					
						
							| 
									
										
										
										
											2015-12-12 19:19:38 +01:00
										 |  |  | var TESTING_BUNDLE_CONTENT = | 
					
						
							| 
									
										
										
										
											2016-01-29 13:58:06 +01:00
										 |  |  |     'angular2/testing + angular2/http/testing + angular2/router/testing + angular2/platform/testing/browser - rxjs/* - ' + | 
					
						
							| 
									
										
										
										
											2015-12-12 19:19:38 +01:00
										 |  |  |     ANGULAR2_BUNDLE_CONFIG.join(' - '); | 
					
						
							| 
									
										
										
										
											2015-12-14 23:19:18 +01:00
										 |  |  | var UPGRADE_BUNDLE_CONTENT = 'angular2/upgrade - rxjs/* - ' + ANGULAR2_BUNDLE_CONFIG.join(' - '); | 
					
						
							| 
									
										
										
										
											2015-12-10 16:04:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-23 15:26:51 -07:00
										 |  |  | var BENCHPRESS_BUNDLE_CONFIG = { | 
					
						
							|  |  |  |   entries: ['./dist/js/cjs/benchpress/index.js'], | 
					
						
							|  |  |  |   packageJson: './dist/js/cjs/benchpress/package.json', | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |   includes: ['angular2'], | 
					
						
							|  |  |  |   excludes: ['reflect-metadata', 'selenium-webdriver', 'zone.js'], | 
					
						
							| 
									
										
										
										
											2015-11-30 17:22:52 -08:00
										 |  |  |   ignore: [], | 
					
						
							| 
									
										
										
										
											2015-12-11 16:48:40 +01:00
										 |  |  |   dest: CONFIG.dest.bundles.benchpress | 
					
						
							| 
									
										
										
										
											2015-07-20 15:54:30 -07:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2015-06-23 15:26:51 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-08 17:51:02 +01:00
										 |  |  | var PAYLOAD_TESTS_CONFIG = { | 
					
						
							|  |  |  |   ts: { | 
					
						
							| 
									
										
										
										
											2016-01-20 17:56:00 +01:00
										 |  |  |     bundleName: 'app-bundle-deps.min.js', | 
					
						
							|  |  |  |     cases: ['hello_world'], | 
					
						
							|  |  |  |     dist: function(caseName, packaging) { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |       return path.join(__dirname, CONFIG.dest.js.prod.es5, 'payload_tests', caseName, | 
					
						
							|  |  |  |                        'ts/' + packaging); | 
					
						
							| 
									
										
										
										
											2016-01-20 17:56:00 +01:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  |     systemjs: {sizeLimits: {'uncompressed': 880 * 1024, 'gzip level=9': 170 * 1024}}, | 
					
						
							|  |  |  |     webpack: {sizeLimits: {'uncompressed': 560 * 1024, 'gzip level=9': 130 * 1024}} | 
					
						
							| 
									
										
										
										
											2016-01-08 17:51:02 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | // ------------
 | 
					
						
							|  |  |  | // clean
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-02 21:49:10 -08:00
										 |  |  | gulp.task('build/clean.tools', (done) => fse.remove(path.join('dist', 'tools'), done)); | 
					
						
							| 
									
										
										
										
											2015-04-26 23:14:52 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-02 21:49:10 -08:00
										 |  |  | gulp.task('build/clean.js', (done) => fse.remove(CONFIG.dest.js.all, done)); | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-02 21:49:10 -08:00
										 |  |  | gulp.task('build/clean.dart', (done) => fse.remove(CONFIG.dest.dart, done)); | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-02 21:49:10 -08:00
										 |  |  | gulp.task('build/clean.docs', (done) => fse.remove(CONFIG.dest.docs, done)); | 
					
						
							| 
									
										
										
										
											2015-01-16 14:21:55 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-02 21:49:10 -08:00
										 |  |  | gulp.task('build/clean.docs_angular_io', (done) => fse.remove(CONFIG.dest.docs_angular_io, done)); | 
					
						
							| 
									
										
										
										
											2015-06-19 19:04:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-02 21:49:10 -08:00
										 |  |  | gulp.task('build/clean.bundles', (done) => fse.remove(CONFIG.dest.bundles.all, done)); | 
					
						
							| 
									
										
										
										
											2015-12-11 16:48:40 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('build/clean.bundles.benchpress', | 
					
						
							|  |  |  |           (done) => fse.remove(CONFIG.dest.bundles.benchpress, done)); | 
					
						
							| 
									
										
										
										
											2015-01-06 15:19:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | // ------------
 | 
					
						
							|  |  |  | // transpile
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('build/tree.dart', ['build/clean.dart', 'build.tools'], | 
					
						
							|  |  |  |           function(done) { runSequence('!build/tree.dart', sequenceComplete(done)); }); | 
					
						
							| 
									
										
										
										
											2015-05-06 08:45:28 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('!build/tree.dart', | 
					
						
							|  |  |  |           function() { return angularBuilder.rebuildDartTree(cliArgsProjects); }); | 
					
						
							| 
									
										
										
										
											2015-03-18 14:42:18 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-06 08:45:28 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | // ------------
 | 
					
						
							|  |  |  | // pubspec
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-19 11:36:27 -07:00
										 |  |  | // Run a top-level `pub get` for this project.
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | gulp.task('pubget.dart', pubget.dir(gulp, gulpPlugins, {dir: '.', command: DART_SDK.PUB})); | 
					
						
							| 
									
										
										
										
											2015-03-19 11:36:27 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 |  |  | // Run `pub get` only on the angular2 dir of CONFIG.dest.dart
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('!build/pubget.angular2.dart', | 
					
						
							|  |  |  |           pubget.dir(gulp, gulpPlugins, | 
					
						
							|  |  |  |                      {dir: path.join(CONFIG.dest.dart, 'angular2'), command: DART_SDK.PUB})); | 
					
						
							| 
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-19 11:36:27 -07:00
										 |  |  | // Run `pub get` over CONFIG.dest.dart
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('build/pubspec.dart', | 
					
						
							|  |  |  |           pubget.subDir(gulp, gulpPlugins, {dir: CONFIG.dest.dart, command: DART_SDK.PUB})); | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 21:37:14 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | // This is a hacky way to work around dart's pub that creates `packages` symlink in every directory
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | // that contains a dart file with the main method. For our tests this means that every test
 | 
					
						
							|  |  |  | // subfolder
 | 
					
						
							| 
									
										
										
										
											2015-06-30 21:37:14 -07:00
										 |  |  | // has a link to the root `packages` directory which causes Karma to sift through 80k files during
 | 
					
						
							|  |  |  | // each `karma run` invocation.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Since these directories are not needed for karma tests to run, it's safe to delete them without
 | 
					
						
							|  |  |  | // breaking any functionality.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // See #2437 for more info.
 | 
					
						
							|  |  |  | gulp.task('!build/remove-pub-symlinks', function(done) { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var exec = require('child_process').exec; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 21:37:14 -07:00
										 |  |  |   if (process.platform == 'win32') { | 
					
						
							|  |  |  |     done(); | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   exec('find dist/dart/angular2/test/ -name packages | xargs rm -r', | 
					
						
							|  |  |  |        function(error, stdout, stderr) { | 
					
						
							|  |  |  |          if (error) { | 
					
						
							|  |  |  |            done(stderr); | 
					
						
							|  |  |  |            return; | 
					
						
							|  |  |  |          } | 
					
						
							|  |  |  |          done(); | 
					
						
							|  |  |  |        }); | 
					
						
							| 
									
										
										
										
											2015-06-30 21:37:14 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | // ------------
 | 
					
						
							| 
									
										
										
										
											2014-12-22 17:50:10 -08:00
										 |  |  | // dartanalyzer
 | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-08 16:15:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | gulp.task('build/analyze.dart', () => { | 
					
						
							|  |  |  |   var dartanalyzer = require('./tools/build/dartanalyzer'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return dartanalyzer(gulp, gulpPlugins, {dest: CONFIG.dest.dart, command: DART_SDK.ANALYZER}); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gulp.task('build/analyze.ddc.dart', () => { | 
					
						
							|  |  |  |   var dartanalyzer = require('./tools/build/dartanalyzer'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   return dartanalyzer(gulp, gulpPlugins, | 
					
						
							|  |  |  |                       {dest: CONFIG.dest.dart, command: DART_SDK.ANALYZER, use_ddc: true}); | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gulp.task('build/check.apidocs.dart', () => { | 
					
						
							|  |  |  |   var dartapidocs = require('./tools/build/dartapidocs'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   return dartapidocs(gulp, gulpPlugins, | 
					
						
							|  |  |  |                      {dest: CONFIG.dest.dart, output: os.tmpdir(), command: DART_SDK.DARTDOCGEN}); | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-06-03 17:22:30 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-06 15:07:33 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-22 17:50:10 -08:00
										 |  |  | // ------------
 | 
					
						
							|  |  |  | // pubbuild
 | 
					
						
							| 
									
										
										
										
											2015-07-20 15:54:30 -07:00
										 |  |  | // WARNING: this task is very slow (~15m as of July 2015)
 | 
					
						
							| 
									
										
										
										
											2014-12-22 17:50:10 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-19 16:08:23 -08:00
										 |  |  | gulp.task( | 
					
						
							|  |  |  |     'build/pubbuild.dart', | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |     pubbuild.subdirs(gulp, gulpPlugins, | 
					
						
							|  |  |  |                      {src: CONFIG.dest.dart, dest: CONFIG.dest.js.dart2js, command: DART_SDK.PUB})); | 
					
						
							| 
									
										
										
										
											2014-12-22 17:50:10 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-30 11:03:11 -08:00
										 |  |  | // ------------
 | 
					
						
							| 
									
										
										
										
											2015-04-01 10:45:56 -07:00
										 |  |  | // formatting
 | 
					
						
							| 
									
										
										
										
											2015-01-30 11:03:11 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-11 13:29:32 -07:00
										 |  |  | function doCheckFormat() { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var clangFormat = require('clang-format'); | 
					
						
							|  |  |  |   var gulpFormat = require('gulp-clang-format'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-29 10:35:36 -07:00
										 |  |  |   return gulp.src([ | 
					
						
							|  |  |  |                'modules/**/*.ts', | 
					
						
							|  |  |  |                'tools/**/*.ts', | 
					
						
							|  |  |  |                '!**/typings/**/*.d.ts', | 
					
						
							|  |  |  |                // workaround https://github.com/angular/clang-format/issues/28
 | 
					
						
							|  |  |  |                '!tools/compiler_cli/src/main.ts', | 
					
						
							|  |  |  |                'gulpfile.js' | 
					
						
							|  |  |  |              ]) | 
					
						
							| 
									
										
										
										
											2015-06-25 16:21:43 -07:00
										 |  |  |       .pipe(gulpFormat.checkFormat('file', clangFormat)); | 
					
						
							| 
									
										
										
										
											2015-04-11 13:29:32 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-01 10:45:56 -07:00
										 |  |  | gulp.task('check-format', function() { | 
					
						
							| 
									
										
										
										
											2015-04-11 13:29:32 -07:00
										 |  |  |   return doCheckFormat().on('warning', function(e) { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |     console.log("NOTE: this will be promoted to an ERROR in the continuous build"); | 
					
						
							| 
									
										
										
										
											2015-04-11 13:29:32 -07:00
										 |  |  |   }); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gulp.task('enforce-format', function() { | 
					
						
							|  |  |  |   return doCheckFormat().on('warning', function(e) { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |     console.log("ERROR: You forgot to run clang-format on your change."); | 
					
						
							|  |  |  |     console.log("See https://github.com/angular/angular/blob/master/DEVELOPER.md#clang-format"); | 
					
						
							| 
									
										
										
										
											2015-04-11 13:29:32 -07:00
										 |  |  |     process.exit(1); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2015-04-01 10:45:56 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-24 15:36:16 -07:00
										 |  |  | gulp.task('lint', ['build.tools'], function() { | 
					
						
							| 
									
										
										
										
											2015-09-23 15:02:37 -07:00
										 |  |  |   var tslint = require('gulp-tslint'); | 
					
						
							| 
									
										
										
										
											2015-07-07 20:03:00 -07:00
										 |  |  |   // Built-in rules are at
 | 
					
						
							| 
									
										
										
										
											2015-06-24 15:36:16 -07:00
										 |  |  |   // https://github.com/palantir/tslint#supported-rules
 | 
					
						
							| 
									
										
										
										
											2016-03-28 14:25:22 -07:00
										 |  |  |   var tslintConfig = require('./tslint.json'); | 
					
						
							| 
									
										
										
										
											2015-10-13 00:29:13 -07:00
										 |  |  |   return gulp.src(['modules/angular2/src/**/*.ts', '!modules/angular2/src/testing/**']) | 
					
						
							| 
									
										
										
										
											2015-09-25 12:58:00 -07:00
										 |  |  |       .pipe(tslint({ | 
					
						
							| 
									
										
										
										
											2015-10-27 20:51:03 -07:00
										 |  |  |         tslint: require('tslint').default, | 
					
						
							| 
									
										
										
										
											2015-09-25 12:58:00 -07:00
										 |  |  |         configuration: tslintConfig, | 
					
						
							|  |  |  |         rulesDirectory: 'dist/tools/tslint' | 
					
						
							|  |  |  |       })) | 
					
						
							| 
									
										
										
										
											2015-07-07 20:03:00 -07:00
										 |  |  |       .pipe(tslint.report('prose', {emitError: true})); | 
					
						
							| 
									
										
										
										
											2015-06-24 15:36:16 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-16 18:48:14 +01:00
										 |  |  | // ------------
 | 
					
						
							|  |  |  | // check circular dependencies in Node.js context
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | gulp.task('build/checkCircularDependencies', function(done) { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var madge = require('madge'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-25 12:04:59 -08:00
										 |  |  |   var dependencyObject = madge([CONFIG.dest.js.dev.es5], { | 
					
						
							| 
									
										
										
										
											2015-11-16 16:18:59 -08:00
										 |  |  |     format: 'cjs', | 
					
						
							| 
									
										
										
										
											2015-06-10 00:02:37 -07:00
										 |  |  |     extensions: ['.js'], | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |     onParseFile: function(data) { data.src = data.src.replace(/\/\* circular \*\//g, "//"); } | 
					
						
							| 
									
										
										
										
											2015-03-16 18:48:14 +01:00
										 |  |  |   }); | 
					
						
							|  |  |  |   var circularDependencies = dependencyObject.circular().getArray(); | 
					
						
							|  |  |  |   if (circularDependencies.length > 0) { | 
					
						
							|  |  |  |     console.log(circularDependencies); | 
					
						
							|  |  |  |     process.exit(1); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   done(); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-12 10:30:08 -07:00
										 |  |  | function jsServeDev() { | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |   return jsserve(gulp, gulpPlugins, {path: CONFIG.dest.js.dev.es5, port: 8000})(); | 
					
						
							| 
									
										
										
										
											2015-06-12 10:30:08 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function jsServeProd() { | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |   return jsserve(gulp, gulpPlugins, {path: CONFIG.dest.js.prod.es5, port: 8001})(); | 
					
						
							| 
									
										
										
										
											2015-06-12 10:30:08 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function jsServeDartJs() { | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |   return jsserve(gulp, gulpPlugins, {path: CONFIG.dest.js.dart2js, port: 8002})(); | 
					
						
							| 
									
										
										
										
											2015-06-12 10:30:08 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-29 18:22:28 -08:00
										 |  |  | function jsServeDartDevCompiler() { | 
					
						
							|  |  |  |   return jsserve(gulp, gulpPlugins, {path: CONFIG.dest.js.dart_dev_compiler, port: 8003})(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 15:54:30 -07:00
										 |  |  | function proxyServeDart() { | 
					
						
							|  |  |  |   return jsserve(gulp, gulpPlugins, { | 
					
						
							|  |  |  |     port: 8002, | 
					
						
							|  |  |  |     proxies: [ | 
					
						
							| 
									
										
										
										
											2015-10-10 00:25:17 +02:00
										 |  |  |       {route: '/playground', url: 'http://localhost:8004'}, | 
					
						
							| 
									
										
										
										
											2015-07-20 15:54:30 -07:00
										 |  |  |       {route: '/benchmarks_external', url: 'http://localhost:8008'}, | 
					
						
							|  |  |  |       {route: '/benchmarks', url: 'http://localhost:8006'} | 
					
						
							|  |  |  |     ] | 
					
						
							|  |  |  |   })(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-18 14:56:38 -07:00
										 |  |  | // ------------------
 | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | // web servers
 | 
					
						
							| 
									
										
										
										
											2016-02-25 14:24:17 -08:00
										 |  |  | gulp.task('serve.js.dev', ['build.js.dev', 'build.js.cjs'], function(neverDone) { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var watch = require('./tools/build/watch'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |   watch('modules/**', {ignoreInitial: true}, '!broccoli.js.dev'); | 
					
						
							| 
									
										
										
										
											2015-06-12 10:30:08 -07:00
										 |  |  |   jsServeDev(); | 
					
						
							| 
									
										
										
										
											2015-06-10 16:52:19 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-12 10:30:08 -07:00
										 |  |  | gulp.task('serve.js.prod', jsServeProd); | 
					
						
							| 
									
										
										
										
											2015-04-27 15:24:32 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-16 11:11:20 -07:00
										 |  |  | gulp.task('serve.e2e.dev', ['build.js.dev', 'build.js.cjs'], function(neverDone) { | 
					
						
							|  |  |  |   var watch = require('./tools/build/watch'); | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-16 11:11:20 -07:00
										 |  |  |   watch('modules/**', {ignoreInitial: true}, ['!broccoli.js.dev', '!build.js.cjs']); | 
					
						
							|  |  |  |   jsServeDev(); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-04-27 15:24:32 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-16 11:11:20 -07:00
										 |  |  | gulp.task('serve.e2e.prod', ['build.js.prod', 'build.js.cjs'], function(neverDone) { | 
					
						
							|  |  |  |   var watch = require('./tools/build/watch'); | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-16 11:11:20 -07:00
										 |  |  |   watch('modules/**', {ignoreInitial: true}, ['!broccoli.js.prod', '!build.js.cjs']); | 
					
						
							|  |  |  |   jsServeProd(); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2014-12-22 17:50:10 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-12 10:30:08 -07:00
										 |  |  | gulp.task('serve.js.dart2js', jsServeDartJs); | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-29 18:22:28 -08:00
										 |  |  | gulp.task('serve.js.ddc', jsServeDartDevCompiler); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 15:54:30 -07:00
										 |  |  | gulp.task('!proxyServeDart', proxyServeDart); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gulp.task('serve.dart', function(done) { | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |   runSequence( | 
					
						
							|  |  |  |       [ | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |         '!proxyServeDart', | 
					
						
							|  |  |  |         'serve/playground.dart', | 
					
						
							|  |  |  |         'serve/benchmarks.dart', | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |         'serve/benchmarks_external.dart' | 
					
						
							|  |  |  |       ], | 
					
						
							|  |  |  |       done); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('serve/playground.dart', | 
					
						
							|  |  |  |           pubserve(gulp, gulpPlugins, | 
					
						
							|  |  |  |                    {command: DART_SDK.PUB, path: CONFIG.dest.dart + '/playground', port: 8004})); | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('serve/benchmarks.dart', | 
					
						
							|  |  |  |           pubserve(gulp, gulpPlugins, | 
					
						
							|  |  |  |                    {command: DART_SDK.PUB, path: CONFIG.dest.dart + '/benchmarks', port: 8006})); | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | gulp.task( | 
					
						
							|  |  |  |     'serve/benchmarks_external.dart', | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |     pubserve(gulp, gulpPlugins, | 
					
						
							|  |  |  |              {command: DART_SDK.PUB, path: CONFIG.dest.dart + '/benchmarks_external', port: 8008})); | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-22 09:42:05 -07:00
										 |  |  | gulp.task('serve.e2e.dart', ['build.js.cjs'], function(neverDone) { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var watch = require('./tools/build/watch'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-22 09:42:05 -07:00
										 |  |  |   // Note: we are not using build.dart as the dart analyzer takes too long...
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |   watch('modules/**', {ignoreInitial: true}, ['!build/tree.dart', '!build.js.cjs']); | 
					
						
							| 
									
										
										
										
											2016-03-16 11:11:20 -07:00
										 |  |  |   runSequence('build/packages.dart', 'build/pubspec.dart', 'serve.dart'); | 
					
						
							| 
									
										
										
										
											2015-07-22 09:42:05 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-07 18:29:19 +01:00
										 |  |  | // ------------------
 | 
					
						
							| 
									
										
										
										
											2015-03-19 11:36:27 -07:00
										 |  |  | // CI tests suites
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 21:57:16 -07:00
										 |  |  | function execProcess(name, args, done) { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var exec = require('child_process').exec; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 21:57:16 -07:00
										 |  |  |   var cmd = process.platform === 'win32' ? 'node_modules\\.bin\\' + name + ' ' : | 
					
						
							|  |  |  |                                            'node node_modules/.bin/' + name + ' '; | 
					
						
							|  |  |  |   cmd += args; | 
					
						
							|  |  |  |   exec(cmd, done); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | function runKarma(configFile, done) { | 
					
						
							|  |  |  |   execProcess('karma', 'run ' + configFile, function(e, stdout) { | 
					
						
							| 
									
										
										
										
											2015-06-09 13:44:42 +02:00
										 |  |  |     // ignore errors, we don't want to fail the build in the interactive (non-ci) mode
 | 
					
						
							|  |  |  |     // karma server will print all test failures
 | 
					
						
							|  |  |  |     done(); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 21:57:16 -07:00
										 |  |  | // Gulp-typescript doesn't work with typescript@next:
 | 
					
						
							|  |  |  | // https://github.com/ivogabe/gulp-typescript/issues/331
 | 
					
						
							|  |  |  | function runTsc(project, done) { | 
					
						
							|  |  |  |   execProcess('tsc', '-p ' + project, function(e, stdout, stderr) { | 
					
						
							|  |  |  |     if (e) { | 
					
						
							|  |  |  |       console.log(stdout); | 
					
						
							|  |  |  |       console.error(stderr); | 
					
						
							|  |  |  |       done(e); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       done(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-19 11:36:27 -07:00
										 |  |  | gulp.task('test.js', function(done) { | 
					
						
							| 
									
										
										
										
											2016-04-28 21:58:51 -07:00
										 |  |  |   runSequence('test.compiler_cli', 'test.unit.tools/ci', 'test.transpiler.unittest', | 
					
						
							|  |  |  |               'test.unit.js/ci', 'test.unit.cjs/ci', 'test.typings', 'check-public-api', | 
					
						
							| 
									
										
										
										
											2016-04-28 21:57:16 -07:00
										 |  |  |               sequenceComplete(done)); | 
					
						
							| 
									
										
										
										
											2015-03-19 11:36:27 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gulp.task('test.dart', function(done) { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   runSequence('versions.dart', 'test.transpiler.unittest', 'test.unit.dart/ci', | 
					
						
							|  |  |  |               sequenceComplete(done)); | 
					
						
							| 
									
										
										
										
											2015-06-17 13:24:59 +02:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | gulp.task('versions.dart', function() { dartSdk.logVersion(DART_SDK); }); | 
					
						
							| 
									
										
										
										
											2015-03-19 11:36:27 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Reuse the Travis scripts
 | 
					
						
							|  |  |  | // TODO: rename test_*.sh to test_all_*.sh
 | 
					
						
							| 
									
										
										
										
											2015-08-30 22:17:20 +02:00
										 |  |  | gulp.task('test.all.js', shell.task(['./scripts/ci/test_js.sh'])); | 
					
						
							|  |  |  | gulp.task('test.all.dart', shell.task(['./scripts/ci/test_dart.sh'])); | 
					
						
							| 
									
										
										
										
											2015-03-19 11:36:27 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-20 17:44:23 -08:00
										 |  |  | // karma tests
 | 
					
						
							|  |  |  | //     These tests run in the browser and are allowed to access
 | 
					
						
							|  |  |  | //     HTML DOM APIs.
 | 
					
						
							| 
									
										
										
										
											2015-11-19 21:19:04 +01:00
										 |  |  | function getBrowsersFromCLI(provider, isDart) { | 
					
						
							| 
									
										
										
										
											2015-11-04 11:59:44 +01:00
										 |  |  |   var isProvider = false; | 
					
						
							| 
									
										
										
										
											2015-11-19 21:19:04 +01:00
										 |  |  |   var rawInput = | 
					
						
							|  |  |  |       cliArgs.browsers ? cliArgs.browsers : (isDart ? 'DartiumWithWebPlatform' : 'Chrome'); | 
					
						
							| 
									
										
										
										
											2015-06-02 16:29:09 +02:00
										 |  |  |   var inputList = rawInput.replace(' ', '').split(','); | 
					
						
							|  |  |  |   var outputList = []; | 
					
						
							|  |  |  |   for (var i = 0; i < inputList.length; i++) { | 
					
						
							|  |  |  |     var input = inputList[i]; | 
					
						
							| 
									
										
										
										
											2015-08-24 16:24:34 +02:00
										 |  |  |     var karmaChromeLauncher = require('karma-chrome-launcher'); | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |     if (browserProvidersConf.customLaunchers.hasOwnProperty(input) || | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |         karmaChromeLauncher.hasOwnProperty("launcher:" + input)) { | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |       // In case of non-sauce browsers, or browsers defined in karma-chrome-launcher (Chrome,
 | 
					
						
							|  |  |  |       // ChromeCanary and Dartium):
 | 
					
						
							| 
									
										
										
										
											2015-08-24 16:24:34 +02:00
										 |  |  |       // overrides everything, ignoring other options
 | 
					
						
							| 
									
										
										
										
											2015-06-02 16:29:09 +02:00
										 |  |  |       outputList = [input]; | 
					
						
							| 
									
										
										
										
											2015-11-04 11:59:44 +01:00
										 |  |  |       isProvider = false; | 
					
						
							| 
									
										
										
										
											2015-06-02 16:29:09 +02:00
										 |  |  |       break; | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |     } else if (provider && | 
					
						
							|  |  |  |                browserProvidersConf.customLaunchers.hasOwnProperty(provider + "_" + | 
					
						
							|  |  |  |                                                                    input.toUpperCase())) { | 
					
						
							| 
									
										
										
										
											2015-11-04 11:59:44 +01:00
										 |  |  |       isProvider = true; | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |       outputList.push(provider + "_" + input.toUpperCase()); | 
					
						
							|  |  |  |     } else if (provider && provider == 'SL' && | 
					
						
							|  |  |  |                browserProvidersConf.sauceAliases.hasOwnProperty(input.toUpperCase())) { | 
					
						
							| 
									
										
										
										
											2015-11-04 11:59:44 +01:00
										 |  |  |       outputList = outputList.concat(browserProvidersConf.sauceAliases[input.toUpperCase()]); | 
					
						
							|  |  |  |       isProvider = true; | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |     } else if (provider && provider == 'BS' && | 
					
						
							|  |  |  |                browserProvidersConf.browserstackAliases.hasOwnProperty(input.toUpperCase())) { | 
					
						
							| 
									
										
										
										
											2015-11-04 11:59:44 +01:00
										 |  |  |       outputList = outputList.concat(browserProvidersConf.browserstackAliases[input.toUpperCase()]); | 
					
						
							|  |  |  |       isProvider = true; | 
					
						
							| 
									
										
										
										
											2015-06-02 16:29:09 +02:00
										 |  |  |     } else { | 
					
						
							|  |  |  |       throw new Error('ERROR: unknown browser found in getBrowsersFromCLI()'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return { | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |     browsersToRun: | 
					
						
							|  |  |  |         outputList.filter(function(item, pos, self) { return self.indexOf(item) == pos; }), | 
					
						
							| 
									
										
										
										
											2015-11-04 11:59:44 +01:00
										 |  |  |     isProvider: isProvider | 
					
						
							| 
									
										
										
										
											2015-07-29 17:00:54 -07:00
										 |  |  |   }; | 
					
						
							| 
									
										
										
										
											2014-11-07 18:29:19 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-04-27 16:11:20 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | gulp.task('test.unit.js', ['build.js.dev'], function(neverDone) { | 
					
						
							|  |  |  |   var watch = require('./tools/build/watch'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-13 01:58:17 -08:00
										 |  |  |   printModulesWarning(); | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |   runSequence('!test.unit.js/karma-server', function() { | 
					
						
							|  |  |  |     watch('modules/**', {ignoreInitial: true}, ['!broccoli.js.dev', '!test.unit.js/karma-run']); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2015-05-06 08:45:28 -07:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-04-27 16:11:20 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | gulp.task('watch.js.dev', ['build.js.dev'], function(neverDone) { | 
					
						
							|  |  |  |   var watch = require('./tools/build/watch'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-13 01:58:17 -08:00
										 |  |  |   printModulesWarning(); | 
					
						
							|  |  |  |   watch('modules/**', ['!broccoli.js.dev']); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-10-13 13:42:38 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | gulp.task('test.unit.js.sauce', ['build.js.dev'], function(done) { | 
					
						
							| 
									
										
										
										
											2015-11-13 01:58:17 -08:00
										 |  |  |   printModulesWarning(); | 
					
						
							| 
									
										
										
										
											2015-11-04 11:59:44 +01:00
										 |  |  |   var browserConf = getBrowsersFromCLI('SL'); | 
					
						
							|  |  |  |   if (browserConf.isProvider) { | 
					
						
							|  |  |  |     launchKarmaWithExternalBrowsers(['dots'], browserConf.browsersToRun, done); | 
					
						
							| 
									
										
										
										
											2015-06-02 16:29:09 +02:00
										 |  |  |   } else { | 
					
						
							|  |  |  |     throw new Error('ERROR: no Saucelabs browsers provided, add them with the --browsers option'); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-04-27 16:11:20 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | gulp.task('test.unit.js.browserstack', ['build.js.dev'], function(done) { | 
					
						
							| 
									
										
										
										
											2015-11-13 01:58:17 -08:00
										 |  |  |   printModulesWarning(); | 
					
						
							| 
									
										
										
										
											2015-11-04 11:59:44 +01:00
										 |  |  |   var browserConf = getBrowsersFromCLI('BS'); | 
					
						
							|  |  |  |   if (browserConf.isProvider) { | 
					
						
							|  |  |  |     launchKarmaWithExternalBrowsers(['dots'], browserConf.browsersToRun, done); | 
					
						
							|  |  |  |   } else { | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |     throw new Error( | 
					
						
							|  |  |  |         'ERROR: no Browserstack browsers provided, add them with the --browsers option'); | 
					
						
							| 
									
										
										
										
											2015-11-04 11:59:44 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function launchKarmaWithExternalBrowsers(reporters, browsers, done) { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var karma = require('karma'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   new karma.Server( | 
					
						
							|  |  |  |                { | 
					
						
							|  |  |  |                  configFile: __dirname + '/karma-js.conf.js', | 
					
						
							|  |  |  |                  singleRun: true, | 
					
						
							|  |  |  |                  browserNoActivityTimeout: 240000, | 
					
						
							|  |  |  |                  captureTimeout: 120000, | 
					
						
							|  |  |  |                  reporters: reporters, | 
					
						
							|  |  |  |                  browsers: browsers | 
					
						
							|  |  |  |                }, | 
					
						
							|  |  |  |                function(err) { | 
					
						
							|  |  |  |                  done(); | 
					
						
							|  |  |  |                  process.exit(err ? 1 : 0); | 
					
						
							|  |  |  |                }) | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |       .start(); | 
					
						
							| 
									
										
										
										
											2015-11-04 11:59:44 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-17 01:01:59 +02:00
										 |  |  | gulp.task('!test.unit.js/karma-server', function(done) { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var karma = require('karma'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-17 01:01:59 +02:00
										 |  |  |   var watchStarted = false; | 
					
						
							| 
									
										
										
										
											2015-11-23 14:58:18 -08:00
										 |  |  |   var server = new karma.Server({configFile: __dirname + '/karma-js.conf.js'}); | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |   server.on('run_complete', function() { | 
					
						
							| 
									
										
										
										
											2015-10-17 01:01:59 +02:00
										 |  |  |     if (!watchStarted) { | 
					
						
							|  |  |  |       watchStarted = true; | 
					
						
							|  |  |  |       done(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   server.start(); | 
					
						
							| 
									
										
										
										
											2015-04-27 16:11:20 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-06 08:45:28 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | gulp.task('!test.unit.js/karma-run', function(done) { | 
					
						
							| 
									
										
										
										
											2015-05-19 23:14:20 -07:00
										 |  |  |   // run the run command in a new process to avoid duplicate logging by both server and runner from
 | 
					
						
							|  |  |  |   // a single process
 | 
					
						
							| 
									
										
										
										
											2015-06-09 13:44:42 +02:00
										 |  |  |   runKarma('karma-js.conf.js', done); | 
					
						
							| 
									
										
										
										
											2014-11-07 18:29:19 +01:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-04-27 16:11:20 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | gulp.task('test.unit.router', function(neverDone) { | 
					
						
							|  |  |  |   var watch = require('./tools/build/watch'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |   runSequence('!test.unit.router/karma-server', function() { | 
					
						
							|  |  |  |     watch('modules/**', ['buildRouter.dev', '!test.unit.router/karma-run']); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2015-08-20 13:19:34 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gulp.task('!test.unit.router/karma-server', function() { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var karma = require('karma'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-23 14:58:18 -08:00
										 |  |  |   new karma.Server({configFile: __dirname + '/modules/angular1_router/karma-router.conf.js'}) | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |       .start(); | 
					
						
							| 
									
										
										
										
											2015-08-20 13:19:34 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gulp.task('!test.unit.router/karma-run', function(done) { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var karma = require('karma'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   karma.runner.run({configFile: __dirname + '/modules/angular1_router/karma-router.conf.js'}, | 
					
						
							|  |  |  |                    function(exitCode) { | 
					
						
							|  |  |  |                      // ignore exitCode, we don't want to fail the build in the interactive (non-ci)
 | 
					
						
							|  |  |  |                      // mode
 | 
					
						
							|  |  |  |                      // karma will print all test failures
 | 
					
						
							|  |  |  |                      done(); | 
					
						
							|  |  |  |                    }); | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-29 13:28:59 -08:00
										 |  |  | gulp.task('buildRouter.dev', function() { | 
					
						
							|  |  |  |   var modulesSrcDir = __dirname + '/modules'; | 
					
						
							|  |  |  |   var distDir = __dirname + '/dist'; | 
					
						
							|  |  |  |   buildRouter(modulesSrcDir, distDir); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | gulp.task('test.unit.dart', function(done) { | 
					
						
							| 
									
										
										
										
											2015-11-13 01:58:17 -08:00
										 |  |  |   printModulesWarning(); | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   runSequence('build/tree.dart', 'build/pure-packages.dart', '!build/pubget.angular2.dart', | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  |               '!build/remove-pub-symlinks', function(error) { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |                 var watch = require('./tools/build/watch'); | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |                 // if initial build failed (likely due to build or formatting step) then exit
 | 
					
						
							|  |  |  |                 // otherwise karma server doesn't start and we can't continue running properly
 | 
					
						
							|  |  |  |                 if (error) { | 
					
						
							|  |  |  |                   done(error); | 
					
						
							|  |  |  |                   return; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 // treatTestErrorsAsFatal = false;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 watch(['modules/angular2/**'], | 
					
						
							|  |  |  |                       ['!build/tree.dart', '!test.unit.dart/run/angular2']); | 
					
						
							|  |  |  |               }); | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-19 16:08:23 -08:00
										 |  |  | // Dart Payload Size Test
 | 
					
						
							|  |  |  | // This test will fail if the size of our hello_world app goes beyond one of
 | 
					
						
							|  |  |  | // these values when compressed at the specified level.
 | 
					
						
							|  |  |  | // Measure in bytes.
 | 
					
						
							| 
									
										
										
										
											2016-01-08 17:51:02 +01:00
										 |  |  | var _DART_PAYLOAD_SIZE_LIMITS = {'uncompressed': 320 * 1024, 'gzip level=9': 90 * 1024}; | 
					
						
							| 
									
										
										
										
											2015-11-19 16:08:23 -08:00
										 |  |  | gulp.task('test.payload.dart/ci', function(done) { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   runSequence('build/packages.dart', '!pubget.payload.dart', '!pubbuild.payload.dart', | 
					
						
							|  |  |  |               '!checkAndReport.payload.dart', done); | 
					
						
							| 
									
										
										
										
											2015-11-19 16:08:23 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('!pubget.payload.dart', | 
					
						
							|  |  |  |           pubget.dir(gulp, gulpPlugins, | 
					
						
							|  |  |  |                      {dir: 'modules_dart/payload/hello_world', command: DART_SDK.PUB})); | 
					
						
							| 
									
										
										
										
											2015-11-19 16:08:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('!pubbuild.payload.dart', | 
					
						
							|  |  |  |           pubbuild.single(gulp, gulpPlugins, | 
					
						
							|  |  |  |                           {command: DART_SDK.PUB, src: 'modules_dart/payload/hello_world'})); | 
					
						
							| 
									
										
										
										
											2015-11-19 16:08:23 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | gulp.task('!checkAndReport.payload.dart', function() { | 
					
						
							|  |  |  |   var reportSize = require('./tools/analytics/reportsize'); | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   return reportSize('modules_dart/payload/hello_world/build/web/*.dart.js', | 
					
						
							|  |  |  |                     {failConditions: _DART_PAYLOAD_SIZE_LIMITS, prefix: 'hello_world'}); | 
					
						
							| 
									
										
										
										
											2015-11-19 16:08:23 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-08 17:51:02 +01:00
										 |  |  | // JS payload size tracking
 | 
					
						
							|  |  |  | gulp.task('test.payload.js/ci', function(done) { | 
					
						
							|  |  |  |   runSequence('build.payload.js', '!checkAndReport.payload.js', sequenceComplete(done)); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-20 17:56:00 +01:00
										 |  |  | gulp.task('build.payload.js', ['build.js'], function(done) { | 
					
						
							|  |  |  |   runSequence('!build.payload.js.webpack', '!build.payload.js.systemjs', sequenceComplete(done)); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2016-01-08 17:51:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | gulp.task('!build.payload.js.webpack', function() { | 
					
						
							| 
									
										
										
										
											2016-01-18 15:08:49 +01:00
										 |  |  |   var webpack = require('./tools/build/webpack/promiseify'); | 
					
						
							| 
									
										
										
										
											2016-01-08 17:51:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   var ES5_PROD_ROOT = __dirname + '/' + CONFIG.dest.js.prod.es5; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-18 15:08:49 +01:00
										 |  |  |   return Promise.all(PAYLOAD_TESTS_CONFIG.ts.cases.map(function(caseName) { | 
					
						
							| 
									
										
										
										
											2016-01-20 17:56:00 +01:00
										 |  |  |     var CASE_PATH = PAYLOAD_TESTS_CONFIG.ts.dist(caseName, 'webpack'); | 
					
						
							| 
									
										
										
										
											2016-01-08 17:51:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return webpack({ | 
					
						
							|  |  |  |              // bundle app + framework
 | 
					
						
							|  |  |  |              entry: CASE_PATH + '/index.js', | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |              output: {path: CASE_PATH, filename: "app-bundle.js"}, | 
					
						
							| 
									
										
										
										
											2016-01-08 17:51:02 +01:00
										 |  |  |              resolve: { | 
					
						
							|  |  |  |                extensions: ['', '.js'], | 
					
						
							|  |  |  |                packageAlias: '',  // option added to ignore "broken" package.json in our dist folder
 | 
					
						
							|  |  |  |                root: [ES5_PROD_ROOT] | 
					
						
							|  |  |  |              } | 
					
						
							|  |  |  |            }) | 
					
						
							|  |  |  |         .then(function() {  // pad bundle with mandatory dependencies
 | 
					
						
							|  |  |  |           return new Promise(function(resolve, reject) { | 
					
						
							|  |  |  |             gulp.src([ | 
					
						
							| 
									
										
										
										
											2016-02-25 14:24:17 -08:00
										 |  |  |                   'node_modules/zone.js/dist/zone.js', | 
					
						
							| 
									
										
										
										
											2016-01-08 17:51:02 +01:00
										 |  |  |                   'node_modules/zone.js/dist/long-stack-trace-zone.js', | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |                   'node_modules/reflect-metadata/Reflect.js', | 
					
						
							|  |  |  |                   CASE_PATH + '/app-bundle.js' | 
					
						
							| 
									
										
										
										
											2016-01-08 17:51:02 +01:00
										 |  |  |                 ]) | 
					
						
							| 
									
										
										
										
											2016-01-20 17:56:00 +01:00
										 |  |  |                 .pipe(gulpPlugins.concat(PAYLOAD_TESTS_CONFIG.ts.bundleName)) | 
					
						
							|  |  |  |                 .pipe(gulpPlugins.uglify()) | 
					
						
							|  |  |  |                 .pipe(gulp.dest(CASE_PATH)) | 
					
						
							|  |  |  |                 .on('end', resolve) | 
					
						
							|  |  |  |                 .on('error', reject); | 
					
						
							|  |  |  |           }); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |   })); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gulp.task('!build.payload.js.systemjs', function() { | 
					
						
							|  |  |  |   var bundler = require('./tools/build/bundle'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return Promise.all(PAYLOAD_TESTS_CONFIG.ts.cases.map(function(caseName) { | 
					
						
							|  |  |  |     var CASE_PATH = PAYLOAD_TESTS_CONFIG.ts.dist(caseName, 'systemjs'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return bundler | 
					
						
							|  |  |  |         .bundle( | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               paths: {'index': CASE_PATH + '/index.js'}, | 
					
						
							|  |  |  |               meta: {'angular2/core': {build: false}, 'angular2/platform/browser': {build: false}} | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             'index', CASE_PATH + '/index.register.js', {}) | 
					
						
							|  |  |  |         .then(function() { | 
					
						
							|  |  |  |           return new Promise(function(resolve, reject) { | 
					
						
							|  |  |  |             gulp.src([ | 
					
						
							|  |  |  |                   'node_modules/systemjs/dist/system.src.js', | 
					
						
							|  |  |  |                   'dist/js/prod/es5/bundle/angular2-polyfills.js', | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |                   'dist/js/prod/es5/bundle/angular2.js', | 
					
						
							|  |  |  |                   'dist/js/prod/es5//rxjs/bundles/Rx.js', | 
					
						
							|  |  |  |                   CASE_PATH + '/index.register.js', | 
					
						
							|  |  |  |                   'tools/build/systemjs/payload_tests_import.js' | 
					
						
							| 
									
										
										
										
											2016-01-20 17:56:00 +01:00
										 |  |  |                 ]) | 
					
						
							|  |  |  |                 .pipe(gulpPlugins.concat(PAYLOAD_TESTS_CONFIG.ts.bundleName)) | 
					
						
							|  |  |  |                 .pipe(gulpPlugins.uglify()) | 
					
						
							| 
									
										
										
										
											2016-01-08 17:51:02 +01:00
										 |  |  |                 .pipe(gulp.dest(CASE_PATH)) | 
					
						
							|  |  |  |                 .on('end', resolve) | 
					
						
							|  |  |  |                 .on('error', reject); | 
					
						
							|  |  |  |           }); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |   })); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gulp.task('!checkAndReport.payload.js', function() { | 
					
						
							|  |  |  |   var reportSize = require('./tools/analytics/reportsize'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-20 17:56:00 +01:00
										 |  |  |   function caseSizeStream(caseName, packaging) { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |     return reportSize(PAYLOAD_TESTS_CONFIG.ts.dist(caseName, packaging) + '/' + | 
					
						
							|  |  |  |                           PAYLOAD_TESTS_CONFIG.ts.bundleName, | 
					
						
							|  |  |  |                       { | 
					
						
							|  |  |  |                         failConditions: PAYLOAD_TESTS_CONFIG.ts[packaging].sizeLimits, | 
					
						
							|  |  |  |                         prefix: caseName + '_' + packaging | 
					
						
							| 
									
										
										
										
											2016-04-28 21:57:16 -07:00
										 |  |  |                       }); | 
					
						
							| 
									
										
										
										
											2016-01-20 17:56:00 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return PAYLOAD_TESTS_CONFIG.ts.cases.reduce(function(sizeReportingStreams, caseName) { | 
					
						
							|  |  |  |     sizeReportingStreams.add(caseSizeStream(caseName, 'systemjs')); | 
					
						
							|  |  |  |     sizeReportingStreams.add(caseSizeStream(caseName, 'webpack')); | 
					
						
							| 
									
										
										
										
											2016-01-08 17:51:02 +01:00
										 |  |  |   }, merge2()); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | gulp.task('watch.dart.dev', function(done) { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   runSequence('build/tree.dart', 'build/pure-packages.dart', '!build/pubget.angular2.dart', | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  |               '!build/remove-pub-symlinks', function(error) { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |                 var watch = require('./tools/build/watch'); | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |                 // if initial build failed (likely due to build or formatting step) then exit
 | 
					
						
							|  |  |  |                 // otherwise karma server doesn't start and we can't continue running properly
 | 
					
						
							|  |  |  |                 if (error) { | 
					
						
							|  |  |  |                   done(error); | 
					
						
							|  |  |  |                   return; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  |                 watch(['modules/angular2/**', 'modules_dart/**'], {ignoreInitial: true}, | 
					
						
							|  |  |  |                       ['!build/tree.dart', 'build/pure-packages.dart']); | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |               }); | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gulp.task('test.unit.router/ci', function(done) { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var karma = require('karma'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-20 13:19:34 -07:00
										 |  |  |   var browserConf = getBrowsersFromCLI(); | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   new karma.Server( | 
					
						
							|  |  |  |                { | 
					
						
							|  |  |  |                  configFile: __dirname + '/modules/angular1_router/karma-router.conf.js', | 
					
						
							|  |  |  |                  singleRun: true, | 
					
						
							|  |  |  |                  reporters: ['dots'], | 
					
						
							|  |  |  |                  browsers: browserConf.browsersToRun | 
					
						
							|  |  |  |                }, | 
					
						
							|  |  |  |                done) | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |       .start(); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gulp.task('test.unit.js/ci', function(done) { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var karma = require('karma'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-02 16:29:09 +02:00
										 |  |  |   var browserConf = getBrowsersFromCLI(); | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   new karma.Server( | 
					
						
							|  |  |  |                { | 
					
						
							|  |  |  |                  configFile: __dirname + '/karma-js.conf.js', | 
					
						
							|  |  |  |                  singleRun: true, | 
					
						
							|  |  |  |                  reporters: ['dots'], | 
					
						
							|  |  |  |                  browsers: browserConf.browsersToRun | 
					
						
							|  |  |  |                }, | 
					
						
							|  |  |  |                function(err) { done(); }) | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |       .start(); | 
					
						
							| 
									
										
										
										
											2015-06-02 16:29:09 +02:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | gulp.task('test.unit.js.sauce/ci', function(done) { | 
					
						
							| 
									
										
										
										
											2015-12-10 14:40:00 +01:00
										 |  |  |   var browsers = browserProvidersConf.sauceAliases.CI_REQUIRED; | 
					
						
							|  |  |  |   if (cliArgs.mode && cliArgs.mode == 'saucelabs_optional') { | 
					
						
							|  |  |  |     browsers = browserProvidersConf.sauceAliases.CI_OPTIONAL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   launchKarmaWithExternalBrowsers(['dots', 'saucelabs'], browsers, done); | 
					
						
							| 
									
										
										
										
											2014-11-07 18:29:19 +01:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-04-27 16:11:20 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | gulp.task('test.unit.js.browserstack/ci', function(done) { | 
					
						
							| 
									
										
										
										
											2015-12-10 14:40:00 +01:00
										 |  |  |   var browsers = browserProvidersConf.browserstackAliases.CI_REQUIRED; | 
					
						
							|  |  |  |   if (cliArgs.mode && cliArgs.mode == 'browserstack_optional') { | 
					
						
							|  |  |  |     browsers = browserProvidersConf.browserstackAliases.CI_OPTIONAL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   launchKarmaWithExternalBrowsers(['dots'], browsers, done); | 
					
						
							| 
									
										
										
										
											2015-10-27 16:09:09 +01:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | gulp.task('test.unit.dart/ci', function(done) { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   runSequence('test.dart.dartium_symlink', '!test.unit.dart/run/angular2', | 
					
						
							|  |  |  |               '!test.unit.dart/run/angular2_testing', '!test.unit.dart/run/benchpress', | 
					
						
							|  |  |  |               sequenceComplete(done)); | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  | // At the moment, dart test requires dartium to be an executable on the path.
 | 
					
						
							|  |  |  | // Make a temporary directory and symlink dartium from there (just for this command)
 | 
					
						
							|  |  |  | // so that it can run.
 | 
					
						
							|  |  |  | // TODO(juliemr): this won't work with windows - remove the hack and make this platform agnostic.
 | 
					
						
							|  |  |  | var dartiumTmpdir = path.join(os.tmpdir(), 'dartium' + new Date().getTime().toString()); | 
					
						
							|  |  |  | var dartiumPathPrefix = 'PATH=$PATH:' + dartiumTmpdir + ' '; | 
					
						
							|  |  |  | gulp.task( | 
					
						
							|  |  |  |     'test.dart.dartium_symlink', | 
					
						
							|  |  |  |     shell.task(['mkdir ' + dartiumTmpdir, 'ln -s $DARTIUM_BIN ' + dartiumTmpdir + '/dartium'])); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gulp.task('!test.unit.dart/run/angular2', function() { | 
					
						
							|  |  |  |   var pubtest = require('./tools/build/pubtest'); | 
					
						
							|  |  |  |   return pubtest({ | 
					
						
							|  |  |  |     dir: path.join(CONFIG.dest.dart, 'angular2'), | 
					
						
							|  |  |  |     dartiumTmpdir: dartiumTmpdir, | 
					
						
							|  |  |  |     command: DART_SDK.PUB, | 
					
						
							|  |  |  |     files: '**/*_spec.dart', | 
					
						
							|  |  |  |     bunchFiles: true, | 
					
						
							|  |  |  |     useExclusiveTests: true | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2014-11-07 18:29:19 +01:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-04-13 18:59:37 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  | gulp.task('!test.unit.dart/run/angular2_testing', function() { | 
					
						
							|  |  |  |   var pubtest = require('./tools/build/pubtest'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return pubtest({ | 
					
						
							|  |  |  |     dir: path.join(CONFIG.dest.dart, 'angular2_testing'), | 
					
						
							|  |  |  |     dartiumTmpdir: dartiumTmpdir, | 
					
						
							|  |  |  |     command: DART_SDK.PUB, | 
					
						
							|  |  |  |     files: '**/*_test.dart', | 
					
						
							|  |  |  |     useExclusiveTests: true | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gulp.task('!test.unit.dart/run/benchpress', function() { | 
					
						
							|  |  |  |   var pubtest = require('./tools/build/pubtest'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return pubtest({ | 
					
						
							|  |  |  |     dir: path.join(CONFIG.dest.dart, 'benchpress'), | 
					
						
							|  |  |  |     dartiumTmpdir: dartiumTmpdir, | 
					
						
							|  |  |  |     command: DART_SDK.PUB, | 
					
						
							|  |  |  |     files: '**/*_spec.dart', | 
					
						
							|  |  |  |     useExclusiveTests: true | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-04-13 23:56:07 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-26 00:31:53 -07:00
										 |  |  | gulp.task('test.unit.cjs/ci', function(done) { | 
					
						
							| 
									
										
										
										
											2015-08-20 14:28:25 -07:00
										 |  |  |   runJasmineTests(['dist/js/cjs/{angular2,benchpress}/test/**/*_spec.js'], done); | 
					
						
							| 
									
										
										
										
											2015-04-26 00:31:53 -07:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-04-13 23:56:07 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:03 -07:00
										 |  |  | gulp.task('check-public-api', ['build.tools'], | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |           function(done) { runJasmineTests(['dist/tools/public_api_guard/**/*_spec.js'], done); }); | 
					
						
							| 
									
										
										
										
											2015-04-13 23:56:07 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | gulp.task('test.unit.cjs', ['build/clean.js', 'build.tools'], function(neverDone) { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var watch = require('./tools/build/watch'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-13 01:58:17 -08:00
										 |  |  |   printModulesWarning(); | 
					
						
							| 
									
										
										
										
											2015-05-13 22:21:04 -07:00
										 |  |  |   treatTestErrorsAsFatal = false; | 
					
						
							| 
									
										
										
										
											2015-11-13 01:58:17 -08:00
										 |  |  |   watch('modules/**', ['!build.js.cjs', 'test.unit.cjs/ci']); | 
					
						
							| 
									
										
										
										
											2015-03-01 22:17:36 +01:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-02-20 17:44:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-29 17:27:44 -07:00
										 |  |  | // Use this target to continuously run dartvm unit-tests (such as transformer
 | 
					
						
							|  |  |  | // tests) while coding. Note: these tests do not use Karma.
 | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | gulp.task('test.unit.dartvm', function(neverDone) { | 
					
						
							|  |  |  |   var watch = require('./tools/build/watch'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  |   runSequence('build/tree.dart', 'build/pure-packages.dart', '!build/pubget.angular2.dart', | 
					
						
							|  |  |  |               '!test.unit.dartvm/run', function(error) { | 
					
						
							|  |  |  |                 // Watch for changes made in the TS and Dart code under "modules" and
 | 
					
						
							|  |  |  |                 // run ts2dart and test change detector generator prior to rerunning the
 | 
					
						
							|  |  |  |                 // tests.
 | 
					
						
							|  |  |  |                 watch('modules/angular2/**', {ignoreInitial: true}, | 
					
						
							|  |  |  |                       ['!build/tree.dart', '!test.unit.dartvm/run']); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 // Watch for changes made in Dart code under "modules_dart", then copy it
 | 
					
						
							|  |  |  |                 // to dist and run test change detector generator prior to retunning the
 | 
					
						
							|  |  |  |                 // tests.
 | 
					
						
							|  |  |  |                 watch('modules_dart/**', {ignoreInitial: true}, | 
					
						
							|  |  |  |                       ['build/pure-packages.dart', '!test.unit.dartvm/run']); | 
					
						
							|  |  |  |               }); | 
					
						
							| 
									
										
										
										
											2015-06-05 11:06:24 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('!test.unit.dartvm/run', | 
					
						
							|  |  |  |           runServerDartTests(gulp, gulpPlugins, {dir: 'dist/dart/angular2'})); | 
					
						
							| 
									
										
										
										
											2015-06-05 11:06:24 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-26 23:14:52 -07:00
										 |  |  | gulp.task('test.unit.tools/ci', function(done) { | 
					
						
							| 
									
										
										
										
											2015-05-13 22:40:53 -04:00
										 |  |  |   runJasmineTests(['dist/tools/**/*.spec.js', 'tools/**/*.spec.js'], done); | 
					
						
							| 
									
										
										
										
											2015-04-24 16:23:25 -07:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-04-24 10:15:52 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | gulp.task('test.unit.tools', ['build/clean.tools'], function(neverDone) { | 
					
						
							|  |  |  |   var watch = require('./tools/build/watch'); | 
					
						
							| 
									
										
										
										
											2015-05-13 22:21:04 -07:00
										 |  |  |   treatTestErrorsAsFatal = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   watch(['tools/**', '!tools/**/test-fixtures/**'], ['!build.tools', 'test.unit.tools/ci']); | 
					
						
							| 
									
										
										
										
											2015-04-24 10:15:52 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-27 00:46:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-20 17:44:23 -08:00
										 |  |  | // ------------------
 | 
					
						
							|  |  |  | // server tests
 | 
					
						
							|  |  |  | //     These tests run on the VM on the command-line and are
 | 
					
						
							|  |  |  | //     allowed to access the file system and network.
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | gulp.task('test.server.dart', runServerDartTests(gulp, gulpPlugins, {dest: 'dist/dart'})); | 
					
						
							| 
									
										
										
										
											2015-02-20 17:44:23 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // -----------------
 | 
					
						
							|  |  |  | // test builders
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('test.transpiler.unittest', | 
					
						
							|  |  |  |           function(done) { runJasmineTests(['tools/transpiler/unittest/**/*.js'], done); }); | 
					
						
							| 
									
										
										
										
											2014-11-07 18:29:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-23 10:36:54 -07:00
										 |  |  | // -----------------
 | 
					
						
							| 
									
										
										
										
											2015-07-29 17:00:54 -07:00
										 |  |  | // Pre-test checks
 | 
					
						
							| 
									
										
										
										
											2015-06-23 10:36:54 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | gulp.task('pre-test-checks', function(done) { | 
					
						
							|  |  |  |   runSequence('build/checkCircularDependencies', sequenceComplete(done)); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-29 17:00:54 -07:00
										 |  |  | // -----------------
 | 
					
						
							|  |  |  | // Checks which should fail the build, but should not block us running the tests.
 | 
					
						
							|  |  |  | // This task is run in a separate travis worker, so these checks provide faster
 | 
					
						
							|  |  |  | // feedback while allowing tests to execute.
 | 
					
						
							|  |  |  | gulp.task('static-checks', ['!build.tools'], function(done) { | 
					
						
							|  |  |  |   runSequence( | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |       // We do not run test.typings here because it requires building, which is too slow.
 | 
					
						
							|  |  |  |       ['enforce-format', 'lint'], sequenceComplete(done)); | 
					
						
							| 
									
										
										
										
											2015-06-23 10:36:54 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-16 10:46:12 -07:00
										 |  |  | // -----------------
 | 
					
						
							| 
									
										
										
										
											2015-10-01 19:49:45 -07:00
										 |  |  | // Tests for the typings we deliver for TS users
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2015-10-28 15:22:40 -07:00
										 |  |  | // Typings are contained in individual .d.ts files produced by the compiler,
 | 
					
						
							| 
									
										
										
										
											2015-10-01 19:49:45 -07:00
										 |  |  | // distributed in our npm package, and loaded from node_modules by
 | 
					
						
							|  |  |  | // the typescript compiler.
 | 
					
						
							| 
									
										
										
										
											2015-06-16 10:46:12 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-10 13:51:11 -07:00
										 |  |  | // Make sure the typings tests are isolated, by running in a tempdir
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | var tmpdir = path.join(os.tmpdir(), 'test.typings', new Date().getTime().toString()); | 
					
						
							| 
									
										
										
										
											2016-04-10 13:51:11 -07:00
										 |  |  | gulp.task('!pre.test.typings.layoutNodeModule', function() { | 
					
						
							| 
									
										
										
										
											2016-03-23 20:35:48 -04:00
										 |  |  |   return gulp.src(['dist/js/cjs/angular2/**/*', 'node_modules/rxjs/**/*'], {base: 'dist/js/cjs'}) | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |       .pipe(gulp.dest(path.join(tmpdir, 'node_modules'))); | 
					
						
							| 
									
										
										
										
											2015-10-01 19:49:45 -07:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2016-03-23 20:35:48 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | gulp.task('!pre.test.typings.copyDeps', function() { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   return gulp.src( | 
					
						
							|  |  |  |                  [ | 
					
						
							|  |  |  |                    'modules/angular2/typings/angular-protractor/*.ts', | 
					
						
							|  |  |  |                    'modules/angular2/typings/jasmine/*.ts', | 
					
						
							|  |  |  |                    'modules/angular2/typings/selenium-webdriver/*.ts', | 
					
						
							|  |  |  |                  ], | 
					
						
							|  |  |  |                  {base: 'modules/angular2/typings'}) | 
					
						
							| 
									
										
										
										
											2016-03-23 20:35:48 -04:00
										 |  |  |       .pipe(gulp.dest(tmpdir)); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-01 19:49:45 -07:00
										 |  |  | gulp.task('!pre.test.typings.copyTypingsSpec', function() { | 
					
						
							| 
									
										
										
										
											2016-03-23 20:35:48 -04:00
										 |  |  |   return gulp.src(['modules/angular2/examples/**/*.ts']).pipe(gulp.dest(tmpdir)); | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2016-02-01 10:29:42 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-10 13:51:11 -07:00
										 |  |  | gulp.task('!test.typings', | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |           [ | 
					
						
							|  |  |  |             '!pre.test.typings.layoutNodeModule', | 
					
						
							|  |  |  |             '!pre.test.typings.copyTypingsSpec', | 
					
						
							|  |  |  |             '!pre.test.typings.copyDeps' | 
					
						
							|  |  |  |           ], | 
					
						
							|  |  |  |           function() { | 
					
						
							|  |  |  |             var tsc = require('gulp-typescript'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             return gulp.src([tmpdir + '/**/*.ts', '!' + tmpdir + '/node_modules/**/*']) | 
					
						
							|  |  |  |                 .pipe(tsc({ | 
					
						
							|  |  |  |                   target: 'ES6', | 
					
						
							|  |  |  |                   module: 'commonjs', | 
					
						
							|  |  |  |                   experimentalDecorators: true, | 
					
						
							|  |  |  |                   noImplicitAny: true, | 
					
						
							|  |  |  |                   moduleResolution: 'node', | 
					
						
							|  |  |  |                   typescript: require('typescript') | 
					
						
							|  |  |  |                 })); | 
					
						
							|  |  |  |           }); | 
					
						
							| 
									
										
										
										
											2015-10-01 19:49:45 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-10 13:51:11 -07:00
										 |  |  | gulp.task('test.typings', ['build.js.cjs'], | 
					
						
							|  |  |  |           function(done) { runSequence('!test.typings', sequenceComplete(done)); }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-02 09:56:38 -07:00
										 |  |  | gulp.task('!build.compiler_cli', function(done) { runTsc('tools/compiler_cli/src', done); }); | 
					
						
							| 
									
										
										
										
											2016-04-28 21:57:16 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-01 11:22:39 -07:00
										 |  |  | gulp.task('!clean.compiler_cli', function(done) { | 
					
						
							|  |  |  |   fse.remove(path.join('dist', 'tools', 'compiler_cli', 'test'), | 
					
						
							|  |  |  |              fse.remove(path.join('tools', 'compiler_cli', 'test', 'src', '*.ngfactory.ts'), | 
					
						
							|  |  |  |                         fse.remove(path.join('tools', 'compiler_cli', 'test', 'src', 'a', | 
					
						
							|  |  |  |                                              '*.ngfactory.ts'), | 
					
						
							|  |  |  |                                    done))); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 21:57:16 -07:00
										 |  |  | gulp.task('!test.compiler_cli.codegen', function(done) { | 
					
						
							|  |  |  |   try { | 
					
						
							| 
									
										
										
										
											2016-05-02 09:56:38 -07:00
										 |  |  |     require('./dist/tools/compiler_cli/main') | 
					
						
							| 
									
										
										
										
											2016-04-28 21:57:16 -07:00
										 |  |  |         .main("tools/compiler_cli/test") | 
					
						
							| 
									
										
										
										
											2016-05-01 11:22:39 -07:00
										 |  |  |         .then(done) | 
					
						
							| 
									
										
										
										
											2016-05-02 15:52:47 -06:00
										 |  |  |         .catch(function(rej) { done(rej); }); | 
					
						
							| 
									
										
										
										
											2016-04-28 21:57:16 -07:00
										 |  |  |   } catch (err) { | 
					
						
							|  |  |  |     done(err); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 12:27:37 -07:00
										 |  |  | gulp.task('!test.compiler_cli.unit', | 
					
						
							| 
									
										
										
										
											2016-05-02 09:56:38 -07:00
										 |  |  |           function(done) { runJasmineTests(['dist/tools/compiler_cli/**/*_spec.js'], done) }); | 
					
						
							| 
									
										
										
										
											2016-04-30 12:27:37 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-01 11:22:39 -07:00
										 |  |  | // This task overwrites our careful tsickle-lowered Decorators with normal .js emit.
 | 
					
						
							|  |  |  | // So it should only be run after asserting on the .js file content.
 | 
					
						
							|  |  |  | gulp.task('!test.compiler_cli.verify_codegen', | 
					
						
							|  |  |  |           function(done) { runTsc('tools/compiler_cli/test', done); }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 21:57:16 -07:00
										 |  |  | // End-to-end test for compiler CLI.
 | 
					
						
							|  |  |  | // Calls the compiler using its command-line interface, then compiles the app with the codegen.
 | 
					
						
							|  |  |  | // TODO(alexeagle): wire up the playground tests with offline compilation, similar to dart.
 | 
					
						
							| 
									
										
										
										
											2016-04-30 12:27:37 -07:00
										 |  |  | gulp.task('test.compiler_cli', ['!build.compiler_cli'], function(done) { | 
					
						
							| 
									
										
										
										
											2016-05-01 11:22:39 -07:00
										 |  |  |   runSequence('!clean.compiler_cli', '!test.compiler_cli.codegen', '!test.compiler_cli.unit', | 
					
						
							|  |  |  |               '!test.compiler_cli.verify_codegen', sequenceComplete(done)); | 
					
						
							| 
									
										
										
										
											2016-04-30 12:27:37 -07:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2016-04-28 21:57:16 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | // -----------------
 | 
					
						
							|  |  |  | // orchestrated targets
 | 
					
						
							| 
									
										
										
										
											2015-02-27 14:50:06 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-23 17:37:05 -07:00
										 |  |  | // Pure Dart packages only contain Dart code and conform to pub package layout.
 | 
					
						
							|  |  |  | // These packages need no transpilation. All code is copied over to `dist`
 | 
					
						
							|  |  |  | // unmodified and directory structure is preserved.
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2015-08-19 10:36:52 -07:00
										 |  |  | // This task is expected to be run after build/tree.dart
 | 
					
						
							| 
									
										
										
										
											2015-12-03 17:26:18 -08:00
										 |  |  | gulp.task('build/pure-packages.dart', function(done) { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   runSequence('build/pure-packages.dart/standalone', 'build/pure-packages.dart/license', | 
					
						
							|  |  |  |               'build/pure-packages.dart/angular2', sequenceComplete(done)); | 
					
						
							| 
									
										
										
										
											2015-12-03 17:26:18 -08:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-04-23 17:37:05 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-03 17:26:18 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | gulp.task('build/pure-packages.dart/standalone', function() { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   return gulp.src([ | 
					
						
							|  |  |  |                'modules_dart/**/*', | 
					
						
							|  |  |  |                '!modules_dart/**/*.proto', | 
					
						
							|  |  |  |                '!modules_dart/**/packages{,/**}', | 
					
						
							|  |  |  |                '!modules_dart/**/.packages', | 
					
						
							|  |  |  |                '!modules_dart/payload{,/**}', | 
					
						
							|  |  |  |                '!modules_dart/transform{,/**}', | 
					
						
							|  |  |  |              ]) | 
					
						
							| 
									
										
										
										
											2015-12-03 17:26:18 -08:00
										 |  |  |       .pipe(gulp.dest(CONFIG.dest.dart)); | 
					
						
							| 
									
										
										
										
											2015-04-23 17:37:05 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-18 17:00:43 -08:00
										 |  |  | gulp.task('build/pure-packages.dart/license', function() { | 
					
						
							|  |  |  |   return gulp.src(['LICENSE']).pipe(gulp.dest(path.join(CONFIG.dest.dart, 'angular2_testing'))); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gulp.task('build/pure-packages.dart/angular2', function() { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   return gulp.src([ | 
					
						
							|  |  |  |                'modules_dart/transform/**/*', | 
					
						
							|  |  |  |                '!modules_dart/transform/**/*.proto', | 
					
						
							|  |  |  |                '!modules_dart/transform/pubspec.yaml', | 
					
						
							|  |  |  |                '!modules_dart/transform/**/packages{,/**}', | 
					
						
							|  |  |  |              ]) | 
					
						
							| 
									
										
										
										
											2015-12-18 17:00:43 -08:00
										 |  |  |       .pipe(gulp.dest(path.join(CONFIG.dest.dart, 'angular2'))); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-12-03 17:26:18 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-27 14:50:06 -08:00
										 |  |  | // Builds all Dart packages, but does not compile them
 | 
					
						
							|  |  |  | gulp.task('build/packages.dart', function(done) { | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  |   runSequence('lint_protos.dart', 'pubget.dart', 'build/tree.dart', 'build/pure-packages.dart', | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |               // Run after 'build/tree.dart' because broccoli clears the dist/dart folder
 | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  |               '!build/pubget.angular2.dart', sequenceComplete(done)); | 
					
						
							| 
									
										
										
										
											2015-02-27 14:50:06 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Builds and compiles all Dart packages
 | 
					
						
							|  |  |  | gulp.task('build.dart', function(done) { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   runSequence('build/packages.dart', 'build/pubspec.dart', 'build/analyze.dart', | 
					
						
							|  |  |  |               'build/check.apidocs.dart', sequenceComplete(done)); | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-26 23:14:52 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-04 08:32:58 -07:00
										 |  |  | // public task to build tools
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('build.tools', ['build/clean.tools'], | 
					
						
							|  |  |  |           function(done) { runSequence('!build.tools', sequenceComplete(done)); }); | 
					
						
							| 
									
										
										
										
											2015-04-27 00:46:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-24 16:23:25 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-04 08:32:58 -07:00
										 |  |  | // private task to build tools
 | 
					
						
							|  |  |  | gulp.task('!build.tools', function() { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var sourcemaps = require('gulp-sourcemaps'); | 
					
						
							|  |  |  |   var tsc = require('gulp-typescript'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 21:57:16 -07:00
										 |  |  |   var stream = gulp.src(['tools/**/*.ts', '!tools/compiler_cli/**']) | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |                    .pipe(sourcemaps.init()) | 
					
						
							|  |  |  |                    .pipe(tsc({ | 
					
						
							|  |  |  |                      target: 'ES5', | 
					
						
							|  |  |  |                      module: 'commonjs', | 
					
						
							|  |  |  |                      declaration: true, | 
					
						
							| 
									
										
										
										
											2016-01-22 10:51:16 -08:00
										 |  |  |                      noImplicitAny: true, | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |                      // Don't use the version of typescript that gulp-typescript depends on
 | 
					
						
							|  |  |  |                      // see https://github.com/ivogabe/gulp-typescript#typescript-version
 | 
					
						
							|  |  |  |                      typescript: require('typescript') | 
					
						
							|  |  |  |                    })); | 
					
						
							| 
									
										
										
										
											2016-03-24 10:00:19 -07:00
										 |  |  |   stream = | 
					
						
							|  |  |  |       merge2([stream.js.pipe(gulp.dest('dist/tools')), stream.dts.pipe(gulp.dest('dist/tools'))]) | 
					
						
							|  |  |  |           .on('error', | 
					
						
							|  |  |  |               function(error) { | 
					
						
							|  |  |  |                 // nodejs doesn't propagate errors from the src stream into the final
 | 
					
						
							|  |  |  |                 // stream so we are
 | 
					
						
							|  |  |  |                 // forwarding the error into the final stream
 | 
					
						
							|  |  |  |                 stream.emit('error', error); | 
					
						
							|  |  |  |               }) | 
					
						
							|  |  |  |           .pipe(sourcemaps.write('.')) | 
					
						
							|  |  |  |           .on('end', function() { | 
					
						
							|  |  |  |             var AngularBuilder = require('./dist/tools/broccoli/angular_builder').AngularBuilder; | 
					
						
							|  |  |  |             angularBuilder = | 
					
						
							|  |  |  |                 new AngularBuilder({outputPath: 'dist', dartSDK: DART_SDK, logs: logs}); | 
					
						
							|  |  |  |           }); | 
					
						
							| 
									
										
										
										
											2015-04-24 15:59:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-28 22:00:41 +02:00
										 |  |  |   return stream; | 
					
						
							| 
									
										
										
										
											2015-04-10 16:45:24 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('broccoli.js.dev', ['build.tools'], | 
					
						
							|  |  |  |           function(done) { runSequence('!broccoli.js.dev', sequenceComplete(done)); }); | 
					
						
							| 
									
										
										
										
											2015-05-06 08:45:28 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-29 17:01:10 -08:00
										 |  |  | gulp.task('!broccoli.js.dev', () => angularBuilder.rebuildBrowserDevTree({ | 
					
						
							|  |  |  |   generateEs6: generateEs6, | 
					
						
							|  |  |  |   projects: cliArgsProjects, | 
					
						
							|  |  |  |   noTypeChecks: cliArgs.noTypeChecks, | 
					
						
							|  |  |  |   useBundles: cliArgs.useBundles | 
					
						
							|  |  |  | })); | 
					
						
							| 
									
										
										
										
											2015-04-10 11:48:37 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-29 17:01:10 -08:00
										 |  |  | gulp.task('!broccoli.js.prod', () => angularBuilder.rebuildBrowserProdTree({ | 
					
						
							|  |  |  |   generateEs6: generateEs6, | 
					
						
							|  |  |  |   projects: cliArgsProjects, | 
					
						
							|  |  |  |   noTypeChecks: cliArgs.noTypeChecks, | 
					
						
							|  |  |  |   useBundles: cliArgs.useBundles | 
					
						
							|  |  |  | })); | 
					
						
							| 
									
										
										
										
											2015-04-10 11:48:37 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('build.js.dev', ['build/clean.js'], | 
					
						
							|  |  |  |           function(done) { runSequence('broccoli.js.dev', sequenceComplete(done)); }); | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('build.js.prod', ['build.tools'], | 
					
						
							|  |  |  |           function(done) { runSequence('!broccoli.js.prod', sequenceComplete(done)); }); | 
					
						
							| 
									
										
										
										
											2015-04-26 00:31:53 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-05 16:09:09 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * public task | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('build.js.cjs', ['build.tools'], | 
					
						
							|  |  |  |           function(done) { runSequence('!build.js.cjs', sequenceComplete(done)); }); | 
					
						
							| 
									
										
										
										
											2015-05-05 16:09:09 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-26 00:31:53 -07:00
										 |  |  | var firstBuildJsCjs = true; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-05 16:09:09 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * private task | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | gulp.task('!build.js.cjs', function() { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   return angularBuilder.rebuildNodeTree({ | 
					
						
							|  |  |  |                          generateEs6: generateEs6, | 
					
						
							|  |  |  |                          projects: cliArgsProjects, | 
					
						
							|  |  |  |                          noTypeChecks: cliArgs.noTypeChecks, | 
					
						
							|  |  |  |                          useBundles: cliArgs.useBundles | 
					
						
							|  |  |  |                        }) | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |       .then(function() { | 
					
						
							|  |  |  |         if (firstBuildJsCjs) { | 
					
						
							|  |  |  |           firstBuildJsCjs = false; | 
					
						
							|  |  |  |           console.log('creating node_modules symlink hack'); | 
					
						
							|  |  |  |           // linknodemodules is all sync
 | 
					
						
							|  |  |  |           linknodemodules(gulp, gulpPlugins, {dir: CONFIG.dest.js.cjs})(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-01-06 15:19:22 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-26 00:31:53 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-23 13:18:05 -07:00
										 |  |  | var bundleConfig = { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   paths: {"*": "dist/js/prod/es5/*.js"}, | 
					
						
							| 
									
										
										
										
											2015-09-23 17:14:25 -07:00
										 |  |  |   // Files that end up empty after transpilation confuse system-builder
 | 
					
						
							|  |  |  |   // and need to be explitily listed here.
 | 
					
						
							|  |  |  |   // TODO: upgrade system builder and find a way to declare all input as cjs.
 | 
					
						
							| 
									
										
										
										
											2015-04-06 16:43:53 -07:00
										 |  |  |   meta: { | 
					
						
							| 
									
										
										
										
											2015-09-23 17:14:25 -07:00
										 |  |  |     'angular2/src/router/route_definition': {format: 'cjs'}, | 
					
						
							| 
									
										
										
										
											2015-11-05 14:58:24 -08:00
										 |  |  |     'angular2/src/common/directives/observable_list_diff': {format: 'cjs'}, | 
					
						
							| 
									
										
										
										
											2015-09-23 17:14:25 -07:00
										 |  |  |     'angular2/lifecycle_hooks': {format: 'cjs'} | 
					
						
							| 
									
										
										
										
											2015-08-10 15:34:20 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-03-23 13:18:05 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // production build
 | 
					
						
							| 
									
										
										
										
											2015-07-24 14:45:00 -07:00
										 |  |  | gulp.task('!bundle.js.prod', ['build.js.prod'], function() { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var bundler = require('./tools/build/bundle'); | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |   var bundlerConfig = {sourceMaps: true}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-10 16:04:07 +01:00
										 |  |  |   return bundler.bundle(bundleConfig, NG2_BUNDLE_CONTENT, './dist/build/angular2.js', bundlerConfig) | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |       .then(function() { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |         return Promise.all([ | 
					
						
							| 
									
										
										
										
											2015-12-10 16:04:07 +01:00
										 |  |  |           bundler.bundle(bundleConfig, HTTP_BUNDLE_CONTENT, './dist/build/http.js', bundlerConfig), | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |           bundler.bundle(bundleConfig, ROUTER_BUNDLE_CONTENT, './dist/build/router.js', | 
					
						
							|  |  |  |                          bundlerConfig), | 
					
						
							| 
									
										
										
										
											2016-04-29 18:05:36 -07:00
										 |  |  |           bundler.bundle(bundleConfig, ALT_ROUTER_BUNDLE_CONTENT, './dist/build/alt_router.js', | 
					
						
							|  |  |  |                          bundlerConfig), | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |           bundler.bundle(bundleConfig, UPGRADE_BUNDLE_CONTENT, './dist/build/upgrade.js', | 
					
						
							|  |  |  |                          bundlerConfig) | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |         ]); | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-03-23 13:18:05 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // minified production build
 | 
					
						
							| 
									
										
										
										
											2015-07-24 14:45:00 -07:00
										 |  |  | gulp.task('!bundle.js.min', ['build.js.prod'], function() { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var bundler = require('./tools/build/bundle'); | 
					
						
							| 
									
										
										
										
											2016-04-08 17:04:29 -07:00
										 |  |  |   var bundlerConfig = | 
					
						
							|  |  |  |       {sourceMaps: true, minify: true, mangle: false, uglify: {compress: {keep_fnames: true}}}; | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   return bundler.bundle(bundleConfig, NG2_BUNDLE_CONTENT, './dist/build/angular2.min.js', | 
					
						
							|  |  |  |                         bundlerConfig) | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |       .then(function() { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |         return Promise.all([ | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |           bundler.bundle(bundleConfig, HTTP_BUNDLE_CONTENT, './dist/build/http.min.js', | 
					
						
							|  |  |  |                          bundlerConfig), | 
					
						
							|  |  |  |           bundler.bundle(bundleConfig, ROUTER_BUNDLE_CONTENT, './dist/build/router.min.js', | 
					
						
							|  |  |  |                          bundlerConfig), | 
					
						
							| 
									
										
										
										
											2016-04-29 18:05:36 -07:00
										 |  |  |           bundler.bundle(bundleConfig, ALT_ROUTER_BUNDLE_CONTENT, './dist/build/alt_router.min.js', | 
					
						
							|  |  |  |                          bundlerConfig), | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |           bundler.bundle(bundleConfig, UPGRADE_BUNDLE_CONTENT, './dist/build/upgrade.min.js', | 
					
						
							|  |  |  |                          bundlerConfig) | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |         ]); | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-03-23 13:18:05 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // development build
 | 
					
						
							| 
									
										
										
										
											2015-07-24 14:45:00 -07:00
										 |  |  | gulp.task('!bundle.js.dev', ['build.js.dev'], function() { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var bundler = require('./tools/build/bundle'); | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |   var bundlerConfig = {sourceMaps: true}; | 
					
						
							| 
									
										
										
										
											2015-10-13 15:42:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-06 16:43:53 -07:00
										 |  |  |   var devBundleConfig = merge(true, bundleConfig); | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   devBundleConfig.paths = merge(true, devBundleConfig.paths, {"*": "dist/js/dev/es5/*.js"}); | 
					
						
							| 
									
										
										
										
											2015-10-13 15:42:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   return bundler.bundle(devBundleConfig, NG2_BUNDLE_CONTENT, './dist/build/angular2.dev.js', | 
					
						
							|  |  |  |                         bundlerConfig) | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |       .then(function() { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |         return Promise.all([ | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |           bundler.bundle(devBundleConfig, HTTP_BUNDLE_CONTENT, './dist/build/http.dev.js', | 
					
						
							|  |  |  |                          bundlerConfig), | 
					
						
							|  |  |  |           bundler.bundle(devBundleConfig, ROUTER_BUNDLE_CONTENT, './dist/build/router.dev.js', | 
					
						
							|  |  |  |                          bundlerConfig), | 
					
						
							| 
									
										
										
										
											2016-04-29 18:05:36 -07:00
										 |  |  |           bundler.bundle(devBundleConfig, ALT_ROUTER_BUNDLE_CONTENT, | 
					
						
							|  |  |  |                          './dist/build/alt_router.dev.js', bundlerConfig), | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |           bundler.bundle(devBundleConfig, UPGRADE_BUNDLE_CONTENT, './dist/build/upgrade.dev.js', | 
					
						
							|  |  |  |                          bundlerConfig) | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |         ]); | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-04-13 16:48:04 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-27 10:39:39 -07:00
										 |  |  | // WebWorker build
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task("!bundle.web_worker.js.dev", ["build.js.dev"], function() { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var bundler = require('./tools/build/bundle'); | 
					
						
							| 
									
										
										
										
											2015-08-27 10:39:39 -07:00
										 |  |  |   var devBundleConfig = merge(true, bundleConfig); | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   devBundleConfig.paths = merge(true, devBundleConfig.paths, {"*": "dist/js/dev/es5/*.js"}); | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   return bundler.bundle(devBundleConfig, 'angular2/web_worker/ui', | 
					
						
							|  |  |  |                         './dist/build/web_worker/ui.dev.js', {sourceMaps: true}) | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |       .then(function() { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |         return bundler.bundle(devBundleConfig, 'angular2/web_worker/worker', | 
					
						
							|  |  |  |                               './dist/build/web_worker/worker.dev.js', {sourceMaps: true}); | 
					
						
							| 
									
										
										
										
											2015-08-27 10:39:39 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-06 11:37:59 -07:00
										 |  |  | gulp.task('!bundle.testing', ['build.js.dev'], function() { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var bundler = require('./tools/build/bundle'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-22 12:22:46 -07:00
										 |  |  |   var devBundleConfig = merge(true, bundleConfig); | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   devBundleConfig.paths = merge(true, devBundleConfig.paths, {"*": "dist/js/dev/es5/*.js"}); | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   return bundler.bundle(devBundleConfig, TESTING_BUNDLE_CONTENT, './dist/js/bundle/testing.dev.js', | 
					
						
							|  |  |  |                         {sourceMaps: true}); | 
					
						
							| 
									
										
										
										
											2015-06-22 12:22:46 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-08 14:51:29 +01:00
										 |  |  | gulp.task('!bundles.js.docs', ['clean'], function() { | 
					
						
							|  |  |  |   return gulp.src('modules/angular2/docs/bundles/*').pipe(gulp.dest('dist/js/bundle')); | 
					
						
							| 
									
										
										
										
											2015-12-14 15:28:57 +01:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-16 15:59:05 +01:00
										 |  |  | gulp.task('!bundles.js.umd', ['build.js.dev'], function() { | 
					
						
							| 
									
										
										
										
											2016-01-18 15:08:49 +01:00
										 |  |  |   var webpack = require('./tools/build/webpack/promiseify'); | 
					
						
							| 
									
										
										
										
											2015-11-16 15:59:05 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   function resolveOptions(devOrProd) { | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       root: __dirname + '/dist/js/' + devOrProd + '/es5', | 
					
						
							|  |  |  |       packageAlias: ''  // this option is added to ignore "broken" package.json in our dist folder
 | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   function outputOptions(outFileName, devOrProd) { | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       filename: | 
					
						
							|  |  |  |           'dist/js/bundle/' + outFileName + '.umd' + (devOrProd === 'dev' ? '.dev' : '') + '.js', | 
					
						
							|  |  |  |       library: 'ng', | 
					
						
							|  |  |  |       libraryTarget: 'umd' | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   function webPackConf(entryPoints, outFileName, devOrProd) { | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       entry: entryPoints, | 
					
						
							|  |  |  |       resolve: resolveOptions(devOrProd), | 
					
						
							| 
									
										
										
										
											2015-11-30 14:08:22 +01:00
										 |  |  |       module: {preLoaders: [{test: /\.js$/, loader: 'source-map-loader'}]}, | 
					
						
							|  |  |  |       devtool: devOrProd === 'dev' ? 'inline-source-map' : undefined, | 
					
						
							| 
									
										
										
										
											2015-12-14 17:33:40 -08:00
										 |  |  |       output: outputOptions(outFileName, devOrProd), | 
					
						
							|  |  |  |       externals: { | 
					
						
							|  |  |  |         'rxjs/Observable': 'umd Rx', | 
					
						
							|  |  |  |         'rxjs/Subject': 'umd Rx', | 
					
						
							|  |  |  |         'rxjs/subject/ReplaySubject': { | 
					
						
							|  |  |  |           commonjs: 'rxjs/subject/ReplaySubject', | 
					
						
							|  |  |  |           commonjs2: 'rxjs/subject/ReplaySubject', | 
					
						
							|  |  |  |           amd: 'rxjs/subject/ReplaySubject', | 
					
						
							|  |  |  |           root: ['Rx'] | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         'rxjs/operator/take': { | 
					
						
							|  |  |  |           commonjs: 'rxjs/operator/take', | 
					
						
							|  |  |  |           commonjs2: 'rxjs/operator/take', | 
					
						
							|  |  |  |           amd: 'rxjs/operator/take', | 
					
						
							|  |  |  |           root: ['Rx', 'Observable', 'prototype'] | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         'rxjs/observable/fromPromise': { | 
					
						
							|  |  |  |           commonjs: 'rxjs/observable/fromPromise', | 
					
						
							|  |  |  |           commonjs2: 'rxjs/observable/fromPromise', | 
					
						
							|  |  |  |           amd: 'rxjs/observable/fromPromise', | 
					
						
							|  |  |  |           root: ['Rx', 'Observable'] | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         'rxjs/operator/toPromise': { | 
					
						
							|  |  |  |           commonjs: 'rxjs/operator/toPromise', | 
					
						
							|  |  |  |           commonjs2: 'rxjs/operator/toPromise', | 
					
						
							|  |  |  |           amd: 'rxjs/operator/toPromise', | 
					
						
							|  |  |  |           root: ['Rx', 'Observable', 'prototype'] | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2015-11-16 15:59:05 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-18 15:08:49 +01:00
										 |  |  |   return Promise.all([ | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |     webpack(webPackConf([__dirname + '/tools/build/webpack/angular2-all.umd.js'], 'angular2-all', | 
					
						
							|  |  |  |                         'dev')), | 
					
						
							|  |  |  |     webpack(webPackConf([__dirname + '/tools/build/webpack/angular2-all.umd.js'], 'angular2-all', | 
					
						
							|  |  |  |                         'prod')), | 
					
						
							|  |  |  |     webpack(webPackConf([__dirname + '/tools/build/webpack/angular2-all-testing.umd.js'], | 
					
						
							|  |  |  |                         'angular2-all-testing', 'dev')) | 
					
						
							| 
									
										
										
										
											2015-11-16 15:59:05 +01:00
										 |  |  |   ]); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-08 23:01:52 +01:00
										 |  |  | gulp.task('bundles.js.umd.min', ['!bundles.js.umd', '!bundle.ng.polyfills'], function() { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var rename = require('gulp-rename'); | 
					
						
							|  |  |  |   var uglify = require('gulp-uglify'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-16 15:59:05 +01:00
										 |  |  |   // minify production bundles
 | 
					
						
							| 
									
										
										
										
											2015-12-15 10:48:48 +01:00
										 |  |  |   return gulp.src(['dist/js/bundle/angular2-polyfills.js', 'dist/js/bundle/angular2-all.umd.js']) | 
					
						
							| 
									
										
										
										
											2015-11-16 15:59:05 +01:00
										 |  |  |       .pipe(uglify()) | 
					
						
							|  |  |  |       .pipe(rename({extname: '.min.js'})) | 
					
						
							|  |  |  |       .pipe(gulp.dest('dist/js/bundle')); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-24 14:45:00 -07:00
										 |  |  | gulp.task('!bundle.js.prod.deps', ['!bundle.js.prod'], function() { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var bundler = require('./tools/build/bundle'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   return merge2(bundler.modify(['dist/build/angular2.js'], 'angular2.js'), | 
					
						
							|  |  |  |                 bundler.modify(['dist/build/http.js'], 'http.js'), | 
					
						
							|  |  |  |                 bundler.modify(['dist/build/router.js'], 'router.js'), | 
					
						
							| 
									
										
										
										
											2016-04-29 18:05:36 -07:00
										 |  |  |                 bundler.modify(['dist/build/alt_router.js'], 'alt_router.js'), | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |                 bundler.modify(['dist/build/upgrade.js'], 'upgrade.js')) | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |       .pipe(gulp.dest('dist/js/bundle')); | 
					
						
							| 
									
										
										
										
											2015-04-02 19:53:11 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-24 14:45:00 -07:00
										 |  |  | gulp.task('!bundle.js.min.deps', ['!bundle.js.min'], function() { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var bundler = require('./tools/build/bundle'); | 
					
						
							|  |  |  |   var uglify = require('gulp-uglify'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   return merge2(bundler.modify(['dist/build/angular2.min.js'], 'angular2.min.js'), | 
					
						
							|  |  |  |                 bundler.modify(['dist/build/http.min.js'], 'http.min.js'), | 
					
						
							|  |  |  |                 bundler.modify(['dist/build/router.min.js'], 'router.min.js'), | 
					
						
							| 
									
										
										
										
											2016-04-29 18:05:36 -07:00
										 |  |  |                 bundler.modify(['dist/build/alt_router.min.js'], 'alt_router.min.js'), | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |                 bundler.modify(['dist/build/upgrade.min.js'], 'upgrade.min.js')) | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |       .pipe(uglify()) | 
					
						
							|  |  |  |       .pipe(gulp.dest('dist/js/bundle')); | 
					
						
							| 
									
										
										
										
											2015-03-23 13:18:05 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('!bundle.ng.polyfills', ['clean'], | 
					
						
							|  |  |  |           function() { return addDevDependencies('angular2-polyfills.js'); }); | 
					
						
							| 
									
										
										
										
											2015-11-16 15:29:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 09:47:17 +02:00
										 |  |  | var JS_DEV_DEPS = [ | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   licenseWrap('node_modules/zone.js/LICENSE', true), | 
					
						
							|  |  |  |   'node_modules/zone.js/dist/zone.js', | 
					
						
							| 
									
										
										
										
											2015-09-11 16:00:26 -07:00
										 |  |  |   'node_modules/zone.js/dist/long-stack-trace-zone.js', | 
					
						
							|  |  |  |   licenseWrap('node_modules/reflect-metadata/LICENSE', true), | 
					
						
							|  |  |  |   'node_modules/reflect-metadata/Reflect.js' | 
					
						
							| 
									
										
										
										
											2015-05-12 09:47:17 +02:00
										 |  |  | ]; | 
					
						
							| 
									
										
										
										
											2015-04-13 16:48:04 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 17:43:30 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-27 10:39:39 -07:00
										 |  |  | function addDevDependencies(outputFile) { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var bundler = require('./tools/build/bundle'); | 
					
						
							|  |  |  |   var insert = require('gulp-insert'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |   return bundler.modify(JS_DEV_DEPS.concat(['dist/build/' + outputFile]), outputFile) | 
					
						
							| 
									
										
										
										
											2015-08-27 10:39:39 -07:00
										 |  |  |       .pipe(gulp.dest('dist/js/bundle')); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-24 14:45:00 -07:00
										 |  |  | gulp.task('!bundle.js.dev.deps', ['!bundle.js.dev'], function() { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var bundler = require('./tools/build/bundle'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   return merge2(bundler.modify(['dist/build/angular2.dev.js'], 'angular2.dev.js'), | 
					
						
							|  |  |  |                 bundler.modify(['dist/build/http.dev.js'], 'http.dev.js'), | 
					
						
							|  |  |  |                 bundler.modify(['dist/build/router.dev.js'], 'router.dev.js'), | 
					
						
							| 
									
										
										
										
											2016-04-29 18:05:36 -07:00
										 |  |  |                 bundler.modify(['dist/build/alt_router.dev.js'], 'alt_router.dev.js'), | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |                 bundler.modify(['dist/build/upgrade.dev.js'], 'upgrade.dev.js')) | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |       .pipe(gulp.dest('dist/js/bundle')); | 
					
						
							| 
									
										
										
										
											2015-04-13 16:48:04 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-27 10:39:39 -07:00
										 |  |  | gulp.task('!bundle.web_worker.js.dev.deps', ['!bundle.web_worker.js.dev'], function() { | 
					
						
							| 
									
										
										
										
											2015-12-14 17:29:56 +01:00
										 |  |  |   var bundler = require('./tools/build/bundle'); | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   return merge2(bundler.modify(['dist/build/web_worker/ui.dev.js'], "web_worker/ui.dev.js"), | 
					
						
							|  |  |  |                 bundler.modify(['dist/build/web_worker/worker.dev.js'], "web_worker/worker.dev.js")) | 
					
						
							| 
									
										
										
										
											2015-12-14 17:29:56 +01:00
										 |  |  |       .pipe(gulp.dest('dist/js/bundle')); | 
					
						
							| 
									
										
										
										
											2015-08-27 10:39:39 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-15 01:16:39 -08:00
										 |  |  | gulp.task('!bundle.copy', function() { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   return merge2(gulp.src('dist/js/bundle/**').pipe(gulp.dest('dist/js/prod/es5/bundle')), | 
					
						
							|  |  |  |                 gulp.src('dist/js/bundle/**').pipe(gulp.dest('dist/js/dev/es5/bundle'))); | 
					
						
							| 
									
										
										
										
											2015-11-15 01:16:39 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-19 16:08:23 -08:00
										 |  |  | gulp.task('!bundles.js.checksize', function(done) { | 
					
						
							| 
									
										
										
										
											2015-11-19 14:50:44 -08:00
										 |  |  |   var reportSize = require('./tools/analytics/reportsize'); | 
					
						
							| 
									
										
										
										
											2016-01-13 16:22:41 +01:00
										 |  |  |   return reportSize('dist/js/bundle/**/*.js', {printToConsole: ['gzip level=2']}); | 
					
						
							| 
									
										
										
										
											2015-11-15 02:27:59 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('bundles.js', | 
					
						
							|  |  |  |           [ | 
					
						
							|  |  |  |             '!bundle.js.prod.deps', | 
					
						
							|  |  |  |             '!bundle.js.dev.deps', | 
					
						
							|  |  |  |             '!bundle.js.min.deps', | 
					
						
							|  |  |  |             '!bundle.web_worker.js.dev.deps', | 
					
						
							|  |  |  |             'bundles.js.umd.min', | 
					
						
							|  |  |  |             '!bundle.testing', | 
					
						
							|  |  |  |             '!bundle.ng.polyfills', | 
					
						
							|  |  |  |             '!bundles.js.docs' | 
					
						
							|  |  |  |           ], | 
					
						
							|  |  |  |           function(done) { runSequence('!bundle.copy', '!bundles.js.checksize', done); }); | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | gulp.task('build.js', | 
					
						
							|  |  |  |           ['build.js.dev', 'build.js.prod', 'build.js.cjs', 'bundles.js', 'benchpress.bundle']); | 
					
						
							| 
									
										
										
										
											2015-04-08 08:28:12 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | gulp.task('clean', [ | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   'build/clean.tools', | 
					
						
							|  |  |  |   'build/clean.js', | 
					
						
							|  |  |  |   'build/clean.dart', | 
					
						
							|  |  |  |   'build/clean.docs', | 
					
						
							| 
									
										
										
										
											2015-12-11 16:48:40 +01:00
										 |  |  |   'build/clean.bundles' | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | ]); | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-11 11:40:29 -08:00
										 |  |  | gulp.task('build', ['build.js', 'build.dart']); | 
					
						
							| 
									
										
										
										
											2015-02-17 11:56:24 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 |  |  | // ------------
 | 
					
						
							| 
									
										
										
										
											2015-09-09 09:31:33 -07:00
										 |  |  | // transform codegen
 | 
					
						
							|  |  |  | gulp.task('lint_protos.dart', function(done) { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var proto = require('./tools/build/proto'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |   return proto.lint({dir: 'modules_dart/transform/lib/src/transform/common/model/'}, done); | 
					
						
							| 
									
										
										
										
											2015-09-09 09:31:33 -07:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-09 09:31:33 -07:00
										 |  |  | gulp.task('gen_protos.dart', function(done) { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var proto = require('./tools/build/proto'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |   return proto.generate( | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         dir: 'modules_dart/transform/lib/src/transform/common/model/', | 
					
						
							|  |  |  |         plugin: 'tools/build/protoc-gen-dart' | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       done); | 
					
						
							| 
									
										
										
										
											2015-09-09 09:31:33 -07:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-17 11:56:24 -08:00
										 |  |  | // ------------
 | 
					
						
							| 
									
										
										
										
											2015-04-26 00:31:53 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | gulp.task('cleanup.builder', function() { return angularBuilder.cleanup(); }); | 
					
						
							| 
									
										
										
										
											2015-04-26 00:31:53 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-11 16:48:40 +01:00
										 |  |  | gulp.task('benchpress.bundle', ['build/clean.bundles.benchpress', 'build.js.cjs'], function(cb) { | 
					
						
							| 
									
										
										
										
											2015-11-26 23:45:40 -08:00
										 |  |  |   var bundler = require('./tools/build/bundle'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |   bundler.benchpressBundle(BENCHPRESS_BUNDLE_CONFIG.entries, BENCHPRESS_BUNDLE_CONFIG.packageJson, | 
					
						
							|  |  |  |                            BENCHPRESS_BUNDLE_CONFIG.includes, BENCHPRESS_BUNDLE_CONFIG.excludes, | 
					
						
							|  |  |  |                            BENCHPRESS_BUNDLE_CONFIG.ignore, BENCHPRESS_BUNDLE_CONFIG.dest, cb); | 
					
						
							| 
									
										
										
										
											2015-08-04 15:32:17 -07:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-06-23 15:26:51 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-26 00:31:53 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  | // register cleanup listener for ctrl+c/kill used to quit any persistent task (autotest or serve
 | 
					
						
							|  |  |  | // tasks)
 | 
					
						
							| 
									
										
										
										
											2015-04-26 00:31:53 -07:00
										 |  |  | process.on('SIGINT', function() { | 
					
						
							| 
									
										
										
										
											2015-10-27 12:26:36 +01:00
										 |  |  |   if (!angularBuilder.uninitialized) { | 
					
						
							| 
									
										
										
										
											2015-11-12 23:57:35 -08:00
										 |  |  |     runSequence('cleanup.builder', function() { process.exit(); }); | 
					
						
							| 
									
										
										
										
											2015-10-27 12:21:34 +01:00
										 |  |  |   } else { | 
					
						
							|  |  |  |     process.exit(); | 
					
						
							| 
									
										
										
										
											2015-06-05 23:43:11 -07:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-04-26 00:31:53 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-19 21:58:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-26 00:31:53 -07:00
										 |  |  | // register cleanup listener for all non-persistent tasks
 | 
					
						
							| 
									
										
										
										
											2015-05-12 21:19:59 -07:00
										 |  |  | var beforeExitRan = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-26 00:31:53 -07:00
										 |  |  | process.on('beforeExit', function() { | 
					
						
							| 
									
										
										
										
											2015-05-12 21:19:59 -07:00
										 |  |  |   if (beforeExitRan) return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   beforeExitRan = true; | 
					
						
							| 
									
										
										
										
											2015-06-05 23:43:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-27 12:26:36 +01:00
										 |  |  |   if (!angularBuilder.uninitialized) { | 
					
						
							| 
									
										
										
										
											2015-06-05 23:43:11 -07:00
										 |  |  |     gulp.start('cleanup.builder'); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-04-26 00:31:53 -07:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-10-11 02:23:05 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:51:28 -08:00
										 |  |  | var firstTask = true; | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:03 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-12 23:51:28 -08:00
										 |  |  | gulp.on('task_start', (e) => { | 
					
						
							|  |  |  |   if (firstTask) { | 
					
						
							|  |  |  |     firstTask = false; | 
					
						
							|  |  |  |     analytics.buildSuccess('gulp <startup>', process.uptime() * 1000); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 21:57:16 -07:00
										 |  |  |   analytics.buildStart('gulp ' + e.task); | 
					
						
							| 
									
										
										
										
											2015-11-12 23:51:28 -08:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2016-04-28 21:57:16 -07:00
										 |  |  | gulp.on('task_stop', (e) => { analytics.buildSuccess('gulp ' + e.task, e.duration * 1000); }); | 
					
						
							|  |  |  | gulp.on('task_err', (e) => { analytics.buildError('gulp ' + e.task, e.duration * 1000); }); |