mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
snapshot
This commit is contained in:
96
gulpfile.js
96
gulpfile.js
@ -260,6 +260,100 @@ gulp.task('examples', function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var e2eBabelOptions = {
|
||||||
|
optional: ['es7.decorators'],
|
||||||
|
modules: "system",
|
||||||
|
moduleIds: true,
|
||||||
|
getModuleId: function(name) {
|
||||||
|
return "dist/e2e/" + name.split('/test').join('');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
gulp.task('e2e', function() {
|
||||||
|
var buildTest = lazypipe()
|
||||||
|
//.pipe(traceur, traceurOptions)
|
||||||
|
.pipe(tsc, tscOptions, null, tscReporter)
|
||||||
|
.pipe(babel, e2eBabelOptions)
|
||||||
|
|
||||||
|
var buildE2ETest = lazypipe()
|
||||||
|
//.pipe(traceur, traceurOptions)
|
||||||
|
.pipe(tsc, tscOptions, null, tscReporter)
|
||||||
|
.pipe(babel)
|
||||||
|
|
||||||
|
var indexTemplate = _.template(
|
||||||
|
fs.readFileSync('scripts/e2e/ionic.template.html')
|
||||||
|
)({
|
||||||
|
buildConfig: buildConfig
|
||||||
|
|
||||||
|
})
|
||||||
|
var testTemplate = _.template( fs.readFileSync('scripts/e2e/e2e.template.js') )
|
||||||
|
|
||||||
|
var platforms = [
|
||||||
|
'android',
|
||||||
|
'core',
|
||||||
|
'ios',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Get each test folder with gulp.src
|
||||||
|
return gulp.src(['ionic/components/*/test/*/**/*', '!ionic/components/*/test/*/**/*.spec.ts'])
|
||||||
|
.pipe(cache('e2e', { optimizeMemory: true }))
|
||||||
|
.pipe(gulpif(/e2e.ts$/, buildE2ETest()))
|
||||||
|
.pipe(gulpif(/.ts$/, buildTest()))
|
||||||
|
.on('error', function (err) {
|
||||||
|
console.log("ERROR: " + err.message);
|
||||||
|
this.emit('end');
|
||||||
|
})
|
||||||
|
.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(gulp.dest('dist/e2e/'))
|
||||||
|
|
||||||
|
function createIndexHTML() {
|
||||||
|
return through2.obj(function(file, enc, next) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
var module = path.dirname(file.path)
|
||||||
|
.replace(__dirname, '')
|
||||||
|
.replace('/ionic/components/', 'dist/e2e/')
|
||||||
|
.replace('/test/', '/') +
|
||||||
|
'/index';
|
||||||
|
|
||||||
|
var indexContents = indexTemplate.replace('{{MODULE}}', module);
|
||||||
|
|
||||||
|
self.push(new VinylFile({
|
||||||
|
base: file.base,
|
||||||
|
contents: new Buffer(indexContents),
|
||||||
|
path: path.join(path.dirname(file.path), 'index.html'),
|
||||||
|
}));
|
||||||
|
next(null, file);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function createPlatformTests(file) {
|
||||||
|
return through2.obj(function(file, enc, next) {
|
||||||
|
var self = this
|
||||||
|
var relativePath = path.dirname(file.path.replace(/^.*?ionic(\/|\\)components(\/|\\)/, ''))
|
||||||
|
var contents = file.contents.toString()
|
||||||
|
platforms.forEach(function(platform) {
|
||||||
|
var platformContents = testTemplate({
|
||||||
|
contents: contents,
|
||||||
|
buildConfig: buildConfig,
|
||||||
|
relativePath: relativePath,
|
||||||
|
platform: platform
|
||||||
|
})
|
||||||
|
self.push(new VinylFile({
|
||||||
|
base: file.base,
|
||||||
|
contents: new Buffer(platformContents),
|
||||||
|
path: file.path.replace(/e2e.js$/, platform + '.e2e.js')
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
next()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
gulp.task('sass', function() {
|
gulp.task('sass', function() {
|
||||||
return gulp.src('ionic/ionic.scss')
|
return gulp.src('ionic/ionic.scss')
|
||||||
.pipe(sass({
|
.pipe(sass({
|
||||||
@ -293,7 +387,7 @@ gulp.task('karma-watch', function() {
|
|||||||
return karma.start({ configFile: __dirname + '/scripts/test/karma-watch.conf.js' })
|
return karma.start({ configFile: __dirname + '/scripts/test/karma-watch.conf.js' })
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('e2e', ['sass'], function() {
|
gulp.task('e2e.old', ['sass'], function() {
|
||||||
var indexContents = _.template( fs.readFileSync('scripts/e2e/index.template.html') )({
|
var indexContents = _.template( fs.readFileSync('scripts/e2e/index.template.html') )({
|
||||||
buildConfig: buildConfig
|
buildConfig: buildConfig
|
||||||
});
|
});
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
"gulp-sass": "^1.3.3",
|
"gulp-sass": "^1.3.3",
|
||||||
"gulp-shell": "^0.4.0",
|
"gulp-shell": "^0.4.0",
|
||||||
"gulp-typescript": "^2.7.7",
|
"gulp-typescript": "^2.7.7",
|
||||||
|
"gulp-util": "^3.0.6",
|
||||||
"gulp-watch": "^4.2.4",
|
"gulp-watch": "^4.2.4",
|
||||||
"gulp-wrap": "^0.11.0",
|
"gulp-wrap": "^0.11.0",
|
||||||
"karma": "^0.12.31",
|
"karma": "^0.12.31",
|
||||||
@ -27,6 +28,7 @@
|
|||||||
"lodash": "^2.4.1",
|
"lodash": "^2.4.1",
|
||||||
"node-libs-browser": "^0.5.2",
|
"node-libs-browser": "^0.5.2",
|
||||||
"node-uuid": "^1.4.1",
|
"node-uuid": "^1.4.1",
|
||||||
|
"q": "^1.4.1",
|
||||||
"request": "^2.53.0",
|
"request": "^2.53.0",
|
||||||
"run-sequence": "^1.1.0",
|
"run-sequence": "^1.1.0",
|
||||||
"serve-static": "^1.9.2",
|
"serve-static": "^1.9.2",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
describe('<%= relativePath %>: <%= platform %>', function() {
|
describe('<%= relativePath %>: <%= platform %>', function() {
|
||||||
|
|
||||||
it('should init', function() {
|
it('should init', function() {
|
||||||
browser.get('http://localhost:<%= buildConfig.protractorPort %>/e2e/<%= relativePath %>/index.html?ionicplatform=<%= platform %>');
|
browser.get('http://localhost:<%= buildConfig.protractorPort %>/dist/e2e/<%= relativePath %>/index.html?ionicplatform=<%= platform %>');
|
||||||
});
|
});
|
||||||
|
|
||||||
<%= contents %>
|
<%= contents %>
|
||||||
|
@ -15,7 +15,7 @@ module.exports = function(gulp, argv, buildConfig) {
|
|||||||
var snapshotValues = _.merge(snapshotConfig.platformDefauls, argv);
|
var snapshotValues = _.merge(snapshotConfig.platformDefauls, argv);
|
||||||
|
|
||||||
gulp.task('protractor-server', function() {
|
gulp.task('protractor-server', function() {
|
||||||
var app = connect().use(serveStatic(projectRoot + '/' + buildConfig.dist)); // serve everything that is static
|
var app = connect().use(serveStatic(projectRoot)); // serve everything that is static
|
||||||
protractorHttpServer = http.createServer(app).listen(buildConfig.protractorPort);
|
protractorHttpServer = http.createServer(app).listen(buildConfig.protractorPort);
|
||||||
console.log('Serving `dist` on http://localhost:' + buildConfig.protractorPort);
|
console.log('Serving `dist` on http://localhost:' + buildConfig.protractorPort);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user