Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
feat: add support for lerna mono-repos
Browse files Browse the repository at this point in the history
If the project is a lerna mono-repo it will add an extra question about
the packages the commit affected
  • Loading branch information
carpasse committed Jun 20, 2017
1 parent 1187335 commit 11cbde4
Show file tree
Hide file tree
Showing 12 changed files with 3,458 additions and 164 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
*.log
*.swo
*.swp
.DS_Store
.idea/
node_modules/
npm-debug.log
yarn.lock
yarn.lock
8 changes: 0 additions & 8 deletions .jscsrc

This file was deleted.

25 changes: 0 additions & 25 deletions .jshintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6
8
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

# mol-conventional-changelog


## Setup

Install commitizen
Expand Down Expand Up @@ -95,6 +94,10 @@ The subject contains succinct description of the change:
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
The body should include the motivation for the change and contrast this with previous behavior.

#### Affects [only on [lerna](https://lernajs.io/) environments]

Select the packages the commit affected.

### Breaking Changes

**Breaking Changes** must start with the words `BREAKING CHANGE: `.
Expand Down
123 changes: 2 additions & 121 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,122 +1,3 @@
'use strict';
const {prompter} = require('./src/index');

const inquirer = require('inquirer');
const wrap = require('word-wrap');

inquirer.registerPrompt('limitedInput', require('./prompt/LimitedInput'));

const MAX_SUBJECT_LENGTH = 50;
const MAX_LINE_WIDTH = 72;
const MIN_SUBJECT_LENGTH = 3;
const MIN_SUBJECT_LENGTH_ERROR_MESSAGE = `The subject must have at least ${MIN_SUBJECT_LENGTH} characters`;

module.exports = {
prompter (cz, commit) {
return inquirer.prompt([
{
choices: [
{
name: 'feat: A new feature',
value: 'feat'
},
{
name: 'fix: A bug fix',
value: 'fix'
},
{
name: 'docs: Documentation only changes',
value: 'docs'
},
{
name: 'style: Changes that do not affect the meaning of the code\n (white-space, formatting, missing semi-colons, etc)',
value: 'style'
},
{
name: 'refactor: A code change that neither fixes a bug or adds a feature',
value: 'refactor'
},
{
name: 'perf: A code change that improves performance',
value: 'perf'
},
{
name: 'test: Adding missing tests',
value: 'test'
},
{
name: 'chore: Changes to the build process or auxiliary tools\n and libraries such as documentation generation',
value: 'chore'
}
],
message: 'Select the type of change that you\'re committing:',
name: 'type',
type: 'list'
},
{
filter: (input) => {
let subject;

subject = input.trim();
while (subject.endsWith('.')) {
subject = subject.substr(0, subject.length - 1).trim();
}

return subject;
},
leadingLabel: (answers) => `${answers.type}:`,
maxLength: MAX_SUBJECT_LENGTH,
message: 'Write a short, imperative mood description of the change:',
name: 'subject',
type: 'limitedInput',
validate: (input) => input.length >= MIN_SUBJECT_LENGTH || MIN_SUBJECT_LENGTH_ERROR_MESSAGE
},
{
message: 'Provide a longer description of the change:\n',
name: 'body',
type: 'input'
},
{
message: 'List any breaking changes:\n BREAKING CHANGE:',
name: 'breaking',
type: 'input'
},
{
message: 'Reference any task that this commit closes:\n Issues:',
name: 'footer',
type: 'input'
}
])
.then((answers) => {
const wrapOptions = {
indent: '',
trim: true,
width: MAX_LINE_WIDTH
};

const head = answers.type + ': ' + answers.subject;

// Wrap these lines at MAX_LINE_WIDTH characters
const body = wrap(answers.body, wrapOptions);
const breaking = wrap(answers.breaking, wrapOptions);
const footer = wrap(answers.footer, wrapOptions);

let msg;

msg = head;

if (body) {
msg += '\n\n' + body;
}

if (breaking) {
msg += '\n\nBREAKING CHANGE: ' + breaking;
}

if (footer) {
msg += '\n\nIssues: ' + footer;
}

return commit(msg);
});
}
};
module.exports = {prompter};
Loading

0 comments on commit 11cbde4

Please sign in to comment.