cz-conventional-pivotal-tracker
Advanced tools
Comparing version 0.2.0 to 0.3.0
201
index.js
@@ -8,2 +8,3 @@ "format cjs" | ||
const startsWith = require('lodash.startswith') | ||
const git = require('git-rev') | ||
@@ -40,2 +41,9 @@ function readConfigFile() { | ||
function getPivotalTrackerId(cb) { | ||
git.branch(function (str) { | ||
const parts = str.split('-') | ||
const storyId = parts[parts.length - 1] | ||
cb(`#${storyId}`) | ||
}) | ||
} | ||
// This can be any kind of SystemJS compatible module. | ||
@@ -62,109 +70,112 @@ // We use Commonjs here, but ES6 or AMD would do just | ||
// Let's ask some questions of the user | ||
// so that we can populate our commit | ||
// template. | ||
// | ||
// See inquirer.js docs for specifics. | ||
// You can also opt to use another input | ||
// collection library if you prefer. | ||
cz.prompt([ | ||
{ | ||
type: 'list', | ||
name: 'type', | ||
message: 'Select the type of change that you\'re committing:', | ||
choices: getTypes(config), | ||
}, { | ||
type: 'list', | ||
name: 'scope', | ||
message: 'Denote the scope of this change (devops, app, server, etc.):', | ||
choices: getScopes(config).concat([ | ||
new cz.Separator(), | ||
{ name: 'empty', value: false }, | ||
{ name: 'custom', value: 'custom' }, | ||
]), | ||
when: function(answers) { | ||
return getScopes(config).length | ||
} | ||
}, { | ||
type: 'input', | ||
name: 'scope', | ||
message: 'Denote the SCOPE of this change:', | ||
when: function(answers) { | ||
return !getScopes(config).length || answers.scope === 'custom' | ||
} | ||
}, { | ||
type: 'input', | ||
name: 'subject', | ||
message: 'Write a short, imperative tense description of the change:\n' | ||
}, { | ||
type: 'input', | ||
name: 'body', | ||
message: 'Provide a longer description of the change:\n' | ||
}, { | ||
type: 'input', | ||
name: 'footer', | ||
message: 'List any breaking changes:\n' | ||
}, { | ||
type: 'input', | ||
name: 'story', | ||
message: 'Pivotal Tracker Story ID:\n', | ||
validate: function(input) { | ||
if (input && !startsWith(input, '\#')) { | ||
return 'Pivotal Tracker Story ID must start with \'#\''; | ||
} else { | ||
return true; | ||
getPivotalTrackerId(function(storyId) { | ||
// Let's ask some questions of the user | ||
// so that we can populate our commit | ||
// template. | ||
// | ||
// See inquirer.js docs for specifics. | ||
// You can also opt to use another input | ||
// collection library if you prefer. | ||
cz.prompt([ | ||
{ | ||
type: 'list', | ||
name: 'type', | ||
message: 'Select the type of change that you\'re committing:', | ||
choices: getTypes(config), | ||
}, { | ||
type: 'list', | ||
name: 'scope', | ||
message: 'Denote the scope of this change (devops, app, server, etc.):', | ||
choices: getScopes(config).concat([ | ||
new cz.Separator(), | ||
{ name: 'empty', value: false }, | ||
{ name: 'custom', value: 'custom' }, | ||
]), | ||
when: function(answers) { | ||
return getScopes(config).length | ||
} | ||
}, { | ||
type: 'input', | ||
name: 'scope', | ||
message: 'Denote the SCOPE of this change:', | ||
when: function(answers) { | ||
return !getScopes(config).length || answers.scope === 'custom' | ||
} | ||
}, { | ||
type: 'input', | ||
name: 'subject', | ||
message: 'Write a short, imperative tense description of the change:\n' | ||
}, { | ||
type: 'input', | ||
name: 'body', | ||
message: 'Provide a longer description of the change:\n' | ||
}, { | ||
type: 'input', | ||
name: 'footer', | ||
message: 'List any breaking changes:\n' | ||
}, { | ||
type: 'input', | ||
name: 'story', | ||
message: 'Pivotal Tracker Story ID:\n', | ||
default: storyId, | ||
validate: function(input) { | ||
if (input && !startsWith(input, '\#')) { | ||
return 'Pivotal Tracker Story ID must start with \'#\''; | ||
} else { | ||
return true; | ||
} | ||
} | ||
}, { | ||
type: 'list', | ||
name: 'workflow', | ||
message: 'Workflow command (testing, closed, etc.) (optional):\n', | ||
choices: [ | ||
{name: 'Finishes'}, | ||
{name: 'Fixes'}, | ||
{name: 'Delivers'}, | ||
new cz.Separator(), | ||
{ name: 'none', value: false }, | ||
], | ||
when: function(answers) { | ||
return answers.story | ||
} | ||
} | ||
}, { | ||
type: 'list', | ||
name: 'workflow', | ||
message: 'Workflow command (testing, closed, etc.) (optional):\n', | ||
choices: [ | ||
{name: 'Finishes'}, | ||
{name: 'Fixes'}, | ||
{name: 'Delivers'}, | ||
new cz.Separator(), | ||
{ name: 'none', value: false }, | ||
], | ||
when: function(answers) { | ||
return answers.story | ||
} | ||
} | ||
]).then(function(answers) { | ||
]).then(function(answers) { | ||
var maxLineWidth = 100 | ||
var headTrimLength = maxLineWidth | ||
var maxLineWidth = 100 | ||
var headTrimLength = maxLineWidth | ||
var wrapOptions = { | ||
trim: true, | ||
newline: '\n', | ||
indent:'', | ||
width: maxLineWidth | ||
} | ||
var wrapOptions = { | ||
trim: true, | ||
newline: '\n', | ||
indent:'', | ||
width: maxLineWidth | ||
} | ||
// parentheses are only needed when a scope is present. | ||
var scope = answers.scope.trim() | ||
scope = scope ? '(' + answers.scope.trim() + ')' : '' | ||
// parentheses are only needed when a scope is present. | ||
var scope = answers.scope.trim() | ||
scope = scope ? '(' + answers.scope.trim() + ')' : '' | ||
// Hard limit this line | ||
var subject = answers.type + scope + ': ' + answers.subject.trim() | ||
var pt = '' | ||
// Hard limit this line | ||
var subject = answers.type + scope + ': ' + answers.subject.trim() | ||
var pt = '' | ||
// Add the story Pivotal Tracker story ID. | ||
if (answers.story) { | ||
const workflow = answers.workflow ? `${answers.workflow} ` : '' | ||
pt = ` [${workflow}${answers.story}]` | ||
headTrimLength = maxLineWidth - pt.length | ||
} | ||
// Add the story Pivotal Tracker story ID. | ||
if (answers.story) { | ||
const workflow = answers.workflow ? `${answers.workflow} ` : '' | ||
pt = ` [${workflow}${answers.story}]` | ||
headTrimLength = maxLineWidth - pt.length | ||
} | ||
// Hard limit this line. | ||
var head = (subject).slice(0, headTrimLength) + pt | ||
// Hard limit this line. | ||
var head = (subject).slice(0, headTrimLength) + pt | ||
// Wrap these lines at 100 characters. | ||
var body = wrap(answers.body, wrapOptions) | ||
var footer = wrap(answers.footer, wrapOptions) | ||
// Wrap these lines at 100 characters. | ||
var body = wrap(answers.body, wrapOptions) | ||
var footer = wrap(answers.footer, wrapOptions) | ||
commit(head + '\n\n' + body + '\n\n' + footer) | ||
commit(head + '\n\n' + body + '\n\n' + footer) | ||
}) | ||
}) | ||
} | ||
} |
{ | ||
"name": "cz-conventional-pivotal-tracker", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "A commitizen adapter with support for Pivotal Tracker.", | ||
@@ -24,2 +24,3 @@ "main": "index.js", | ||
"find-config": "^1.0.0", | ||
"git-rev": "^0.2.1", | ||
"lodash.padend": "^4.6.0", | ||
@@ -26,0 +27,0 @@ "lodash.startswith": "^4.2.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7640
161
5
+ Addedgit-rev@^0.2.1
+ Addedgit-rev@0.2.1(transitive)