Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cz-jira-smart-commit

Package Overview
Dependencies
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cz-jira-smart-commit - npm Package Compare versions

Comparing version 2.0.1 to 3.0.0

install.sh

27

index.js

@@ -6,3 +6,6 @@ var inquirer = require('inquirer')

// fine.
module.exports = {prompter: prompter};
module.exports = {
prompter: prompter,
formatCommit: formatCommit
};

@@ -76,13 +79,15 @@ // When a user runs `git cz`, prompter will

},
], commitAnswers);
]).then((answers) => {
formatCommit(commit, answers);
});
}
function commitAnswers(answers) {
commit(filter([
answers.message,
answers.issues,
answers.workflow ? '#' + answers.workflow : undefined,
answers.time ? '#time ' + answers.time : undefined,
answers.comment ? '#comment ' + answers.comment : undefined,
]).join(' '));
}
function formatCommit(commit, answers) {
commit(filter([
answers.message,
answers.issues,
answers.workflow ? '#' + answers.workflow : undefined,
answers.time ? '#time ' + answers.time : undefined,
answers.comment ? '#comment ' + answers.comment : undefined,
]).join(' '));
}

@@ -89,0 +94,0 @@

@@ -1,62 +0,46 @@

import sinon from 'sinon';
import chai from 'chai';
import sinonChai from 'sinon-chai';
import proxyquire from 'proxyquire';
const {expect} = chai;
const sinon = require('sinon');
const chai = require('chai');
const sinonChai = require('sinon-chai');
const expect = chai.expect;
chai.use(sinonChai);
describe(`prompter`, () => {
let inquirer, commit, prompter, commitAnswers;
const czJiraSmartCommit = require('./index.js');
before(() => {
commit = sinon.spy();
inquirer = {prompt: sinon.spy()};
prompter = proxyquire('./', {inquirer}).prompter;
describe('prompt for inputs', () => {
it('should be a function', () => {
expect(czJiraSmartCommit.prompter).to.be.a('function');
});
});
beforeEach(() => {
prompter(null, commit);
commitAnswers = inquirer.prompt.getCall(0).args[1];
});
describe('format commits', () => {
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(' '));
});
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';
['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 comment = 'This took waaaaay too long';
const answers = {message, issues, workflow, time, comment};
delete answers[item];
commitAnswers(answers);
expect(commit).to.have.been.calledWith(filter([
message,
issues,
item !== 'workflow' ? `#${workflow}` : undefined,
item !== 'time' ? `#time ${time}` : undefined,
item !== 'comment' ? `#comment ${comment}` : undefined
]).join(' '));
});
it('should be a function', () => {
expect(czJiraSmartCommit.formatCommit).to.be.a('function');
});
it('should perform a full commit', () => {
czJiraSmartCommit.formatCommit((result) => {
expect(result).to.equal('sample commit message CZ-234 CZ-235 #closed #time 3y 2w 7d 8h 30m #comment This took waaaaay too long')
}, {message, issues, workflow, time, comment});
});
it('should commit without a workflow', () => {
czJiraSmartCommit.formatCommit((result) => {
expect(result).to.equal('sample commit message CZ-234 CZ-235 #time 3y 2w 7d 8h 30m #comment This took waaaaay too long')
}, {message, issues, time, comment});
});
it('should commit without a time', () => {
czJiraSmartCommit.formatCommit((result) => {
expect(result).to.equal('sample commit message CZ-234 CZ-235 #closed #comment This took waaaaay too long')
}, {message, issues, workflow, comment});
});
it('should commit without a comment', () => {
czJiraSmartCommit.formatCommit((result) => {
expect(result).to.equal('sample commit message CZ-234 CZ-235 #closed #time 3y 2w 7d 8h 30m')
}, {message, issues, workflow, time});
});
});
function filter(array) {
return array.filter(Boolean);
}
{
"name": "cz-jira-smart-commit",
"version": "2.0.1",
"version": "3.0.0",
"description": "A commitizen adapter for Jira smart commits",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,2 +9,12 @@ # cz-jira-smart-commit

### Global Installation
For a quick global installation of the plugin, simply run the `install.sh` script present in this repo:
```
chmod +x install.sh
./install.sh
```
### Add this adapter

@@ -11,0 +21,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc