2014-10-28 06:45:48 -04:00
|
|
|
var gulp = require('gulp');
|
2014-12-05 19:26:30 -05:00
|
|
|
var gulpPlugins = require('gulp-load-plugins')();
|
2014-10-28 06:45:48 -04:00
|
|
|
var runSequence = require('run-sequence');
|
2014-12-05 19:26:30 -05:00
|
|
|
var merge = require('merge');
|
|
|
|
var gulpTraceur = require('./tools/transpiler/gulp-traceur');
|
2014-10-08 16:15:38 -04:00
|
|
|
|
2014-12-05 19:26:30 -05:00
|
|
|
var clean = require('./tools/build/clean');
|
|
|
|
var deps = require('./tools/build/deps');
|
|
|
|
var transpile = require('./tools/build/transpile');
|
|
|
|
var html = require('./tools/build/html');
|
|
|
|
var pubspec = require('./tools/build/pubspec');
|
2015-02-11 14:40:29 -05:00
|
|
|
var linknodemodules = require('./tools/build/linknodemodules');
|
2014-12-22 20:50:10 -05:00
|
|
|
var pubbuild = require('./tools/build/pubbuild');
|
2014-12-05 19:26:30 -05:00
|
|
|
var dartanalyzer = require('./tools/build/dartanalyzer');
|
|
|
|
var jsserve = require('./tools/build/jsserve');
|
|
|
|
var pubserve = require('./tools/build/pubserve');
|
2015-01-30 14:03:11 -05:00
|
|
|
var rundartpackage = require('./tools/build/rundartpackage');
|
2015-02-09 17:02:11 -05:00
|
|
|
var multicopy = require('./tools/build/multicopy');
|
2014-11-07 12:29:19 -05:00
|
|
|
var karma = require('karma').server;
|
|
|
|
var minimist = require('minimist');
|
2015-02-07 00:04:43 -05:00
|
|
|
var es5build = require('./tools/build/es5build');
|
2015-02-20 20:44:23 -05:00
|
|
|
var runServerDartTests = require('./tools/build/run_server_dart_tests');
|
2014-12-22 20:50:10 -05:00
|
|
|
|
2014-12-05 19:26:30 -05:00
|
|
|
var DART_SDK = require('./tools/build/dartdetect')(gulp);
|
|
|
|
// -----------------------
|
|
|
|
// configuration
|
2014-09-18 17:56:38 -04:00
|
|
|
|
2014-12-05 19:26:30 -05:00
|
|
|
var _COMPILER_CONFIG_JS_DEFAULT = {
|
2014-10-30 13:52:32 -04:00
|
|
|
sourceMaps: true,
|
2014-09-24 23:20:59 -04:00
|
|
|
annotations: true, // parse annotations
|
|
|
|
types: true, // parse types
|
|
|
|
script: false, // parse as a module
|
2014-11-07 12:31:51 -05:00
|
|
|
memberVariables: true, // parse class fields
|
2014-12-05 19:26:30 -05:00
|
|
|
modules: 'instantiate'
|
2014-09-24 23:20:59 -04:00
|
|
|
};
|
|
|
|
|
2014-12-05 19:26:30 -05:00
|
|
|
var _HTLM_DEFAULT_SCRIPTS_JS = [
|
|
|
|
{src: '/deps/traceur-runtime.js', mimeType: 'text/javascript'},
|
2015-02-02 19:25:34 -05:00
|
|
|
{src: '/rtts_assert/rtts_assert.js', mimeType: 'text/javascript'},
|
2014-12-05 19:26:30 -05:00
|
|
|
{src: '/deps/es6-module-loader-sans-promises.src.js', mimeType: 'text/javascript'},
|
2014-12-10 13:48:37 -05:00
|
|
|
{src: '/deps/zone.js', mimeType: 'text/javascript'},
|
2014-12-11 14:36:05 -05:00
|
|
|
{src: '/deps/long-stack-trace-zone.js', mimeType: 'text/javascript'},
|
2014-12-05 19:26:30 -05:00
|
|
|
{src: '/deps/system.src.js', mimeType: 'text/javascript'},
|
|
|
|
{src: '/deps/extension-register.js', mimeType: 'text/javascript'},
|
|
|
|
{src: '/deps/runtime_paths.js', mimeType: 'text/javascript'},
|
|
|
|
{
|
|
|
|
inline: 'System.import(\'$MODULENAME$\').then(function(m) { m.main(); }, console.log.bind(console))',
|
|
|
|
mimeType: 'text/javascript'
|
2014-12-03 09:21:57 -05:00
|
|
|
}
|
2014-12-05 19:26:30 -05:00
|
|
|
];
|
2014-09-25 17:04:46 -04:00
|
|
|
|
2015-01-09 21:00:04 -05:00
|
|
|
var _HTML_DEFAULT_SCRIPTS_DART = [
|
|
|
|
{src: '$MODULENAME_WITHOUT_PATH$.dart', mimeType: 'application/dart'},
|
|
|
|
{src: 'packages/browser/dart.js', mimeType: 'text/javascript'}
|
|
|
|
];
|
2014-09-18 17:56:38 -04:00
|
|
|
|
2014-12-05 19:26:30 -05:00
|
|
|
var CONFIG = {
|
|
|
|
dest: {
|
|
|
|
js: {
|
|
|
|
all: 'dist/js',
|
2015-02-07 00:04:43 -05: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 14:40:29 -05:00
|
|
|
cjs: 'dist/js/cjs',
|
2014-12-22 20:50:10 -05:00
|
|
|
dart2js: 'dist/js/dart2js'
|
2014-12-05 19:26:30 -05:00
|
|
|
},
|
2015-01-06 18:19:22 -05:00
|
|
|
dart: 'dist/dart',
|
2015-01-16 08:21:55 -05:00
|
|
|
docs: 'dist/docs'
|
2014-12-05 19:26:30 -05:00
|
|
|
},
|
2015-02-02 19:25:34 -05:00
|
|
|
srcFolderInsertion: {
|
|
|
|
js: {
|
|
|
|
'**': ''
|
|
|
|
},
|
|
|
|
dart: {
|
|
|
|
'**': 'lib',
|
|
|
|
'*/test/**': '',
|
|
|
|
'benchmarks/**': 'web',
|
|
|
|
'benchmarks/test/**': '',
|
|
|
|
'benchmarks_external/**': 'web',
|
|
|
|
'benchmarks_external/test/**': '',
|
|
|
|
'example*/**': 'web',
|
|
|
|
'example*/test/**': ''
|
|
|
|
}
|
2014-12-05 19:26:30 -05:00
|
|
|
},
|
|
|
|
deps: {
|
|
|
|
js: [
|
|
|
|
gulpTraceur.RUNTIME_PATH,
|
|
|
|
"node_modules/es6-module-loader/dist/es6-module-loader-sans-promises.src.js",
|
|
|
|
"node_modules/systemjs/dist/system.src.js",
|
|
|
|
"node_modules/systemjs/lib/extension-register.js",
|
2014-12-10 13:48:37 -05:00
|
|
|
"node_modules/zone.js/zone.js",
|
2014-12-11 14:36:05 -05:00
|
|
|
"node_modules/zone.js/long-stack-trace-zone.js",
|
2015-01-09 21:00:04 -05:00
|
|
|
"tools/build/snippets/runtime_paths.js",
|
|
|
|
"tools/build/snippets/url_params_to_form.js",
|
2014-12-05 19:26:30 -05:00
|
|
|
"node_modules/angular/angular.js"
|
2015-01-09 21:00:04 -05:00
|
|
|
],
|
|
|
|
dart: [
|
|
|
|
"tools/build/snippets/url_params_to_form.js"
|
2014-12-05 19:26:30 -05:00
|
|
|
]
|
|
|
|
},
|
|
|
|
transpile: {
|
|
|
|
src: {
|
2015-02-11 14:40:29 -05:00
|
|
|
js: ['modules/**/*.js', 'modules/**/*.es6'],
|
|
|
|
dart: ['modules/**/*.js'],
|
2014-12-05 19:26:30 -05:00
|
|
|
},
|
|
|
|
copy: {
|
2015-02-11 14:40:29 -05:00
|
|
|
js: ['modules/**/*.es5'],
|
2015-01-06 18:19:22 -05:00
|
|
|
dart: ['modules/**/*.dart', '!modules/**/e2e_test/**'],
|
2014-12-05 19:26:30 -05:00
|
|
|
},
|
|
|
|
options: {
|
|
|
|
js: {
|
|
|
|
dev: merge(true, _COMPILER_CONFIG_JS_DEFAULT, {
|
|
|
|
typeAssertionModule: 'rtts_assert/rtts_assert',
|
2015-02-07 00:04:43 -05:00
|
|
|
typeAssertions: true,
|
|
|
|
outputLanguage: 'es6'
|
2014-12-05 19:26:30 -05:00
|
|
|
}),
|
|
|
|
prod: merge(true, _COMPILER_CONFIG_JS_DEFAULT, {
|
2015-02-07 00:04:43 -05:00
|
|
|
typeAssertions: false,
|
|
|
|
outputLanguage: 'es6'
|
2015-02-11 14:40:29 -05:00
|
|
|
}),
|
|
|
|
cjs: merge(true, _COMPILER_CONFIG_JS_DEFAULT, {
|
|
|
|
typeAssertionModule: 'rtts_assert/rtts_assert',
|
|
|
|
typeAssertions: true,
|
|
|
|
modules: 'commonjs'
|
2014-12-05 19:26:30 -05:00
|
|
|
})
|
|
|
|
},
|
|
|
|
dart: {
|
|
|
|
sourceMaps: true,
|
|
|
|
annotations: true, // parse annotations
|
|
|
|
types: true, // parse types
|
|
|
|
script: false, // parse as a module
|
|
|
|
memberVariables: true, // parse class fields
|
|
|
|
outputLanguage: 'dart'
|
2015-02-11 14:40:29 -05:00
|
|
|
}
|
2014-12-05 19:26:30 -05:00
|
|
|
}
|
|
|
|
},
|
2015-02-10 14:06:59 -05:00
|
|
|
copy: {
|
|
|
|
js: ['modules/**/README.md', 'modules/**/package.json'],
|
|
|
|
dart: []
|
|
|
|
},
|
|
|
|
multicopy: {
|
|
|
|
src: {
|
|
|
|
dart: ['LICENSE'],
|
|
|
|
js: ['LICENSE', 'tools/build/es5build.js']
|
|
|
|
}
|
|
|
|
},
|
2014-12-05 19:26:30 -05:00
|
|
|
html: {
|
|
|
|
src: {
|
|
|
|
js: ['modules/*/src/**/*.html'],
|
|
|
|
dart: ['modules/*/src/**/*.html']
|
|
|
|
},
|
|
|
|
scriptsPerFolder: {
|
|
|
|
js: {
|
2015-02-02 19:25:34 -05:00
|
|
|
'**': _HTLM_DEFAULT_SCRIPTS_JS,
|
2015-01-09 21:00:04 -05:00
|
|
|
'benchmarks/**':
|
|
|
|
[
|
|
|
|
{ src: '/deps/url_params_to_form.js', mimeType: 'text/javascript' }
|
|
|
|
].concat(_HTLM_DEFAULT_SCRIPTS_JS),
|
2014-12-05 19:26:30 -05:00
|
|
|
'benchmarks_external/**':
|
2015-01-09 21:00:04 -05:00
|
|
|
[
|
|
|
|
{ src: '/deps/angular.js', mimeType: 'text/javascript' },
|
|
|
|
{ src: '/deps/url_params_to_form.js', mimeType: 'text/javascript' }
|
|
|
|
].concat(_HTLM_DEFAULT_SCRIPTS_JS)
|
2014-12-05 19:26:30 -05:00
|
|
|
},
|
|
|
|
dart: {
|
2015-02-02 19:25:34 -05:00
|
|
|
'**': _HTML_DEFAULT_SCRIPTS_DART,
|
2015-01-09 21:00:04 -05:00
|
|
|
'benchmarks*/**':
|
|
|
|
[
|
|
|
|
{ src: '/deps/url_params_to_form.js', mimeType: 'text/javascript' }
|
|
|
|
].concat(_HTML_DEFAULT_SCRIPTS_DART)
|
2014-10-02 15:27:01 -04:00
|
|
|
}
|
2014-12-05 19:26:30 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
pubspec: {
|
|
|
|
src: 'modules/*/pubspec.yaml'
|
2015-01-30 14:03:11 -05:00
|
|
|
},
|
|
|
|
formatDart: {
|
|
|
|
packageName: 'dart_style',
|
|
|
|
args: ['dart_style:format', '-w', 'dist/dart']
|
2014-11-17 23:47:05 -05:00
|
|
|
}
|
2014-12-05 19:26:30 -05:00
|
|
|
};
|
2014-10-08 16:15:38 -04:00
|
|
|
|
2014-12-05 19:26:30 -05:00
|
|
|
// ------------
|
|
|
|
// clean
|
|
|
|
|
|
|
|
gulp.task('build/clean.js', clean(gulp, gulpPlugins, {
|
|
|
|
path: CONFIG.dest.js.all
|
|
|
|
}));
|
|
|
|
|
|
|
|
gulp.task('build/clean.dart', clean(gulp, gulpPlugins, {
|
|
|
|
path: CONFIG.dest.dart
|
|
|
|
}));
|
|
|
|
|
2015-01-16 08:21:55 -05:00
|
|
|
gulp.task('build/clean.docs', clean(gulp, gulpPlugins, {
|
|
|
|
path: CONFIG.dest.docs
|
|
|
|
}));
|
|
|
|
|
2015-01-06 18:19:22 -05:00
|
|
|
|
2014-12-05 19:26:30 -05:00
|
|
|
// ------------
|
|
|
|
// deps
|
|
|
|
|
|
|
|
gulp.task('build/deps.js.dev', deps(gulp, gulpPlugins, {
|
|
|
|
src: CONFIG.deps.js,
|
2015-02-07 00:04:43 -05:00
|
|
|
dest: CONFIG.dest.js.dev.es5
|
2014-12-05 19:26:30 -05:00
|
|
|
}));
|
|
|
|
|
|
|
|
gulp.task('build/deps.js.prod', deps(gulp, gulpPlugins, {
|
|
|
|
src: CONFIG.deps.js,
|
2015-02-07 00:04:43 -05:00
|
|
|
dest: CONFIG.dest.js.prod.es5
|
2014-12-05 19:26:30 -05:00
|
|
|
}));
|
|
|
|
|
2015-01-09 21:00:04 -05:00
|
|
|
gulp.task('build/deps.js.dart2js', deps(gulp, gulpPlugins, {
|
|
|
|
src: CONFIG.deps.dart,
|
|
|
|
dest: CONFIG.dest.js.dart2js
|
|
|
|
}));
|
|
|
|
|
2014-12-05 19:26:30 -05:00
|
|
|
// ------------
|
|
|
|
// transpile
|
|
|
|
|
2015-02-07 00:04:43 -05:00
|
|
|
gulp.task('build/transpile.js.dev.es6', transpile(gulp, gulpPlugins, {
|
2014-12-05 19:26:30 -05:00
|
|
|
src: CONFIG.transpile.src.js,
|
|
|
|
copy: CONFIG.transpile.copy.js,
|
2015-02-07 00:04:43 -05:00
|
|
|
dest: CONFIG.dest.js.dev.es6,
|
|
|
|
outputExt: 'es6',
|
2014-12-05 19:26:30 -05:00
|
|
|
options: CONFIG.transpile.options.js.dev,
|
2015-02-02 19:25:34 -05:00
|
|
|
srcFolderInsertion: CONFIG.srcFolderInsertion.js
|
2014-12-05 19:26:30 -05:00
|
|
|
}));
|
|
|
|
|
2015-02-10 18:18:16 -05:00
|
|
|
gulp.task('build/transpile.js.dev.es5', function() {
|
|
|
|
return es5build({
|
|
|
|
src: CONFIG.dest.js.dev.es6,
|
|
|
|
dest: CONFIG.dest.js.dev.es5,
|
|
|
|
modules: 'instantiate'
|
|
|
|
});
|
|
|
|
});
|
2015-02-07 00:04:43 -05:00
|
|
|
|
2015-02-10 18:18:16 -05:00
|
|
|
gulp.task('build/transpile.js.dev', function(done) {
|
|
|
|
runSequence(
|
2015-02-07 00:04:43 -05:00
|
|
|
'build/transpile.js.dev.es6',
|
2015-02-10 18:18:16 -05:00
|
|
|
'build/transpile.js.dev.es5',
|
|
|
|
done
|
2015-02-07 00:04:43 -05:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('build/transpile.js.prod.es6', transpile(gulp, gulpPlugins, {
|
2014-12-05 19:26:30 -05:00
|
|
|
src: CONFIG.transpile.src.js,
|
|
|
|
copy: CONFIG.transpile.copy.js,
|
2015-02-07 00:04:43 -05:00
|
|
|
dest: CONFIG.dest.js.prod.es6,
|
|
|
|
outputExt: 'es6',
|
2014-12-05 19:26:30 -05:00
|
|
|
options: CONFIG.transpile.options.js.prod,
|
2015-02-02 19:25:34 -05:00
|
|
|
srcFolderInsertion: CONFIG.srcFolderInsertion.js
|
2014-12-05 19:26:30 -05:00
|
|
|
}));
|
|
|
|
|
2015-02-10 18:18:16 -05:00
|
|
|
gulp.task('build/transpile.js.prod.es5', function() {
|
|
|
|
return es5build({
|
|
|
|
src: CONFIG.dest.js.prod.es6,
|
|
|
|
dest: CONFIG.dest.js.prod.es5,
|
|
|
|
modules: 'instantiate'
|
|
|
|
});
|
|
|
|
});
|
2015-02-07 00:04:43 -05:00
|
|
|
|
2015-02-10 18:18:16 -05:00
|
|
|
gulp.task('build/transpile.js.prod', function(done) {
|
|
|
|
runSequence(
|
2015-02-07 00:04:43 -05:00
|
|
|
'build/transpile.js.prod.es6',
|
2015-02-10 18:18:16 -05:00
|
|
|
'build/transpile.js.prod.es5',
|
|
|
|
done
|
2015-02-07 00:04:43 -05:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2015-02-11 14:40:29 -05:00
|
|
|
gulp.task('build/transpile.js.cjs', transpile(gulp, gulpPlugins, {
|
2015-02-11 13:13:49 -05:00
|
|
|
src: CONFIG.transpile.src.js,
|
2015-02-11 14:40:29 -05:00
|
|
|
copy: CONFIG.transpile.copy.js,
|
|
|
|
dest: CONFIG.dest.js.cjs,
|
|
|
|
outputExt: 'js',
|
|
|
|
options: CONFIG.transpile.options.js.cjs,
|
|
|
|
srcFolderInsertion: CONFIG.srcFolderInsertion.js
|
|
|
|
}));
|
|
|
|
|
2014-12-05 19:26:30 -05:00
|
|
|
gulp.task('build/transpile.dart', transpile(gulp, gulpPlugins, {
|
|
|
|
src: CONFIG.transpile.src.dart,
|
|
|
|
copy: CONFIG.transpile.copy.dart,
|
|
|
|
dest: CONFIG.dest.dart,
|
|
|
|
outputExt: 'dart',
|
|
|
|
options: CONFIG.transpile.options.dart,
|
2015-02-02 19:25:34 -05:00
|
|
|
srcFolderInsertion: CONFIG.srcFolderInsertion.dart
|
2014-12-05 19:26:30 -05:00
|
|
|
}));
|
|
|
|
|
|
|
|
// ------------
|
|
|
|
// html
|
|
|
|
|
|
|
|
gulp.task('build/html.js.dev', html(gulp, gulpPlugins, {
|
|
|
|
src: CONFIG.html.src.js,
|
2015-02-07 00:04:43 -05:00
|
|
|
dest: CONFIG.dest.js.dev.es5,
|
2015-02-02 19:25:34 -05:00
|
|
|
srcFolderInsertion: CONFIG.srcFolderInsertion.js,
|
2014-12-05 19:26:30 -05:00
|
|
|
scriptsPerFolder: CONFIG.html.scriptsPerFolder.js
|
|
|
|
}));
|
|
|
|
|
|
|
|
gulp.task('build/html.js.prod', html(gulp, gulpPlugins, {
|
|
|
|
src: CONFIG.html.src.js,
|
2015-02-07 00:04:43 -05:00
|
|
|
dest: CONFIG.dest.js.prod.es5,
|
2015-02-02 19:25:34 -05:00
|
|
|
srcFolderInsertion: CONFIG.srcFolderInsertion.js,
|
2014-12-05 19:26:30 -05:00
|
|
|
scriptsPerFolder: CONFIG.html.scriptsPerFolder.js
|
|
|
|
}));
|
|
|
|
|
|
|
|
gulp.task('build/html.dart', html(gulp, gulpPlugins, {
|
|
|
|
src: CONFIG.html.src.dart,
|
|
|
|
dest: CONFIG.dest.dart,
|
2015-02-02 19:25:34 -05:00
|
|
|
srcFolderInsertion: CONFIG.srcFolderInsertion.dart,
|
2014-12-05 19:26:30 -05:00
|
|
|
scriptsPerFolder: CONFIG.html.scriptsPerFolder.dart
|
|
|
|
}));
|
|
|
|
|
2015-02-09 17:02:11 -05:00
|
|
|
// ------------
|
2015-02-10 14:06:59 -05:00
|
|
|
// copy
|
|
|
|
|
|
|
|
gulp.task('build/copy.js.dev', function() {
|
|
|
|
return gulp.src(CONFIG.copy.js)
|
2015-02-10 18:18:16 -05:00
|
|
|
.pipe(gulpPlugins.template({
|
|
|
|
'channel': 'dev',
|
|
|
|
'packageJson': require('./package.json')
|
|
|
|
}))
|
2015-02-10 14:06:59 -05:00
|
|
|
.pipe(gulp.dest(CONFIG.dest.js.dev.es6));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('build/copy.js.prod', function() {
|
|
|
|
return gulp.src(CONFIG.copy.js)
|
2015-02-10 18:18:16 -05:00
|
|
|
.pipe(gulpPlugins.template({
|
|
|
|
'channel': 'prod',
|
|
|
|
'packageJson': require('./package.json')
|
|
|
|
}))
|
2015-02-10 14:06:59 -05:00
|
|
|
.pipe(gulp.dest(CONFIG.dest.js.prod.es6));
|
|
|
|
});
|
|
|
|
|
|
|
|
// ------------
|
|
|
|
// multicopy
|
2015-02-09 17:02:11 -05:00
|
|
|
|
2015-02-10 14:06:59 -05:00
|
|
|
gulp.task('build/multicopy.js.dev', multicopy(gulp, gulpPlugins, {
|
|
|
|
src: CONFIG.multicopy.src.js,
|
|
|
|
dest: CONFIG.dest.js.dev.es6
|
2015-02-09 17:02:11 -05:00
|
|
|
}));
|
|
|
|
|
2015-02-10 14:06:59 -05:00
|
|
|
gulp.task('build/multicopy.js.prod', multicopy(gulp, gulpPlugins, {
|
|
|
|
src: CONFIG.multicopy.src.js,
|
|
|
|
dest: CONFIG.dest.js.prod.es6
|
2015-02-09 17:02:11 -05:00
|
|
|
}));
|
|
|
|
|
2015-02-10 14:06:59 -05:00
|
|
|
gulp.task('build/multicopy.dart', multicopy(gulp, gulpPlugins, {
|
|
|
|
src: CONFIG.multicopy.src.dart,
|
2015-02-09 17:02:11 -05:00
|
|
|
dest: CONFIG.dest.dart
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2014-12-05 19:26:30 -05:00
|
|
|
// ------------
|
|
|
|
// pubspec
|
|
|
|
|
|
|
|
gulp.task('build/pubspec.dart', pubspec(gulp, gulpPlugins, {
|
|
|
|
src: CONFIG.pubspec.src,
|
|
|
|
dest: CONFIG.dest.dart,
|
|
|
|
command: DART_SDK.PUB
|
|
|
|
}));
|
|
|
|
|
2015-02-11 14:40:29 -05:00
|
|
|
// ------------
|
|
|
|
// linknodemodules
|
|
|
|
|
|
|
|
gulp.task('build/linknodemodules.js.cjs', linknodemodules(gulp, gulpPlugins, {
|
|
|
|
dir: CONFIG.dest.js.cjs
|
|
|
|
}));
|
|
|
|
|
2014-12-05 19:26:30 -05:00
|
|
|
// ------------
|
2014-12-22 20:50:10 -05:00
|
|
|
// dartanalyzer
|
2014-12-05 19:26:30 -05:00
|
|
|
|
|
|
|
gulp.task('build/analyze.dart', dartanalyzer(gulp, gulpPlugins, {
|
|
|
|
dest: CONFIG.dest.dart,
|
2015-02-02 19:25:34 -05:00
|
|
|
command: DART_SDK.ANALYZER
|
2014-12-05 19:26:30 -05:00
|
|
|
}));
|
2014-10-08 16:15:38 -04:00
|
|
|
|
2014-12-22 20:50:10 -05:00
|
|
|
// ------------
|
|
|
|
// pubbuild
|
|
|
|
|
|
|
|
gulp.task('build/pubbuild.dart', pubbuild(gulp, gulpPlugins, {
|
|
|
|
src: CONFIG.dest.dart,
|
|
|
|
dest: CONFIG.dest.js.dart2js,
|
|
|
|
command: DART_SDK.PUB
|
|
|
|
}));
|
|
|
|
|
2015-01-30 14:03:11 -05:00
|
|
|
// ------------
|
|
|
|
// format dart
|
|
|
|
|
|
|
|
gulp.task('build/format.dart', rundartpackage(gulp, gulpPlugins, {
|
|
|
|
pub: DART_SDK.PUB,
|
|
|
|
packageName: CONFIG.formatDart.packageName,
|
|
|
|
args: CONFIG.formatDart.args
|
|
|
|
}));
|
|
|
|
|
2014-09-18 17:56:38 -04:00
|
|
|
// ------------------
|
2014-12-05 19:26:30 -05:00
|
|
|
// web servers
|
|
|
|
gulp.task('serve.js.dev', jsserve(gulp, gulpPlugins, {
|
2015-02-07 00:04:43 -05:00
|
|
|
path: CONFIG.dest.js.dev.es5,
|
2014-12-22 20:50:10 -05:00
|
|
|
port: 8000
|
2014-12-05 19:26:30 -05:00
|
|
|
}));
|
|
|
|
|
|
|
|
gulp.task('serve.js.prod', jsserve(gulp, gulpPlugins, {
|
2015-02-07 00:04:43 -05:00
|
|
|
path: CONFIG.dest.js.prod.es5,
|
2014-12-22 20:50:10 -05:00
|
|
|
port: 8001
|
|
|
|
}));
|
|
|
|
|
|
|
|
gulp.task('serve.js.dart2js', jsserve(gulp, gulpPlugins, {
|
|
|
|
path: CONFIG.dest.js.dart2js,
|
|
|
|
port: 8002
|
2014-12-05 19:26:30 -05:00
|
|
|
}));
|
|
|
|
|
|
|
|
gulp.task('serve/examples.dart', pubserve(gulp, gulpPlugins, {
|
|
|
|
command: DART_SDK.PUB,
|
|
|
|
path: CONFIG.dest.dart + '/examples'
|
|
|
|
}));
|
|
|
|
|
|
|
|
gulp.task('serve/benchmarks.dart', pubserve(gulp, gulpPlugins, {
|
|
|
|
command: DART_SDK.PUB,
|
|
|
|
path: CONFIG.dest.dart + '/benchmarks'
|
|
|
|
}));
|
|
|
|
|
|
|
|
gulp.task('serve/benchmarks_external.dart', pubserve(gulp, gulpPlugins, {
|
|
|
|
command: DART_SDK.PUB,
|
|
|
|
path: CONFIG.dest.dart + '/benchmarks_external'
|
|
|
|
}));
|
2014-12-04 09:02:03 -05:00
|
|
|
|
|
|
|
// --------------
|
|
|
|
// doc generation
|
|
|
|
var Dgeni = require('dgeni');
|
|
|
|
gulp.task('docs/dgeni', function() {
|
|
|
|
try {
|
|
|
|
var dgeni = new Dgeni([require('./docs/dgeni-package')]);
|
|
|
|
return dgeni.generate();
|
|
|
|
} catch(x) {
|
|
|
|
console.log(x.stack);
|
|
|
|
throw x;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var bower = require('bower');
|
|
|
|
gulp.task('docs/bower', function() {
|
|
|
|
var bowerTask = bower.commands.install(undefined, undefined, { cwd: 'docs' });
|
|
|
|
bowerTask.on('log', function (result) {
|
|
|
|
console.log('bower:', result.id, result.data.endpoint.name);
|
|
|
|
});
|
|
|
|
bowerTask.on('error', function(error) {
|
|
|
|
console.log(error);
|
|
|
|
});
|
|
|
|
return bowerTask;
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('docs/assets', ['docs/bower'], function() {
|
|
|
|
return gulp.src('docs/bower_components/**/*')
|
2014-12-05 19:26:30 -05:00
|
|
|
.pipe(gulp.dest('dist/docs/lib'));
|
2014-12-04 09:02:03 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('docs/app', function() {
|
|
|
|
return gulp.src('docs/app/**/*')
|
2014-12-05 19:26:30 -05:00
|
|
|
.pipe(gulp.dest('dist/docs'));
|
2014-12-04 09:02:03 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('docs', ['docs/assets', 'docs/app', 'docs/dgeni']);
|
2014-12-06 05:41:07 -05:00
|
|
|
gulp.task('docs/watch', function() {
|
|
|
|
return gulp.watch('docs/app/**/*', ['docs/app']);
|
2014-12-04 09:02:03 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
var jasmine = require('gulp-jasmine');
|
|
|
|
gulp.task('docs/test', function () {
|
|
|
|
return gulp.src('docs/**/*.spec.js')
|
2014-12-06 05:41:07 -05:00
|
|
|
.pipe(jasmine({
|
|
|
|
includeStackTrace: true
|
|
|
|
}));
|
2014-12-04 09:02:03 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
var webserver = require('gulp-webserver');
|
|
|
|
gulp.task('docs/serve', function() {
|
2014-12-05 19:26:30 -05:00
|
|
|
gulp.src('dist/docs/')
|
2014-12-04 09:02:03 -05:00
|
|
|
.pipe(webserver({
|
|
|
|
fallback: 'index.html'
|
|
|
|
}));
|
|
|
|
});
|
2014-12-05 19:26:30 -05:00
|
|
|
|
2014-11-07 12:29:19 -05:00
|
|
|
// ------------------
|
2015-02-20 20:44:23 -05:00
|
|
|
// karma tests
|
|
|
|
// These tests run in the browser and are allowed to access
|
|
|
|
// HTML DOM APIs.
|
2014-11-07 12:29:19 -05:00
|
|
|
function getBrowsersFromCLI() {
|
|
|
|
var args = minimist(process.argv.slice(2));
|
|
|
|
return [args.browsers?args.browsers:'DartiumWithWebPlatform']
|
|
|
|
}
|
2015-02-20 20:44:23 -05:00
|
|
|
gulp.task('test.unit.js', function (done) {
|
2014-11-07 12:29:19 -05:00
|
|
|
karma.start({configFile: __dirname + '/karma-js.conf.js'}, done);
|
|
|
|
});
|
2015-02-20 20:44:23 -05:00
|
|
|
gulp.task('test.unit.dart', function (done) {
|
2014-11-07 12:29:19 -05:00
|
|
|
karma.start({configFile: __dirname + '/karma-dart.conf.js'}, done);
|
|
|
|
});
|
2015-02-20 20:44:23 -05:00
|
|
|
gulp.task('test.unit.js/ci', function (done) {
|
|
|
|
karma.start({configFile: __dirname + '/karma-js.conf.js',
|
|
|
|
singleRun: true, reporters: ['dots'], browsers: getBrowsersFromCLI()}, done);
|
2014-11-07 12:29:19 -05:00
|
|
|
});
|
2015-02-20 20:44:23 -05:00
|
|
|
gulp.task('test.unit.dart/ci', function (done) {
|
|
|
|
karma.start({configFile: __dirname + '/karma-dart.conf.js',
|
|
|
|
singleRun: true, reporters: ['dots'], browsers: getBrowsersFromCLI()}, done);
|
2014-11-07 12:29:19 -05:00
|
|
|
});
|
2015-02-20 20:44:23 -05:00
|
|
|
|
|
|
|
// ------------------
|
|
|
|
// server tests
|
|
|
|
// These tests run on the VM on the command-line and are
|
|
|
|
// allowed to access the file system and network.
|
|
|
|
gulp.task('test.server.dart', runServerDartTests(gulp, gulpPlugins, {
|
|
|
|
dest: 'dist/dart'
|
|
|
|
}));
|
|
|
|
|
|
|
|
// -----------------
|
|
|
|
// test builders
|
2015-02-04 17:59:12 -05:00
|
|
|
gulp.task('test.transpiler.unittest', function (done) {
|
|
|
|
return gulp.src('tools/transpiler/unittest/**/*.js')
|
2015-02-06 16:36:31 -05:00
|
|
|
.pipe(jasmine({
|
|
|
|
includeStackTrace: true
|
|
|
|
}))
|
2015-02-04 17:59:12 -05:00
|
|
|
});
|
2014-11-07 12:29:19 -05:00
|
|
|
|
2015-02-20 20:44:23 -05:00
|
|
|
// Copy test resources to dist
|
2015-02-17 11:38:54 -05:00
|
|
|
gulp.task('tests/transform.dart', function() {
|
|
|
|
return gulp.src('modules/angular2/test/transform/**')
|
|
|
|
.pipe(gulp.dest('dist/dart/angular2/test/transform'));
|
|
|
|
});
|
|
|
|
|
2014-12-05 19:26:30 -05:00
|
|
|
// -----------------
|
|
|
|
// orchestrated targets
|
2015-02-10 18:18:16 -05:00
|
|
|
gulp.task('build.dart', function(done) {
|
|
|
|
runSequence(
|
2015-01-09 21:00:04 -05:00
|
|
|
['build/deps.js.dart2js', 'build/transpile.dart', 'build/html.dart'],
|
2015-02-17 11:38:54 -05:00
|
|
|
'tests/transform.dart',
|
2015-02-20 20:12:54 -05:00
|
|
|
'build/format.dart',
|
2014-12-12 19:24:36 -05:00
|
|
|
'build/pubspec.dart',
|
2015-02-10 14:06:59 -05:00
|
|
|
'build/multicopy.dart',
|
2014-12-22 20:50:10 -05:00
|
|
|
'build/pubbuild.dart',
|
2015-01-30 14:03:11 -05:00
|
|
|
'build/analyze.dart',
|
2015-02-10 18:18:16 -05:00
|
|
|
done
|
2014-12-05 19:26:30 -05:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2015-02-10 18:18:16 -05:00
|
|
|
gulp.task('build.js.dev', function(done) {
|
|
|
|
runSequence(
|
2015-02-10 14:06:59 -05:00
|
|
|
['build/deps.js.dev', 'build/transpile.js.dev', 'build/html.js.dev', 'build/copy.js.dev'],
|
2015-02-10 18:18:16 -05:00
|
|
|
'build/multicopy.js.dev',
|
|
|
|
done
|
2014-12-05 19:26:30 -05:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2015-02-10 18:18:16 -05:00
|
|
|
gulp.task('build.js.prod', function(done) {
|
|
|
|
runSequence(
|
2015-02-10 14:06:59 -05:00
|
|
|
['build/deps.js.prod', 'build/transpile.js.prod', 'build/html.js.prod', 'build/copy.js.prod'],
|
2015-02-10 18:18:16 -05:00
|
|
|
'build/multicopy.js.prod',
|
|
|
|
done
|
2014-12-05 19:26:30 -05:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2015-02-11 14:40:29 -05:00
|
|
|
gulp.task('build.js.cjs', function(done) {
|
2015-02-10 18:18:16 -05:00
|
|
|
runSequence(
|
2015-02-11 14:40:29 -05:00
|
|
|
'build/transpile.js.cjs',
|
|
|
|
'build/linknodemodules.js.cjs',
|
2015-02-10 18:18:16 -05:00
|
|
|
done
|
2015-02-11 14:40:29 -05:00
|
|
|
);;
|
2015-01-06 18:19:22 -05:00
|
|
|
});
|
|
|
|
|
2015-02-11 14:40:29 -05:00
|
|
|
gulp.task('build.js', ['build.js.dev', 'build.js.prod', 'build.js.cjs']);
|
2014-12-05 19:26:30 -05:00
|
|
|
|
2015-02-11 14:40:29 -05:00
|
|
|
gulp.task('clean', ['build/clean.js', 'build/clean.dart', 'build/clean.docs']);
|
2014-12-05 19:26:30 -05:00
|
|
|
|
2015-02-11 14:40:29 -05:00
|
|
|
gulp.task('build', ['build.js', 'build.dart']);
|