Fixes MYRIAD-114

Fixed gulp build to not include local paths and gradle-ized build.
Removed public/ from git repo and added it to .gitignore.

This closes: #28
Review: https://github.com/apache/incubator-myriad/pull/28


Project: http://git-wip-us.apache.org/repos/asf/incubator-myriad/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-myriad/commit/c47dc235
Tree: http://git-wip-us.apache.org/repos/asf/incubator-myriad/tree/c47dc235
Diff: http://git-wip-us.apache.org/repos/asf/incubator-myriad/diff/c47dc235

Branch: refs/heads/master
Commit: c47dc2359723a56bad442d26a6de0d9518a8ad28
Parents: 47d90da
Author: klucar <klu...@gmail.com>
Authored: Tue Nov 3 14:08:49 2015 -0800
Committer: Santosh Marella <mare...@gmail.com>
Committed: Tue Nov 3 14:08:49 2015 -0800

----------------------------------------------------------------------
 myriad-scheduler/build.gradle                   |    41 +
 .../src/main/resources/webapp/.gitignore        |     2 +-
 .../src/main/resources/webapp/gulpfile.js       |   106 +-
 .../src/main/resources/webapp/js/app.js         |     3 +-
 .../src/main/resources/webapp/package.json      |    28 +-
 .../webapp/public/css/bootstrap-default.min.css |     5 -
 .../webapp/public/css/bootstrap-myriad-2.css    |  6492 ---
 .../webapp/public/css/bootstrap-myriad.css      |  6492 ---
 .../webapp/public/css/bootstrap-slate.min.css   |     7 -
 .../webapp/public/css/bootstrap.min.css         |     7 -
 .../main/resources/webapp/public/css/myriad.css |    35 -
 .../webapp/public/img/favicon-16x16.png         |   Bin 1362 -> 0 bytes
 .../webapp/public/img/favicon-32x32.png         |   Bin 2262 -> 0 bytes
 .../webapp/public/img/favicon-96x96.png         |   Bin 6872 -> 0 bytes
 .../resources/webapp/public/img/favicon.ico     |   Bin 1150 -> 0 bytes
 .../resources/webapp/public/img/navbar_logo.png |   Bin 18128 -> 0 bytes
 .../src/main/resources/webapp/public/index.html |    34 -
 .../main/resources/webapp/public/js/myriad.js   | 39569 -----------------
 18 files changed, 102 insertions(+), 52719 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/c47dc235/myriad-scheduler/build.gradle
----------------------------------------------------------------------
diff --git a/myriad-scheduler/build.gradle b/myriad-scheduler/build.gradle
index a596562..63d69ed 100644
--- a/myriad-scheduler/build.gradle
+++ b/myriad-scheduler/build.gradle
@@ -16,6 +16,9 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+ plugins {
+     id "com.moowork.gulp" version "0.11"
+ }
 
 dependencies {
     compile project(':myriad-commons')
@@ -35,6 +38,7 @@ dependencies {
     compile "org.apache.commons:commons-lang3:3.4"
     compile 'com.google.inject.extensions:guice-multibindings:3.0'
     testCompile 
"org.apache.hadoop:hadoop-yarn-server-resourcemanager:${hadoopVer}:tests"
+
 }
 
 configurations {
@@ -52,8 +56,13 @@ jar {
     dependsOn copyRunTimeDeps
 }
 
+clean {
+    dependsOn gulp_clean
+}
+
 processResources {
     exclude ('*/node_modules/**')
+    dependsOn gulp_build
 }
 
 sourceSets {
@@ -69,3 +78,35 @@ sourceSets {
         }
     }
 }
+
+node {
+    // Version of node to use.
+    version = '4.2.1'
+
+    // Base URL for fetching node distributions (change if you have a mirror).
+    distBaseUrl = 'https://nodejs.org/dist'
+
+    // If true, it will download node using above parameters.
+    // If false, it will try to use globally installed node.
+    download = true
+
+    // Set the work directory where node_modules should be located
+    nodeModulesDir = file("${project.projectDir}/src/main/resources/webapp")
+}
+
+gulp {
+    // Set the directory where gulpfile.js should be found
+    workDir = file("${project.projectDir}/src/main/resources/webapp")
+
+    // Whether colors should output on the terminal
+    colors = false
+
+    // Whether output from Gulp should be buffered - useful when running tasks 
in parallel
+    bufferOutput = false
+
+    // processes your package.json before running gulp build
+    gulp_build.dependsOn 'npmInstall'
+
+    // makes sure on each build that gulp is installed
+    gulp_build.dependsOn 'installGulp'
+}

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/c47dc235/myriad-scheduler/src/main/resources/webapp/.gitignore
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/main/resources/webapp/.gitignore 
b/myriad-scheduler/src/main/resources/webapp/.gitignore
index d570088..0a03045 100644
--- a/myriad-scheduler/src/main/resources/webapp/.gitignore
+++ b/myriad-scheduler/src/main/resources/webapp/.gitignore
@@ -1,2 +1,2 @@
 node_modules/
-
+public/

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/c47dc235/myriad-scheduler/src/main/resources/webapp/gulpfile.js
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/main/resources/webapp/gulpfile.js 
b/myriad-scheduler/src/main/resources/webapp/gulpfile.js
index 4df22b5..25d36c1 100644
--- a/myriad-scheduler/src/main/resources/webapp/gulpfile.js
+++ b/myriad-scheduler/src/main/resources/webapp/gulpfile.js
@@ -1,85 +1,63 @@
 'use strict';
 
-var browserify = require('browserify');
 var gulp = require('gulp');
+
 var transform = require('vinyl-transform');
 var source = require('vinyl-source-stream');
-var uglify = require('gulp-uglify');
-var sourcemaps = require('gulp-sourcemaps');
-var rename = require('gulp-rename');
-var reactify = require('reactify');
+var buffer = require('vinyl-buffer');
 var watchify = require('watchify');
+var babelify = require('babelify');
+var browserify = require('browserify');
+var rename = require('gulp-rename');
+var uglify = require('gulp-uglify');
 var webserver = require('gulp-webserver');
-var buffer = require('vinyl-buffer');
-
+var del = require('del');
 
-gulp.task('webserver', function() {
-    gulp.src('app')
-    .pipe(webserver({
-        livereload: true,
-        directoryListing: true,
-        open: true
-    }));
+gulp.task("js", ['clean'], function () {
+  browserify({
+    entries: ['./js/app.js'], // Only need initial file, browserify finds the 
deps
+    transform: ['babelify'],
+    debug: false,
+    fullPaths: false
+    })
+    .bundle()
+    .pipe(source('bundle.js'))
+    .pipe(rename('myriad.js'))
+    .pipe(buffer())
+    .pipe(uglify())
+    .pipe(gulp.dest("public/js/"));
 });
 
-var getBundler = function () {
-    
-    return browserify({
+gulp.task("js-dev", ['clean'], function () {
+  browserify({
     entries: ['./js/app.js'], // Only need initial file, browserify finds the 
deps
-    transform: [reactify], // We want to convert JSX to normal javascript
-    debug: true, // Gives us sourcemapping
-    cache: {}, packageCache: {}, fullPaths: true // Requirement of watchify
-})};
-
-gulp.task('javascript', function () {
-
-  var b = getBundler();
-  
-  return b.bundle()
-    .pipe(source('./js/app.js'))
-    .pipe(buffer())
-    //.pipe(uglify())
+    transform: ['babelify'],
+    debug: true,
+    fullPaths: true
+    })
+    .bundle()
+    .pipe(source('bundle.js'))
     .pipe(rename('myriad.js'))
-    .pipe(gulp.dest('./public/js'));
+    .pipe(gulp.dest("public/js/"));
 });
 
-gulp.task('html', function () {
+
+gulp.task('html', ['clean'], function () {
     return gulp.src('*.html')
         .pipe( gulp.dest('public/'))
 });
 
-gulp.task('css', function () {
+gulp.task('css', ['clean'], function () {
     return gulp.src('css/*.css')
         .pipe( gulp.dest('public/css/'))
 });
 
-gulp.task('img', function () {
+gulp.task('img', ['clean'], function () {
     return gulp.src('img/**')
         .pipe( gulp.dest('public/img/'))
 });
 
-gulp.task('dev-js', function () {
- 
-    var watcher  = watchify(getBundler());
-
-    return watcher
-    .on('update', function () { // When any files update
-        var updateStart = Date.now();
-        console.log('Updating!');
-        watcher.bundle() // Create new bundle that uses the cache for high 
performance
-        .pipe(source('app.js'))
-    // This is where you add uglifying etc.
-        .pipe(gulp.dest('./public/js/'));
-        console.log('Updated!', (Date.now() - updateStart) + 'ms');
-    })
-    .bundle() // Create the initial bundle when starting the task
-    .pipe(source('app.js'))
-    .pipe(rename('myriad.js'))
-    .pipe(gulp.dest('./public/js/'));
-
-});
-
-gulp.task('webserver', function() {
+gulp.task('webserver', ['build-dev'], function() {
   gulp.src('./public')
     .pipe(webserver({
       livereload: true,
@@ -89,14 +67,22 @@ gulp.task('webserver', function() {
     }));
 });
 
-gulp.task('watch', function() {
+gulp.task('watch', ['build-dev'], function() {
     gulp.watch('index.html', ['html']);
     gulp.watch('css/**', ['css']);
-    gulp.watch('js/**', ['javascript']);
+    gulp.watch('js/**', ['js-dev']);
     gulp.watch('img/**', ['img']);
 });
 
-gulp.task('dev', ['default', 'watch', 'webserver']);
+gulp.task('clean', function() {
+  return del(['./public']);
+});
+
+gulp.task('build-dev', ['js-dev', 'html', 'css', 'img']);
+
+gulp.task('dev', ['watch', 'webserver']);
+
+gulp.task('default', ['js', 'html', 'css', 'img']);
 
-gulp.task('default', ['javascript', 'html', 'css', 'img']);
+gulp.task('build', ['default']); // gradle calls gulp build by default
 

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/c47dc235/myriad-scheduler/src/main/resources/webapp/js/app.js
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/main/resources/webapp/js/app.js 
b/myriad-scheduler/src/main/resources/webapp/js/app.js
index 4723f65..d0ed4a5 100644
--- a/myriad-scheduler/src/main/resources/webapp/js/app.js
+++ b/myriad-scheduler/src/main/resources/webapp/js/app.js
@@ -14,7 +14,7 @@ var Router = require('react-router')
 
 var routes = (
   <Route name="myriad" path="/" handler={Myriad} >
-    <Route name="frameworkDown" path="frameworkDown" {...this.props} 
handler={ShutdownFrameworkComponent} />
+    <Route name="frameworkDown" path="frameworkDown" 
handler={ShutdownFrameworkComponent} />
     <Route name="flex" path="flex" handler={FlexComponent} />
     <Route name="tasks" path="tasks" handler={TasksComponent} />
     <Route name="help" path="help" handler={HelpComponent} />
@@ -27,4 +27,3 @@ var routes = (
 Router.run(routes, function (Handler) {
   React.render(<Handler/>, document.getElementById("myriad"));
 });
-

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/c47dc235/myriad-scheduler/src/main/resources/webapp/package.json
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/main/resources/webapp/package.json 
b/myriad-scheduler/src/main/resources/webapp/package.json
index 076bd95..350d6b8 100644
--- a/myriad-scheduler/src/main/resources/webapp/package.json
+++ b/myriad-scheduler/src/main/resources/webapp/package.json
@@ -3,6 +3,7 @@
   "version": "0.0.1",
   "description": "Myriad Dashboard",
   "main": "main.js",
+  "private": true,
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1"
   },
@@ -14,38 +15,35 @@
   "license": "Apache-2.0",
   "dependencies": {
     "change-case": "^2.2.0",
-    "jquery": "^2.1.3",
     "react": "^0.12.2",
     "react-bootstrap": "^0.16.1",
     "react-router": "^0.12.4",
     "react-router-bootstrap": "^0.9.1",
-    "react-tools": "^0.12.2",
     "superagent": "^1.0.0",
     "xml2js": "^0.4.5"
   },
   "devDependencies": {
+    "babelify": "^6.3.0",
     "browserify": "^9.0.3",
+    "del": "^2.0.2",
     "gulp": "^3.8.11",
+    "gulp-autoprefixer": "~2.3.1",
+    "gulp-cache": "~0.2.10",
     "gulp-concat": "~2.5.2",
+    "gulp-connect": "~2.2.0",
+    "gulp-imagemin": "~2.2.1",
+    "gulp-jshint": "~1.11.0",
+    "gulp-livereload": "~3.8.0",
+    "gulp-minify-css": "~1.1.6",
+    "gulp-notify": "~2.2.0",
     "gulp-rename": "~1.2.2",
+    "gulp-ruby-sass": "~1.0.5",
     "gulp-sourcemaps": "^1.5.0",
     "gulp-uglify": "~1.2.0",
     "gulp-webserver": "^0.9.0",
-    "reactify": "^1.0.0",
     "vinyl-buffer": "^1.0.0",
     "vinyl-source-stream": "^1.1.0",
     "vinyl-transform": "^1.0.0",
-    "watchify": "^2.4.0",
-    "gulp-connect": "~2.2.0",
-    "del": "~1.2.0",
-    "gulp-livereload": "~3.8.0",
-    "gulp-ruby-sass": "~1.0.5",
-    "gulp-imagemin": "~2.2.1",
-    "gulp-autoprefixer": "~2.3.1",
-    "gulp-cache": "~0.2.10",
-    "gulp-minify-css": "~1.1.6",
-    "gulp-jshint": "~1.11.0",
-    "gulp-notify": "~2.2.0",
-    "gulp-clean": "~0.3.1"
+    "watchify": "^2.4.0"
   }
 }

Reply via email to