mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
wip
This commit is contained in:
248
gulpfile.js
248
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'));
|
||||
});
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
// form
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as util from 'ionic/util';
|
||||
import Hammer from 'hammer';
|
||||
//import Hammer from 'hammer';
|
||||
|
||||
export class Gesture {
|
||||
constructor(element, opts = {}) {
|
||||
|
||||
28
scripts/e2e/angular.template.html
Normal file
28
scripts/e2e/angular.template.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<ion-app>
|
||||
Loading...
|
||||
</ion-app>
|
||||
</body>
|
||||
|
||||
<script src="traceur-runtime.js"></script>
|
||||
<script src="es6-module-loader-sans-promises.src.js"></script>
|
||||
<script src="zone.js"></script>
|
||||
<script src="long-stack-trace-zone.js"></script>
|
||||
<script src="system.src.js"></script>
|
||||
<script src="extension-register.js"></script>
|
||||
<script src="extension-cjs.js"></script>
|
||||
<script src="Reflect.js"></script>
|
||||
<script src="runtime_paths.js"></script>
|
||||
|
||||
<script>
|
||||
System.import('examples/src/ionic/nav/basic/main').catch(console.error.bind(console));
|
||||
</script>
|
||||
|
||||
</html>
|
||||
@@ -1 +0,0 @@
|
||||
// register(System);
|
||||
Reference in New Issue
Block a user