Skip to content

Commit

Permalink
Updates dependencies and switches to npm scripts
Browse files Browse the repository at this point in the history
No more gulp! npm scripts forever!

gulp lint has been replaced by npm run lint
gulp release has been replaced by npm run release

still need to remove npm test and pull it out.
  • Loading branch information
designfrontier committed Jul 25, 2016
1 parent afd00e9 commit 3abc509
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 74 deletions.
30 changes: 30 additions & 0 deletions bin/lint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/env node
'use strict';

const eslint = require('eslint')
, CLIEngine = eslint.CLIEngine
, linter = new CLIEngine({
useEslintrc: true,
})
, report = linter.executeOnFiles([
'./utils/**/*.js'
, '!./utils/**/*_test.js'
, './routes/**/*.js'
, '!./routes/**/*_test.js'
, './security/**/*.js'
, '!./security/**/*_test.js'
, './web-sockets/**/*.js'
, '!./web-sockets/**/*_test.js'
, '*.js'
, '!*_test.js'
, '!gulpfile.js' ])
, formatter = linter.getFormatter()
, errorCheck = (errorCount, file) => {
return errorCount + file.errorCount;
};

console.log(formatter(report.results));

if (report.results.reduce(errorCheck, 0) > 0) {
process.exit(1);
}
72 changes: 72 additions & 0 deletions bin/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/env node
'use strict';
const minimist = require('minimist')
, cp = require('child-process')
, fs = require('fs')
, chalk = require('chalk')
, knownOptions = {
string: 'type'
, default: { type: 'patch' }
}
, options = minimist(process.argv.slice(2), knownOptions)
, incrementVersion = (version, type) => {
const versionArr = version.split('.');

if (type === 'major') {
versionArr[0] = parseInt(versionArr[0], 10) + 1;
versionArr[1] = 0;
versionArr[2] = 0;
} else if (type === 'minor') {
versionArr[1] = parseInt(versionArr[1], 10) + 1;
versionArr[2] = 0;
} else {
versionArr[2] = parseInt(versionArr[2], 10) + 1;
}

return versionArr.join('.');
}
, pkg = require('../package.json')
, newVersion = incrementVersion(pkg.version, options.type)
, gitLogCommand = 'git log `git describe --tags --abbrev=0`..HEAD --pretty=format:" - %s"';

// this is the task to automat most of the release stuff... because it is lame and boring
console.log(`\n\nPreparing for a ${chalk.bgGreen.bold(options.type)} release...\n\n`);


cp.exec(gitLogCommand, (err, stdout) => {
const history = fs.readFileSync('./history.md')
, historyHeader = `### - ${newVersion} * ${new Date().toLocaleString()} *\n\n`;

console.log('Updating the history.md file');

fs.writeFile('./history.md', `${historyHeader} ${stdout} \n\n\n ${history}`);

cp.exec('git log --all --format="%aN <%aE>" | sort -u', (errLog, stdoutLog) => {
// write out the Authors file with all contributors
console.log('Updating the AUTHORS file');

fs.writeFileSync('./AUTHORS', stdoutLog);

cp.exec('git add .', () => {
cp.exec(`git commit -m "preparing for release of v${newVersion}"`, () => {
console.log('commited the automated updates');
// run npm version
cp.exec(`npm version ${options.type}`, () => {
console.log('npm version to rev for release');
cp.exec('npm publish', () => {
console.log('pushing to origin');

cp.exec('git push origin master', Function.prototype);
cp.exec(`git push origin v${newVersion}`, (errPush) => {
if (errPush) {
console.log(errPush);
}
console.log(chalk.green('DONE! Congrats on the Release!'));
});
});
});

});
});
});
});
Empty file added bin/test.js
Empty file.
74 changes: 2 additions & 72 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,8 @@

const gulp = require('gulp')
, mocha = require('gulp-mocha')
, minimist = require('minimist')
, cp = require('child_process')
, chalk = require('chalk')
, fs = require('fs')
, istanbul = require('gulp-istanbul')
, coveralls = require('gulp-coveralls')
, eslint = require('gulp-eslint')

, pkg = require('./package.json')

, knownOptions = {
string: 'type'
, default: { type: 'patch' }
}

, incrementVersion = (version, type) => {
const versionArr = version.split('.');
Expand All @@ -32,20 +20,9 @@ const gulp = require('gulp')
}

return versionArr.join('.');
}

, options = minimist(process.argv.slice(2), knownOptions);
};

gulp.task('default');

gulp.task('lint', () => {
return gulp.src([ '**/*.js', '!node_modules/**/*', '!coverage/**/*', '!test_stubs/**/*' ])
.pipe(eslint('./.eslintrc'))
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});

gulp.task('test', [ 'lint' ], () => {
gulp.task('test', () => {
return gulp.src([
'./utils/**/*.js'
, '!./utils/**/*_test.js'
Expand Down Expand Up @@ -75,53 +52,6 @@ gulp.task('coveralls', () => {
.pipe(coveralls());
});

gulp.task('release', [ 'test' ], () => {
const newVersion = incrementVersion(pkg.version, options.type)
, gitLogCommand = 'git log `git describe --tags --abbrev=0`..HEAD --pretty=format:" - %s"';

// this is the task to automat most of the release stuff... because it is lame and boring
console.log(`\n\nPreparing for a ${chalk.bgGreen.bold(options.type)} release...\n\n`);


cp.exec(gitLogCommand, (err, stdout) => {
const history = fs.readFileSync('./history.md')
, historyHeader = `### - ${newVersion} * ${new Date().toLocaleString()} *\n\n`;

console.log('Updating the history.md file');

fs.writeFile('./history.md', `${historyHeader} ${stdout} \n\n\n ${history}`);

cp.exec('git log --all --format="%aN <%aE>" | sort -u', (errLog, stdoutLog) => {
// write out the Authors file with all contributors
console.log('Updating the AUTHORS file');

fs.writeFileSync('./AUTHORS', stdoutLog);

cp.exec('git add .', () => {
cp.exec(`git commit -m "preparing for release of v${newVersion}"`, () => {
console.log('commited the automated updates');
// run npm version
cp.exec(`npm version ${options.type}`, () => {
console.log('npm version to rev for release');
cp.exec('npm publish', () => {
console.log('pushing to origin');

cp.exec('git push origin master', Function.prototype);
cp.exec(`git push origin v${newVersion}`, (errPush) => {
if (errPush) {
console.log(errPush);
}
console.log(chalk.green('DONE! Congrats on the Release!'));
});
});
});

});
});
});
});
});

// so we can test the gulpfile
if (typeof exports !== 'undefined') {
exports.incrementVersion = incrementVersion;
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
"main": "index.js",
"scripts": {
"start": "node app.js",
"test": "gulp test",
"codeship": "gulp test && gulp coveralls"
"test": "npm run lint && gulp test",
"codeship": "gulp test && gulp coveralls",
"lint": "bin/lint.js",
"release": "npm test && echo ' => releasing' && bin/release.js"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 3abc509

Please sign in to comment.