cz-jira-smart-commit
Advanced tools
Comparing version 1.0.3 to 2.0.1
37
index.js
@@ -0,1 +1,3 @@ | ||
var inquirer = require('inquirer') | ||
// This can be any kind of SystemJS compatible module. | ||
@@ -26,5 +28,17 @@ // We use Commonjs here, but ES6 or AMD would do just | ||
// collection library if you prefer. | ||
cz.prompt([ | ||
inquirer.prompt([ | ||
{ | ||
type: 'input', | ||
name: 'message', | ||
message: 'GitHub commit message (required):\n', | ||
validate: function(input) { | ||
if (!input) { | ||
return 'empty commit message'; | ||
} else { | ||
return true; | ||
} | ||
} | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'issues', | ||
@@ -42,7 +56,2 @@ message: 'Jira Issue ID(s) (required):\n', | ||
type: 'input', | ||
name: 'time', | ||
message: 'Time spent (i.e. 3h 15m) (optional):\n' | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'workflow', | ||
@@ -60,10 +69,10 @@ message: 'Workflow command (testing, closed, etc.) (optional):\n', | ||
type: 'input', | ||
name: 'time', | ||
message: 'Time spent (i.e. 3h 15m) (optional):\n' | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'comment', | ||
message: 'Jira comment (optional):\n' | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'message', | ||
message: 'Anything else that would be helpful to note (not included in the Jira issue) (optional):\n' | ||
} | ||
], commitAnswers); | ||
@@ -73,7 +82,7 @@ | ||
commit(filter([ | ||
answers.message, | ||
answers.issues, | ||
answers.workflow ? '#' + answers.workflow : undefined, | ||
answers.time ? '#time ' + answers.time : undefined, | ||
answers.comment ? '#comment ' + answers.comment : undefined, | ||
answers.time ? '#time ' + answers.time : undefined, | ||
answers.workflow ? '#' + answers.workflow : undefined, | ||
answers.message ? '\n' + answers.message : undefined | ||
]).join(' ')); | ||
@@ -80,0 +89,0 @@ } |
import sinon from 'sinon'; | ||
import chai from 'chai'; | ||
import sinonChai from 'sinon-chai'; | ||
import {prompter} from './index'; | ||
import proxyquire from 'proxyquire'; | ||
@@ -10,63 +10,54 @@ const {expect} = chai; | ||
describe(`prompter`, () => { | ||
let cz, commit; | ||
beforeEach(() => { | ||
cz = {prompt: sinon.spy()}; | ||
let inquirer, commit, prompter, commitAnswers; | ||
before(() => { | ||
commit = sinon.spy(); | ||
inquirer = {prompt: sinon.spy()}; | ||
prompter = proxyquire('./', {inquirer}).prompter; | ||
}); | ||
it(`call cz.prompt`, () => { | ||
prompter(cz); | ||
expect(cz.prompt).to.have.been.calledWith(sinon.match.array, sinon.match.func); | ||
beforeEach(() => { | ||
prompter(null, commit); | ||
commitAnswers = inquirer.prompt.getCall(0).args[1]; | ||
}); | ||
describe(`commitAnswers`, () => { | ||
let commitAnswers; | ||
beforeEach(() => { | ||
prompter(cz, commit); | ||
commitAnswers = cz.prompt.getCall(0).args[1]; | ||
}); | ||
it(`should call commit with the proper message`, () => { | ||
const message = 'sample commit message'; | ||
const issues = 'CZ-234 CZ-235'; | ||
const workflow = 'closed'; | ||
const time = '3y 2w 7d 8h 30m'; | ||
const comment = 'This took waaaaay too long'; | ||
commitAnswers({message, issues, workflow, time, comment}); | ||
expect(commit).to.have.been.calledWith([ | ||
message, | ||
issues, | ||
`#${workflow}`, | ||
`#time ${time}`, | ||
`#comment ${comment}` | ||
].join(' ')); | ||
}); | ||
it(`should call commit with the proper message`, () => { | ||
['workflow', 'time', 'comment'].forEach((item) => { | ||
it(`should just leave off ${item} if it's not specified`, () => { | ||
const message = 'sample commit message'; | ||
const issues = 'CZ-234 CZ-235'; | ||
const workflow = 'closed'; | ||
const time = '3y 2w 7d 8h 30m'; | ||
const workflow = 'closed'; | ||
const comment = 'This took waaaaay too long'; | ||
const message = 'It would not have been so bad except I got distracted...'; | ||
commitAnswers({issues, time, workflow, comment, message}); | ||
expect(commit).to.have.been.calledWith([ | ||
const answers = {message, issues, workflow, time, comment}; | ||
delete answers[item]; | ||
commitAnswers(answers); | ||
expect(commit).to.have.been.calledWith(filter([ | ||
message, | ||
issues, | ||
`#comment ${comment}`, | ||
`#time ${time}`, | ||
`#${workflow}`, | ||
'\n' + message | ||
].join(' ')); | ||
item !== 'workflow' ? `#${workflow}` : undefined, | ||
item !== 'time' ? `#time ${time}` : undefined, | ||
item !== 'comment' ? `#comment ${comment}` : undefined | ||
]).join(' ')); | ||
}); | ||
['comment', 'time', 'workflow', 'message'].forEach((item) => { | ||
it(`should just leave off ${item} if it's not specified`, () => { | ||
const issues = 'CZ-234 CZ-235'; | ||
const time = '3y 2w 7d 8h 30m'; | ||
const workflow = 'closed'; | ||
const comment = 'This took waaaaay too long'; | ||
const message = 'It would not have been so bad except I got distracted...'; | ||
const answers = {issues, time, workflow, comment, message}; | ||
delete answers[item]; | ||
commitAnswers(answers); | ||
expect(commit).to.have.been.calledWith(filter([ | ||
issues, | ||
item !== 'comment' ? `#comment ${comment}` : undefined, | ||
item !== 'time' ? `#time ${time}` : undefined, | ||
item !== 'workflow' ? `#${workflow}` : undefined, | ||
item !== 'message' ? '\n' + message : undefined | ||
]).join(' ')); | ||
}); | ||
}) | ||
}); | ||
}); | ||
function filter(array) { | ||
return array.filter(function(item) { | ||
return !!item; | ||
}); | ||
return array.filter(Boolean); | ||
} |
{ | ||
"name": "cz-jira-smart-commit", | ||
"version": "1.0.3", | ||
"version": "2.0.1", | ||
"description": "A commitizen adapter for Jira smart commits", | ||
@@ -24,2 +24,5 @@ "main": "index.js", | ||
"author": "Kent C. Dodds <kent@doddsfamily.us> (http://kentcdodds.com/)", | ||
"contributors": [ | ||
"Jane Kim <jane@janekim.me> (http://janekim.me)" | ||
], | ||
"license": "MIT", | ||
@@ -35,6 +38,10 @@ "bugs": { | ||
"nodemon": "1.4.0", | ||
"proxyquire": "^1.7.10", | ||
"sinon": "1.15.4", | ||
"sinon-chai": "2.8.0", | ||
"with-package": "0.2.0" | ||
}, | ||
"dependencies": { | ||
"inquirer": "^1.1.3" | ||
} | ||
} |
# cz-jira-smart-commit | ||
A commitizen adapter for [Jira smart commits](https://confluence.atlassian.com/display/FISHEYE/Using+smart+commits) | ||
A commitizen adapter for [Jira smart commits](https://confluence.atlassian.com/display/FISHEYE/Using+smart+commits). | ||
@@ -25,10 +25,16 @@ ![Screenshot](other/screenshot.png) | ||
or use commitizen to init | ||
``` | ||
commitizen init cz-jira-smart-commit | ||
``` | ||
### Day to day work | ||
Instead of `git commit -m 'Your message'`, you type: `git gz` with this adapter and it prompts you for: | ||
Instead of `git commit -m 'Your message'`, you type: `git cz` with this adapter and it prompts you for: | ||
- commit message | ||
- Jira Issue Key(s) | ||
- Workflow command | ||
- Time Spent | ||
- Workflow command | ||
- Comment | ||
@@ -35,0 +41,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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
43
85882
1
8
8
1
+ Addedinquirer@^1.1.3
+ Addedansi-escapes@1.4.0(transitive)
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedcli-cursor@1.0.2(transitive)
+ Addedcli-width@2.2.1(transitive)
+ Addedcode-point-at@1.1.0(transitive)
+ Addedconcat-stream@1.6.2(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedexit-hook@1.1.1(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedexternal-editor@1.1.1(transitive)
+ Addedfigures@1.7.0(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedinquirer@1.2.3(transitive)
+ Addedis-fullwidth-code-point@1.0.0(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedmute-stream@0.0.6(transitive)
+ Addednumber-is-nan@1.0.1(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedonetime@1.1.0(transitive)
+ Addedos-shim@0.1.3(transitive)
+ Addedos-tmpdir@1.0.2(transitive)
+ Addedpinkie@2.0.4(transitive)
+ Addedpinkie-promise@2.0.1(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedrestore-cursor@1.0.1(transitive)
+ Addedrun-async@2.4.1(transitive)
+ Addedrx@4.1.0(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedspawn-sync@1.0.15(transitive)
+ Addedstring-width@1.0.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedtmp@0.0.29(transitive)
+ Addedtypedarray@0.0.6(transitive)
+ Addedutil-deprecate@1.0.2(transitive)