mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
e2e task
This commit is contained in:
146
gulpfile.js
146
gulpfile.js
@ -12,32 +12,12 @@ var tsc = require('gulp-typescript');
|
|||||||
var cache = require('gulp-cached');
|
var cache = require('gulp-cached');
|
||||||
var minimist = require('minimist');
|
var minimist = require('minimist');
|
||||||
|
|
||||||
function getBabelOptions(moduleName, moduleType) {
|
|
||||||
return {
|
|
||||||
optional: ['es7.decorators'],
|
|
||||||
modules: moduleType || "system",
|
|
||||||
moduleIds: true,
|
|
||||||
getModuleId: function(name) {
|
|
||||||
if (moduleName == "e2e"){
|
|
||||||
return name.replace(/^.*\/test\/[^\/]*\//, '');
|
|
||||||
}
|
|
||||||
else if (moduleName == "demos"){
|
|
||||||
return name.replace(/^(.*?)\//, '')
|
|
||||||
}
|
|
||||||
|
|
||||||
return moduleName + '/' + name.split('/test').join('');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function buildDemoBundle(opts, done) {
|
function buildDemoBundle(opts, done) {
|
||||||
var glob = require('glob');
|
var glob = require('glob');
|
||||||
var webpack = require('webpack');
|
var webpack = require('webpack');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
|
|
||||||
var numWebpacks = 0;
|
|
||||||
var fp = 'dist/demos/'+opts.demo+'/index.js';
|
var fp = 'dist/demos/'+opts.demo+'/index.js';
|
||||||
if (opts.demo == 'api') {
|
if (opts.demo == 'api') {
|
||||||
fp = "dist/demos/**/index.js";
|
fp = "dist/demos/**/index.js";
|
||||||
@ -89,8 +69,6 @@ var flagConfig = {
|
|||||||
alias: {'p': 'port', 'v': 'version', 'a': 'ngVersion'},
|
alias: {'p': 'port', 'v': 'version', 'a': 'ngVersion'},
|
||||||
default: { port: 8000 }
|
default: { port: 8000 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var flags = minimist(process.argv.slice(2), flagConfig);
|
var flags = minimist(process.argv.slice(2), flagConfig);
|
||||||
|
|
||||||
gulp.task('build', function(done) {
|
gulp.task('build', function(done) {
|
||||||
@ -203,22 +181,35 @@ gulp.task('bundle', ['transpile', 'copy.web-animations'], function(done){
|
|||||||
// prepend.push('window.Element.prototype.animate=undefined;');
|
// prepend.push('window.Element.prototype.animate=undefined;');
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
var config = require('./scripts/npm/ionic.webpack.config.js');
|
||||||
|
bundle({
|
||||||
|
config: config,
|
||||||
|
cb: done,
|
||||||
|
stats: true
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
function bundle(args) {
|
||||||
var webpack = require('webpack');
|
var webpack = require('webpack');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var config = require('./scripts/npm/ionic.webpack.config.js');
|
|
||||||
|
|
||||||
webpack(config, function(err, stats){
|
var numTasks = args.numTasks ? args.numTasks : 0;
|
||||||
var statsOptions = {
|
|
||||||
'colors': true,
|
webpack(args.config, function(err, stats){
|
||||||
'modules': false,
|
if (args.stats) {
|
||||||
'chunks': false,
|
var statsOptions = {
|
||||||
'exclude': ['node_module'],
|
'colors': true,
|
||||||
'errorDetails': true
|
'modules': false,
|
||||||
|
'chunks': false,
|
||||||
|
'exclude': ['node_module'],
|
||||||
|
'errorDetails': true
|
||||||
|
}
|
||||||
|
console.log(stats.toString(statsOptions));
|
||||||
}
|
}
|
||||||
console.log(stats.toString(statsOptions));
|
|
||||||
cb();
|
if (numTasks === 0 && args.cb) args.cb();
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
gulp.task('temp.hack', function(){
|
gulp.task('temp.hack', function(){
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
@ -258,30 +249,19 @@ gulp.task('tests', function() {
|
|||||||
.pipe(gulp.dest('dist/tests'))
|
.pipe(gulp.dest('dist/tests'))
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('e2e', function() {
|
gulp.task('e2e.build', function() {
|
||||||
var gulpif = require('gulp-if');
|
var gulpif = require('gulp-if');
|
||||||
var lazypipe = require('lazypipe');
|
var merge = require('merge2');
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var VinylFile = require('vinyl');
|
var VinylFile = require('vinyl');
|
||||||
|
|
||||||
var buildTest = lazypipe()
|
|
||||||
//.pipe(traceur, traceurOptions)
|
|
||||||
.pipe(tsc, tscOptions, undefined, tscReporter)
|
|
||||||
.pipe(babel, getBabelOptions('e2e'))
|
|
||||||
|
|
||||||
var buildE2ETest = lazypipe()
|
|
||||||
//.pipe(traceur, traceurOptions)
|
|
||||||
.pipe(tsc, tscOptions, undefined, tscReporter)
|
|
||||||
.pipe(babel)
|
|
||||||
|
|
||||||
var indexTemplate = _.template(
|
var indexTemplate = _.template(
|
||||||
fs.readFileSync('scripts/e2e/e2e.template.html')
|
fs.readFileSync('scripts/e2e/e2e.template.html')
|
||||||
)({
|
)({
|
||||||
buildConfig: buildConfig
|
buildConfig: buildConfig
|
||||||
|
|
||||||
})
|
})
|
||||||
var testTemplate = _.template( fs.readFileSync('scripts/e2e/e2e.template.js') )
|
var testTemplate = _.template(fs.readFileSync('scripts/e2e/e2e.template.js'));
|
||||||
|
|
||||||
var platforms = [
|
var platforms = [
|
||||||
'android',
|
'android',
|
||||||
@ -289,20 +269,30 @@ gulp.task('e2e', function() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Get each test folder with gulp.src
|
// Get each test folder with gulp.src
|
||||||
return gulp.src(['ionic/components/*/test/*/**/*', '!ionic/components/*/test/*/**/*.spec.ts'])
|
var tsResult = gulp.src([
|
||||||
.pipe(cache('e2e', { optimizeMemory: true }))
|
'ionic/components/*/test/*/**/*.ts',
|
||||||
.pipe(gulpif(/e2e.ts$/, buildE2ETest()))
|
'!ionic/components/*/test/*/**/*.spec.ts'
|
||||||
.pipe(gulpif(/.ts$/, buildTest()))
|
])
|
||||||
.on('error', function (err) {
|
.pipe(cache('e2e.ts'))
|
||||||
console.log("ERROR: " + err.message);
|
.pipe(tsc(tscOptions, undefined, tscReporter))
|
||||||
this.emit('end');
|
.pipe(gulpif(/index.js$/, createIndexHTML()))
|
||||||
})
|
|
||||||
.pipe(gulpif(/index.js$/, createIndexHTML())) //TSC changes .ts to .js
|
|
||||||
.pipe(rename(function(file) {
|
|
||||||
file.dirname = file.dirname.replace(path.sep + 'test' + path.sep, path.sep)
|
|
||||||
}))
|
|
||||||
.pipe(gulpif(/e2e.js$/, createPlatformTests()))
|
.pipe(gulpif(/e2e.js$/, createPlatformTests()))
|
||||||
.pipe(gulp.dest('dist/e2e/'))
|
|
||||||
|
var testFiles = gulp.src([
|
||||||
|
'ionic/components/*/test/*/**/*',
|
||||||
|
'!ionic/components/*/test/*/**/*.ts'
|
||||||
|
])
|
||||||
|
.pipe(cache('e2e.files'))
|
||||||
|
|
||||||
|
return merge([
|
||||||
|
tsResult,
|
||||||
|
testFiles
|
||||||
|
])
|
||||||
|
.pipe(rename(function(file) {
|
||||||
|
var sep = path.sep;
|
||||||
|
file.dirname = file.dirname.replace(sep + 'test' + sep, sep)
|
||||||
|
}))
|
||||||
|
.pipe(gulp.dest('dist/e2e/'));
|
||||||
|
|
||||||
function createIndexHTML() {
|
function createIndexHTML() {
|
||||||
return through2.obj(function(file, enc, next) {
|
return through2.obj(function(file, enc, next) {
|
||||||
@ -338,6 +328,40 @@ gulp.task('e2e', function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('e2e.bundle', ['e2e.build'], function(done) {
|
||||||
|
var glob = require('glob');
|
||||||
|
var webpack = require('webpack');
|
||||||
|
var path = require('path');
|
||||||
|
var _ = require('lodash');
|
||||||
|
|
||||||
|
return glob("dist/e2e/**/index.js", function(err, files){
|
||||||
|
var numTasks = files.length;
|
||||||
|
files.forEach(function(file){
|
||||||
|
var config = require('./scripts/e2e/webpack.config.js');
|
||||||
|
|
||||||
|
// add our bundle entry, removing previous if necessary
|
||||||
|
// since config is cached
|
||||||
|
if (config.entry.length > 1) {
|
||||||
|
config.entry.pop();
|
||||||
|
}
|
||||||
|
config.entry.push('./' + file);
|
||||||
|
config.output = {
|
||||||
|
libraryTarget: 'commonjs2',
|
||||||
|
filename: path.dirname(file) + '/bundle.js'
|
||||||
|
}
|
||||||
|
|
||||||
|
bundle({
|
||||||
|
config: config,
|
||||||
|
numTasks: --numTasks,
|
||||||
|
stats: false,
|
||||||
|
cb: done
|
||||||
|
});
|
||||||
|
})
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('e2e', ['e2e.bundle']);
|
||||||
|
|
||||||
gulp.task('sass', function() {
|
gulp.task('sass', function() {
|
||||||
var sass = require('gulp-sass');
|
var sass = require('gulp-sass');
|
||||||
var autoprefixer = require('gulp-autoprefixer');
|
var autoprefixer = require('gulp-autoprefixer');
|
||||||
|
@ -5,8 +5,12 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||||
|
|
||||||
<link ios-href="../../../css/ionic.ios.css" rel="stylesheet">
|
<link ios-href="/dist/bundles/ionic.ios.css" rel="stylesheet">
|
||||||
<link md-href="../../../css/ionic.md.css" rel="stylesheet">
|
<link md-href="/dist/bundles/ionic.md.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<script src="/node_modules/systemjs/node_modules/es6-module-loader/dist/es6-module-loader.src.js"></script>
|
||||||
|
<script src="/node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
<script src="/node_modules/angular2/bundles/angular2-polyfills.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
if (!console.time) {
|
if (!console.time) {
|
||||||
@ -78,19 +82,15 @@
|
|||||||
<ion-loading-icon></ion-loading-icon>
|
<ion-loading-icon></ion-loading-icon>
|
||||||
</ion-app>
|
</ion-app>
|
||||||
|
|
||||||
<script src="../../../js/ionic.bundle.js"></script>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
System.config({
|
System.config({
|
||||||
"paths": {
|
map: {
|
||||||
"*": "*.js",
|
'rxjs': '/node_modules/rxjs',
|
||||||
"ionic/*": "ionic/*",
|
'angular2': '/node_modules/angular2/bundles/angular2.umd.dev.js',
|
||||||
"angular2/*": "angular2/*",
|
'ionic/ionic': '/dist/bundles/ionic.js'
|
||||||
"rxjs/*": "rxjs/*"
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
System.import("index").then(function(m) {}, console.error.bind(console));
|
System.import('bundle.js').then(function(m) {}, console.error.bind(console));
|
||||||
|
|
||||||
console.timeEnd('script init');
|
console.timeEnd('script init');
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
37
scripts/e2e/webpack.config.js
Normal file
37
scripts/e2e/webpack.config.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
module.exports = {
|
||||||
|
entry: [
|
||||||
|
"web-animations.min"
|
||||||
|
],
|
||||||
|
externals: [
|
||||||
|
{
|
||||||
|
'ionic/ionic': {
|
||||||
|
commonjs2: 'ionic/ionic'
|
||||||
|
},
|
||||||
|
'angular2/core': {
|
||||||
|
commonjs2: ['angular2', 'core']
|
||||||
|
},
|
||||||
|
'angular2/common': {
|
||||||
|
commonjs2: ['angular2', 'common']
|
||||||
|
},
|
||||||
|
'angular2/router' : {
|
||||||
|
commonjs2: ['angular2', 'router']
|
||||||
|
},
|
||||||
|
'angular2/http': {
|
||||||
|
commonjs2: ['angular2', 'http']
|
||||||
|
},
|
||||||
|
'angular2/platform/browser': {
|
||||||
|
commonjs2: ['angular2', 'platform', 'browser']
|
||||||
|
},
|
||||||
|
'angular2/instrumentation': {
|
||||||
|
commonjs2: ['angular2', 'instrumentation']
|
||||||
|
},
|
||||||
|
}
|
||||||
|
],
|
||||||
|
module: {
|
||||||
|
loaders: [{ test: /\.ts$/, loader: "awesome-typescript-loader" }]
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {'web-animations.min': './dist/js/web-animations.min'},
|
||||||
|
extensions: ["", ".js", ".ts"]
|
||||||
|
}
|
||||||
|
};
|
Reference in New Issue
Block a user