feat(build): add general copy/multicopy method
This commit is contained in:
parent
cfe71def7e
commit
3f25f5a356
294
gulpfile.js
294
gulpfile.js
@ -5,21 +5,21 @@ var merge = require('merge');
|
|||||||
var gulpTraceur = require('./tools/transpiler/gulp-traceur');
|
var gulpTraceur = require('./tools/transpiler/gulp-traceur');
|
||||||
|
|
||||||
var clean = require('./tools/build/clean');
|
var clean = require('./tools/build/clean');
|
||||||
var deps = require('./tools/build/deps');
|
|
||||||
var transpile = require('./tools/build/transpile');
|
var transpile = require('./tools/build/transpile');
|
||||||
var html = require('./tools/build/html');
|
var html = require('./tools/build/html');
|
||||||
var pubspec = require('./tools/build/pubspec');
|
var pubget = require('./tools/build/pubget');
|
||||||
var linknodemodules = require('./tools/build/linknodemodules');
|
var linknodemodules = require('./tools/build/linknodemodules');
|
||||||
var pubbuild = require('./tools/build/pubbuild');
|
var pubbuild = require('./tools/build/pubbuild');
|
||||||
var dartanalyzer = require('./tools/build/dartanalyzer');
|
var dartanalyzer = require('./tools/build/dartanalyzer');
|
||||||
var jsserve = require('./tools/build/jsserve');
|
var jsserve = require('./tools/build/jsserve');
|
||||||
var pubserve = require('./tools/build/pubserve');
|
var pubserve = require('./tools/build/pubserve');
|
||||||
var rundartpackage = require('./tools/build/rundartpackage');
|
var rundartpackage = require('./tools/build/rundartpackage');
|
||||||
var multicopy = require('./tools/build/multicopy');
|
var copy = require('./tools/build/copy');
|
||||||
var karma = require('karma').server;
|
var karma = require('karma').server;
|
||||||
var minimist = require('minimist');
|
var minimist = require('minimist');
|
||||||
var es5build = require('./tools/build/es5build');
|
var es5build = require('./tools/build/es5build');
|
||||||
var runServerDartTests = require('./tools/build/run_server_dart_tests');
|
var runServerDartTests = require('./tools/build/run_server_dart_tests');
|
||||||
|
var util = require('./tools/build/util');
|
||||||
|
|
||||||
var DART_SDK = require('./tools/build/dartdetect')(gulp);
|
var DART_SDK = require('./tools/build/dartdetect')(gulp);
|
||||||
// -----------------------
|
// -----------------------
|
||||||
@ -35,14 +35,13 @@ var _COMPILER_CONFIG_JS_DEFAULT = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var _HTLM_DEFAULT_SCRIPTS_JS = [
|
var _HTLM_DEFAULT_SCRIPTS_JS = [
|
||||||
{src: '/deps/traceur-runtime.js', mimeType: 'text/javascript'},
|
{src: '../../traceur-runtime.js', mimeType: 'text/javascript'},
|
||||||
{src: '/rtts_assert/rtts_assert.js', mimeType: 'text/javascript'},
|
{src: '../../es6-module-loader-sans-promises.src.js', mimeType: 'text/javascript'},
|
||||||
{src: '/deps/es6-module-loader-sans-promises.src.js', mimeType: 'text/javascript'},
|
{src: '../../zone.js', mimeType: 'text/javascript'},
|
||||||
{src: '/deps/zone.js', mimeType: 'text/javascript'},
|
{src: '../../long-stack-trace-zone.js', mimeType: 'text/javascript'},
|
||||||
{src: '/deps/long-stack-trace-zone.js', mimeType: 'text/javascript'},
|
{src: '../../system.src.js', mimeType: 'text/javascript'},
|
||||||
{src: '/deps/system.src.js', mimeType: 'text/javascript'},
|
{src: '../../extension-register.js', mimeType: 'text/javascript'},
|
||||||
{src: '/deps/extension-register.js', mimeType: 'text/javascript'},
|
{src: '../../runtime_paths.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))',
|
inline: 'System.import(\'$MODULENAME$\').then(function(m) { m.main(); }, console.log.bind(console))',
|
||||||
mimeType: 'text/javascript'
|
mimeType: 'text/javascript'
|
||||||
@ -54,6 +53,52 @@ var _HTML_DEFAULT_SCRIPTS_DART = [
|
|||||||
{src: 'packages/browser/dart.js', mimeType: 'text/javascript'}
|
{src: 'packages/browser/dart.js', mimeType: 'text/javascript'}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
var BASE_PACKAGE_JSON = require('./package.json');
|
||||||
|
var COMMON_PACKAGE_JSON = {
|
||||||
|
version: BASE_PACKAGE_JSON.version,
|
||||||
|
homepage: BASE_PACKAGE_JSON.homepage,
|
||||||
|
bugs: BASE_PACKAGE_JSON.bugs,
|
||||||
|
license: BASE_PACKAGE_JSON.license,
|
||||||
|
contributors: BASE_PACKAGE_JSON.contributors,
|
||||||
|
dependencies: BASE_PACKAGE_JSON.dependencies,
|
||||||
|
devDependencies: {
|
||||||
|
"yargs": BASE_PACKAGE_JSON.devDependencies['yargs'],
|
||||||
|
"gulp-sourcemaps": BASE_PACKAGE_JSON.devDependencies['gulp-sourcemaps'],
|
||||||
|
"gulp-traceur": BASE_PACKAGE_JSON.devDependencies['gulp-traceur'],
|
||||||
|
"gulp": BASE_PACKAGE_JSON.devDependencies['gulp'],
|
||||||
|
"gulp-rename": BASE_PACKAGE_JSON.devDependencies['gulp-rename'],
|
||||||
|
"through2": BASE_PACKAGE_JSON.devDependencies['through2']
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var SRC_FOLDER_INSERTION = {
|
||||||
|
js: {
|
||||||
|
'**': ''
|
||||||
|
},
|
||||||
|
dart: {
|
||||||
|
'**': 'lib',
|
||||||
|
'*/test/**': '',
|
||||||
|
'benchmarks/**': 'web',
|
||||||
|
'benchmarks/test/**': '',
|
||||||
|
'benchmarks_external/**': 'web',
|
||||||
|
'benchmarks_external/test/**': '',
|
||||||
|
'example*/**': 'web',
|
||||||
|
'example*/test/**': ''
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var ES5_DEPS = [
|
||||||
|
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',
|
||||||
|
'node_modules/zone.js/zone.js',
|
||||||
|
'node_modules/zone.js/long-stack-trace-zone.js',
|
||||||
|
'tools/build/snippets/runtime_paths.js',
|
||||||
|
'tools/build/snippets/url_params_to_form.js',
|
||||||
|
'node_modules/angular/angular.js'
|
||||||
|
];
|
||||||
|
|
||||||
var CONFIG = {
|
var CONFIG = {
|
||||||
dest: {
|
dest: {
|
||||||
js: {
|
js: {
|
||||||
@ -72,46 +117,12 @@ var CONFIG = {
|
|||||||
dart: 'dist/dart',
|
dart: 'dist/dart',
|
||||||
docs: 'dist/docs'
|
docs: 'dist/docs'
|
||||||
},
|
},
|
||||||
srcFolderInsertion: {
|
srcFolderInsertion: SRC_FOLDER_INSERTION,
|
||||||
js: {
|
|
||||||
'**': ''
|
|
||||||
},
|
|
||||||
dart: {
|
|
||||||
'**': 'lib',
|
|
||||||
'*/test/**': '',
|
|
||||||
'benchmarks/**': 'web',
|
|
||||||
'benchmarks/test/**': '',
|
|
||||||
'benchmarks_external/**': 'web',
|
|
||||||
'benchmarks_external/test/**': '',
|
|
||||||
'example*/**': 'web',
|
|
||||||
'example*/test/**': ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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",
|
|
||||||
"node_modules/zone.js/zone.js",
|
|
||||||
"node_modules/zone.js/long-stack-trace-zone.js",
|
|
||||||
"tools/build/snippets/runtime_paths.js",
|
|
||||||
"tools/build/snippets/url_params_to_form.js",
|
|
||||||
"node_modules/angular/angular.js"
|
|
||||||
],
|
|
||||||
dart: [
|
|
||||||
"tools/build/snippets/url_params_to_form.js"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
transpile: {
|
transpile: {
|
||||||
src: {
|
src: {
|
||||||
js: ['modules/**/*.js', 'modules/**/*.es6'],
|
js: ['modules/**/*.js', 'modules/**/*.es6'],
|
||||||
dart: ['modules/**/*.js'],
|
dart: ['modules/**/*.js'],
|
||||||
},
|
},
|
||||||
copy: {
|
|
||||||
js: ['modules/**/*.es5'],
|
|
||||||
dart: ['modules/**/*.dart', '!modules/**/e2e_test/**'],
|
|
||||||
},
|
|
||||||
options: {
|
options: {
|
||||||
js: {
|
js: {
|
||||||
dev: merge(true, _COMPILER_CONFIG_JS_DEFAULT, {
|
dev: merge(true, _COMPILER_CONFIG_JS_DEFAULT, {
|
||||||
@ -140,13 +151,67 @@ var CONFIG = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
copy: {
|
copy: {
|
||||||
js: ['modules/**/README.md', 'modules/**/package.json'],
|
js: {
|
||||||
dart: []
|
cjs: {
|
||||||
|
src: ['modules/**/README.js.md', 'modules/**/package.json', 'modules/**/*.cjs'],
|
||||||
|
pipes: {
|
||||||
|
'**/*.cjs': gulpPlugins.rename({extname: '.js'}),
|
||||||
|
'**/*.js.md': gulpPlugins.rename(function(file) {
|
||||||
|
file.basename = file.basename.substring(0, file.basename.lastIndexOf('.'));
|
||||||
|
}),
|
||||||
|
'**/package.json': gulpPlugins.template({ 'packageJson': COMMON_PACKAGE_JSON })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dart: {
|
||||||
|
src: ['modules/**/README.dart.md', 'modules/**/*.dart', 'modules/*/pubspec.yaml', '!modules/**/e2e_test/**'],
|
||||||
|
pipes: {
|
||||||
|
'**/*.dart': util.insertSrcFolder(gulpPlugins, SRC_FOLDER_INSERTION.dart),
|
||||||
|
'**/*.dart.md': gulpPlugins.rename(function(file) {
|
||||||
|
file.basename = file.basename.substring(0, file.basename.lastIndexOf('.'));
|
||||||
|
}),
|
||||||
|
'**/pubspec.yaml': gulpPlugins.template({ 'packageJson': COMMON_PACKAGE_JSON })
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
multicopy: {
|
multicopy: {
|
||||||
src: {
|
js: {
|
||||||
dart: ['LICENSE'],
|
cjs: {
|
||||||
js: ['LICENSE', 'tools/build/es5build.js']
|
src: [
|
||||||
|
'LICENSE'
|
||||||
|
],
|
||||||
|
pipes: {}
|
||||||
|
},
|
||||||
|
dev: {
|
||||||
|
es6: {
|
||||||
|
src: ['tools/build/es5build.js'],
|
||||||
|
pipes: {}
|
||||||
|
},
|
||||||
|
es5: {
|
||||||
|
src: ES5_DEPS,
|
||||||
|
pipes: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
prod: {
|
||||||
|
es6: {
|
||||||
|
src: ['tools/build/es5build.js'],
|
||||||
|
pipes: {}
|
||||||
|
},
|
||||||
|
es5: {
|
||||||
|
src: ES5_DEPS,
|
||||||
|
pipes: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dart2js: {
|
||||||
|
src: ['tools/build/snippets/url_params_to_form.js'],
|
||||||
|
exclude: ['rtts_assert/'],
|
||||||
|
pipes: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dart: {
|
||||||
|
src: ['LICENSE'],
|
||||||
|
exclude: ['rtts_assert/'],
|
||||||
|
pipes: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
html: {
|
html: {
|
||||||
@ -159,26 +224,23 @@ var CONFIG = {
|
|||||||
'**': _HTLM_DEFAULT_SCRIPTS_JS,
|
'**': _HTLM_DEFAULT_SCRIPTS_JS,
|
||||||
'benchmarks/**':
|
'benchmarks/**':
|
||||||
[
|
[
|
||||||
{ src: '/deps/url_params_to_form.js', mimeType: 'text/javascript' }
|
{ src: '../../url_params_to_form.js', mimeType: 'text/javascript' }
|
||||||
].concat(_HTLM_DEFAULT_SCRIPTS_JS),
|
].concat(_HTLM_DEFAULT_SCRIPTS_JS),
|
||||||
'benchmarks_external/**':
|
'benchmarks_external/**':
|
||||||
[
|
[
|
||||||
{ src: '/deps/angular.js', mimeType: 'text/javascript' },
|
{ src: '../../angular.js', mimeType: 'text/javascript' },
|
||||||
{ src: '/deps/url_params_to_form.js', mimeType: 'text/javascript' }
|
{ src: '../../url_params_to_form.js', mimeType: 'text/javascript' }
|
||||||
].concat(_HTLM_DEFAULT_SCRIPTS_JS)
|
].concat(_HTLM_DEFAULT_SCRIPTS_JS)
|
||||||
},
|
},
|
||||||
dart: {
|
dart: {
|
||||||
'**': _HTML_DEFAULT_SCRIPTS_DART,
|
'**': _HTML_DEFAULT_SCRIPTS_DART,
|
||||||
'benchmarks*/**':
|
'benchmarks*/**':
|
||||||
[
|
[
|
||||||
{ src: '/deps/url_params_to_form.js', mimeType: 'text/javascript' }
|
{ src: '../../url_params_to_form.js', mimeType: 'text/javascript' }
|
||||||
].concat(_HTML_DEFAULT_SCRIPTS_DART)
|
].concat(_HTML_DEFAULT_SCRIPTS_DART)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pubspec: {
|
|
||||||
src: 'modules/*/pubspec.yaml'
|
|
||||||
},
|
|
||||||
formatDart: {
|
formatDart: {
|
||||||
packageName: 'dart_style',
|
packageName: 'dart_style',
|
||||||
args: ['dart_style:format', '-w', 'dist/dart']
|
args: ['dart_style:format', '-w', 'dist/dart']
|
||||||
@ -201,30 +263,11 @@ gulp.task('build/clean.docs', clean(gulp, gulpPlugins, {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
// ------------
|
|
||||||
// deps
|
|
||||||
|
|
||||||
gulp.task('build/deps.js.dev', deps(gulp, gulpPlugins, {
|
|
||||||
src: CONFIG.deps.js,
|
|
||||||
dest: CONFIG.dest.js.dev.es5
|
|
||||||
}));
|
|
||||||
|
|
||||||
gulp.task('build/deps.js.prod', deps(gulp, gulpPlugins, {
|
|
||||||
src: CONFIG.deps.js,
|
|
||||||
dest: CONFIG.dest.js.prod.es5
|
|
||||||
}));
|
|
||||||
|
|
||||||
gulp.task('build/deps.js.dart2js', deps(gulp, gulpPlugins, {
|
|
||||||
src: CONFIG.deps.dart,
|
|
||||||
dest: CONFIG.dest.js.dart2js
|
|
||||||
}));
|
|
||||||
|
|
||||||
// ------------
|
// ------------
|
||||||
// transpile
|
// transpile
|
||||||
|
|
||||||
gulp.task('build/transpile.js.dev.es6', transpile(gulp, gulpPlugins, {
|
gulp.task('build/transpile.js.dev.es6', transpile(gulp, gulpPlugins, {
|
||||||
src: CONFIG.transpile.src.js,
|
src: CONFIG.transpile.src.js,
|
||||||
copy: CONFIG.transpile.copy.js,
|
|
||||||
dest: CONFIG.dest.js.dev.es6,
|
dest: CONFIG.dest.js.dev.es6,
|
||||||
outputExt: 'es6',
|
outputExt: 'es6',
|
||||||
options: CONFIG.transpile.options.js.dev,
|
options: CONFIG.transpile.options.js.dev,
|
||||||
@ -249,7 +292,6 @@ gulp.task('build/transpile.js.dev', function(done) {
|
|||||||
|
|
||||||
gulp.task('build/transpile.js.prod.es6', transpile(gulp, gulpPlugins, {
|
gulp.task('build/transpile.js.prod.es6', transpile(gulp, gulpPlugins, {
|
||||||
src: CONFIG.transpile.src.js,
|
src: CONFIG.transpile.src.js,
|
||||||
copy: CONFIG.transpile.copy.js,
|
|
||||||
dest: CONFIG.dest.js.prod.es6,
|
dest: CONFIG.dest.js.prod.es6,
|
||||||
outputExt: 'es6',
|
outputExt: 'es6',
|
||||||
options: CONFIG.transpile.options.js.prod,
|
options: CONFIG.transpile.options.js.prod,
|
||||||
@ -274,7 +316,6 @@ gulp.task('build/transpile.js.prod', function(done) {
|
|||||||
|
|
||||||
gulp.task('build/transpile.js.cjs', transpile(gulp, gulpPlugins, {
|
gulp.task('build/transpile.js.cjs', transpile(gulp, gulpPlugins, {
|
||||||
src: CONFIG.transpile.src.js,
|
src: CONFIG.transpile.src.js,
|
||||||
copy: CONFIG.transpile.copy.js,
|
|
||||||
dest: CONFIG.dest.js.cjs,
|
dest: CONFIG.dest.js.cjs,
|
||||||
outputExt: 'js',
|
outputExt: 'js',
|
||||||
options: CONFIG.transpile.options.js.cjs,
|
options: CONFIG.transpile.options.js.cjs,
|
||||||
@ -283,7 +324,6 @@ gulp.task('build/transpile.js.cjs', transpile(gulp, gulpPlugins, {
|
|||||||
|
|
||||||
gulp.task('build/transpile.dart', transpile(gulp, gulpPlugins, {
|
gulp.task('build/transpile.dart', transpile(gulp, gulpPlugins, {
|
||||||
src: CONFIG.transpile.src.dart,
|
src: CONFIG.transpile.src.dart,
|
||||||
copy: CONFIG.transpile.copy.dart,
|
|
||||||
dest: CONFIG.dest.dart,
|
dest: CONFIG.dest.dart,
|
||||||
outputExt: 'dart',
|
outputExt: 'dart',
|
||||||
options: CONFIG.transpile.options.dart,
|
options: CONFIG.transpile.options.dart,
|
||||||
@ -317,49 +357,77 @@ gulp.task('build/html.dart', html(gulp, gulpPlugins, {
|
|||||||
// ------------
|
// ------------
|
||||||
// copy
|
// copy
|
||||||
|
|
||||||
gulp.task('build/copy.js.dev', function() {
|
gulp.task('build/copy.js.cjs', copy.copy(gulp, gulpPlugins, {
|
||||||
return gulp.src(CONFIG.copy.js)
|
src: CONFIG.copy.js.cjs.src,
|
||||||
.pipe(gulpPlugins.template({
|
pipes: CONFIG.copy.js.cjs.pipes,
|
||||||
'channel': 'dev',
|
dest: CONFIG.dest.js.cjs
|
||||||
'packageJson': require('./package.json')
|
}));
|
||||||
}))
|
|
||||||
.pipe(gulp.dest(CONFIG.dest.js.dev.es6));
|
gulp.task('build/copy.dart', copy.copy(gulp, gulpPlugins, {
|
||||||
});
|
src: CONFIG.copy.dart.src,
|
||||||
|
pipes: CONFIG.copy.dart.pipes,
|
||||||
|
dest: CONFIG.dest.dart
|
||||||
|
}));
|
||||||
|
|
||||||
gulp.task('build/copy.js.prod', function() {
|
|
||||||
return gulp.src(CONFIG.copy.js)
|
|
||||||
.pipe(gulpPlugins.template({
|
|
||||||
'channel': 'prod',
|
|
||||||
'packageJson': require('./package.json')
|
|
||||||
}))
|
|
||||||
.pipe(gulp.dest(CONFIG.dest.js.prod.es6));
|
|
||||||
});
|
|
||||||
|
|
||||||
// ------------
|
// ------------
|
||||||
// multicopy
|
// multicopy
|
||||||
|
|
||||||
gulp.task('build/multicopy.js.dev', multicopy(gulp, gulpPlugins, {
|
gulp.task('build/multicopy.js.cjs', copy.multicopy(gulp, gulpPlugins, {
|
||||||
src: CONFIG.multicopy.src.js,
|
src: CONFIG.multicopy.js.cjs.src,
|
||||||
|
pipes: CONFIG.multicopy.js.cjs.pipes,
|
||||||
|
exclude: CONFIG.multicopy.js.cjs.exclude,
|
||||||
|
dest: CONFIG.dest.js.cjs
|
||||||
|
}));
|
||||||
|
|
||||||
|
gulp.task('build/multicopy.js.dev.es6', copy.multicopy(gulp, gulpPlugins, {
|
||||||
|
src: CONFIG.multicopy.js.dev.es6.src,
|
||||||
|
pipes: CONFIG.multicopy.js.dev.es6.pipes,
|
||||||
|
exclude: CONFIG.multicopy.js.dev.es6.exclude,
|
||||||
dest: CONFIG.dest.js.dev.es6
|
dest: CONFIG.dest.js.dev.es6
|
||||||
}));
|
}));
|
||||||
|
|
||||||
gulp.task('build/multicopy.js.prod', multicopy(gulp, gulpPlugins, {
|
gulp.task('build/multicopy.js.dev.es5', copy.multicopy(gulp, gulpPlugins, {
|
||||||
src: CONFIG.multicopy.src.js,
|
src: CONFIG.multicopy.js.dev.es5.src,
|
||||||
|
pipes: CONFIG.multicopy.js.dev.es5.pipes,
|
||||||
|
exclude: CONFIG.multicopy.js.dev.es5.exclude,
|
||||||
|
dest: CONFIG.dest.js.dev.es5
|
||||||
|
}));
|
||||||
|
|
||||||
|
gulp.task('build/multicopy.js.prod.es6', copy.multicopy(gulp, gulpPlugins, {
|
||||||
|
src: CONFIG.multicopy.js.prod.es6.src,
|
||||||
|
pipes: CONFIG.multicopy.js.prod.es6.pipes,
|
||||||
|
exclude: CONFIG.multicopy.js.prod.es6.exclude,
|
||||||
dest: CONFIG.dest.js.prod.es6
|
dest: CONFIG.dest.js.prod.es6
|
||||||
}));
|
}));
|
||||||
|
|
||||||
gulp.task('build/multicopy.dart', multicopy(gulp, gulpPlugins, {
|
gulp.task('build/multicopy.js.prod.es5', copy.multicopy(gulp, gulpPlugins, {
|
||||||
src: CONFIG.multicopy.src.dart,
|
src: CONFIG.multicopy.js.prod.es5.src,
|
||||||
|
pipes: CONFIG.multicopy.js.prod.es5.pipes,
|
||||||
|
exclude: CONFIG.multicopy.js.prod.es5.exclude,
|
||||||
|
dest: CONFIG.dest.js.prod.es5
|
||||||
|
}));
|
||||||
|
|
||||||
|
gulp.task('build/multicopy.dart', copy.multicopy(gulp, gulpPlugins, {
|
||||||
|
src: CONFIG.multicopy.dart.src,
|
||||||
|
pipes: CONFIG.multicopy.dart.pipes,
|
||||||
|
exclude: CONFIG.multicopy.dart.exclude,
|
||||||
dest: CONFIG.dest.dart
|
dest: CONFIG.dest.dart
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
gulp.task('build/multicopy.js.dart2js', copy.multicopy(gulp, gulpPlugins, {
|
||||||
|
src: CONFIG.multicopy.js.dart2js.src,
|
||||||
|
pipes: CONFIG.multicopy.js.dart2js.pipes,
|
||||||
|
exclude: CONFIG.multicopy.js.dart2js.exclude,
|
||||||
|
dest: CONFIG.dest.js.dart2js
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
// ------------
|
// ------------
|
||||||
// pubspec
|
// pubspec
|
||||||
|
|
||||||
gulp.task('build/pubspec.dart', pubspec(gulp, gulpPlugins, {
|
gulp.task('build/pubspec.dart', pubget(gulp, gulpPlugins, {
|
||||||
src: CONFIG.pubspec.src,
|
dir: CONFIG.dest.dart,
|
||||||
dest: CONFIG.dest.dart,
|
|
||||||
command: DART_SDK.PUB
|
command: DART_SDK.PUB
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -534,12 +602,14 @@ gulp.task('tests/transform.dart', function() {
|
|||||||
// orchestrated targets
|
// orchestrated targets
|
||||||
gulp.task('build.dart', function(done) {
|
gulp.task('build.dart', function(done) {
|
||||||
runSequence(
|
runSequence(
|
||||||
['build/deps.js.dart2js', 'build/transpile.dart', 'build/html.dart'],
|
['build/transpile.dart', 'build/html.dart', 'build/copy.dart', 'build/multicopy.dart'],
|
||||||
'tests/transform.dart',
|
'tests/transform.dart',
|
||||||
'build/format.dart',
|
'build/format.dart',
|
||||||
'build/pubspec.dart',
|
'build/pubspec.dart',
|
||||||
'build/multicopy.dart',
|
|
||||||
'build/pubbuild.dart',
|
'build/pubbuild.dart',
|
||||||
|
// Note: pubbuild.dart will clear the dart2js folder, so we need to copy
|
||||||
|
// our files after this :-(
|
||||||
|
'build/multicopy.js.dart2js',
|
||||||
'build/analyze.dart',
|
'build/analyze.dart',
|
||||||
done
|
done
|
||||||
);
|
);
|
||||||
@ -547,24 +617,22 @@ gulp.task('build.dart', function(done) {
|
|||||||
|
|
||||||
gulp.task('build.js.dev', function(done) {
|
gulp.task('build.js.dev', function(done) {
|
||||||
runSequence(
|
runSequence(
|
||||||
['build/deps.js.dev', 'build/transpile.js.dev', 'build/html.js.dev', 'build/copy.js.dev'],
|
['build/transpile.js.dev', 'build/html.js.dev', 'build/multicopy.js.dev.es6', 'build/multicopy.js.dev.es5'],
|
||||||
'build/multicopy.js.dev',
|
|
||||||
done
|
done
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build.js.prod', function(done) {
|
gulp.task('build.js.prod', function(done) {
|
||||||
runSequence(
|
runSequence(
|
||||||
['build/deps.js.prod', 'build/transpile.js.prod', 'build/html.js.prod', 'build/copy.js.prod'],
|
['build/transpile.js.prod', 'build/html.js.prod', 'build/multicopy.js.prod.es6', 'build/multicopy.js.prod.es5'],
|
||||||
'build/multicopy.js.prod',
|
|
||||||
done
|
done
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build.js.cjs', function(done) {
|
gulp.task('build.js.cjs', function(done) {
|
||||||
runSequence(
|
runSequence(
|
||||||
'build/transpile.js.cjs',
|
['build/transpile.js.cjs', 'build/copy.js.cjs', 'build/multicopy.js.cjs'],
|
||||||
'build/linknodemodules.js.cjs',
|
['build/linknodemodules.js.cjs'],
|
||||||
done
|
done
|
||||||
);;
|
);;
|
||||||
});
|
});
|
||||||
|
@ -67,6 +67,7 @@
|
|||||||
"run-sequence": "^0.3.6",
|
"run-sequence": "^0.3.6",
|
||||||
"source-map": "^0.3.0",
|
"source-map": "^0.3.0",
|
||||||
"sprintf-js": "1.0.*",
|
"sprintf-js": "1.0.*",
|
||||||
|
"ternary-stream": "^1.2.3",
|
||||||
"through2": "^0.6.1",
|
"through2": "^0.6.1",
|
||||||
"yargs": "2.3.*"
|
"yargs": "2.3.*"
|
||||||
}
|
}
|
||||||
|
46
tools/build/copy.js
Normal file
46
tools/build/copy.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/**
|
||||||
|
* A utility that allows copying one file to multiple directories, such
|
||||||
|
* as the LICENSE file.
|
||||||
|
*/
|
||||||
|
var path = require('path');
|
||||||
|
var util = require('./util');
|
||||||
|
var ternaryStream = require('ternary-stream');
|
||||||
|
var minimatch = require('minimatch');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
multicopy: multicopy,
|
||||||
|
copy: copy
|
||||||
|
};
|
||||||
|
|
||||||
|
function createCopyPipe(gulp, plugins, config) {
|
||||||
|
var pipe = gulp.src(config.src);
|
||||||
|
Object.keys(config.pipes).forEach(function(pattern) {
|
||||||
|
pipe = pipe.pipe(ternaryStream(function(file) {
|
||||||
|
return minimatch(file.relative, pattern);
|
||||||
|
}, config.pipes[pattern]));
|
||||||
|
});
|
||||||
|
return pipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
function copy(gulp, plugins, config) {
|
||||||
|
return function() {
|
||||||
|
return createCopyPipe(gulp, plugins, config)
|
||||||
|
.pipe(gulp.dest(config.dest));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function multicopy(gulp, plugins, config) {
|
||||||
|
return function() {
|
||||||
|
var pipe = createCopyPipe(gulp, plugins, config);
|
||||||
|
var modules = util.subDirs('modules');
|
||||||
|
if (config.exclude) {
|
||||||
|
modules = modules.filter(function(module) {
|
||||||
|
return config.exclude.indexOf(module) === -1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
modules.map(function(module) {
|
||||||
|
pipe = pipe.pipe(gulp.dest(path.join(config.dest, module)));
|
||||||
|
});
|
||||||
|
return pipe;
|
||||||
|
};
|
||||||
|
}
|
@ -9,7 +9,7 @@ var util = require('./util');
|
|||||||
module.exports = function(gulp, plugins, config) {
|
module.exports = function(gulp, plugins, config) {
|
||||||
return function() {
|
return function() {
|
||||||
var tempFile = '_analyzer.dart';
|
var tempFile = '_analyzer.dart';
|
||||||
return util.forEachSubDir(
|
return util.forEachSubDirSequential(
|
||||||
config.dest,
|
config.dest,
|
||||||
function(dir) {
|
function(dir) {
|
||||||
var srcFiles = [].slice.call(glob.sync('{/lib,/web}/**/*.dart', {
|
var srcFiles = [].slice.call(glob.sync('{/lib,/web}/**/*.dart', {
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
var path = require('path');
|
|
||||||
|
|
||||||
module.exports = function(gulp, plugins, config) {
|
|
||||||
return function() {
|
|
||||||
return gulp.src(config.src)
|
|
||||||
.pipe(gulp.dest(path.join(config.dest, 'deps')));
|
|
||||||
};
|
|
||||||
};
|
|
@ -1,29 +0,0 @@
|
|||||||
/**
|
|
||||||
* A utility that allows copying one file to multiple directories, such
|
|
||||||
* as the LICENSE file.
|
|
||||||
*/
|
|
||||||
var path = require('path');
|
|
||||||
var fs = require('fs');
|
|
||||||
|
|
||||||
module.exports = function(gulp, plugins, config) {
|
|
||||||
return function() {
|
|
||||||
var subDirs = getSubdirs(config.dest);
|
|
||||||
config.src.forEach(function(srcFile) {
|
|
||||||
var content = fs.readFileSync(srcFile);
|
|
||||||
subDirs.forEach(function(subDir) {
|
|
||||||
var destFile = path.join(config.dest, subDir, path.basename(srcFile));
|
|
||||||
fs.writeFileSync(destFile, content);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
function getSubdirs(rootDir) {
|
|
||||||
return fs.readdirSync(rootDir).filter(function(file) {
|
|
||||||
if (file[0] === '.') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var dirPath = path.join(rootDir, file);
|
|
||||||
return fs.statSync(dirPath).isDirectory();
|
|
||||||
});
|
|
||||||
}
|
|
17
tools/build/pubget.js
Normal file
17
tools/build/pubget.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
var util = require('./util');
|
||||||
|
var spawn = require('child_process').spawn;
|
||||||
|
var path = require('path');
|
||||||
|
|
||||||
|
module.exports = function(gulp, plugins, config) {
|
||||||
|
return function() {
|
||||||
|
// We need to execute pubspec serially as otherwise we can get into trouble
|
||||||
|
// with the pub cache...
|
||||||
|
return util.forEachSubDirSequential(config.dir, function(subDir) {
|
||||||
|
return util.processToPromise(spawn(config.command, ['get'], {
|
||||||
|
stdio: 'inherit',
|
||||||
|
cwd: subDir
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
@ -1,40 +0,0 @@
|
|||||||
var util = require('./util');
|
|
||||||
var Q = require('q');
|
|
||||||
var spawn = require('child_process').spawn;
|
|
||||||
var through2 = require('through2');
|
|
||||||
var path = require('path');
|
|
||||||
|
|
||||||
module.exports = function(gulp, plugins, config) {
|
|
||||||
return function() {
|
|
||||||
var files = [];
|
|
||||||
var pubSpecCopy = util.streamToPromise(gulp.src(config.src)
|
|
||||||
.pipe(plugins.changed(config.dest)) // Only forward files that changed.
|
|
||||||
.pipe(plugins.template({
|
|
||||||
'packageJson': require('../../package.json')
|
|
||||||
}))
|
|
||||||
.pipe(through2.obj(function(file, enc, done) {
|
|
||||||
files.push(path.resolve(process.cwd(), config.dest, file.relative));
|
|
||||||
this.push(file);
|
|
||||||
done();
|
|
||||||
}))
|
|
||||||
.pipe(gulp.dest(config.dest)));
|
|
||||||
|
|
||||||
// We need to wait for all pubspecs to be present before executing
|
|
||||||
// `pub get` as it checks the folders of the dependencies!
|
|
||||||
// We need to execute pubspec serially as otherwise we can get into trouble
|
|
||||||
// with the pub cache...
|
|
||||||
return pubSpecCopy.then(nextFile);
|
|
||||||
|
|
||||||
function nextFile() {
|
|
||||||
if (!files.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var file = files.shift();
|
|
||||||
return util.processToPromise(spawn(config.command, ['get'], {
|
|
||||||
stdio: 'inherit',
|
|
||||||
cwd: path.dirname(file)
|
|
||||||
})).then(nextFile);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
@ -8,7 +8,7 @@ var util = require('./util');
|
|||||||
|
|
||||||
module.exports = function(gulp, plugins, config) {
|
module.exports = function(gulp, plugins, config) {
|
||||||
return function() {
|
return function() {
|
||||||
return util.forEachSubDir(
|
return util.forEachSubDirSequential(
|
||||||
config.dest,
|
config.dest,
|
||||||
function(dir) {
|
function(dir) {
|
||||||
var testDir = path.join(dir, 'test');
|
var testDir = path.join(dir, 'test');
|
||||||
@ -18,7 +18,7 @@ module.exports = function(gulp, plugins, config) {
|
|||||||
}));
|
}));
|
||||||
if (testFiles.length == 0) {
|
if (testFiles.length == 0) {
|
||||||
// No test files found
|
// No test files found
|
||||||
return;
|
return Q.resolve();
|
||||||
}
|
}
|
||||||
var header = ['library _all_tests;', ''];
|
var header = ['library _all_tests;', ''];
|
||||||
var main = ['main() {'];
|
var main = ['main() {'];
|
||||||
|
@ -1,24 +1,16 @@
|
|||||||
var util = require('./util');
|
var util = require('./util');
|
||||||
var gulpTraceur = require('../transpiler/gulp-traceur');
|
var gulpTraceur = require('../transpiler/gulp-traceur');
|
||||||
var file2moduleName = require('./file2modulename');
|
var file2moduleName = require('./file2modulename');
|
||||||
var mergeStreams = require('event-stream').merge;
|
|
||||||
|
|
||||||
module.exports = function(gulp, plugins, config) {
|
module.exports = function(gulp, plugins, config) {
|
||||||
return function() {
|
return function() {
|
||||||
var transpile = gulp.src(config.src)
|
return gulp.src(config.src)
|
||||||
.pipe(plugins.rename({extname: '.'+config.outputExt}))
|
.pipe(plugins.rename({extname: '.'+config.outputExt}))
|
||||||
.pipe(util.insertSrcFolder(plugins, config.srcFolderInsertion, config.modulesFolder))
|
.pipe(util.insertSrcFolder(plugins, config.srcFolderInsertion))
|
||||||
.pipe(gulpTraceur(
|
.pipe(gulpTraceur(
|
||||||
config.options,
|
config.options,
|
||||||
file2moduleName)
|
file2moduleName)
|
||||||
)
|
)
|
||||||
.pipe(gulp.dest(config.dest));
|
.pipe(gulp.dest(config.dest));
|
||||||
|
|
||||||
var copy = gulp.src(config.copy)
|
|
||||||
.pipe(plugins.rename({extname: '.'+config.outputExt}))
|
|
||||||
.pipe(util.insertSrcFolder(plugins, config.srcFolderInsertion, config.modulesFolder))
|
|
||||||
.pipe(gulp.dest(config.dest));
|
|
||||||
|
|
||||||
return mergeStreams(transpile, copy);
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -8,17 +8,37 @@ module.exports = {
|
|||||||
streamToPromise: streamToPromise,
|
streamToPromise: streamToPromise,
|
||||||
insertSrcFolder: insertSrcFolder,
|
insertSrcFolder: insertSrcFolder,
|
||||||
filterByFile: filterByFile,
|
filterByFile: filterByFile,
|
||||||
forEachSubDir: forEachSubDir
|
subDirs: subDirs,
|
||||||
|
forEachSubDir: forEachSubDir,
|
||||||
|
forEachSubDirSequential: forEachSubDirSequential
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function subDirs(dir) {
|
||||||
|
return [].slice.call(glob.sync('*/', {cwd: dir}));
|
||||||
|
}
|
||||||
|
|
||||||
function forEachSubDir(dir, callback) {
|
function forEachSubDir(dir, callback) {
|
||||||
var moduleFolders = [].slice.call(glob.sync(dir + '/*'));
|
var dirs = subDirs(dir);
|
||||||
return Q.all(moduleFolders.map(function(subDir) {
|
return Q.all(dirs.map(function(subdir) {
|
||||||
return callback(subDir);
|
return callback(path.join(dir, subdir));
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function forEachSubDirSequential(dir, callback) {
|
||||||
|
var dirs = subDirs(dir);
|
||||||
|
return next(0);
|
||||||
|
|
||||||
|
function next(index) {
|
||||||
|
if (index < dirs.length) {
|
||||||
|
return callback(path.join(dir, dirs[index])).then(function() {
|
||||||
|
return next(index+1);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function processToPromise(process) {
|
function processToPromise(process) {
|
||||||
var defer = Q.defer();
|
var defer = Q.defer();
|
||||||
process.on('close', function(code) {
|
process.on('close', function(code) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user