Skip to content

Commit

Permalink
update build setup
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 29, 2013
1 parent d8e3853 commit d704fb5
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 54 deletions.
14 changes: 1 addition & 13 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@
"node": true,
"laxbreak": true,
"globals": {
"console": true,
"it": true,
"describe": true,
"before": true,
"after": true,
"assert": true,
"mock": true,
"Vue": true,
"$": true,
"mockHTMLEvent": true,
"mockMouseEvent": true,
"mockKeyEvent": true,
"casper": true
"console": true
}
}
8 changes: 5 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ module.exports = function( grunt ) {
reporter: require('jshint-stylish'),
jshintrc: true
},
dev: {
build: {
src: ['Gruntfile.js', 'tasks/*.js']
},
src: {
src: 'src/**/*.js'
},
test: {
Expand Down Expand Up @@ -61,8 +64,7 @@ module.exports = function( grunt ) {
grunt.registerTask( 'default', [
'jshint',
'build',
'test',
'size'
'test'
])

}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-watch": "~0.5.3",
"grunt-component-build": "~0.4.1",
"grunt-contrib-jshint": "~0.8.0",
"grunt-contrib-uglify": "~0.2.7",
"grunt-mocha": "~0.4.6",
"jscoverage": "~0.3.8",
"jshint-stylish": "~0.1.4",
"semver": "~2.2.1",
"shell-task": "~0.1.1",
"load-grunt-tasks": "~0.2.1"
"map-stream": "0.0.4",
"uglify-js": "~2.4.8",
"vinyl-fs": "git://github.com/wearefractal/vinyl-fs",
"gulp-component": "~0.1.3"
}
}
7 changes: 6 additions & 1 deletion tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,16 @@ function uglify (file, cb) {
function gzip (file, cb) {
zlib.gzip(file.contents, function (err, buf) {
file.contents = buf
file.path = file.path + '.gz'
cb(err, file)
})
}

function size (file, cb) {
console.log(file.relative + ': ' + (file.contents.length / 1024).toFixed(2) + 'kb')
console.log(blue(file.relative + ': ') + (file.contents.length / 1024).toFixed(2) + 'kb')
cb(null, file)
}

function blue (str) {
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m'
}
6 changes: 3 additions & 3 deletions tasks/dev.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
var gulp = require('vinyl-fs'),
var fs = require('vinyl-fs'),
component = require('gulp-component')

module.exports = function (grunt) {
grunt.registerTask('dev', function () {
gulp.src('./component.json')
fs.src('./component.json')
.pipe(component.scripts({
standalone: 'Vue',
name: 'vue'
}))
.pipe(gulp.dest('./dist'))
.pipe(fs.dest('./dist'))
.on('end', this.async())
})
}
16 changes: 10 additions & 6 deletions tasks/instrument.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
var gulp = require('vinyl-fs'),
var fs = require('vinyl-fs'),
component = require('gulp-component'),
jsc = require('gulp-jscoverage')
jsc = require('jscoverage'),
map = require('map-stream')

module.exports = function (grunt) {
grunt.registerTask('instrument', function () {
gulp.src('./component.json')
fs.src('./component.json')
.pipe(component.scripts({
name: 'vue.test'
name: 'vue.test-cov'
}))
.pipe(jsc())
.pipe(gulp.dest('./test'))
.pipe(map(function (file, cb) {
file.contents = new Buffer(jsc.process(file.path, file.contents.toString()))
cb(null, file)
}))
.pipe(fs.dest('./test'))
.on('end', this.async())
})
}
13 changes: 7 additions & 6 deletions tasks/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ module.exports = function (grunt) {

grunt.registerTask('version', function (version) {
;['package', 'bower', 'component'].forEach(function (file) {
file = './' + file + '.json'
file = file + '.json'
var json = grunt.file.read(file)
json = json.replace(/"version"\s*:\s*"(.+?)"/, '"version": "' + version + '"')
grunt.file.write(file, json)
console.log('updated ' + blue(file))
})
})

Expand Down Expand Up @@ -42,11 +43,7 @@ module.exports = function (grunt) {
output: process.stdout
}).question('Releasing version v' + next + '. Continue? (Y/n)', function (answer) {
if (!answer || answer.toLowerCase() === 'y') {
console.log(
'\n\x1b[1m\x1b[34m' +
'Releasing: v' + next +
'\x1b[39m\x1b[22m'
)
console.log(blue('Releasing: v' + next))
grunt.task.run([
'jshint',
'build:' + next,
Expand All @@ -58,4 +55,8 @@ module.exports = function (grunt) {
done()
})
})
}

function blue (str) {
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m'
}
19 changes: 0 additions & 19 deletions tasks/size.js

This file was deleted.

0 comments on commit d704fb5

Please sign in to comment.