diff --git a/tools/tasks/build.assets.dev.ts b/tools/tasks/build.assets.dev.ts index d57ef72..22b28c1 100644 --- a/tools/tasks/build.assets.dev.ts +++ b/tools/tasks/build.assets.dev.ts @@ -2,14 +2,15 @@ import {join} from 'path'; import {APP_SRC, APP_DEST} from '../config'; export = function buildImagesDev(gulp, plugins) { - return function () { + return function() { return gulp.src([ - join(APP_SRC, '**/*.gif'), - join(APP_SRC, '**/*.jpg'), - join(APP_SRC, '**/*.png'), - join(APP_SRC, '**/*.svg'), - join(APP_SRC, '**/*.css'), - join(APP_SRC, '**/*.html') - ]).pipe(gulp.dest(APP_DEST)); + join(APP_SRC, '**/*.gif'), + join(APP_SRC, '**/*.jpg'), + join(APP_SRC, '**/*.png'), + join(APP_SRC, '**/*.svg'), + join(APP_SRC, '**/*.css'), + join(APP_SRC, '**/*.html') + ]) + .pipe(gulp.dest(APP_DEST)); }; } diff --git a/tools/tasks/build.assets.prod.ts b/tools/tasks/build.assets.prod.ts index 38af2ae..fe70d17 100644 --- a/tools/tasks/build.assets.prod.ts +++ b/tools/tasks/build.assets.prod.ts @@ -2,12 +2,13 @@ import {join} from 'path'; import {APP_SRC, APP_DEST} from '../config'; export = function buildImagesDev(gulp, plugins) { - return function () { + return function() { return gulp.src([ - join(APP_SRC, '**/*.gif'), - join(APP_SRC, '**/*.jpg'), - join(APP_SRC, '**/*.png'), - join(APP_SRC, '**/*.svg') - ]).pipe(gulp.dest(APP_DEST)); + join(APP_SRC, '**/*.gif'), + join(APP_SRC, '**/*.jpg'), + join(APP_SRC, '**/*.png'), + join(APP_SRC, '**/*.svg') + ]) + .pipe(gulp.dest(APP_DEST)); }; } diff --git a/tools/tasks/build.bundles.ts b/tools/tasks/build.bundles.ts index 52eb381..681516b 100644 --- a/tools/tasks/build.bundles.ts +++ b/tools/tasks/build.bundles.ts @@ -10,7 +10,7 @@ const BUNDLE_OPTS = { }; export = function bundles(gulp, plugins) { - return function (done) { + return function(done) { let builder = new Builder(SYSTEM_CONFIG_BUILDER); parallel([ @@ -20,7 +20,9 @@ export = function bundles(gulp, plugins) { function bundleApp(done) { builder.bundle( 'bootstrap - angular2/*', - join(BUNDLES_DEST, 'app.js'), BUNDLE_OPTS).then(done); + join(BUNDLES_DEST, 'app.js'), + BUNDLE_OPTS + ).then(done); } }; }; diff --git a/tools/tasks/build.deps.ts b/tools/tasks/build.deps.ts index 071f4cd..076b871 100644 --- a/tools/tasks/build.deps.ts +++ b/tools/tasks/build.deps.ts @@ -2,7 +2,7 @@ import * as merge from 'merge-stream'; import {DEPENDENCIES} from '../config'; export = function buildDepsProd(gulp, plugins) { - return function () { + return function() { let stream = merge(); DEPENDENCIES.forEach(dep => { @@ -11,9 +11,13 @@ export = function buildDepsProd(gulp, plugins) { return stream; + // Private + function addStream(dep) { let stream = gulp.src(dep.src); + stream.pipe(gulp.dest(dep.dest)); + return stream; } }; diff --git a/tools/tasks/build.docs.ts b/tools/tasks/build.docs.ts index a464c67..048c652 100644 --- a/tools/tasks/build.docs.ts +++ b/tools/tasks/build.docs.ts @@ -3,25 +3,26 @@ import {APP_SRC, APP_TITLE, DOCS_DEST} from '../config'; export = function buildDocs(gulp, plugins, option) { return function() { - let src = [ - join(APP_SRC, '**/*.ts'), - '!' + join(APP_SRC, '**/*_spec.ts') - ]; + join(APP_SRC, '**/*.ts'), + '!' + join(APP_SRC, '**/*_spec.ts') + ]; return gulp.src(src) - .pipe(plugins.typedoc({ - // TypeScript options (see typescript docs) - module: 'commonjs', - target: 'es5', - includeDeclarations: true, - // Output options (see typedoc docs) - out: DOCS_DEST, - json: join(DOCS_DEST , 'data/docs.json' ), - name: APP_TITLE, - ignoreCompilerErrors: false, - experimentalDecorators: true, - version: true - })); - }; + .pipe( + plugins.typedoc({ + // TypeScript options (see typescript docs) + module: 'commonjs', + target: 'es5', + includeDeclarations: true, + // Output options (see typedoc docs) + out: DOCS_DEST, + json: join(DOCS_DEST , 'data/docs.json' ), + name: APP_TITLE, + ignoreCompilerErrors: false, + experimentalDecorators: true, + version: true + }) + ); + }; } diff --git a/tools/tasks/build.html_css.prod.ts b/tools/tasks/build.html_css.prod.ts index 93d0aa9..d6e7dba 100644 --- a/tools/tasks/build.html_css.prod.ts +++ b/tools/tasks/build.html_css.prod.ts @@ -2,22 +2,20 @@ import * as merge from 'merge-stream'; import {join} from 'path'; import {APP_SRC, TMP_DIR} from '../config'; -// const HTML_MINIFIER_OPTS = { empty: true }; - export = function buildJSDev(gulp, plugins) { - return function () { - + return function() { return merge(minifyHtml(), minifyCss()); + // Private + function minifyHtml() { return gulp.src(join(APP_SRC, '**/*.html')) - // .pipe(plugins.minifyHtml(HTML_MINIFIER_OPTS)) .pipe(gulp.dest(TMP_DIR)); } function minifyCss() { return gulp.src(join(APP_SRC, '**/*.css')) - .pipe(plugins.minifyCss()) + .pipe(plugins.cssnano()) .pipe(gulp.dest(TMP_DIR)); } }; diff --git a/tools/tasks/build.index.ts b/tools/tasks/build.index.ts index bbf98ee..4cf8042 100644 --- a/tools/tasks/build.index.ts +++ b/tools/tasks/build.index.ts @@ -3,7 +3,7 @@ import {APP_SRC, APP_DEST, DEPENDENCIES, ENV} from '../config'; import {transformPath, templateLocals} from '../utils'; export = function buildIndexDev(gulp, plugins) { - return function () { + return function() { return gulp.src(join(APP_SRC, 'index.html')) // NOTE: There might be a way to pipe in loop. .pipe(inject('shims')) @@ -13,6 +13,7 @@ export = function buildIndexDev(gulp, plugins) { .pipe(gulp.dest(APP_DEST)); }; + // Private function inject(name?: string) { return plugins.inject(gulp.src(getInjectablesDependenciesRef(name), { read: false }), { @@ -29,6 +30,7 @@ export = function buildIndexDev(gulp, plugins) { function mapPath(dep) { let prodPath = join(dep.dest, dep.src.split(sep).pop()); + return ('prod' === ENV ? prodPath : dep.src ); } }; diff --git a/tools/tasks/build.js.dev.ts b/tools/tasks/build.js.dev.ts index 6765fd1..e891ced 100644 --- a/tools/tasks/build.js.dev.ts +++ b/tools/tasks/build.js.dev.ts @@ -4,11 +4,12 @@ import {templateLocals, tsProjectFn} from '../utils'; export = function buildJSDev(gulp, plugins) { let tsProject = tsProjectFn(plugins); - return function () { + + return function() { let src = [ - join(APP_SRC, '**/*.ts'), - '!' + join(APP_SRC, '**/*_spec.ts') - ]; + join(APP_SRC, '**/*.ts'), + '!' + join(APP_SRC, '**/*_spec.ts') + ]; let result = gulp.src(src) .pipe(plugins.plumber()) diff --git a/tools/tasks/build.js.prod.ts b/tools/tasks/build.js.prod.ts index 54ed21a..1ea861c 100644 --- a/tools/tasks/build.js.prod.ts +++ b/tools/tasks/build.js.prod.ts @@ -3,12 +3,12 @@ import {APP_SRC, TMP_DIR} from '../config'; import {templateLocals, tsProjectFn} from '../utils'; export = function buildJSDev(gulp, plugins) { - return function () { + return function() { let tsProject = tsProjectFn(plugins); let src = [ - join(APP_SRC, '**/*.ts'), - '!' + join(APP_SRC, '**/*_spec.ts') - ]; + join(APP_SRC, '**/*.ts'), + '!' + join(APP_SRC, '**/*_spec.ts') + ]; let result = gulp.src(src) .pipe(plugins.plumber()) diff --git a/tools/tasks/build.sass.dev.ts b/tools/tasks/build.sass.dev.ts index 7e76848..792571e 100644 --- a/tools/tasks/build.sass.dev.ts +++ b/tools/tasks/build.sass.dev.ts @@ -1,10 +1,10 @@ import {join} from 'path'; -import {APP_SRC} from '../config'; +import {APP_SRC, APP_DEST} from '../config'; export = function buildSassDev(gulp, plugins, option) { - return function () { + return function() { return gulp.src(join(APP_SRC, '**', '*.scss')) .pipe(plugins.sass().on('error', plugins.sass.logError)) - .pipe(gulp.dest(APP_SRC)); + .pipe(gulp.dest(APP_DEST)); }; } diff --git a/tools/tasks/build.sass.prod.ts b/tools/tasks/build.sass.prod.ts new file mode 100644 index 0000000..d97dd3c --- /dev/null +++ b/tools/tasks/build.sass.prod.ts @@ -0,0 +1,10 @@ +import {join} from 'path'; +import {APP_SRC, APP_DEST} from '../config'; + +export = function buildSassProd(gulp, plugins, option) { + return function() { + return gulp.src(join(APP_SRC, '**', '*.scss')) + .pipe(plugins.sass().on('error', plugins.sass.logError)) + .pipe(gulp.dest(APP_DEST)); + }; +} diff --git a/tools/tasks/build.test.ts b/tools/tasks/build.test.ts index 3e089cd..e4d3c9e 100644 --- a/tools/tasks/build.test.ts +++ b/tools/tasks/build.test.ts @@ -3,12 +3,12 @@ import {APP_SRC, TEST_DEST} from '../config'; import {tsProjectFn} from '../utils'; export = function buildTest(gulp, plugins) { - return function () { + return function() { let tsProject = tsProjectFn(plugins); let src = [ - join(APP_SRC, '**/*.ts'), - '!' + join(APP_SRC, 'bootstrap.ts') - ]; + join(APP_SRC, '**/*.ts'), + '!' + join(APP_SRC, 'bootstrap.ts') + ]; let result = gulp.src(src) .pipe(plugins.plumber()) diff --git a/tools/tasks/check.versions.ts b/tools/tasks/check.versions.ts index 211d5ed..6dead02 100644 --- a/tools/tasks/check.versions.ts +++ b/tools/tasks/check.versions.ts @@ -6,12 +6,12 @@ function reportError(message: string) { } module.exports = function check(gulp, plugins) { - return function () { + return function() { let exec = require('child_process').exec; let semver = require('semver'); exec('npm --version', - function (error, stdout, stderr) { + function(error, stdout, stderr) { if (error !== null) { reportError('npm preinstall error: ' + error + stderr); } @@ -22,7 +22,7 @@ module.exports = function check(gulp, plugins) { }); exec('node --version', - function (error, stdout, stderr) { + function(error, stdout, stderr) { if (error !== null) { reportError('npm preinstall error: ' + error + stderr); } diff --git a/tools/tasks/clean.ts b/tools/tasks/clean.ts index 7244a19..11fd860 100644 --- a/tools/tasks/clean.ts +++ b/tools/tasks/clean.ts @@ -5,8 +5,7 @@ import * as del from 'del'; import {APP_DEST, TEST_DEST, TMP_DIR} from '../config'; export = function clean(gulp, plugins, option) { - return function (done) { - + return function(done) { switch(option) { case 'all' : cleanAll(done); break; case 'dist' : cleanDist(done); break; @@ -28,21 +27,20 @@ function cleanAll(done) { function cleanDist(done) { del(APP_DEST).then((paths) => { util.log('Deleted', chalk.yellow(paths && paths.join(', ') || '-')); - done(); }); } + function cleanTest(done) { del(TEST_DEST).then((paths) => { util.log('Deleted', chalk.yellow(paths && paths.join(', ') || '-')); - done(); }); } + function cleanTmp(done) { del(TMP_DIR).then((paths) => { util.log('Deleted', chalk.yellow(paths && paths.join(', ') || '-')); - done(); }); } diff --git a/tools/tasks/karma.start.ts b/tools/tasks/karma.start.ts index 313aacd..db97615 100644 --- a/tools/tasks/karma.start.ts +++ b/tools/tasks/karma.start.ts @@ -2,7 +2,7 @@ import * as karma from 'karma'; import {join} from 'path'; export = function karmaStart() { - return function (done) { + return function(done) { new (karma).Server({ configFile: join(process.cwd(), 'karma.conf.js'), singleRun: true diff --git a/tools/tasks/serve.docs.ts b/tools/tasks/serve.docs.ts index 2aa5f05..26c8699 100644 --- a/tools/tasks/serve.docs.ts +++ b/tools/tasks/serve.docs.ts @@ -1,7 +1,7 @@ import {serveDocs} from '../utils'; export = function serverStart(gulp, plugins) { - return function () { + return function() { serveDocs(); }; }; diff --git a/tools/tasks/server.start.ts b/tools/tasks/server.start.ts index e733e92..e084e0a 100644 --- a/tools/tasks/server.start.ts +++ b/tools/tasks/server.start.ts @@ -1,7 +1,7 @@ import {serveSPA} from '../utils'; export = function serverStart(gulp, plugins) { - return function () { + return function() { serveSPA(); }; }; diff --git a/tools/tasks/tslint.ts b/tools/tasks/tslint.ts index ccea264..1447697 100644 --- a/tools/tasks/tslint.ts +++ b/tools/tasks/tslint.ts @@ -4,11 +4,11 @@ import {APP_SRC, TOOLS_DIR} from '../config'; export = function tslint(gulp, plugins) { return function () { let src = [ - join(APP_SRC, '**/*.ts'), - '!' + join(APP_SRC, '**/*.d.ts'), - join(TOOLS_DIR, '**/*.ts'), - '!' + join(TOOLS_DIR, '**/*.d.ts') - ]; + join(APP_SRC, '**/*.ts'), + join(TOOLS_DIR, '**/*.ts'), + '!' + join(APP_SRC, '**/*.d.ts'), + '!' + join(TOOLS_DIR, '**/*.d.ts') + ]; return gulp.src(src) .pipe(plugins.tslint()) diff --git a/tools/tasks/watch.dev.ts b/tools/tasks/watch.dev.ts index bfa37a3..c02a50f 100644 --- a/tools/tasks/watch.dev.ts +++ b/tools/tasks/watch.dev.ts @@ -2,7 +2,7 @@ import {join} from 'path'; import {APP_SRC} from '../config'; export = function watchDev(gulp, plugins) { - return function () { + return function() { plugins.watch(join(APP_SRC, '**/*'), () => gulp.start('build.dev')); }; }; diff --git a/tools/tasks/watch.serve.ts b/tools/tasks/watch.serve.ts index 2bb18f1..403a6e9 100644 --- a/tools/tasks/watch.serve.ts +++ b/tools/tasks/watch.serve.ts @@ -4,9 +4,9 @@ import {APP_SRC} from '../config'; import {notifyLiveReload} from '../utils'; export = function watchServe(gulp, plugins) { - return function () { - plugins.watch(join(APP_SRC, '**'), e => - runSequence('build.dev', () => notifyLiveReload(e)) + return function() { + plugins.watch(join(APP_SRC, '**'), event => + runSequence('build.dev', () => notifyLiveReload(event)) ); }; }; diff --git a/tools/tasks/watch.test.ts b/tools/tasks/watch.test.ts index 2a8b55b..a30f97e 100644 --- a/tools/tasks/watch.test.ts +++ b/tools/tasks/watch.test.ts @@ -2,7 +2,7 @@ import {join} from 'path'; import {APP_SRC} from '../config'; export = function watchTest(gulp, plugins) { - return function () { + return function() { plugins.watch(join(APP_SRC, '**/*.ts'), () => gulp.start('build.test')); }; };