js-release
Advanced tools
Comparing version 0.1.12 to 0.1.13
@@ -12,3 +12,3 @@ #!/usr/bin/env node | ||
const ignoreStaged = args.indexOf('-i') !== -1 || args.indexOf('--ignore-not-staged') !== -1; | ||
const mode = cmd === 'create' ? args[1] : null; | ||
const mode = cmd === 'release' ? args[1] : null; | ||
@@ -24,5 +24,5 @@ const exit = (err) => { | ||
if (cmd === 'init') return init({ mode, dryRun, ignoreStaged }, exit); | ||
if (cmd === 'create') return release({ mode, dryRun, ignoreStaged }, exit); | ||
if (cmd === 'release') return release({ mode, dryRun, ignoreStaged }, exit); | ||
if (cmd === 'changelog') return changelog({ mode }, exit); | ||
if (cmd !== 'help') console.error(new Error('Unknown command')); | ||
if (cmd !== 'help') console.info('Unknown command !!'); | ||
@@ -36,3 +36,3 @@ console.log(` | ||
* js-release changelog display changelog, merge commits since last release | ||
* js-release create <patch|minor|major> create a new (patch|minor|major) release | ||
* js-release release <patch|minor|major> create a new (patch|minor|major) release | ||
* js-release init create the first release extracted from the package.json version | ||
@@ -39,0 +39,0 @@ |
@@ -64,3 +64,3 @@ const read = require('read'); | ||
services.bumpVersion({ | ||
version: registry.currentVersion, | ||
currentVersion: registry.currentVersion, | ||
dryRun: registry.dryRun, | ||
@@ -67,0 +67,0 @@ }, err => callback(err, registry)); |
@@ -74,3 +74,5 @@ const read = require('read'); | ||
services.bumpVersion({ | ||
version: registry.mode, | ||
mode: registry.mode, | ||
currentVersion: registry.currentVersion, | ||
nextVersion: `v${registry.nextVersion}`, | ||
dryRun: registry.dryRun, | ||
@@ -77,0 +79,0 @@ }, err => callback(err, registry)); |
const exec = require('child_process').exec; | ||
const read = require('read'); | ||
const semver = require('semver'); | ||
const path = require('path'); | ||
const mversion = require('mversion'); | ||
@@ -31,3 +31,2 @@ const clean = str => str.replace(/\n/mg, ''); | ||
console.log('... Checking if repo is master'); | ||
return callback(null, true); | ||
@@ -42,5 +41,4 @@ exec('git rev-parse --abbrev-ref HEAD', (err, stdout) => { | ||
console.log('... Checking if repo has pending modifications'); | ||
return callback(null, true); | ||
return exec('git status --untracked-files=no --porcelain', (err, stdout) => { | ||
exec('git status --untracked-files=no --porcelain', (err, stdout) => { | ||
if (err) return callback(err); | ||
@@ -63,19 +61,25 @@ return callback(null, clean(stdout) === ''); | ||
module.exports.bumpVersion = ({ version, dryRun = false }, callback) => { | ||
module.exports.bumpVersion = ({ | ||
currentVersion, | ||
nextVersion = null, | ||
mode = null, | ||
dryRun = false, | ||
}, callback) => { | ||
console.log('... Create version using mVersion'); | ||
// -m means auto commit + version message | ||
const autoCommit = !semver.valid(version); | ||
const cmd = [ | ||
path.join(__dirname, '..', 'node_modules/.bin/mversion'), | ||
version, | ||
autoCommit ? '-m' : '', | ||
].join(' '); | ||
let options = {}; | ||
// if patch|minor|major | ||
if (mode || (nextVersion && currentVersion !== nextVersion)) { | ||
options = { version: mode, commitMessage: nextVersion }; | ||
} else { | ||
options = { version: currentVersion }; | ||
} | ||
if (dryRun) { | ||
console.log(`[Dry run] ${cmd}`); | ||
console.log(`[Dry run] mversion.update(${JSON.stringify(options)})`); | ||
return callback(); | ||
} | ||
return exec(cmd, callback); | ||
return mversion.update(options, callback); | ||
}; | ||
@@ -82,0 +86,0 @@ |
{ | ||
"name": "js-release", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"description": "Tool to create releases on github", | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -10,3 +10,3 @@ [![bitHound Overall Score](https://www.bithound.io/projects/badges/df14fad0-3fa4-11e7-9e8c-41dfde680279/score.svg)](https://www.bithound.io/github/lemonde/js-release) | ||
* Afficher le changelog, c'est à dire les commits de merge depuis la dernière release : `node cli changelog` | ||
* Créer une release, mode interactif : `node cli create (patch|minor|major)` | ||
* Créer une release, mode interactif : `node cli release (patch|minor|major)` | ||
* Créer une release initiale, mode interactif : `node cli init` |
68490
284