Skip to content

Commit

Permalink
Merge pull request #8 from leonardoanalista/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
leonardoanalista committed Nov 18, 2015
2 parents 070fd69 + 0ac3fb8 commit b412a96
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 17 deletions.
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ This is a customizable Commitizen plugin. You can specify the commit types, scop
## Steps:
- install commitizen case you don't have it: `npm install -g commitizen`
- install the cz-customizable: `npm install cz-customizable --save-dev`
- configure `commitizen` to use `cz-customizable` as plugin. There are a few ways to do this.
- Option 1: change your `package.json`
- configure `commitizen` to use `cz-customizable` as plugin. Add those lines to your `package.json`:
```
...
"config": {
Expand All @@ -18,15 +17,11 @@ This is a customizable Commitizen plugin. You can specify the commit types, scop
}
}
```
- Option 2: Create a file called `.cz.json`
```
{
"path": "node_modules/cz-customizable"
}
```
- the `postinstall` script will automatically create a `.cz-config` in the root of your project. It also crates a symlink inside `node_modules/cz-customizable` to point to your config file.

- the `postinstall` script will automatically create a `.cz-config` in the root of your project *if it doesn't exsit*. It also creates a symlink inside `node_modules/cz-customizable` to point to your config file.

- you should commit your `.cz-config.js` file to your git.

* if you don't provide a config file, this adapter will use the contents of the default file `node_modules/cz-customizable/cz-config-EXAMPLE.js`


Expand All @@ -35,15 +30,15 @@ From now on, instead of `git commit` you type `git cz` and let the tool do the w
Hopefully this will help you to have consistent commit messages and have a fully automated deployemnt without any human intervention.

## Related tools:
- https://github.com/commitizen/cz-cli
- https://github.com/stevemao/conventional-recommended-bump
- https://github.com/semantic-release/semantic-release
- (https://github.com/commitizen/cz-cli)
- (https://github.com/stevemao/conventional-recommended-bump)
- (https://github.com/semantic-release/semantic-release)


It prompts for [conventional changelog](https://github.com/ajoslin/conventional-changelog/blob/master/conventions/angular.md) standard.


## Troubleshooting:
## Troubleshooting:
### you can't see the file `.cz-config` in the root of your porject.
- you can manually copy from `node_modules/cz-customizable/cz-config-EXAMPLE.js` to your project root (where your package.json is) and rename to `.cz-config.js`

Expand All @@ -57,4 +52,11 @@ It prompts for [conventional changelog](https://github.com/ajoslin/conventional-
- Windows (something like this): ```mklink /D node_modules\cz-customizable\.cz-config.js ..\..\.cz-config.js```


Please feel free to send any suggestion.
## CONTRIBUTING

Please refer to the [Contributor Guidelines](https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md) and [Conduct of Code](https://github.com/angular/code-of-conduct/blob/master/CODE_OF_CONDUCT.md) from [AngularJs](https://github.com/angular/angular.js) project.




Leonardo Correa
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ module.exports = {

prompter: function(cz, commit) {
var config = readConfigFile();
config.scopeOverrides = config.scopeOverrides || {};

log.info('\n\nLine 1 will be cropped at 100 characters. All other lines will be wrapped after 100 characters.\n');

Expand Down Expand Up @@ -131,7 +132,6 @@ module.exports = {

var commitStr = buildCommit(answers);
commit(commitStr);
// log.info('<<< this is dry run >>>');
});
}
};
54 changes: 52 additions & 2 deletions spec/czCustomizableSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('cz-customizable', function() {
scope: 'myScope',
subject: 'create a new cool feature'
};
expect(getQuestion(6).message(answers)).toMatch('Are you sure');
expect(getQuestion(6).message(answers)).toMatch('Are you sure you want to proceed with the commit above?');
});

it('should call not call commit() function if there is no final confirmation', function() {
Expand All @@ -90,7 +90,7 @@ describe('cz-customizable', function() {
expect(commit).not.toHaveBeenCalled();
});

it('should call commit() function with commit message when user confirms commit', function() {
it('should call commit() function with commit message when user confirms commit and split body when pipes are present', function() {
module.prompter(cz, commit);
var commitAnswers = cz.prompt.mostRecentCall.args[1];

Expand Down Expand Up @@ -168,4 +168,54 @@ describe('cz-customizable', function() {

});



describe('optional fixOverride', function() {

beforeEach(function() {
module.__set__({
readConfigFile: function() {
return {
types: [{value: 'feat', name: 'feat: my feat'}],
scopes: [{name: 'myScope'}]
};
}
});

cz = {prompt: jasmine.createSpy()};
commit = jasmine.createSpy();
});


it('should call cz.prompt with questions', function() {
module.prompter(cz, commit);

var getQuestion = function(number) {
return cz.prompt.mostRecentCall.args[0][number - 1];
};

//question 1
expect(getQuestion(1).name).toEqual('type');
expect(getQuestion(1).type).toEqual('list');
expect(getQuestion(1).choices[0]).toEqual({value: 'feat', name: 'feat: my feat'});

//question 2
expect(getQuestion(2).name).toEqual('scope');
expect(getQuestion(2).choices({})[0]).toEqual({name: 'myScope'});
expect(getQuestion(2).choices({type: 'fix'})[0]).toEqual({name: 'myScope'}); //should override scope
expect(getQuestion(2).when({type: 'fix'})).toEqual(true);
expect(getQuestion(2).when({type: 'WIP'})).toEqual(false);
expect(getQuestion(2).when({type: 'wip'})).toEqual(false);

var answers = {
confirmCommit: true,
type: 'feat',
scope: 'myScope',
subject: 'create a new cool feature'
};
expect(getQuestion(6).message(answers)).toMatch('Are you sure you want to proceed with the commit above?');
});
});


});

0 comments on commit b412a96

Please sign in to comment.