diff --git a/build/prepare_deploy.js b/build/prepare_deploy.js
new file mode 100755
index 00000000..74638103
--- /dev/null
+++ b/build/prepare_deploy.js
@@ -0,0 +1,32 @@
+#!/usr/bin/env node
+'use strict';
+require('shelljs/global');
+
+var paths = require('./paths');
+var path = require('path');
+
+// copy old releases
+mkdir('-p', '.ghpages-tmp');
+cd('.ghpages-tmp');
+
+// reset local changes before checkout
+exec('git reset --hard');
+exec('git fetch origin gh-pages:gh-pages');
+exec('git checkout gh-pages');
+cp('-R', '../releases/*', '.');
+exec('git checkout @{-1}');
+cd('..');
+
+// build
+exec('npm run build-dist');
+cd('demo');
+mkdir('-p', 'dist');
+cp('-R', '../dist/*', './dist/');
+mkdir('-p', 'releases');
+cp('-R', '../.ghpages-tmp/*', './releases/');
+cd('..');
+var version = 'v' + require(path.join(__dirname, '../package.json')).version + '/';
+var versionDir = path.join(paths.releases, version);
+mkdir('-p', versionDir)
+cp(paths.redocBuilt + '.min.js', versionDir);
+cp(paths.redocBuilt + '.min.js', path.join(paths.releases, 'latest/'));
diff --git a/build/prepare_deploy.sh b/build/prepare_deploy.sh
deleted file mode 100755
index c544aa4b..00000000
--- a/build/prepare_deploy.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-set -e
-set -x
-# copy old releases
-mkdir -p .ghpages-tmp && cd .ghpages-tmp
-# reset local changes before checkout
-git reset --hard
-git fetch origin gh-pages:gh-pages
-git checkout gh-pages
-cp -R ../releases/* .
-git checkout @{-1}
-cd -
-
-# build
-npm run build-dist
-cd demo
-cp -R ../dist/* ./dist/
-mkdir -p releases
-cp -R ../.ghpages-tmp/* ./releases/
-cd -
-gulp copy-version
diff --git a/build/run_tests.js b/build/run_tests.js
new file mode 100755
index 00000000..40b488fa
--- /dev/null
+++ b/build/run_tests.js
@@ -0,0 +1,13 @@
+#!/usr/bin/env node
+'use strict';
+
+require('shelljs/global');
+set('-e');
+
+if (process.env.JOB === 'e2e-guru') {
+ exec('npm run e2e');
+} else {
+ exec('npm run unit');
+ console.log('Starting Basic E2E');
+ exec('npm run e2e');
+}
diff --git a/build/run_tests.sh b/build/run_tests.sh
deleted file mode 100755
index 6d05f49d..00000000
--- a/build/run_tests.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-if [ "$JOB" = "e2e-guru" ]; then
- npm run e2e
-else
- npm run unit
- echo "Starting Basic E2E"
- npm run e2e
-fi
diff --git a/build/tasks/build.js b/build/tasks/build.js
index 9062edf0..3ab8725c 100644
--- a/build/tasks/build.js
+++ b/build/tasks/build.js
@@ -12,6 +12,7 @@ var sass = require('gulp-sass');
var replace = require('gulp-replace');
var rename = require('gulp-rename');
var argv = require('yargs').argv;
+var gulpIf = require('gulp-if');
gulp.task('build', function (callback) {
if (argv.skipRebuild) {
@@ -23,10 +24,18 @@ gulp.task('build', function (callback) {
'concatPrism',
'bundle',
'concatDeps',
+ 'copyDebug',
callback
);
});
+gulp.task('copyDebug', () => {
+ if (!argv.prod) {
+ // copy for be accessible from demo for debug
+ cp(paths.redocBuilt + '.js', paths.redocBuilt + '.min.js');
+ }
+});
+
gulp.task('rebuild', function(done) {
return runSequence(
'bundle',
@@ -43,16 +52,16 @@ gulp.task('inlineTemplates', ['sass'], function() {
});
var JS_DEPS = argv.prod ? [
+ 'lib/utils/browser-update.js',
+ 'node_modules/zone.js/dist/zone.min.js',
+ 'node_modules/reflect-metadata/Reflect.js',
+ 'node_modules/babel-polyfill/dist/polyfill.min.js'
+]: [
'lib/utils/browser-update.js',
'node_modules/zone.js/dist/zone.js',
'node_modules/zone.js/dist/long-stack-trace-zone.js',
'node_modules/reflect-metadata/Reflect.js',
'node_modules/babel-polyfill/dist/polyfill.js'
-] : [
- 'lib/utils/browser-update.js',
- 'node_modules/zone.js/dist/zone.min.js',
- 'node_modules/reflect-metadata/Reflect.js',
- 'node_modules/babel-polyfill/dist/polyfill.min.js'
];
var outputFileName = paths.redocBuilt + (argv.prod ? '.min.js' : '.js');
@@ -66,13 +75,13 @@ gulp.task('sass', function () {
// concatenate angular2 deps
gulp.task('concatDeps', function() {
return gulp.src(JS_DEPS.concat([outputFileName]))
- .pipe(sourcemaps.init({loadMaps: true}))
+ .pipe(gulpIf(!argv.prod, sourcemaps.init({loadMaps: true})))
.pipe(concat(outputFileName))
- .pipe(sourcemaps.write('.'))
+ .pipe(gulpIf(!argv.prod, sourcemaps.write('.')))
.pipe(gulp.dest('.'))
});
-gulp.task('bundle', ['inlineTemplates'], function bundle(cb) {
+gulp.task('bundle', ['injectVersionFile', 'inlineTemplates'], function bundle(done) {
fs.existsSync('dist') || fs.mkdirSync('dist');
var builder = new Builder('./', 'system.config.js');
@@ -81,13 +90,11 @@ gulp.task('bundle', ['inlineTemplates'], function bundle(cb) {
outputFileName,
{ format:'umd', sourceMaps: !argv.prod, lowResSourceMaps: true, minify: argv.prod }
)
- .then(function() {
+ .then(() => {
// wait some time to allow flush
- setTimeout(() => cb(), 500);
+ setTimeout(() => done(), 500);
})
- .catch(function(err) {
- cb(new Error(err));
- });
+ .catch(err => done(err));
});
gulp.task('concatPrism', function() {
@@ -121,3 +128,9 @@ gulp.task('concatPrism', function() {
.pipe(concat(path.join(paths.tmp, 'prismjs-bundle.js')))
.pipe(gulp.dest('.'))
});
+
+// needs inlineTemplates run before to create .tmp/lib folder
+gulp.task('injectVersionFile', ['inlineTemplates'], function() {
+ var version = require('../../package.json').version;
+ fs.writeFileSync(path.join(paths.tmp, 'lib/version.json'), JSON.stringify(version));
+})
diff --git a/build/tasks/test.js b/build/tasks/test.js
index 6b93998e..444b2307 100644
--- a/build/tasks/test.js
+++ b/build/tasks/test.js
@@ -5,7 +5,7 @@ var Server = require('karma').Server;
/**
* Run test once and exit
*/
-gulp.task('test', ['concatPrism', 'inlineTemplates'], function (done) {
+gulp.task('test', ['concatPrism', 'inlineTemplates', 'injectVersionFile'], function (done) {
new Server({
configFile: __dirname + '/../../karma.conf.js',
singleRun: true
diff --git a/demo/index.html b/demo/index.html
index 0c4ccf2c..cbcd26f1 100644
--- a/demo/index.html
+++ b/demo/index.html
@@ -18,8 +18,7 @@
-
-
+