Skip to content

Commit

Permalink
change scripts for release
Browse files Browse the repository at this point in the history
  • Loading branch information
leeluolee committed Sep 29, 2015
1 parent d43bf65 commit 0111250
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"debug" : false, // Allow debugger statements e.g. browser breakpoints.
"eqnull" : true, // Tolerate use of `== null`.
"es5" : false, // Allow EcmaScript 5 syntax.
"esnext" : false, // Allow ES.next specific features such as `const` and `let`.
"esnext" : true, // Allow ES.next specific features such as `const` and `let`.
"evil" : true, // Tolerate use of `eval`.
"expr" : true, // Tolerate `ExpressionStatement` as Programs.
"funcscope" : false, // Tolerate declarations of variables inside of control structures while accessing them later from the outside.
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "regularjs",
"version": "0.3.2",
"version": "0.3.3",
"main": "src/index.js",
"scripts": [
"src/Regular.js",
Expand Down
15 changes: 4 additions & 11 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,16 @@ var through = require('through2');
var before_mocha = require('./test/before_mocha.js');
var pkg;



try{
pkg = require('./package.json')
pkg_bower = require('./bower.json')
pkg_component = require('./component.json')
}catch(e){}

// gulp.task('node', function() {
// return gulp.src('src/node.js')
// .pipe(webpack({
// output: {
// filename: 'regular-parser.js',
// libraryTarget: "umd"
// }
// }
// ))
// .pipe(gulp.dest('dist/'));
// });

require('./scripts/release')(gulp);

gulp.task('default', ['test'], function() {});

Expand Down
67 changes: 67 additions & 0 deletions scripts/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// form https://github.com/lfender6445/gulp-release-tasks/blob/master/package.json
// but stateman also need release to component.json
module.exports = function (gulp) {

var argv = require('yargs').argv;
var bump = require('gulp-bump');
var fs = require('fs');
var git = require('gulp-git');
var runSequence = require('gulp-run-sequence');
var spawn = require('child_process').spawn;
var tag_version = require('gulp-tag-version');
var through = require('through2');

var branch = argv.branch || 'master';
var rootDir = require('path').resolve(argv.rootDir || './') + '/';

var commitIt = function (file, enc, cb) {
if (file.isNull()) return cb(null, file);
if (file.isStream()) return cb(new Error('Streaming not supported'));

var commitMessage = "Bumps version to " + require(file.path).version;
gulp.src('./*.json', {cwd: rootDir}).pipe(git.commit(commitMessage, {cwd: rootDir}));
};

var paths = {
versionsToBump: ['package.json', 'bower.json', 'manifest.json', 'component.json'].map(function (fileName) {
return rootDir + fileName;
})
};

// gulp.task('release', function (cb) {
// runSequence('tag-and-push', 'npm-publish', 'bump', cb);
// });

gulp.task('tag-and-push', function () {
var pkg = require(rootDir + 'package.json');

return gulp.src('./', {cwd: rootDir})
.pipe(tag_version({version: pkg.version, cwd: rootDir}))
.on('end', function () {
git.push('origin', branch, {args: '--tags', cwd: rootDir});
});
});

var versioning = function () {
if (argv.minor) {
return 'minor';
}
if (argv.major) {
return 'major';
}
return 'patch';
};

gulp.task('bump', function () {
gulp.src(paths.versionsToBump, {cwd: rootDir})
.pipe(bump({type: versioning()}))
.pipe(gulp.dest('./', {cwd: rootDir}))
.pipe(through.obj(commitIt))
// .pipe(git.push('origin', branch, {cwd: rootDir}));
});

gulp.task('npm-publish', function (done) {
spawn('npm', ['publish', rootDir], {stdio: 'inherit'}).on('close', done);
});

};

0 comments on commit 0111250

Please sign in to comment.