Skip to content

Commit

Permalink
Merge pull request #11 from mcfly-io/feat-prod
Browse files Browse the repository at this point in the history
  • Loading branch information
Tallyb authored Jun 10, 2018
2 parents a93d63d + 0b8f371 commit 2c0908b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

[![NPM][npm-nodei-image]][npm-nodei-url]


## Installation
```bash
npm i --save-dev mcfly-semantic-release
Expand All @@ -19,7 +20,13 @@ In your `package.json`
}
```

Optionnaly additional files or files patterns (globs) can be added to also have their version bumped
Running release will do the following:
- Bumps version. By default, this will publish a patch version, if you want to control the semver option you can pass an optional 'patch', 'minor' or 'major' to the `--type` argument.
- Updates version in files: by default it will only update the root level `package.json`. Optionnaly use `--file` to specify file paths or files patterns (globs) that can have their version updated as well. Files can be `package.json` files or `config.xml` files
- Commit the changed files with a standard commit message. Default message is `chore(app): Version <version number>`. Use `--production` to suffix the commit message with the work `production` (can be later used in CI)
- Generates changlog based on Angular standard commit messages.
- Generate a tag with the version number.
- Generates a github release with the version number.

```json
"scripts": {
Expand All @@ -36,8 +43,6 @@ Then, to publish a new version execute the following command:
npm run release
```

By default, this will publish a patch version, if you want to control the semver option you can pass an optional 'patch', 'minor' or 'major' type argument.

**Example :**

```bash
Expand Down
17 changes: 4 additions & 13 deletions bin/mcfly-semantic-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,9 @@ const inquirer = require('inquirer');
const path = require('path');
const versionHelper = require('../lib/versionHelper');
const args = require('yargs')
.option('files', {
type: 'array',
desc: 'Files and files patterns to change'
}).argv;
// var files = args.files ? [].concat(args.files) : [];

// if (files.length === 0) {
// files.push('./package.json');
// }
// files = _.map(files, (file) => {
// return path.isAbsolute(file) ? file : path.join(process.cwd(), file);
// });
.option('files', { type: 'array', desc: 'Files and files patterns to change'})
.option('production', {type: 'boolean', desc: 'Generate production commit message'})
.argv;

var files;
var msg = {};
Expand Down Expand Up @@ -110,7 +101,7 @@ fileHelper.getFiles(args.files)
})
.then((msg) => {
console.log(chalk.yellow('Committing version...'));
return gitHelper.commitVersion(msg.nextVersion)
return gitHelper.commitVersion(msg.nextVersion, args.production)
.then(() => msg);
})
.delay(1000)
Expand Down
5 changes: 3 additions & 2 deletions lib/gitHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ var getCurrentBranch = function() {
});
};

var commitVersion = function(version) {
var commitVersion = function(version, production) {
let commitMessage = `chore(app): Version ${version} ${production ? ' production' : ''} `;
return Promise
.fromCallback((cb) => {
git
.add('./*')
.commit('docs(changelog): version ' + version)
.commit(commitMessage)
.addAnnotatedTag(version, 'v' + version)
.push('origin', 'master')
.pushTags('origin', cb);
Expand Down

0 comments on commit 2c0908b

Please sign in to comment.