From 466e976c7630900e20752d6b05a8e16078daf135 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Mon, 11 May 2015 19:48:42 -0500 Subject: [PATCH] wip --- gulpfile.js | 248 +++++++++++------- ionic/components/app/app.js | 0 ionic/components/form/form.js | 1 + ionic/components/nav/test/basic/main.js | 12 +- .../nav/test/basic/pages/first-page.js | 2 +- .../nav/test/basic/pages/second-page.js | 2 +- ionic/gestures/drag-gesture.js | 2 +- ionic/gestures/gesture.js | 2 +- scripts/e2e/angular.template.html | 28 ++ scripts/e2e/system-init.js | 1 - 10 files changed, 196 insertions(+), 102 deletions(-) delete mode 100644 ionic/components/app/app.js create mode 100644 scripts/e2e/angular.template.html delete mode 100644 scripts/e2e/system-init.js diff --git a/gulpfile.js b/gulpfile.js index 3b55424609..d047783fa3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,27 +1,165 @@ var _ = require('lodash'); var buildConfig = require('./scripts/build/config'); -var SystemJsBuilder = require('systemjs-builder'); -var exec = require('child_process').exec; var fs = require('fs'); var gulp = require('gulp'); var karma = require('karma').server; var path = require('path'); var VinylFile = require('vinyl'); - var argv = require('yargs').argv; -var babel = require('gulp-babel'); var cached = require('gulp-cached'); var concat = require('gulp-concat'); -var debug = require('gulp-debug'); var del = require('del'); var gulpif = require('gulp-if'); -var karma = require('karma').server; -var plumber = require('gulp-plumber'); var rename = require('gulp-rename'); var sass = require('gulp-sass'); -var shell = require('gulp-shell'); var through2 = require('through2'); -var traceur = require('gulp-traceur'); +var exec = require('child_process').exec; +var spawn = require('child_process').spawn; +var runSequence = require('run-sequence'); + + +// !!! TEMP HACK !!! +// first run ./update-angular.sh +gulp.task('build', function(done) { + + if (!fs.existsSync('./dist/angular')) { + console.error('hey yo, run "gulp update.angular" first'); + return; + } + + runSequence( + 'ionic.copy.js', + 'ionic.examples', + 'angular.build', + done + ); + +}); + + +gulp.task('ionic.copy.js', function(done) { + console.log('copying ionic src JS to dist/angular/modules/ionic...'); + return gulp.src('ionic/**/*.js') + .pipe(gulp.dest('dist/angular/modules/ionic')); +}); + + +gulp.task('ionic.examples', function() { + var indexContents = _.template( fs.readFileSync('scripts/e2e/angular.template.html') )({ + buildConfig: buildConfig + }); + + // Get each test folder with gulp.src + return gulp.src('ionic/components/*/test/*/**/*') + .pipe(cached('ionicexamples')) + .pipe(rename(function(file) { + file.dirname = file.dirname.replace(path.sep + 'test' + path.sep, path.sep) + })) + .pipe(gulpif(/main.js$/, processMain())) + .pipe(gulp.dest('dist/angular/modules/examples/src/ionic')) + + function processMain() { + return through2.obj(function(file, enc, next) { + var self = this; + self.push(new VinylFile({ + base: file.base, + contents: new Buffer(indexContents), + path: path.join(path.dirname(file.path), 'index.html'), + })); + next(null, file); + }) + } + +}); + + +gulp.task('serve', function(done) { + + runSequence( + 'build', + 'angular.serve', + done + ); + +}); + + +gulp.task('angular.serve', function(done) { + + var serve = spawn('gulp', ['serve.js.dev'], { + cwd: './dist/angular' + }); + + serve.stdout.on('data', function (data) { + console.log('' + data); + }); + + serve.stderr.on('data', function (data) { + console.log('' + data); + }); + + serve.on('close', function (code) { + console.log('gulp serve exited with code ' + code); + }); + +}); + + +gulp.task('angular.build', function(done) { + + var child = exec('gulp build.js.dev', { + cwd: './dist/angular' + }, function (error, stdout, stderr) { + console.log('stdout: ' + stdout); + console.log('stderr: ' + stderr); + if (error !== null) { + console.log('exec error: ' + error); + } + done(); + }); + +}); + + +gulp.task('update.angular', function(done) { + + if (!fs.existsSync('./dist')) { + fs.mkdirSync('./dist'); + } + if (!fs.existsSync('./dist/angular')) { + fs.mkdirSync('./dist/angular'); + + console.log('cloning angular master...'); + exec('git clone git@github.com:angular/angular ./dist/angular', function() { + npmInstall(); + }); + + } else { + console.log('angular master: cleaning modules'); + del(['dist/angular/modules'], {cwd: './dist/angular'}, function() { + + console.log('angular master: reset --hard...'); + exec('git reset --hard origin/master', {cwd: './dist/angular'}, function () { + + console.log('angular master: git pull origin master...'); + exec('git pull origin master', function () { + npmInstall(); + }); + }); + + }) + } + + function npmInstall() { + console.log('angular master: npm install (may take a while, chill out)...'); + exec('npm install', {cwd: './dist/angular'}, function () { + done(); + }); + } + +}); + + require('./scripts/snapshot/snapshot.task')(gulp, argv, buildConfig); @@ -30,9 +168,6 @@ gulp.task('default', ['clean'], function() { gulp.run('build'); }); -gulp.task('build', ['e2e', 'ionic-js', 'ng2', 'sass']); - -gulp.task('lib', ['fonts', 'dependencies']); gulp.task('watch', ['default'], function() { gulp.watch(buildConfig.src.scss, ['sass']) @@ -54,14 +189,6 @@ gulp.task('karma-watch', function() { return karma.start({ configFile: __dirname + '/scripts/test/karma-watch.conf.js' }) }); -gulp.task('dependencies', function() { - var copyFrom = buildConfig.scripts - .map(function(data) { return data.from; }) - .filter(function(item) { return !!item; }); - return gulp.src(copyFrom) - .pipe(gulp.dest(buildConfig.distLib)) -}); - gulp.task('sass', function() { return gulp.src('ionic/ionic.scss') .pipe(sass({ @@ -77,10 +204,15 @@ gulp.task('fonts', function() { .pipe(gulp.dest('dist/fonts')); }); + gulp.task('clean', function(done) { - del([buildConfig.dist], done); + del(['dist/e2e'], done); }); + + + + gulp.task('e2e', ['ionic-js', 'sass'], function() { var indexContents = _.template( fs.readFileSync('scripts/e2e/index.template.html') )({ buildConfig: buildConfig @@ -100,8 +232,8 @@ gulp.task('e2e', ['ionic-js', 'sass'], function() { file.dirname = file.dirname.replace(path.sep + 'test' + path.sep, path.sep) })) .pipe(gulpif(/main.js$/, processMain())) - .pipe(gulpif(/e2e.js$/, createPlatformTests())) - .pipe(gulp.dest(buildConfig.dist + '/e2e')) + //.pipe(gulpif(/e2e.js$/, createPlatformTests())) + //.pipe(gulp.dest(buildConfig.dist + '/e2e')) function processMain() { return through2.obj(function(file, enc, next) { @@ -112,37 +244,9 @@ gulp.task('e2e', ['ionic-js', 'sass'], function() { path: path.join(path.dirname(file.path), 'index.html'), })); next(null, file); - - // var builder = new SystemJsBuilder({ - // baseURL: __dirname, - // traceurOptions: { annotations: true, types: true }, - // meta: { - // 'angular2/angular2': { build: false }, - // 'ionic/ionic': { build: false }, - // }, - // map: { - // hammer: 'node_modules/hammerjs/hammer', - // rx: 'node_modules/rx' - // }, - // paths: { - // 'angular2/*': 'dist/lib/angular2/*.js', - // 'app/*': path.dirname(file.path) + '/*.js' - // }, - // }); - // builder.build('app/main').then(function(output) { - // self.push(new VinylFile({ - // base: file.base, - // contents: new Buffer(output.source), - // path: file.path, - // })); - // next(); - // }) - // .catch(function(err) { - // console.log('error', err); - // throw new Error(err); - // }); }) } + function createPlatformTests(file) { return through2.obj(function(file, enc, next) { var self = this @@ -166,43 +270,3 @@ gulp.task('e2e', ['ionic-js', 'sass'], function() { } }); - -gulp.task('ng2-copy', function() { - return gulp.src('node_modules/angular2/es6/prod/**/*.es6') - .pipe(rename({ extname: '.js' })) - .pipe(gulp.dest(path.join(buildConfig.distLib, 'angular2'))); -}); - -gulp.task('ng2', ['lib', 'ng2-copy'], function() { - var builder = new SystemJsBuilder({ - paths: { - "angular2/*": "node_modules/angular2/es6/prod/*.es6", - "rx/*": "node_modules/angular2/node_modules/rx/*.js" - } - }); - return builder.build('angular2/angular2', path.join(buildConfig.distLib, 'angular2.js')).then(function() { - return builder.build('angular2/di', path.join(buildConfig.distLib, 'angular2-di.js')); - }); -}); - -gulp.task('ng2-di', ['ng2'], function() { -}); - -gulp.task('ionic-js', function() { - var builder = new SystemJsBuilder({ - traceurOptions: { - annotations: true, - types: true, - }, - meta: { - 'angular2/angular2': { build: false }, - 'angular2/di': { build: false }, - }, - paths: { - "hammer": 'node_modules/hammerjs/*.js', - "angular2/*": "node_modules/angular2/es6/prod/*.es6", - "rx/*": "node_modules/angular2/node_modules/rx/*.js", - } - }); - return builder.build('ionic/ionic', path.join(buildConfig.distLib, 'ionic2.js')); -}); diff --git a/ionic/components/app/app.js b/ionic/components/app/app.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ionic/components/form/form.js b/ionic/components/form/form.js index e69de29bb2..7d6cb4908d 100644 --- a/ionic/components/form/form.js +++ b/ionic/components/form/form.js @@ -0,0 +1 @@ +// form diff --git a/ionic/components/nav/test/basic/main.js b/ionic/components/nav/test/basic/main.js index 404837d31a..668f95e0f5 100644 --- a/ionic/components/nav/test/basic/main.js +++ b/ionic/components/nav/test/basic/main.js @@ -1,16 +1,18 @@ -import {Component, View, bootstrap} from 'angular2/angular2' +import {bootstrap} from 'angular2/angular2' import {Nav} from 'ionic/components/nav/nav' import {Log} from 'ionic/util' -import {FirstPage} from 'pages/first-page' +import {FirstPage} from './pages/first-page' -@Component({ selector: '[ion-app]' }) +import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations'; +import {View} from 'angular2/src/core/annotations_impl/view'; + + +@Component({ selector: 'ion-app' }) @View({ - directives: [Nav], templateUrl: 'main.html' }) class IonicApp { constructor() { - this.initial = FirstPage console.log('IonicApp Start'); } } diff --git a/ionic/components/nav/test/basic/pages/first-page.js b/ionic/components/nav/test/basic/pages/first-page.js index 459d8fde98..f76c76a533 100644 --- a/ionic/components/nav/test/basic/pages/first-page.js +++ b/ionic/components/nav/test/basic/pages/first-page.js @@ -1,6 +1,6 @@ import {Component, View, Parent} from 'angular2/angular2' import {NavController, Toolbar, Content} from 'ionic/ionic' -import {SecondPage} from 'pages/second-page' +import {SecondPage} from './second-page' @Component() diff --git a/ionic/components/nav/test/basic/pages/second-page.js b/ionic/components/nav/test/basic/pages/second-page.js index 4dab8e3cc6..a4dcad8950 100644 --- a/ionic/components/nav/test/basic/pages/second-page.js +++ b/ionic/components/nav/test/basic/pages/second-page.js @@ -1,6 +1,6 @@ import {Component, View, Parent} from 'angular2/angular2' import {NavController, Toolbar, Content} from 'ionic/ionic' -import {ThirdPage} from 'pages/third-page' +import {ThirdPage} from './third-page' @Component() diff --git a/ionic/gestures/drag-gesture.js b/ionic/gestures/drag-gesture.js index 3281d2b900..6c18c09398 100644 --- a/ionic/gestures/drag-gesture.js +++ b/ionic/gestures/drag-gesture.js @@ -1,6 +1,6 @@ import {Gesture} from 'ionic/gestures/gesture'; import * as util from 'ionic/util'; -import Hammer from 'hammer'; +//import Hammer from 'hammer'; /* * BUG(ajoslin): HammerJS 2.x does not have an alternative to HammerJS 1.x's diff --git a/ionic/gestures/gesture.js b/ionic/gestures/gesture.js index b4b642a4da..b14dcdcd57 100644 --- a/ionic/gestures/gesture.js +++ b/ionic/gestures/gesture.js @@ -1,5 +1,5 @@ import * as util from 'ionic/util'; -import Hammer from 'hammer'; +//import Hammer from 'hammer'; export class Gesture { constructor(element, opts = {}) { diff --git a/scripts/e2e/angular.template.html b/scripts/e2e/angular.template.html new file mode 100644 index 0000000000..d533b86650 --- /dev/null +++ b/scripts/e2e/angular.template.html @@ -0,0 +1,28 @@ + + + + + + + + + + Loading... + + + + + + + + + + + + + + + + diff --git a/scripts/e2e/system-init.js b/scripts/e2e/system-init.js deleted file mode 100644 index 4f92e14b20..0000000000 --- a/scripts/e2e/system-init.js +++ /dev/null @@ -1 +0,0 @@ -// register(System);