improving.. breaking.. the gulpfile
This commit is contained in:
parent
0595b7f10c
commit
2ef445fc40
3 changed files with 44 additions and 190 deletions
215
gulpfile.js
215
gulpfile.js
|
@ -1,195 +1,42 @@
|
||||||
/* eslint-env node */
|
/* eslint-env node */
|
||||||
|
|
||||||
/** Gulp Commands
|
|
||||||
|
|
||||||
gulp command*
|
|
||||||
[--export ModuleType]
|
|
||||||
[--name ModuleName]
|
|
||||||
[--testport TestPort]
|
|
||||||
[--testfiles TestFiles]
|
|
||||||
|
|
||||||
Module name (ModuleName):
|
|
||||||
Compile this to "y.js" (default)
|
|
||||||
|
|
||||||
Supported module types (ModuleType):
|
|
||||||
- amd
|
|
||||||
- amdStrict
|
|
||||||
- common
|
|
||||||
- commonStrict
|
|
||||||
- ignore (default)
|
|
||||||
- system
|
|
||||||
- umd
|
|
||||||
- umdStrict
|
|
||||||
|
|
||||||
Test port (TestPort):
|
|
||||||
Serve the specs on port 8888 (default)
|
|
||||||
|
|
||||||
Test files (TestFiles):
|
|
||||||
Specify which specs to use!
|
|
||||||
|
|
||||||
Commands:
|
|
||||||
- build:deploy
|
|
||||||
Build this library for deployment (es6->es5, minified)
|
|
||||||
- dev:browser
|
|
||||||
Watch the ./src directory.
|
|
||||||
Builds the library on changes.
|
|
||||||
Starts an http-server and serves the test suite on http://127.0.0.1:8888.
|
|
||||||
- dev:node
|
|
||||||
Watch the ./src directory.
|
|
||||||
Builds and specs the library on changes.
|
|
||||||
Usefull to run with node-inspector.
|
|
||||||
`node-debug $(which gulp) dev:node
|
|
||||||
- test:
|
|
||||||
Test this library
|
|
||||||
*/
|
|
||||||
|
|
||||||
var gulp = require('gulp')
|
var gulp = require('gulp')
|
||||||
var minimist = require('minimist')
|
|
||||||
var concat = require('gulp-concat')
|
|
||||||
var $ = require('gulp-load-plugins')()
|
var $ = require('gulp-load-plugins')()
|
||||||
|
var runSequence = require('run-sequence').use(gulp)
|
||||||
|
|
||||||
var options = minimist(process.argv.slice(2), {
|
require('../yjs/gulpfile.helper.js')(gulp, {
|
||||||
string: ['export', 'name', 'testport', 'testfiles', 'regenerator'],
|
polyfills: [],
|
||||||
default: {
|
files: [
|
||||||
export: 'ignore',
|
|
||||||
name: 'y-webrtc.js',
|
|
||||||
testport: '8888',
|
|
||||||
testfiles: 'src/**/*.js',
|
|
||||||
regenerator: process.version < 'v0.12'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
var polyfills = [
|
|
||||||
]
|
|
||||||
|
|
||||||
var concatOrder = [
|
|
||||||
'WebRTC.js'
|
'WebRTC.js'
|
||||||
]
|
],
|
||||||
|
targetName: 'y-webrtc.js',
|
||||||
var files = {
|
moduleName: 'y-webrtc',
|
||||||
src: polyfills.concat(concatOrder.map(function (f) {
|
browserify: true
|
||||||
return 'src/' + f
|
|
||||||
})),
|
|
||||||
test: [].concat(concatOrder.map(function (f) {
|
|
||||||
return 'build/' + f
|
|
||||||
}).concat(['build/**/*.spec.js']))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.regenerator) {
|
|
||||||
files.test = polyfills.concat(files.test)
|
|
||||||
}
|
|
||||||
|
|
||||||
gulp.task('deploy:build', function () {
|
|
||||||
return gulp.src(files.src)
|
|
||||||
.pipe($.sourcemaps.init())
|
|
||||||
.pipe(concat('y-webrtc.js'))
|
|
||||||
.pipe($.babel({
|
|
||||||
loose: 'all',
|
|
||||||
modules: 'ignore',
|
|
||||||
experimental: true
|
|
||||||
}))
|
|
||||||
.pipe($.uglify())
|
|
||||||
.pipe($.sourcemaps.write('.'))
|
|
||||||
.pipe(gulp.dest('./dist/'))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('deploy:updateSubmodule', function () {
|
gulp.task('default', ['updateSubmodule'], function (cb) {
|
||||||
return $.git.updateSubmodule({ args: '--init' })
|
gulp.src('package.json')
|
||||||
})
|
.pipe($.prompt.prompt({
|
||||||
|
type: 'checkbox',
|
||||||
gulp.task('deploy:copy', function () {
|
name: 'tasks',
|
||||||
return gulp.src(['README.md'], {base: '.'})
|
message: 'Which tasks would you like to run?',
|
||||||
.pipe(gulp.dest('dist/'))
|
choices: [
|
||||||
})
|
'test Test this project',
|
||||||
|
'dev:browser Watch files & serve the testsuite for the browser',
|
||||||
gulp.task('deploy:bump', function () {
|
'dev:nodejs Watch filse & test this project with nodejs',
|
||||||
return gulp.src(['./package.json', './dist/package.json'], {base: '.'})
|
'bump Bump the current state of the project',
|
||||||
.pipe($.bump({type: 'patch'}))
|
'publish Publish this project. Creates a github tag',
|
||||||
.pipe(gulp.dest('./'))
|
'dist Build the distribution files'
|
||||||
})
|
]
|
||||||
|
}, function (res) {
|
||||||
gulp.task('deploy', ['deploy:updateSubmodule', 'deploy:bump', 'deploy:build', 'deploy:copy'], function () {
|
var tasks = res.tasks.map(function (task) {
|
||||||
return gulp.src('./package.json', {read: false})
|
return task.split(' ')[0]
|
||||||
.pipe($.shell([
|
})
|
||||||
'standard',
|
if (tasks.length > 0) {
|
||||||
'echo "Deploying version <%= getVersion(file.path) %>"',
|
console.info('gulp ' + tasks.join(' '))
|
||||||
'git pull',
|
runSequence(tasks, cb)
|
||||||
'cd ./dist/ && git add -A',
|
} else {
|
||||||
'cd ./dist/ && git commit -am "Deploy <%= getVersion(file.path) %>" -n',
|
console.info('Ok, .. goodbye')
|
||||||
'cd ./dist/ && git push',
|
|
||||||
'cd ./dist/ && git tag -a v<%= getVersion(file.path) %> -m "Release <%= getVersion(file.path) %>"',
|
|
||||||
'cd ./dist/ && git push origin --tags',
|
|
||||||
'git commit -am "Release <%= getVersion(file.path) %>" -n',
|
|
||||||
'git push'
|
|
||||||
], {
|
|
||||||
templateData: {
|
|
||||||
getVersion: function (s) {
|
|
||||||
return require(s).version
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('build:test', function () {
|
|
||||||
var babelOptions = {
|
|
||||||
loose: 'all',
|
|
||||||
modules: 'ignore',
|
|
||||||
experimental: true
|
|
||||||
}
|
|
||||||
if (!options.regenerator) {
|
|
||||||
babelOptions.blacklist = 'regenerator'
|
|
||||||
}
|
|
||||||
gulp.src(files.src)
|
|
||||||
.pipe($.sourcemaps.init())
|
|
||||||
.pipe(concat('y-webrtc.js'))
|
|
||||||
.pipe($.babel(babelOptions))
|
|
||||||
.pipe($.sourcemaps.write())
|
|
||||||
.pipe(gulp.dest('.'))
|
|
||||||
|
|
||||||
return gulp.src('src/**/*.js')
|
|
||||||
.pipe($.sourcemaps.init())
|
|
||||||
.pipe($.babel(babelOptions))
|
|
||||||
.pipe($.sourcemaps.write())
|
|
||||||
.pipe(gulp.dest('build'))
|
|
||||||
})
|
|
||||||
|
|
||||||
gulp.task('dev:node', ['test'], function () {
|
|
||||||
gulp.watch('src/**/*.js', ['test'])
|
|
||||||
})
|
|
||||||
|
|
||||||
gulp.task('dev:browser', ['build:test'], function () {
|
|
||||||
gulp.watch('src/**/*.js', ['build:test'])
|
|
||||||
|
|
||||||
gulp.src(files.test)
|
|
||||||
.pipe($.watch(['build/**/*.js']))
|
|
||||||
.pipe($.jasmineBrowser.specRunner())
|
|
||||||
.pipe($.jasmineBrowser.server({port: options.testport}))
|
|
||||||
})
|
|
||||||
|
|
||||||
gulp.task('dev', ['build:test'], function () {
|
|
||||||
gulp.start('dev:browser')
|
|
||||||
gulp.start('dev:node')
|
|
||||||
})
|
|
||||||
|
|
||||||
gulp.task('copy:dist', ['deploy:build'], function () {
|
|
||||||
return gulp.src(['./dist/y-webrtc.js', './dist/y-webrtc.js.map'])
|
|
||||||
.pipe(gulp.dest('../yjs/dist/Examples/bower_components/y-webrtc/'))
|
|
||||||
})
|
|
||||||
|
|
||||||
gulp.task('dev:examples', ['copy:dist'], function () {
|
|
||||||
return gulp.watch('src/**/*.js', ['copy:dist'])
|
|
||||||
})
|
|
||||||
|
|
||||||
gulp.task('test', ['build:test'], function () {
|
|
||||||
var testfiles = files.test
|
|
||||||
if (typeof Promise === 'undefined') {
|
|
||||||
testfiles.concat(['src/polyfills.js'])
|
|
||||||
}
|
|
||||||
return gulp.src(testfiles)
|
|
||||||
.pipe($.jasmine({
|
|
||||||
verbose: true,
|
|
||||||
includeStuckTrace: true
|
|
||||||
}))
|
|
||||||
})
|
|
||||||
|
|
||||||
gulp.task('default', ['test'])
|
|
||||||
|
|
13
package.json
13
package.json
|
@ -33,11 +33,10 @@
|
||||||
"url": "https://github.com/y-js/y-webrtc/issues"
|
"url": "https://github.com/y-js/y-webrtc/issues"
|
||||||
},
|
},
|
||||||
"homepage": "http://y-js.org",
|
"homepage": "http://y-js.org",
|
||||||
"dependencies": {
|
"dependencies": {},
|
||||||
"simplewebrtc": "^1.19.1"
|
|
||||||
},
|
|
||||||
"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",
|
||||||
|
@ -47,6 +46,8 @@
|
||||||
"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",
|
||||||
|
"gulp-prompt": "^0.1.2",
|
||||||
|
"gulp-rename": "^1.2.2",
|
||||||
"gulp-serve": "^1.2.0",
|
"gulp-serve": "^1.2.0",
|
||||||
"gulp-shell": "^0.5.1",
|
"gulp-shell": "^0.5.1",
|
||||||
"gulp-sourcemaps": "^1.5.2",
|
"gulp-sourcemaps": "^1.5.2",
|
||||||
|
@ -57,6 +58,10 @@
|
||||||
"minimist": "^1.2.0",
|
"minimist": "^1.2.0",
|
||||||
"pre-commit": "^1.1.1",
|
"pre-commit": "^1.1.1",
|
||||||
"promise-polyfill": "^2.1.0",
|
"promise-polyfill": "^2.1.0",
|
||||||
"standard": "^5.2.2"
|
"run-sequence": "^1.1.4",
|
||||||
|
"simplewebrtc": "^1.19.1",
|
||||||
|
"standard": "^5.2.2",
|
||||||
|
"vinyl-buffer": "^1.0.0",
|
||||||
|
"vinyl-source-stream": "^1.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
/* global Y, SimpleWebRTC */
|
/* global Y */
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
var SimpleWebRTC = require('simplewebrtc')
|
||||||
|
|
||||||
class WebRTC extends Y.AbstractConnector {
|
class WebRTC extends Y.AbstractConnector {
|
||||||
constructor (y, options) {
|
constructor (y, options) {
|
||||||
if (options === undefined) {
|
if (options === undefined) {
|
||||||
|
|
Loading…
Reference in a new issue