improving.. breaking.. the gulpfile
This commit is contained in:
parent
0832be2380
commit
138afe39dc
@ -5,28 +5,47 @@ var minimist = require('minimist')
|
|||||||
module.exports = function (gulp, helperOptions) {
|
module.exports = function (gulp, helperOptions) {
|
||||||
var runSequence = require('run-sequence').use(gulp)
|
var runSequence = require('run-sequence').use(gulp)
|
||||||
var options = minimist(process.argv.slice(2), {
|
var options = minimist(process.argv.slice(2), {
|
||||||
string: ['modulename', 'export', 'name', 'testport', 'testfiles', 'regenerator'],
|
string: ['modulename', 'export', 'name', 'testport', 'testfiles'],
|
||||||
default: {
|
default: {
|
||||||
modulename: helperOptions.moduleName,
|
modulename: helperOptions.moduleName,
|
||||||
targetName: helperOptions.targetName,
|
targetName: helperOptions.targetName,
|
||||||
export: 'ignore',
|
export: 'ignore',
|
||||||
testport: '8888',
|
testport: '8888',
|
||||||
testfiles: 'src/**/*.js',
|
testfiles: '**/*.spec.js',
|
||||||
regenerator: process.version < 'v0.12'
|
browserify: helperOptions.browserify != null ? helperOptions.browserify : false,
|
||||||
|
regenerator: true,
|
||||||
|
debug: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if (options.regenerator === 'false') {
|
||||||
|
options.regenerator = false
|
||||||
|
// TODO: include './node_modules/gulp-babel/node_modules/babel-core/node_modules/regenerator/runtime.js'
|
||||||
|
}
|
||||||
|
var concatOrder = [
|
||||||
|
'y.js',
|
||||||
|
'Connector.js',
|
||||||
|
'Database.js',
|
||||||
|
'Transaction.js',
|
||||||
|
'Struct.js',
|
||||||
|
'Utils.js',
|
||||||
|
'Databases/RedBlackTree.js',
|
||||||
|
'Databases/Memory.js',
|
||||||
|
'Databases/IndexedDB.js',
|
||||||
|
'Connectors/Test.js',
|
||||||
|
'Types/Array.js',
|
||||||
|
'Types/Map.js',
|
||||||
|
'Types/TextBind.js'
|
||||||
|
]
|
||||||
|
var yjsfiles = concatOrder.map(function (f) {
|
||||||
|
return '../yjs/src/' + f
|
||||||
|
})
|
||||||
var files = {
|
var files = {
|
||||||
src: helperOptions.polyfills.concat(helperOptions.concatOrder.map(function (f) {
|
dist: helperOptions.polyfills.concat(helperOptions.files.map(function (f) {
|
||||||
return 'src/' + f
|
return 'src/' + f
|
||||||
})),
|
})),
|
||||||
test: ['build/Helper.spec.js'].concat(helperOptions.concatOrder.map(function (f) {
|
test: ['../yjs/src/Helper.spec.js'].concat(yjsfiles).concat(helperOptions.files.map(function (f) {
|
||||||
return 'build/' + f
|
return 'src/' + f
|
||||||
}).concat(['build/**/*.spec.js']))
|
}).concat(['src/' + options.testfiles]))
|
||||||
}
|
|
||||||
|
|
||||||
if (options.regenerator) {
|
|
||||||
files.test = helperOptions.polyfills.concat(files.test)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var babelOptions = {
|
var babelOptions = {
|
||||||
@ -34,54 +53,64 @@ module.exports = function (gulp, helperOptions) {
|
|||||||
modules: 'ignore',
|
modules: 'ignore',
|
||||||
experimental: true
|
experimental: true
|
||||||
}
|
}
|
||||||
if (!options.regenerator) {
|
if (options.regenerator) {
|
||||||
|
files.test = helperOptions.polyfills.concat(files.test)
|
||||||
|
} else {
|
||||||
babelOptions.blacklist = 'regenerator'
|
babelOptions.blacklist = 'regenerator'
|
||||||
}
|
}
|
||||||
|
// babelOptions.blacklist = 'regenerator'
|
||||||
|
|
||||||
|
gulp.task('dist', ['build:dist'], function () {
|
||||||
|
function createDist (pipe) {
|
||||||
|
return pipe
|
||||||
|
.pipe($.if(options.debug, $.sourcemaps.init({loadMaps: true})))
|
||||||
|
.pipe($.concat(options.targetName))
|
||||||
|
.pipe($.if(!options.debug && options.regenerator, $.uglify()))
|
||||||
|
.pipe($.if(options.debug, $.sourcemaps.write('.')))
|
||||||
|
.pipe(gulp.dest('./dist/'))
|
||||||
|
}
|
||||||
|
var pipe
|
||||||
|
if (options.browserify || true) {
|
||||||
|
var browserify = require('browserify')
|
||||||
|
var source = require('vinyl-source-stream')
|
||||||
|
var buffer = require('vinyl-buffer')
|
||||||
|
|
||||||
|
pipe = browserify({
|
||||||
|
entries: 'build/' + options.targetName,
|
||||||
|
debug: options.debug
|
||||||
|
}).bundle()
|
||||||
|
.pipe(source(options.targetName))
|
||||||
|
.pipe(buffer())
|
||||||
|
} else {
|
||||||
|
pipe = gulp.src('build/' + options.targetName)
|
||||||
|
}
|
||||||
|
return createDist(pipe)
|
||||||
|
})
|
||||||
|
|
||||||
gulp.task('dist', function () {
|
gulp.task('dist', function () {
|
||||||
return gulp.src(files.src)
|
var browserify = require('browserify')
|
||||||
.pipe($.sourcemaps.init())
|
var source = require('vinyl-source-stream')
|
||||||
|
var buffer = require('vinyl-buffer')
|
||||||
|
|
||||||
|
return browserify({
|
||||||
|
entries: files.dist,
|
||||||
|
debug: options.debug
|
||||||
|
}).bundle()
|
||||||
|
.pipe(source(options.targetName))
|
||||||
|
.pipe(buffer())
|
||||||
|
.pipe($.if(options.debug, $.sourcemaps.init({loadMaps: true})))
|
||||||
.pipe($.concat(options.targetName))
|
.pipe($.concat(options.targetName))
|
||||||
.pipe($.babel({
|
.pipe($.if(!options.debug && options.regenerator, $.uglify()))
|
||||||
loose: 'all',
|
.pipe($.if(options.debug, $.sourcemaps.write('.')))
|
||||||
modules: 'ignore',
|
|
||||||
experimental: true
|
|
||||||
}))
|
|
||||||
.pipe($.uglify())
|
|
||||||
.pipe($.sourcemaps.write('.'))
|
|
||||||
.pipe(gulp.dest('./dist/'))
|
.pipe(gulp.dest('./dist/'))
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('watch:dist', function () {
|
gulp.task('watch:dist', function (cb) {
|
||||||
gulp.src(files.src)
|
options.debug = true
|
||||||
.pipe($.watch(files.src))
|
runSequence('dist', function () {
|
||||||
.pipe($.sourcemaps.init())
|
gulp.watch(files.dist, ['dist'])
|
||||||
.pipe($.concat(options.targetName))
|
cb()
|
||||||
.pipe($.babel({
|
})
|
||||||
loose: 'all',
|
|
||||||
modules: 'ignore',
|
|
||||||
experimental: true
|
|
||||||
}))
|
|
||||||
// .pipe($.uglify())
|
|
||||||
.pipe($.sourcemaps.write('.'))
|
|
||||||
.pipe(gulp.dest('./dist/'))
|
|
||||||
})
|
|
||||||
|
|
||||||
gulp.task('build', function () {
|
|
||||||
return gulp.src('src/**/*.js')
|
|
||||||
.pipe($.sourcemaps.init())
|
|
||||||
.pipe($.babel(babelOptions))
|
|
||||||
.pipe($.sourcemaps.write())
|
|
||||||
.pipe(gulp.dest('build'))
|
|
||||||
})
|
|
||||||
|
|
||||||
gulp.task('watch:build', function () {
|
|
||||||
gulp.src('src/**/*.js')
|
|
||||||
.pipe($.watch('src/**/*.js'))
|
|
||||||
.pipe($.sourcemaps.init())
|
|
||||||
.pipe($.babel(babelOptions))
|
|
||||||
.pipe($.sourcemaps.write())
|
|
||||||
.pipe(gulp.dest('build'))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('updateSubmodule', function () {
|
gulp.task('updateSubmodule', function () {
|
||||||
@ -141,7 +170,7 @@ module.exports = function (gulp, helperOptions) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('dev:node', ['test'], function () {
|
gulp.task('dev:node', ['test'], function () {
|
||||||
gulp.watch('src/**/*.js', ['test'])
|
gulp.watch(files.dist, ['test'])
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('dev:browser', ['watch:build'], function () {
|
gulp.task('dev:browser', ['watch:build'], function () {
|
||||||
@ -151,8 +180,9 @@ module.exports = function (gulp, helperOptions) {
|
|||||||
.pipe($.jasmineBrowser.server({port: options.testport}))
|
.pipe($.jasmineBrowser.server({port: options.testport}))
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('test', ['build'], function () {
|
gulp.task('test', function () {
|
||||||
return gulp.src(files.test)
|
console.log(files.test)
|
||||||
|
return gulp.src('./dist/y.js')
|
||||||
.pipe($.jasmine({
|
.pipe($.jasmine({
|
||||||
verbose: true,
|
verbose: true,
|
||||||
includeStuckTrace: true
|
includeStuckTrace: true
|
||||||
|
@ -48,8 +48,8 @@ var $ = require('gulp-load-plugins')()
|
|||||||
var runSequence = require('run-sequence').use(gulp)
|
var runSequence = require('run-sequence').use(gulp)
|
||||||
|
|
||||||
require('./gulpfile.helper.js')(gulp, {
|
require('./gulpfile.helper.js')(gulp, {
|
||||||
polyfills: ['./node_modules/gulp-babel/node_modules/babel-core/node_modules/regenerator/runtime.js'],
|
polyfills: [],
|
||||||
concatOrder: [
|
files: [
|
||||||
'y.js',
|
'y.js',
|
||||||
'Connector.js',
|
'Connector.js',
|
||||||
'Database.js',
|
'Database.js',
|
||||||
@ -60,7 +60,6 @@ require('./gulpfile.helper.js')(gulp, {
|
|||||||
'Databases/Memory.js',
|
'Databases/Memory.js',
|
||||||
'Databases/IndexedDB.js',
|
'Databases/IndexedDB.js',
|
||||||
'Connectors/Test.js',
|
'Connectors/Test.js',
|
||||||
'Connectors/WebRTC.js',
|
|
||||||
'Types/Array.js',
|
'Types/Array.js',
|
||||||
'Types/Map.js',
|
'Types/Map.js',
|
||||||
'Types/TextBind.js'
|
'Types/TextBind.js'
|
||||||
@ -84,7 +83,7 @@ gulp.task('dev:examples', ['updateSubmodule', 'watch:dist'], function () {
|
|||||||
return $.serve('dist/Examples/')()
|
return $.serve('dist/Examples/')()
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('default', function (cb) {
|
gulp.task('default', ['updateSubmodule'], function (cb) {
|
||||||
gulp.src('package.json')
|
gulp.src('package.json')
|
||||||
.pipe($.prompt.prompt({
|
.pipe($.prompt.prompt({
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
|
10
package.json
10
package.json
@ -43,12 +43,14 @@
|
|||||||
"homepage": "http://y-js.org",
|
"homepage": "http://y-js.org",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-eslint": "^4.1.2",
|
"babel-eslint": "^4.1.2",
|
||||||
|
"browserify": "^12.0.1",
|
||||||
"gulp": "^3.9.0",
|
"gulp": "^3.9.0",
|
||||||
"gulp-babel": "^5.2.1",
|
"gulp-babel": "^5.2.1",
|
||||||
"gulp-bump": "^1.0.0",
|
"gulp-bump": "^1.0.0",
|
||||||
"gulp-concat": "^2.6.0",
|
"gulp-concat": "^2.6.0",
|
||||||
"gulp-filter": "^3.0.1",
|
"gulp-filter": "^3.0.1",
|
||||||
"gulp-git": "^1.6.0",
|
"gulp-git": "^1.6.0",
|
||||||
|
"gulp-if": "^2.0.0",
|
||||||
"gulp-jasmine": "^2.0.1",
|
"gulp-jasmine": "^2.0.1",
|
||||||
"gulp-jasmine-browser": "^0.2.3",
|
"gulp-jasmine-browser": "^0.2.3",
|
||||||
"gulp-load-plugins": "^1.0.0",
|
"gulp-load-plugins": "^1.0.0",
|
||||||
@ -58,12 +60,14 @@
|
|||||||
"gulp-shell": "^0.5.1",
|
"gulp-shell": "^0.5.1",
|
||||||
"gulp-sourcemaps": "^1.5.2",
|
"gulp-sourcemaps": "^1.5.2",
|
||||||
"gulp-tag-version": "^1.3.0",
|
"gulp-tag-version": "^1.3.0",
|
||||||
"gulp-uglify": "^1.4.1",
|
"gulp-uglify": "^1.4.2",
|
||||||
"gulp-util": "^3.0.6",
|
"gulp-util": "^3.0.6",
|
||||||
"gulp-watch": "^4.3.5",
|
"gulp-watch": "^4.3.5",
|
||||||
"minimist": "^1.2.0",
|
"minimist": "^1.2.0",
|
||||||
"pre-commit": "^1.1.1",
|
"pre-commit": "^1.1.1",
|
||||||
"promise-polyfill": "^2.1.0",
|
"run-sequence": "^1.1.4",
|
||||||
"standard": "^5.2.2"
|
"standard": "^5.2.2",
|
||||||
|
"vinyl-buffer": "^1.0.0",
|
||||||
|
"vinyl-source-stream": "^1.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
src/y.js
4
src/y.js
@ -46,6 +46,10 @@ class YConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
window.Y = Y
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof YConcurrency_TestingMode !== 'undefined') {
|
if (typeof YConcurrency_TestingMode !== 'undefined') {
|
||||||
g.Y = Y //eslint-disable-line
|
g.Y = Y //eslint-disable-line
|
||||||
// debugger //eslint-disable-line
|
// debugger //eslint-disable-line
|
||||||
|
Loading…
x
Reference in New Issue
Block a user