New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hiflow

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hiflow - npm Package Compare versions

Comparing version 0.3.3 to 0.3.4-rc.1

bin/t.js

16

bin/args.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {

var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties2 = require("babel-runtime/helpers/objectWithoutProperties");
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _yargs = require('yargs');
var _yargs = require("yargs");

@@ -19,5 +19,3 @@ var _yargs2 = _interopRequireDefault(_yargs);

const {
argv
} = _yargs2.default;
const { argv } = _yargs2.default;

@@ -32,3 +30,3 @@ const {

} = argv,
args = (0, _objectWithoutProperties3.default)(argv, ['_', 'verbose', 'v', 'create', 'smart', 'status']);
args = (0, _objectWithoutProperties3.default)(argv, ["_", "verbose", "v", "create", "smart", "status"]);

@@ -44,3 +42,3 @@ exports._ = _;

const [cliCommand = 'help', actionType] = _;
const [cliCommand = "help", actionType] = _;

@@ -51,3 +49,3 @@ const command = exports.command = cliCommand;

const HOME = exports.HOME = require('os').homedir();
const HOME = exports.HOME = require("os").homedir();
//# sourceMappingURL=args.js.map

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {

var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _util = require('util');
var _util = require("util");

@@ -18,3 +18,3 @@ var _util2 = _interopRequireDefault(_util);

const exec = _util2.default.promisify(require('child_process').exec);
const exec = _util2.default.promisify(require("child_process").exec);

@@ -39,3 +39,3 @@ exports.default = (() => {

module.exports = exports['default'];
module.exports = exports["default"];
//# sourceMappingURL=async-exec.js.map

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -7,3 +7,3 @@ Object.defineProperty(exports, "__esModule", {

var _promise = require('babel-runtime/core-js/promise');
var _promise = require("babel-runtime/core-js/promise");

@@ -20,13 +20,13 @@ var _promise2 = _interopRequireDefault(_promise);

var _axios = require('axios');
var _axios = require("axios");
var _axios2 = _interopRequireDefault(_axios);
var _chalk = require('chalk');
var _chalk = require("chalk");
var _chalk2 = _interopRequireDefault(_chalk);
var _config = require('./config');
var _config = require("./config");
var _gitCli = require('./git-cli');
var _gitCli = require("./git-cli");

@@ -54,6 +54,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

url,
method: method || 'get',
method: method || "get",
data: params,
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Basic ${BITBUCKET_TOKEN}`

@@ -70,7 +70,7 @@ }

function getPullRequests() {
return bitbucketRequest(buildAPIUrl('pullrequests')).then(data => data.values);
return bitbucketRequest(buildAPIUrl("pullrequests")).then(data => data.values);
}
function createPullRequest(data) {
return bitbucketRequest(buildAPIUrl('pullrequests'), data, 'POST');
return bitbucketRequest(buildAPIUrl("pullrequests"), data, "POST");
}

@@ -88,3 +88,3 @@

function getRepositoryDefaultReviewers() {
return bitbucketRequest(buildAPIUrl('default-reviewers')).then(data => data && data.values ? data.values : []).catch(e => {
return bitbucketRequest(buildAPIUrl("default-reviewers")).then(data => data && data.values ? data.values : []).catch(e => {
console.log(_chalk2.default.yellow("You don't have access to default reviewers."));

@@ -98,4 +98,4 @@ return [];

function addPullRequestComment(prId, comment) {
return bitbucketRequest(`${BITBUCKET_API_BASEURL_VERSION1}/pullrequests/${prId}/comments`, comment, 'post');
return bitbucketRequest(`${BITBUCKET_API_BASEURL_VERSION1}/pullrequests/${prId}/comments`, comment, "post");
}
//# sourceMappingURL=bitbucket.js.map

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -7,3 +7,3 @@ Object.defineProperty(exports, "__esModule", {

var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");

@@ -20,10 +20,10 @@ var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);

if (currentBranch === 'master') {
if (currentBranch === "master") {
const { doHotfix } = yield _inquirer2.default.prompt({
type: 'confirm',
name: 'doHotfix',
message: 'Do you want to do a hotfix?'
type: "confirm",
name: "doHotfix",
message: "Do you want to do a hotfix?"
});
console.log(doHotfix);
if (doHotfix) branchType = 'hotfix';
if (doHotfix) branchType = "hotfix";
}

@@ -33,7 +33,7 @@

const { type } = yield _inquirer2.default.prompt({
type: 'list',
name: 'type',
message: 'What type of branch?',
choices: ['feature', 'improvement', 'fix', 'hotfix', 'release'],
default: 'feature',
type: "list",
name: "type",
message: "What type of branch?",
choices: ["feature", "improvement", "fix", "hotfix", "release"],
default: "feature",
validate: function (val) {

@@ -51,5 +51,5 @@ return !!val;

const { issue } = yield _inquirer2.default.prompt({
type: 'input',
name: 'issue',
message: branchType === 'release' ? 'Version:' : 'Issue name:',
type: "input",
name: "issue",
message: branchType === "release" ? "Version:" : "Issue name:",
validate: function (val) {

@@ -63,3 +63,3 @@ return !!val;

console.log(_chalk2.default.green('Yes! I\'m excited about this.'));
console.log(_chalk2.default.green("Yes! I'm excited about this."));
(0, _gitCli.createBranch)(`${branchType}/${issue}`);

@@ -80,11 +80,11 @@

var _inquirer = require('inquirer');
var _inquirer = require("inquirer");
var _inquirer2 = _interopRequireDefault(_inquirer);
var _chalk = require('chalk');
var _chalk = require("chalk");
var _chalk2 = _interopRequireDefault(_chalk);
var _gitCli = require('./git-cli');
var _gitCli = require("./git-cli");

@@ -91,0 +91,0 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -8,3 +8,3 @@ Object.defineProperty(exports, "__esModule", {

var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");

@@ -16,3 +16,3 @@ var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);

const currentBranch = (0, _gitCli.getBranch)();
const initialMessage = typeof smart === 'string' ? smart : message;
const initialMessage = typeof smart === "string" ? smart : message;
let smartMessage;

@@ -22,4 +22,4 @@

const { addmessage } = yield _inquirer2.default.prompt({
type: 'input',
name: 'addmessage',
type: "input",
name: "addmessage",
message: `${currentBranch}:`,

@@ -40,5 +40,5 @@ validate: function (val) {

const { issue } = yield _inquirer2.default.prompt({
type: 'input',
name: 'issue',
message: 'Issue:',
type: "input",
name: "issue",
message: "Issue:",
default: issueName,

@@ -54,6 +54,6 @@ validate: function (val) {

const { time } = yield _inquirer2.default.prompt({
type: 'input',
name: 'time',
message: 'How much time have you spent? w/d/h/m/(s)kip',
default: 'skip',
type: "input",
name: "time",
message: "How much time have you spent? w/d/h/m/(s)kip",
default: "skip",
validate: function (val) {

@@ -67,10 +67,10 @@ return !!val;

if (time.includes('w') || time.includes('d') || time.includes('h') || time.includes('m')) {
if (time.includes("w") || time.includes("d") || time.includes("h") || time.includes("m")) {
smartMessage = `${issue} #time ${time}`;
} else {
console.log(_chalk2.default.magenta('No time was tracked'));
console.log(_chalk2.default.magenta("No time was tracked"));
}
}
const completeMessage = `${commitMessage}${smartMessage ? `\n\n${smartMessage}` : ''}`;
const completeMessage = `${commitMessage}${smartMessage ? `\n\n${smartMessage}` : ""}`;
execCommit(completeMessage);

@@ -80,6 +80,6 @@

if ([3, 7].includes(randomNum)) {
console.log(_chalk2.default.yellow('Nailed it!'));
console.log(_chalk2.default.yellow("Nailed it!"));
}
if ([2, 5].includes(randomNum)) {
console.log(_chalk2.default.cyan('Mmmm, the people are gonna like that!'));
console.log(_chalk2.default.cyan("Mmmm, the people are gonna like that!"));
}

@@ -105,9 +105,9 @@

console.log(_chalk2.default.magenta(e.message));
if (e.message.startsWith('Command failed')) {
console.log(_chalk2.default.yellow('Did you add your changes?'));
if (e.message.startsWith("Command failed")) {
console.log(_chalk2.default.yellow("Did you add your changes?"));
}
} else {
console.log(_chalk2.default.yellow('There was an unknown error.'));
console.log(_chalk2.default.yellow("There was an unknown error."));
}
return '';
return "";
}

@@ -125,13 +125,13 @@ });

var _inquirer = require('inquirer');
var _inquirer = require("inquirer");
var _inquirer2 = _interopRequireDefault(_inquirer);
var _chalk = require('chalk');
var _chalk = require("chalk");
var _chalk2 = _interopRequireDefault(_chalk);
var _config = require('./config');
var _config = require("./config");
var _gitCli = require('./git-cli');
var _gitCli = require("./git-cli");

@@ -141,3 +141,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function getIssueFromBranch(branch) {
const [type, issue] = branch.split('/');
const [type, issue] = branch.split("/");
return issue;

@@ -144,0 +144,0 @@ }

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -8,15 +8,15 @@ Object.defineProperty(exports, "__esModule", {

var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends2 = require("babel-runtime/helpers/extends");
var _extends3 = _interopRequireDefault(_extends2);
var _keys = require('babel-runtime/core-js/object/keys');
var _keys = require("babel-runtime/core-js/object/keys");
var _keys2 = _interopRequireDefault(_keys);
var _promise = require('babel-runtime/core-js/promise');
var _promise = require("babel-runtime/core-js/promise");

@@ -30,8 +30,8 @@ var _promise2 = _interopRequireDefault(_promise);

if (!token || token.length < 1) {
console.log(_chalk2.default.yellow('This feature requires bitbucket access.'));
console.log(_chalk2.default.cyan('Let\'s login to your account!'));
console.log(_chalk2.default.yellow("This feature requires bitbucket access."));
console.log(_chalk2.default.cyan("Let's login to your account!"));
return runSetup();
}
return _promise2.default.resolve('success');
return _promise2.default.resolve("success");
});

@@ -54,15 +54,15 @@

var _fs = require('fs');
var _fs = require("fs");
var _fs2 = _interopRequireDefault(_fs);
var _inquirer = require('inquirer');
var _inquirer = require("inquirer");
var _inquirer2 = _interopRequireDefault(_inquirer);
var _chalk = require('chalk');
var _chalk = require("chalk");
var _chalk2 = _interopRequireDefault(_chalk);
var _args = require('./args');
var _args = require("./args");

@@ -74,3 +74,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function writeConfigFile(path, content) {
return new _promise2.default((resolve, reject) => _fs2.default.writeFile(path, content, 'utf8', err => err ? reject(err) : resolve()));
return new _promise2.default((resolve, reject) => _fs2.default.writeFile(path, content, "utf8", err => err ? reject(err) : resolve()));
}

@@ -82,3 +82,3 @@

return memo;
}, []).join('\n');
}, []).join("\n");
}

@@ -88,12 +88,12 @@

if (_fs2.default.existsSync(CONFIG_FILE_PATH)) {
return _fs2.default.readFileSync(CONFIG_FILE_PATH, 'utf8');
return _fs2.default.readFileSync(CONFIG_FILE_PATH, "utf8");
}
throw new Error('Config not found');
throw new Error("Config not found");
}
function parseConfig(settings = '') {
return settings.split('\n').reduce((memo, curr) => {
const key = curr.substring(0, curr.indexOf('=')).trim();
const value = curr.substring(curr.indexOf('=') + 1).trim();
function parseConfig(settings = "") {
return settings.split("\n").reduce((memo, curr) => {
const key = curr.substring(0, curr.indexOf("=")).trim();
const value = curr.substring(curr.indexOf("=") + 1).trim();

@@ -126,3 +126,3 @@ if (key && value) {

function requireSmartCommits() {
return getConfig().SMART_COMMITS === 'always';
return getConfig().SMART_COMMITS === "always";
}

@@ -144,5 +144,5 @@

return _inquirer2.default.prompt([{
type: 'input',
name: 'username',
message: 'What\'s your bitbucket username?',
type: "input",
name: "username",
message: "What's your bitbucket username?",
default: getBitbucketUsername(),

@@ -153,5 +153,5 @@ validate: val => !!val,

}, {
type: 'password',
name: 'password',
message: 'What\'s your bitbucket password?',
type: "password",
name: "password",
message: "What's your bitbucket password?",
validate: val => !!val,

@@ -161,4 +161,4 @@ filter: val => val.trim(),

}, {
type: 'confirm',
name: 'smartcommits',
type: "confirm",
name: "smartcommits",
message: 'Require all commits to use bitbucket "smart" commits?',

@@ -168,34 +168,33 @@ validate: val => !!val,

when: () => true
}]
// {
// type: 'input',
// name: 'jirahost',
// message: 'What\'s your JIRA host name?',
// default: getJiraHost(),
// validate: val => !!val,
// filter: val => val.trim(),
// when: () => true,
// },
// {
// type: 'input',
// name: 'jirausername',
// default: getJiraUsername(),
// message: 'What\'s your JIRA username?',
// validate: val => !!val,
// filter: val => val.trim(),
// when: () => true,
// },
// {
// type: 'password',
// name: 'jirapassword',
// message: 'What\'s your JIRA password?',
// validate: val => !!val,
// filter: val => val.trim(),
// when: () => true,
// },
);
// {
// type: 'input',
// name: 'jirahost',
// message: 'What\'s your JIRA host name?',
// default: getJiraHost(),
// validate: val => !!val,
// filter: val => val.trim(),
// when: () => true,
// },
// {
// type: 'input',
// name: 'jirausername',
// default: getJiraUsername(),
// message: 'What\'s your JIRA username?',
// validate: val => !!val,
// filter: val => val.trim(),
// when: () => true,
// },
// {
// type: 'password',
// name: 'jirapassword',
// message: 'What\'s your JIRA password?',
// validate: val => !!val,
// filter: val => val.trim(),
// when: () => true,
// },
}]);
}
function createToken(username, password) {
return Buffer.from(`${username}:${password}`).toString('base64');
return Buffer.from(`${username}:${password}`).toString("base64");
}

@@ -214,3 +213,3 @@

BITBUCKET_TOKEN: createToken(username, password),
SMART_COMMITS: smartcommits ? 'always' : 'optional'
SMART_COMMITS: smartcommits ? "always" : "optional"
// JIRA_HOST: jirahost,

@@ -224,5 +223,5 @@ // JIRA_USERNAME: jirausername,

return promptUserSetup().then(handlePrompt).then(() => {
console.log(_chalk2.default.cyan('Let\'s do this!'));
console.log(_chalk2.default.cyan("Let's do this!"));
}).catch(() => {});
}
//# sourceMappingURL=config.js.map

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -18,22 +18,28 @@ Object.defineProperty(exports, "__esModule", {

var _child_process = require('child_process');
var _child_process = require("child_process");
function getVersion() {
return (0, _child_process.execSync)('git describe --tags --abbrev=0', { encoding: 'utf8' }).trim();
return (0, _child_process.execSync)("git describe --tags --abbrev=0", {
encoding: "utf8"
}).trim();
}
function getBranch() {
return (0, _child_process.execSync)('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim();
return (0, _child_process.execSync)("git rev-parse --abbrev-ref HEAD", {
encoding: "utf8"
}).trim();
}
function getRemoteURL() {
return (0, _child_process.execSync)('git config --get remote.origin.url', { encoding: 'utf8' }).trim();
return (0, _child_process.execSync)("git config --get remote.origin.url", {
encoding: "utf8"
}).trim();
}
function getRemoteUsernameFromURL(url) {
if (url.includes('https')) {
return url.split('/').reverse()[1].trim();
if (url.startsWith("https") || url.startsWith("ssh://")) {
return url.split("/").reverse()[1].trim();
}
return url.split(':')[1].split('/')[0].trim();
return url.split(":")[1].split("/")[0].trim();
}

@@ -46,3 +52,3 @@

function getRemoteRepositoryNameFromURL(url) {
return url.split('/').pop().trim().replace('.git', '');
return url.split("/").pop().trim().replace(".git", "");
}

@@ -55,16 +61,16 @@

function pullAndRebase() {
return (0, _child_process.execSync)('git pull --rebase', { encoding: 'utf8' });
return (0, _child_process.execSync)("git pull --rebase", { encoding: "utf8" });
}
function checkoutBranch(branchName) {
return (0, _child_process.execSync)(`git checkout ${branchName}`, { encoding: 'utf8' });
return (0, _child_process.execSync)(`git checkout ${branchName}`, { encoding: "utf8" });
}
function createBranch(branchName) {
return (0, _child_process.execSync)(`git checkout -b ${branchName}`, { encoding: 'utf8' });
return (0, _child_process.execSync)(`git checkout -b ${branchName}`, { encoding: "utf8" });
}
function createCommit(message) {
return (0, _child_process.execSync)(`git commit -m "${message}"`, { encoding: 'utf8' });
return (0, _child_process.execSync)(`git commit -m "${message}"`, { encoding: "utf8" });
}
//# sourceMappingURL=git-cli.js.map

@@ -1,99 +0,104 @@

'use strict';
"use strict";
var _gitCli = require('./git-cli');
var _gitCli = require("./git-cli");
const MOCK_REMOTE_SSH_URL = 'git@github.com:billyxs/hiflow.git';
const MOCK_REMOTE_HTTPS_URL = 'https://github.com/billyxs/hiflow.git';
const MOCK_REMOTE_SSH_URL = "git@github.com:billyxs/hiflow.git";
const MOCK_REMOTE_SSH_URL_2 = "ssh://git@github.com/billyxs/hiflow.git";
const MOCK_REMOTE_HTTPS_URL = "https://github.com/billyxs/hiflow.git";
describe('getVersion()', () => {
it('should be a function', () => {
expect(typeof _gitCli.getVersion).toBe('function');
describe("getVersion()", () => {
it("should be a function", () => {
expect(typeof _gitCli.getVersion).toBe("function");
});
it('should return a string', () => {
expect(typeof (0, _gitCli.getVersion)()).toBe('string');
it("should return a string", () => {
expect(typeof (0, _gitCli.getVersion)()).toBe("string");
});
});
describe('getBranch()', () => {
it('should be a function', () => {
expect(typeof _gitCli.getBranch).toBe('function');
describe("getBranch()", () => {
it("should be a function", () => {
expect(typeof _gitCli.getBranch).toBe("function");
});
it('should return a string', () => {
expect(typeof (0, _gitCli.getBranch)()).toBe('string');
it("should return a string", () => {
expect(typeof (0, _gitCli.getBranch)()).toBe("string");
});
});
describe('getRemoteUsernameFromURL()', () => {
it('should be a function', () => {
expect(typeof _gitCli.getRemoteUsernameFromURL).toBe('function');
describe("getRemoteUsernameFromURL()", () => {
it("should be a function", () => {
expect(typeof _gitCli.getRemoteUsernameFromURL).toBe("function");
});
it('should equal billyxs', () => {
expect((0, _gitCli.getRemoteUsernameFromURL)(MOCK_REMOTE_SSH_URL)).toBe('billyxs');
it("should equal billyxs", () => {
expect((0, _gitCli.getRemoteUsernameFromURL)(MOCK_REMOTE_SSH_URL)).toBe("billyxs");
});
it('should equal billyxs', () => {
expect((0, _gitCli.getRemoteUsernameFromURL)(MOCK_REMOTE_HTTPS_URL)).toBe('billyxs');
it("should equal billyxs", () => {
expect((0, _gitCli.getRemoteUsernameFromURL)(MOCK_REMOTE_HTTPS_URL)).toBe("billyxs");
});
it("should equal billyxs", () => {
expect((0, _gitCli.getRemoteUsernameFromURL)(MOCK_REMOTE_SSH_URL_2)).toBe("billyxs");
});
});
describe('getRemoteURL()', () => {
it('should be a function', () => {
expect(typeof _gitCli.getRemoteURL).toBe('function');
describe("getRemoteURL()", () => {
it("should be a function", () => {
expect(typeof _gitCli.getRemoteURL).toBe("function");
});
it('should return a string', () => {
expect(typeof (0, _gitCli.getRemoteURL)()).toBe('string');
it("should return a string", () => {
expect(typeof (0, _gitCli.getRemoteURL)()).toBe("string");
});
});
describe('getRemoteRepositoryNameFromURL()', () => {
it('should be a function', () => {
expect(typeof _gitCli.getRemoteRepositoryNameFromURL).toBe('function');
describe("getRemoteRepositoryNameFromURL()", () => {
it("should be a function", () => {
expect(typeof _gitCli.getRemoteRepositoryNameFromURL).toBe("function");
});
it('should equal billyxs', () => {
expect((0, _gitCli.getRemoteRepositoryNameFromURL)(MOCK_REMOTE_SSH_URL)).toBe('hiflow');
it("should equal billyxs", () => {
expect((0, _gitCli.getRemoteRepositoryNameFromURL)(MOCK_REMOTE_SSH_URL)).toBe("hiflow");
});
it('should equal billyxs', () => {
expect((0, _gitCli.getRemoteRepositoryNameFromURL)(MOCK_REMOTE_HTTPS_URL)).toBe('hiflow');
it("should equal billyxs", () => {
expect((0, _gitCli.getRemoteRepositoryNameFromURL)(MOCK_REMOTE_HTTPS_URL)).toBe("hiflow");
});
});
describe('getRemoteRepositoryName()', () => {
it('should be a function', () => {
expect(typeof _gitCli.getRemoteRepositoryName).toBe('function');
describe("getRemoteRepositoryName()", () => {
it("should be a function", () => {
expect(typeof _gitCli.getRemoteRepositoryName).toBe("function");
});
it('should return a string', () => {
expect(typeof (0, _gitCli.getRemoteRepositoryName)()).toBe('string');
it("should return a string", () => {
expect(typeof (0, _gitCli.getRemoteRepositoryName)()).toBe("string");
});
});
describe('pullAndRebase()', () => {
it('should be a function', () => {
expect(typeof _gitCli.pullAndRebase).toBe('function');
describe("pullAndRebase()", () => {
it("should be a function", () => {
expect(typeof _gitCli.pullAndRebase).toBe("function");
});
});
describe('createBranch()', () => {
it('should be a function', () => {
expect(typeof _gitCli.createBranch).toBe('function');
describe("createBranch()", () => {
it("should be a function", () => {
expect(typeof _gitCli.createBranch).toBe("function");
});
});
describe('checkoutBranch()', () => {
it('should be a function', () => {
expect(typeof _gitCli.checkoutBranch).toBe('function');
describe("checkoutBranch()", () => {
it("should be a function", () => {
expect(typeof _gitCli.checkoutBranch).toBe("function");
});
});
describe('createCommit()', () => {
it('should be a function', () => {
expect(typeof _gitCli.createCommit).toBe('function');
describe("createCommit()", () => {
it("should be a function", () => {
expect(typeof _gitCli.createCommit).toBe("function");
});
});
//# sourceMappingURL=git-cli.test.js.map

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {

var _extends2 = require('babel-runtime/helpers/extends');
var _extends2 = require("babel-runtime/helpers/extends");
var _extends3 = _interopRequireDefault(_extends2);
var _gitCli = require('./git-cli');
var _gitCli = require("./git-cli");

@@ -21,3 +21,3 @@ var gitCli = _interopRequireWildcard(_gitCli);

exports.default = (0, _extends3.default)({}, gitCli);
module.exports = exports['default'];
module.exports = exports["default"];
//# sourceMappingURL=index.js.map

@@ -1,4 +0,4 @@

'use strict';
"use strict";
var _index = require('./index');
var _index = require("./index");

@@ -9,4 +9,4 @@ var _index2 = _interopRequireDefault(_index);

describe('gitCli', () => {
it('should export object', () => {
describe("gitCli", () => {
it("should export object", () => {
expect(_index2.default).toBeDefined();

@@ -13,0 +13,0 @@ });

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {

var _promise = require('babel-runtime/core-js/promise');
var _promise = require("babel-runtime/core-js/promise");
var _promise2 = _interopRequireDefault(_promise);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends2 = require("babel-runtime/helpers/extends");

@@ -20,3 +20,3 @@ var _extends3 = _interopRequireDefault(_extends2);

var _axios = require('axios');
var _axios = require("axios");

@@ -38,11 +38,9 @@ var _axios2 = _interopRequireDefault(_axios);

function http({
url, params = {}, headers = {}, method
} = {}) {
function http({ url, params = {}, headers = {}, method } = {}) {
return (0, _axios2.default)({
url,
method: method || 'get',
method: method || "get",
data: params,
headers: (0, _extends3.default)({
'Content-Type': 'application/json'
"Content-Type": "application/json"
}, headers)

@@ -49,0 +47,0 @@ }).then(handleResponse).catch(e => _promise2.default.reject(handleError(e)));

#!/usr/bin/env node
'use strict';
"use strict";
var _chalk = require('chalk');
var _chalk = require("chalk");
var _chalk2 = _interopRequireDefault(_chalk);
var _args = require('./args');
var _args = require("./args");

@@ -14,25 +14,25 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

switch (_args.command) {
case 'config':
case "config":
{
const { runSetup } = require('./config');
const { runSetup } = require("./config");
runSetup();
break;
}
case 'commit':
case "commit":
{
const { runCommit } = require('./commit');
const { runCommit } = require("./commit");
runCommit({ message: _args.action, smart: _args.smart });
break;
}
case 'checkout':
case "checkout":
{
const { promptCheckoutCommand } = require('./checkout');
const { promptCheckoutCommand } = require("./checkout");
promptCheckoutCommand();
break;
}
case 'pr':
case "pr":
{
const { promptPullRequestCommand } = require('./pr');
const { promptPullRequestCommand } = require("./pr");
promptPullRequestCommand({ status: _args.status, create: _args.create }).catch(e => {
console.log(_chalk2.default.magenta('Sorry, there was an error'));
console.log(_chalk2.default.magenta("Sorry, there was an error"));
if (e) {

@@ -44,13 +44,13 @@ console.log(e);

}
case 'version':
case "version":
{
const pkg = require('../package.json');
const pkg = require("../package.json");
console.log(pkg.version);
break;
}
case 'jira':
case "jira":
{
const jira = require('./jira');
const jira = require("./jira");
jira().catch(e => {
console.log(_chalk2.default.magenta('Sorry, there was an error'));
console.log(_chalk2.default.magenta("Sorry, there was an error"));
if (e) {

@@ -57,0 +57,0 @@ console.log(e);

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -7,11 +7,11 @@ Object.defineProperty(exports, "__esModule", {

var _extends2 = require('babel-runtime/helpers/extends');
var _extends2 = require("babel-runtime/helpers/extends");
var _extends3 = _interopRequireDefault(_extends2);
var _keys = require('babel-runtime/core-js/object/keys');
var _keys = require("babel-runtime/core-js/object/keys");
var _keys2 = _interopRequireDefault(_keys);
var _stringify = require('babel-runtime/core-js/json/stringify');
var _stringify = require("babel-runtime/core-js/json/stringify");

@@ -22,11 +22,11 @@ var _stringify2 = _interopRequireDefault(_stringify);

var _chalk = require('chalk');
var _chalk = require("chalk");
var _chalk2 = _interopRequireDefault(_chalk);
var _jiraApi = require('./jira-api');
var _jiraApi = require("./jira-api");
var _jiraApi2 = _interopRequireDefault(_jiraApi);
var _config = require('../config');
var _config = require("../config");

@@ -39,6 +39,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

console.log(`${fields.reporter.displayName}`);
console.log('description', fields.description);
console.log('timespent', fields.timespent);
console.log('estimate', fields.timeestimate);
console.log('due', fields.duedate);
console.log("description", fields.description);
console.log("timespent", fields.timespent);
console.log("estimate", fields.timeestimate);
console.log("due", fields.duedate);
// console.log(`${key} - ${JSON.stringify(fields.issuetype)}`)

@@ -72,3 +72,3 @@ console.log(`${key} - ${(0, _stringify2.default)(fields.priority)}`);

console.log(`${res.length} Project(s)`);
console.log('--------------------------------');
console.log("--------------------------------");

@@ -78,3 +78,3 @@ res.forEach(({ name, id, key }) => {

console.log(`==> ${(0, _config.getJiraHost)()}/projects/${key}`);
console.log('--------------------------------');
console.log("--------------------------------");
});

@@ -89,3 +89,3 @@ }

}
module.exports = exports['default'];
module.exports = exports["default"];
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -7,3 +7,3 @@ Object.defineProperty(exports, "__esModule", {

var _extends2 = require('babel-runtime/helpers/extends');
var _extends2 = require("babel-runtime/helpers/extends");

@@ -14,3 +14,3 @@ var _extends3 = _interopRequireDefault(_extends2);

var _http = require('../http');
var _http = require("../http");

@@ -48,3 +48,3 @@ var _http2 = _interopRequireDefault(_http);

}
module.exports = exports['default'];
module.exports = exports["default"];
//# sourceMappingURL=jira-api.js.map

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -12,3 +12,3 @@ Object.defineProperty(exports, "__esModule", {

var _chalk = require('chalk');
var _chalk = require("chalk");

@@ -20,12 +20,12 @@ var _chalk2 = _interopRequireDefault(_chalk);

function logPRLink(link) {
console.log(`${_chalk2.default.cyan('==>')} ${link}`);
console.log(`${_chalk2.default.cyan("==>")} ${link}`);
} /* eslint-disable no-console */
function logPRStatus({ state, type, url }) {
if (type === 'build') {
if (type === "build") {
let buildColor = _chalk2.default.white;
if (state === 'INPROGRESS') {
if (state === "INPROGRESS") {
buildColor = _chalk2.default.yellow;
} else if (state === 'SUCCESSFUL') {
} else if (state === "SUCCESSFUL") {
buildColor = _chalk2.default.green;
} else if (state === 'FAILED') {
} else if (state === "FAILED") {
buildColor = _chalk2.default.red;

@@ -45,3 +45,3 @@ }

function logPRDescription(description) {
console.log(`${_chalk2.default.yellow('Description:')}
console.log(`${_chalk2.default.yellow("Description:")}
${description}

@@ -53,7 +53,7 @@ `);

if (approvals.length) {
console.log(`${_chalk2.default.green('\u2713')} Approved by ${approvals.join(', ')}\n`);
console.log(`${_chalk2.default.green("\u2713")} Approved by ${approvals.join(", ")}\n`);
} else {
console.log(`${_chalk2.default.red('\u2717')} Not yet approved \n`);
console.log(`${_chalk2.default.red("\u2717")} Not yet approved \n`);
}
}
//# sourceMappingURL=log.js.map

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -7,19 +7,19 @@ Object.defineProperty(exports, "__esModule", {

var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties2 = require("babel-runtime/helpers/objectWithoutProperties");
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _keys = require('babel-runtime/core-js/object/keys');
var _keys = require("babel-runtime/core-js/object/keys");
var _keys2 = _interopRequireDefault(_keys);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends2 = require("babel-runtime/helpers/extends");
var _extends3 = _interopRequireDefault(_extends2);
var _promise = require('babel-runtime/core-js/promise');
var _promise = require("babel-runtime/core-js/promise");
var _promise2 = _interopRequireDefault(_promise);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");

@@ -67,4 +67,4 @@ var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);

const hasApproved = parseUserApprovals(activity).includes(CURRENT_USERNAME);
const approvalType = hasApproved ? 'unapprove' : 'approve';
const approvalMethod = hasApproved ? 'delete' : 'post';
const approvalType = hasApproved ? "unapprove" : "approve";
const approvalMethod = hasApproved ? "delete" : "post";

@@ -79,3 +79,3 @@ return {

decline: function () {
return (0, _bitbucket.bitbucketRequest)(pr.links.decline.href, {}, 'post');
return (0, _bitbucket.bitbucketRequest)(pr.links.decline.href, {}, "post");
},

@@ -85,3 +85,3 @@ // comment: () => promptComment(pr.id),

merge: function () {
return (0, _bitbucket.bitbucketRequest)(pr.links.merge.href, {}, 'post');
return (0, _bitbucket.bitbucketRequest)(pr.links.merge.href, {}, "post");
},

@@ -109,9 +109,9 @@ quit: function () {}

source: { branch: { name: currentBranch } },
title: '',
description: '',
title: "",
description: "",
reviewers: []
};
const { createpr } = yield _inquirer2.default.prompt({
type: 'confirm',
name: 'createpr',
type: "confirm",
name: "createpr",
message: `Would you like to create a pull request for your branch ${currentBranch}?`,

@@ -133,3 +133,3 @@ validate: function (val) {

spinner.start('Preparing pull request...');
spinner.start("Preparing pull request...");
const [repository, defaultReviewers = []] = yield _promise2.default.all([(0, _bitbucket.getRepository)(),

@@ -142,3 +142,3 @@ // if default reviewers has an error, skip this step

spinner.succeed('All set!');
spinner.succeed("All set!");
if (repository) {

@@ -153,5 +153,5 @@ const {

} = yield _inquirer2.default.prompt([{
type: 'input',
name: 'destination',
message: 'What branch should this pull request merge into?',
type: "input",
name: "destination",
message: "What branch should this pull request merge into?",
default: repository.mainbranch.name,

@@ -168,5 +168,5 @@ validate: function (val) {

}, {
type: 'confirm',
name: 'closeBranch',
message: 'Close branch on merge?',
type: "confirm",
name: "closeBranch",
message: "Close branch on merge?",
when: function () {

@@ -176,5 +176,5 @@ return true;

}, {
type: 'input',
name: 'title',
message: 'Pull request title:',
type: "input",
name: "title",
message: "Pull request title:",
default: currentBranch,

@@ -191,5 +191,5 @@ validate: function (val) {

}, {
type: 'confirm',
name: 'addDescription',
message: 'Add pull request description?',
type: "confirm",
name: "addDescription",
message: "Add pull request description?",
when: function () {

@@ -199,5 +199,5 @@ return true;

}, {
type: 'editor',
name: 'description',
message: 'Description:',
type: "editor",
name: "description",
message: "Description:",
filter: function (val) {

@@ -210,5 +210,5 @@ return val.trim();

}, {
type: 'checkbox',
name: 'reviewers',
message: 'Select your reviewers:',
type: "checkbox",
name: "reviewers",
message: "Select your reviewers:",
choices: defaultReviewers.filter(function (u) {

@@ -227,5 +227,5 @@ return u.username !== CURRENT_USERNAME;

}, {
type: 'input',
name: 'addReviewers',
message: 'Add reviewers? (Enter usernames as csv)',
type: "input",
name: "addReviewers",
message: "Add reviewers? (Enter usernames as csv)",
filter: function (val) {

@@ -236,3 +236,3 @@ return val.trim();

const allReviewers = [...reviewers, ...addReviewers.split(',')].filter(function (i) {
const allReviewers = [...reviewers, ...addReviewers.split(",")].filter(function (i) {
return i && i.trim().length;

@@ -243,3 +243,3 @@ }).map(function (i) {

spinner.start('Creating your pull request...');
spinner.start("Creating your pull request...");
const pullRequest = yield (0, _bitbucket.createPullRequest)((0, _extends3.default)({}, prObj, {

@@ -252,3 +252,3 @@ destination: { branch: { name: destination } },

}));
spinner.succeed('Pull request created!');
spinner.succeed("Pull request created!");

@@ -260,3 +260,3 @@ (0, _log.logPRLink)(pullRequest.links.html.href);

} catch (e) {
spinner.fail('Whoops!');
spinner.fail("Whoops!");
const { fields } = e || {};

@@ -266,6 +266,6 @@ const { source = [] } = fields || {};

source.forEach(function (m) {
if (m.includes('branch not found')) {
console.log(`\n${_chalk2.default.yellow('** Did you push your branch?')}\n`);
if (m.includes("branch not found")) {
console.log(`\n${_chalk2.default.yellow("** Did you push your branch?")}\n`);
}
console.log(`${_chalk2.default.red(' Error: ' + m)}\n`);
console.log(`${_chalk2.default.red(" Error: " + m)}\n`);
});

@@ -289,11 +289,11 @@ }

spinner.start('Getting pull requests...');
spinner.start("Getting pull requests...");
const pullrequests = yield (0, _bitbucket.getPullRequests)();
if (pullrequests.length === 0) {
spinner.succeed(`${_chalk2.default.green('All clear!')}`);
console.log(_chalk2.default.cyan('No pull requests available.\n'));
spinner.succeed(`${_chalk2.default.green("All clear!")}`);
console.log(_chalk2.default.cyan("No pull requests available.\n"));
return true;
}
console.log('');
console.log("");
spinner.succeed(`Found ${pullrequests.length} pull request(s)`);

@@ -326,5 +326,5 @@

if (index === 0) {
console.log(_chalk2.default.dim('===================================='));
console.log(_chalk2.default.dim("===================================="));
} else {
console.log('-------------------------------------');
console.log("-------------------------------------");
}

@@ -335,5 +335,5 @@

if (approvals.length) {
console.log(`${_chalk2.default.green('\u2713')} Approved by ${approvals.join(', ')}\n`);
console.log(`${_chalk2.default.green("\u2713")} Approved by ${approvals.join(", ")}\n`);
} else {
console.log(`${_chalk2.default.red('\u2717')} Not yet approved \n`);
console.log(`${_chalk2.default.red("\u2717")} Not yet approved \n`);
}

@@ -349,3 +349,3 @@ if (statuses && statuses.length) {

} catch (e) {
spinner.fail('Whoops, something happened!');
spinner.fail("Whoops, something happened!");
throw e;

@@ -368,5 +368,5 @@ }

const { action } = yield _inquirer2.default.prompt({
type: 'list',
name: 'action',
message: 'What action would you like to perform?',
type: "list",
name: "action",
message: "What action would you like to perform?",
choices: (0, _keys2.default)(actions).map(function (a) {

@@ -398,3 +398,3 @@ return {

} catch (e) {
spinner.fail('Whoops, something happened');
spinner.fail("Whoops, something happened");
throw e;

@@ -415,8 +415,8 @@ }

spinner.start('Getting pull requests...');
spinner.start("Getting pull requests...");
const list = yield (0, _bitbucket.getPullRequests)();
if (list.length === 0) {
spinner.succeed(`${_chalk2.default.green('All clear!')}`);
console.log(_chalk2.default.cyan('No pull requests available.\n'));
spinner.succeed(`${_chalk2.default.green("All clear!")}`);
console.log(_chalk2.default.cyan("No pull requests available.\n"));
return true;

@@ -427,9 +427,8 @@ }

const { pullrequest } = yield _inquirer2.default.prompt({
type: 'list',
name: 'pullrequest',
message: 'Select a pull request?',
type: "list",
name: "pullrequest",
message: "Select a pull request?",
choices: list.map(function (_ref8) {
let {
author, state, id, title } = _ref8,
pr = (0, _objectWithoutProperties3.default)(_ref8, ['author', 'state', 'id', 'title']);
let { author, state, id, title } = _ref8,
pr = (0, _objectWithoutProperties3.default)(_ref8, ["author", "state", "id", "title"]);
return {

@@ -453,3 +452,3 @@ name: `(${state}) #${id} by ${author.display_name} - ${title}`,

spinner.start('Getting summary...');
spinner.start("Getting summary...");
yield renderPRSummary(pullrequest);

@@ -474,21 +473,21 @@ spinner.stop();

var _inquirer = require('inquirer');
var _inquirer = require("inquirer");
var _inquirer2 = _interopRequireDefault(_inquirer);
var _chalk = require('chalk');
var _chalk = require("chalk");
var _chalk2 = _interopRequireDefault(_chalk);
var _ora = require('ora');
var _ora = require("ora");
var _ora2 = _interopRequireDefault(_ora);
var _config = require('./config');
var _config = require("./config");
var _bitbucket = require('./bitbucket');
var _bitbucket = require("./bitbucket");
var _gitCli = require('./git-cli');
var _gitCli = require("./git-cli");
var _log = require('./log');
var _log = require("./log");

@@ -505,5 +504,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

return _inquirer2.default.prompt({
type: 'input',
name: 'comment',
message: 'Your comment:',
type: "input",
name: "comment",
message: "Your comment:",
validate: val => !!val,

@@ -517,5 +516,5 @@ filter: val => val.trim(),

return _inquirer2.default.prompt({
type: 'confirm',
name: 'repeat',
message: 'See actions again?',
type: "confirm",
name: "repeat",
message: "See actions again?",
validate: val => !!val,

@@ -527,4 +526,4 @@ when: () => true

function promptPullRequestCommand({ create, status }) {
if (!(0, _gitCli.getRemoteURL)().includes('bitbucket')) {
console.log(_chalk2.default.cyan('hi pr currently supported with bitbucket only'));
if (!(0, _gitCli.getRemoteURL)().includes("bitbucket")) {
console.log(_chalk2.default.cyan("hi pr currently supported with bitbucket only"));
return _promise2.default.resolve(true);

@@ -531,0 +530,0 @@ }

{
"name": "hiflow",
"version": "0.3.3",
"version": "0.3.4-rc.1",
"description": "A pull request and gitflow management tool",

@@ -71,2 +71,5 @@ "main": "lib/index.js",

},
"jest": {
"testEnvironment": "node"
},
"repository": {

@@ -73,0 +76,0 @@ "type": "git",

@@ -1,6 +0,4 @@

import yargs from 'yargs'
import yargs from "yargs";
const {
argv,
} = yargs
const { argv } = yargs;

@@ -15,12 +13,12 @@ export const {

...args
} = argv
} = argv;
export const VERBOSE = VERBOSE1 || VERBOSE2
export const VERBOSE = VERBOSE1 || VERBOSE2;
const [cliCommand = 'help', actionType] = _
const [cliCommand = "help", actionType] = _;
export const command = cliCommand
export const command = cliCommand;
export const action = actionType
export const action = actionType;
export const HOME = require('os').homedir()
export const HOME = require("os").homedir();

@@ -1,13 +0,13 @@

import util from 'util'
import util from "util";
const exec = util.promisify(require('child_process').exec)
const exec = util.promisify(require("child_process").exec);
export default async function asyncExec(command) {
try {
const { stdout, stderr } = await exec(command)
if (stderr) throw new Error(stderr)
return stdout.trim()
const { stdout, stderr } = await exec(command);
if (stderr) throw new Error(stderr);
return stdout.trim();
} catch (e) {
return e
return e;
}
}

@@ -1,17 +0,14 @@

import axios from 'axios'
import chalk from 'chalk'
import axios from "axios";
import chalk from "chalk";
import { getBitbucketToken } from './config'
import {
getRemoteRepositoryName,
getRemoteUsername,
} from './git-cli'
import { getBitbucketToken } from "./config";
import { getRemoteRepositoryName, getRemoteUsername } from "./git-cli";
const GIT_REPO_NAME = getRemoteRepositoryName()
const GIT_REPO_ORIGIN_USERNAME = getRemoteUsername()
const BITBUCKET_API_BASEURL = `https://bitbucket.org/!api/2.0/repositories/${GIT_REPO_ORIGIN_USERNAME}/${GIT_REPO_NAME}`
const GIT_REPO_NAME = getRemoteRepositoryName();
const GIT_REPO_ORIGIN_USERNAME = getRemoteUsername();
const BITBUCKET_API_BASEURL = `https://bitbucket.org/!api/2.0/repositories/${GIT_REPO_ORIGIN_USERNAME}/${GIT_REPO_NAME}`;
function handleResponse(response) {
// console.log('data - ', response.data)
return response.data
return response.data;
}

@@ -22,22 +19,22 @@

// console.log('error - ', error)
return error.response.data.error
return error.response.data.error;
}
export function bitbucketRequest(url, params = {}, method) {
const BITBUCKET_TOKEN = getBitbucketToken()
const BITBUCKET_TOKEN = getBitbucketToken();
return axios({
url,
method: method || 'get',
method: method || "get",
data: params,
headers: {
'Content-Type': 'application/json',
Authorization: `Basic ${BITBUCKET_TOKEN}`,
},
"Content-Type": "application/json",
Authorization: `Basic ${BITBUCKET_TOKEN}`
}
})
.then(handleResponse)
.catch(e => Promise.reject(handleError(e)))
.catch(e => Promise.reject(handleError(e)));
}
function buildAPIUrl(path) {
return `${BITBUCKET_API_BASEURL}/${path}`
return `${BITBUCKET_API_BASEURL}/${path}`;
}

@@ -47,17 +44,19 @@

export function getPullRequests() {
return bitbucketRequest(buildAPIUrl('pullrequests'))
.then(data => data.values)
return bitbucketRequest(buildAPIUrl("pullrequests")).then(
data => data.values
);
}
export function createPullRequest(data) {
return bitbucketRequest(buildAPIUrl('pullrequests'), data, 'POST')
return bitbucketRequest(buildAPIUrl("pullrequests"), data, "POST");
}
export function getRepository() {
return bitbucketRequest(BITBUCKET_API_BASEURL)
return bitbucketRequest(BITBUCKET_API_BASEURL);
}
export function getRepositoryStatuses(pullrequestId) {
return bitbucketRequest(buildAPIUrl(`pullrequests/${pullrequestId}/statuses`))
.then(data => data.values)
return bitbucketRequest(
buildAPIUrl(`pullrequests/${pullrequestId}/statuses`)
).then(data => data.values);
}

@@ -67,14 +66,18 @@

export function getRepositoryDefaultReviewers() {
return bitbucketRequest(buildAPIUrl('default-reviewers'))
.then(data => data && data.values ? data.values : [])
return bitbucketRequest(buildAPIUrl("default-reviewers"))
.then(data => (data && data.values ? data.values : []))
.catch(e => {
console.log(chalk.yellow("You don't have access to default reviewers."))
return []
})
console.log(chalk.yellow("You don't have access to default reviewers."));
return [];
});
}
// 1.0 API no longer available. No support for 2.0
const BITBUCKET_API_BASEURL_VERSION1 = `https://bitbucket.org/!api/1.0/repositories/${GIT_REPO_ORIGIN_USERNAME}/${GIT_REPO_NAME}`
const BITBUCKET_API_BASEURL_VERSION1 = `https://bitbucket.org/!api/1.0/repositories/${GIT_REPO_ORIGIN_USERNAME}/${GIT_REPO_NAME}`;
export function addPullRequestComment(prId, comment) {
return bitbucketRequest(`${BITBUCKET_API_BASEURL_VERSION1}/pullrequests/${prId}/comments`, comment, 'post')
return bitbucketRequest(
`${BITBUCKET_API_BASEURL_VERSION1}/pullrequests/${prId}/comments`,
comment,
"post"
);
}

@@ -1,24 +0,21 @@

import inquirer from 'inquirer'
import chalk from 'chalk'
import inquirer from "inquirer";
import chalk from "chalk";
import {
getBranch,
createBranch,
} from './git-cli'
import { getBranch, createBranch } from "./git-cli";
async function promptCheckout() {
const currentBranch = getBranch()
console.log(chalk.cyan(`You are on the ${currentBranch} branch.`))
const currentBranch = getBranch();
console.log(chalk.cyan(`You are on the ${currentBranch} branch.`));
try {
let branchType = null
let branchType = null;
if (currentBranch === 'master') {
if (currentBranch === "master") {
const { doHotfix } = await inquirer.prompt({
type: 'confirm',
name: 'doHotfix',
message: 'Do you want to do a hotfix?',
})
console.log(doHotfix)
if (doHotfix) branchType = 'hotfix'
type: "confirm",
name: "doHotfix",
message: "Do you want to do a hotfix?"
});
console.log(doHotfix);
if (doHotfix) branchType = "hotfix";
}

@@ -28,39 +25,32 @@

const { type } = await inquirer.prompt({
type: 'list',
name: 'type',
message: 'What type of branch?',
choices: [
'feature',
'improvement',
'fix',
'hotfix',
'release',
],
default: 'feature',
type: "list",
name: "type",
message: "What type of branch?",
choices: ["feature", "improvement", "fix", "hotfix", "release"],
default: "feature",
validate: val => !!val,
when: () => true,
})
when: () => true
});
branchType = type
branchType = type;
}
const { issue } = await inquirer.prompt({
type: 'input',
name: 'issue',
message: branchType === 'release' ? 'Version:' : 'Issue name:',
type: "input",
name: "issue",
message: branchType === "release" ? "Version:" : "Issue name:",
validate: val => !!val,
when: () => true,
})
when: () => true
});
console.log(chalk.green('Yes! I\'m excited about this.'))
createBranch(`${branchType}/${issue}`)
console.log(chalk.green("Yes! I'm excited about this."));
createBranch(`${branchType}/${issue}`);
return { success: true }
return { success: true };
} catch (e) {
throw e
throw e;
}
}
export function promptCheckoutCommand() {
return promptCheckout()
return promptCheckout();
}

@@ -1,86 +0,88 @@

import inquirer from 'inquirer'
import chalk from 'chalk'
import {
requireSmartCommits,
} from './config'
import {
getBranch,
createCommit,
} from './git-cli'
import inquirer from "inquirer";
import chalk from "chalk";
import { requireSmartCommits } from "./config";
import { getBranch, createCommit } from "./git-cli";
export function getIssueFromBranch(branch) {
const [type, issue] = branch.split('/')
return issue
const [type, issue] = branch.split("/");
return issue;
}
export function formatMessage({ message, branch }) {
return `${branch}: ${message}`
return `${branch}: ${message}`;
}
export function execCommit(message) {
const branch = getBranch()
const commitMessage = formatMessage({ message, branch })
const result = createCommit(commitMessage)
console.log(result)
return result
const branch = getBranch();
const commitMessage = formatMessage({ message, branch });
const result = createCommit(commitMessage);
console.log(result);
return result;
}
export async function promptCommit({ message, smart } = {}) {
const currentBranch = getBranch()
const initialMessage = typeof smart === 'string' ? smart : message
let smartMessage
const currentBranch = getBranch();
const initialMessage = typeof smart === "string" ? smart : message;
let smartMessage;
try {
const { addmessage } = await inquirer.prompt({
type: 'input',
name: 'addmessage',
type: "input",
name: "addmessage",
message: `${currentBranch}:`,
validate: val => !!val,
when: () => !initialMessage,
})
when: () => !initialMessage
});
const commitMessage = initialMessage || addmessage
const commitMessage = initialMessage || addmessage;
if (requireSmartCommits() || smart) {
const issueName = getIssueFromBranch(currentBranch)
const issueName = getIssueFromBranch(currentBranch);
const { issue } = await inquirer.prompt({
type: 'input',
name: 'issue',
message: 'Issue:',
type: "input",
name: "issue",
message: "Issue:",
default: issueName,
validate: val => !!val,
when: () => true,
})
when: () => true
});
const { time } = await inquirer.prompt({
type: 'input',
name: 'time',
message: 'How much time have you spent? w/d/h/m/(s)kip',
default: 'skip',
type: "input",
name: "time",
message: "How much time have you spent? w/d/h/m/(s)kip",
default: "skip",
validate: val => !!val,
when: () => true,
})
when: () => true
});
if (time.includes('w') || time.includes('d') || time.includes('h') || time.includes('m')) {
smartMessage = `${issue} #time ${time}`
if (
time.includes("w") ||
time.includes("d") ||
time.includes("h") ||
time.includes("m")
) {
smartMessage = `${issue} #time ${time}`;
} else {
console.log(chalk.magenta('No time was tracked'))
console.log(chalk.magenta("No time was tracked"));
}
}
const completeMessage = `${commitMessage}${(smartMessage ? `\n\n${smartMessage}` : '')}`
execCommit(completeMessage)
const completeMessage = `${commitMessage}${
smartMessage ? `\n\n${smartMessage}` : ""
}`;
execCommit(completeMessage);
const randomNum = Math.ceil(Math.random() * 10)
const randomNum = Math.ceil(Math.random() * 10);
if ([3, 7].includes(randomNum)) {
console.log(chalk.yellow('Nailed it!'))
console.log(chalk.yellow("Nailed it!"));
}
if ([2, 5].includes(randomNum)) {
console.log(chalk.cyan('Mmmm, the people are gonna like that!'))
console.log(chalk.cyan("Mmmm, the people are gonna like that!"));
}
return { success: true }
return { success: true };
} catch (e) {
throw e
throw e;
}

@@ -91,14 +93,14 @@ }

try {
return await promptCommit(args)
return await promptCommit(args);
} catch (e) {
if (e && e.message) {
console.log(chalk.magenta(e.message))
if (e.message.startsWith('Command failed')) {
console.log(chalk.yellow('Did you add your changes?'))
console.log(chalk.magenta(e.message));
if (e.message.startsWith("Command failed")) {
console.log(chalk.yellow("Did you add your changes?"));
}
} else {
console.log(chalk.yellow('There was an unknown error.'))
console.log(chalk.yellow("There was an unknown error."));
}
return ''
return "";
}
}

@@ -1,11 +0,12 @@

import fs from 'fs'
import inquirer from 'inquirer'
import chalk from 'chalk'
import { HOME } from './args'
import fs from "fs";
import inquirer from "inquirer";
import chalk from "chalk";
import { HOME } from "./args";
export const CONFIG_FILE_PATH = `${HOME}/.hiflow`
export const CONFIG_FILE_PATH = `${HOME}/.hiflow`;
function writeConfigFile(path, content) {
return new Promise((resolve, reject) =>
fs.writeFile(path, content, 'utf8', err => (err ? reject(err) : resolve())))
fs.writeFile(path, content, "utf8", err => (err ? reject(err) : resolve()))
);
}

@@ -16,6 +17,6 @@

.reduce((memo, curr) => {
memo.push(`${curr.trim()}=${configJSON[curr].trim()}`)
return memo
memo.push(`${curr.trim()}=${configJSON[curr].trim()}`);
return memo;
}, [])
.join('\n')
.join("\n");
}

@@ -25,12 +26,12 @@

if (fs.existsSync(CONFIG_FILE_PATH)) {
return fs.readFileSync(CONFIG_FILE_PATH, 'utf8')
return fs.readFileSync(CONFIG_FILE_PATH, "utf8");
}
throw new Error('Config not found')
throw new Error("Config not found");
}
function parseConfig(settings = '') {
return settings.split('\n').reduce((memo, curr) => {
const key = curr.substring(0, curr.indexOf('=')).trim()
const value = curr.substring(curr.indexOf('=') + 1).trim()
function parseConfig(settings = "") {
return settings.split("\n").reduce((memo, curr) => {
const key = curr.substring(0, curr.indexOf("=")).trim();
const value = curr.substring(curr.indexOf("=") + 1).trim();

@@ -40,7 +41,7 @@ if (key && value) {

...memo,
[key]: value,
}
[key]: value
};
}
return memo
}, {})
return memo;
}, {});
}

@@ -50,5 +51,5 @@

try {
return parseConfig(getConfigFile()) || {}
return parseConfig(getConfigFile()) || {};
} catch (e) {
return {}
return {};
}

@@ -58,23 +59,23 @@ }

export function getBitbucketToken() {
return getConfig().BITBUCKET_TOKEN
return getConfig().BITBUCKET_TOKEN;
}
export function getBitbucketUsername() {
return getConfig().BITBUCKET_USERNAME
return getConfig().BITBUCKET_USERNAME;
}
export function requireSmartCommits() {
return getConfig().SMART_COMMITS === 'always'
return getConfig().SMART_COMMITS === "always";
}
export function getJiraHost() {
return getConfig().JIRA_HOST
return getConfig().JIRA_HOST;
}
export function getJiraUsername() {
return getConfig().JIRA_USERNAME
return getConfig().JIRA_USERNAME;
}
export function getJiraToken() {
return getConfig().JIRA_TOKEN
return getConfig().JIRA_TOKEN;
}

@@ -85,26 +86,26 @@

{
type: 'input',
name: 'username',
message: 'What\'s your bitbucket username?',
type: "input",
name: "username",
message: "What's your bitbucket username?",
default: getBitbucketUsername(),
validate: val => !!val,
filter: val => val.trim(),
when: () => true,
when: () => true
},
{
type: 'password',
name: 'password',
message: 'What\'s your bitbucket password?',
type: "password",
name: "password",
message: "What's your bitbucket password?",
validate: val => !!val,
filter: val => val.trim(),
when: () => true,
when: () => true
},
{
type: 'confirm',
name: 'smartcommits',
type: "confirm",
name: "smartcommits",
message: 'Require all commits to use bitbucket "smart" commits?',
validate: val => !!val,
filter: val => val.trim(),
when: () => true,
},
when: () => true
}
// {

@@ -136,19 +137,19 @@ // type: 'input',

// },
])
]);
}
function createToken(username, password) {
return Buffer.from(`${username}:${password}`).toString('base64')
return Buffer.from(`${username}:${password}`).toString("base64");
}
export async function requireLogin() {
const token = getBitbucketToken()
const token = getBitbucketToken();
if (!token || token.length < 1) {
console.log(chalk.yellow('This feature requires bitbucket access.'))
console.log(chalk.cyan('Let\'s login to your account!'))
return runSetup()
console.log(chalk.yellow("This feature requires bitbucket access."));
console.log(chalk.cyan("Let's login to your account!"));
return runSetup();
}
return Promise.resolve('success')
return Promise.resolve("success");
}

@@ -159,3 +160,3 @@

password,
smartcommits,
smartcommits
// jirahost,

@@ -165,11 +166,14 @@ // jirausername,

}) {
return writeConfigFile(CONFIG_FILE_PATH, formatConfigForSave({
...getConfig(),
BITBUCKET_USERNAME: username,
BITBUCKET_TOKEN: createToken(username, password),
SMART_COMMITS: smartcommits ? 'always' : 'optional',
// JIRA_HOST: jirahost,
// JIRA_USERNAME: jirausername,
// JIRA_TOKEN: createToken(jirausername, jirapassword),
}))
return writeConfigFile(
CONFIG_FILE_PATH,
formatConfigForSave({
...getConfig(),
BITBUCKET_USERNAME: username,
BITBUCKET_TOKEN: createToken(username, password),
SMART_COMMITS: smartcommits ? "always" : "optional"
// JIRA_HOST: jirahost,
// JIRA_USERNAME: jirausername,
// JIRA_TOKEN: createToken(jirausername, jirapassword),
})
);
}

@@ -181,6 +185,5 @@

.then(() => {
console.log(chalk.cyan('Let\'s do this!'))
console.log(chalk.cyan("Let's do this!"));
})
.catch(() => {})
.catch(() => {});
}

@@ -1,25 +0,37 @@

import { execSync } from 'child_process'
import { execSync } from "child_process";
export function getVersion() {
return execSync('git describe --tags --abbrev=0', { encoding: 'utf8' }).trim()
return execSync("git describe --tags --abbrev=0", {
encoding: "utf8"
}).trim();
}
export function getBranch() {
return execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim()
return execSync("git rev-parse --abbrev-ref HEAD", {
encoding: "utf8"
}).trim();
}
export function getRemoteURL() {
return execSync('git config --get remote.origin.url', { encoding: 'utf8' }).trim()
return execSync("git config --get remote.origin.url", {
encoding: "utf8"
}).trim();
}
export function getRemoteUsernameFromURL(url) {
if (url.includes('https')) {
return url.split('/').reverse()[1].trim()
if (url.startsWith("https") || url.startsWith("ssh://")) {
return url
.split("/")
.reverse()[1]
.trim();
}
return url.split(':')[1].split('/')[0].trim()
return url
.split(":")[1]
.split("/")[0]
.trim();
}
export function getRemoteUsername() {
return getRemoteUsernameFromURL(getRemoteURL())
return getRemoteUsernameFromURL(getRemoteURL());
}

@@ -29,26 +41,26 @@

return url
.split('/')
.split("/")
.pop()
.trim()
.replace('.git', '')
.replace(".git", "");
}
export function getRemoteRepositoryName() {
return getRemoteRepositoryNameFromURL(getRemoteURL())
return getRemoteRepositoryNameFromURL(getRemoteURL());
}
export function pullAndRebase() {
return execSync('git pull --rebase', { encoding: 'utf8' })
return execSync("git pull --rebase", { encoding: "utf8" });
}
export function checkoutBranch(branchName) {
return execSync(`git checkout ${branchName}`, { encoding: 'utf8' })
return execSync(`git checkout ${branchName}`, { encoding: "utf8" });
}
export function createBranch(branchName) {
return execSync(`git checkout -b ${branchName}`, { encoding: 'utf8' })
return execSync(`git checkout -b ${branchName}`, { encoding: "utf8" });
}
export function createCommit(message) {
return execSync(`git commit -m "${message}"`, { encoding: 'utf8' })
return execSync(`git commit -m "${message}"`, { encoding: "utf8" });
}

@@ -11,98 +11,105 @@ import {

getVersion,
pullAndRebase,
} from './git-cli'
pullAndRebase
} from "./git-cli";
const MOCK_REMOTE_SSH_URL = 'git@github.com:billyxs/hiflow.git'
const MOCK_REMOTE_HTTPS_URL = 'https://github.com/billyxs/hiflow.git'
const MOCK_REMOTE_SSH_URL = "git@github.com:billyxs/hiflow.git";
const MOCK_REMOTE_SSH_URL_2 = "ssh://git@github.com/billyxs/hiflow.git";
const MOCK_REMOTE_HTTPS_URL = "https://github.com/billyxs/hiflow.git";
describe('getVersion()', () => {
it('should be a function', () => {
expect(typeof getVersion).toBe('function')
})
describe("getVersion()", () => {
it("should be a function", () => {
expect(typeof getVersion).toBe("function");
});
it('should return a string', () => {
expect(typeof getVersion()).toBe('string')
})
})
it("should return a string", () => {
expect(typeof getVersion()).toBe("string");
});
});
describe('getBranch()', () => {
it('should be a function', () => {
expect(typeof getBranch).toBe('function')
})
describe("getBranch()", () => {
it("should be a function", () => {
expect(typeof getBranch).toBe("function");
});
it('should return a string', () => {
expect(typeof getBranch()).toBe('string')
})
})
it("should return a string", () => {
expect(typeof getBranch()).toBe("string");
});
});
describe('getRemoteUsernameFromURL()', () => {
it('should be a function', () => {
expect(typeof getRemoteUsernameFromURL).toBe('function')
})
describe("getRemoteUsernameFromURL()", () => {
it("should be a function", () => {
expect(typeof getRemoteUsernameFromURL).toBe("function");
});
it('should equal billyxs', () => {
expect(getRemoteUsernameFromURL(MOCK_REMOTE_SSH_URL)).toBe('billyxs')
})
it("should equal billyxs", () => {
expect(getRemoteUsernameFromURL(MOCK_REMOTE_SSH_URL)).toBe("billyxs");
});
it('should equal billyxs', () => {
expect(getRemoteUsernameFromURL(MOCK_REMOTE_HTTPS_URL)).toBe('billyxs')
})
})
it("should equal billyxs", () => {
expect(getRemoteUsernameFromURL(MOCK_REMOTE_HTTPS_URL)).toBe("billyxs");
});
describe('getRemoteURL()', () => {
it('should be a function', () => {
expect(typeof getRemoteURL).toBe('function')
})
it("should equal billyxs", () => {
expect(getRemoteUsernameFromURL(MOCK_REMOTE_SSH_URL_2)).toBe("billyxs");
});
});
it('should return a string', () => {
expect(typeof getRemoteURL()).toBe('string')
})
})
describe("getRemoteURL()", () => {
it("should be a function", () => {
expect(typeof getRemoteURL).toBe("function");
});
describe('getRemoteRepositoryNameFromURL()', () => {
it('should be a function', () => {
expect(typeof getRemoteRepositoryNameFromURL).toBe('function')
})
it("should return a string", () => {
expect(typeof getRemoteURL()).toBe("string");
});
});
it('should equal billyxs', () => {
expect(getRemoteRepositoryNameFromURL(MOCK_REMOTE_SSH_URL)).toBe('hiflow')
})
describe("getRemoteRepositoryNameFromURL()", () => {
it("should be a function", () => {
expect(typeof getRemoteRepositoryNameFromURL).toBe("function");
});
it('should equal billyxs', () => {
expect(getRemoteRepositoryNameFromURL(MOCK_REMOTE_HTTPS_URL)).toBe('hiflow')
})
})
it("should equal billyxs", () => {
expect(getRemoteRepositoryNameFromURL(MOCK_REMOTE_SSH_URL)).toBe("hiflow");
});
describe('getRemoteRepositoryName()', () => {
it('should be a function', () => {
expect(typeof getRemoteRepositoryName).toBe('function')
})
it("should equal billyxs", () => {
expect(getRemoteRepositoryNameFromURL(MOCK_REMOTE_HTTPS_URL)).toBe(
"hiflow"
);
});
});
it('should return a string', () => {
expect(typeof getRemoteRepositoryName()).toBe('string')
})
})
describe("getRemoteRepositoryName()", () => {
it("should be a function", () => {
expect(typeof getRemoteRepositoryName).toBe("function");
});
describe('pullAndRebase()', () => {
it('should be a function', () => {
expect(typeof pullAndRebase).toBe('function')
})
})
it("should return a string", () => {
expect(typeof getRemoteRepositoryName()).toBe("string");
});
});
describe('createBranch()', () => {
it('should be a function', () => {
expect(typeof createBranch).toBe('function')
})
})
describe("pullAndRebase()", () => {
it("should be a function", () => {
expect(typeof pullAndRebase).toBe("function");
});
});
describe('checkoutBranch()', () => {
it('should be a function', () => {
expect(typeof checkoutBranch).toBe('function')
})
})
describe("createBranch()", () => {
it("should be a function", () => {
expect(typeof createBranch).toBe("function");
});
});
describe('createCommit()', () => {
it('should be a function', () => {
expect(typeof createCommit).toBe('function')
})
})
describe("checkoutBranch()", () => {
it("should be a function", () => {
expect(typeof checkoutBranch).toBe("function");
});
});
describe("createCommit()", () => {
it("should be a function", () => {
expect(typeof createCommit).toBe("function");
});
});

@@ -1,3 +0,3 @@

import * as gitCli from './git-cli'
import * as gitCli from "./git-cli";
export default { ...gitCli }
export default { ...gitCli };

@@ -1,7 +0,7 @@

import gitCli from './index'
import gitCli from "./index";
describe('gitCli', () => {
it('should export object', () => {
expect(gitCli).toBeDefined()
})
})
describe("gitCli", () => {
it("should export object", () => {
expect(gitCli).toBeDefined();
});
});

@@ -1,6 +0,6 @@

import axios from 'axios'
import axios from "axios";
export function handleResponse(response) {
// console.log('data - ', response.data)
return response.data
return response.data;
}

@@ -11,19 +11,17 @@

// console.log('error - ', error)
return error.response.data.error
return error.response.data.error;
}
export default function http({
url, params = {}, headers = {}, method,
} = {}) {
export default function http({ url, params = {}, headers = {}, method } = {}) {
return axios({
url,
method: method || 'get',
method: method || "get",
data: params,
headers: {
'Content-Type': 'application/json',
...headers,
},
"Content-Type": "application/json",
...headers
}
})
.then(handleResponse)
.catch(e => Promise.reject(handleError(e)))
.catch(e => Promise.reject(handleError(e)));
}
#!/usr/bin/env node
import chalk from 'chalk'
import chalk from "chalk";
import { command, create, status, action, smart } from './args'
import { command, create, status, action, smart } from "./args";
/* eslint-disable global-require */
switch (command) {
case 'config': {
const { runSetup } = require('./config')
runSetup()
break
case "config": {
const { runSetup } = require("./config");
runSetup();
break;
}
case 'commit': {
const { runCommit } = require('./commit')
runCommit({ message: action, smart })
break
case "commit": {
const { runCommit } = require("./commit");
runCommit({ message: action, smart });
break;
}
case 'checkout': {
const { promptCheckoutCommand } = require('./checkout')
promptCheckoutCommand()
break
case "checkout": {
const { promptCheckoutCommand } = require("./checkout");
promptCheckoutCommand();
break;
}
case 'pr': {
const { promptPullRequestCommand } = require('./pr')
promptPullRequestCommand({ status, create })
.catch((e) => {
console.log(chalk.magenta('Sorry, there was an error'))
if (e) {
console.log(e)
}
})
break
case "pr": {
const { promptPullRequestCommand } = require("./pr");
promptPullRequestCommand({ status, create }).catch(e => {
console.log(chalk.magenta("Sorry, there was an error"));
if (e) {
console.log(e);
}
});
break;
}
case 'version': {
const pkg = require('../package.json')
console.log(pkg.version)
break
case "version": {
const pkg = require("../package.json");
console.log(pkg.version);
break;
}
case 'jira': {
const jira = require('./jira')
jira()
.catch((e) => {
console.log(chalk.magenta('Sorry, there was an error'))
if (e) {
console.log(e)
}
})
break
case "jira": {
const jira = require("./jira");
jira().catch(e => {
console.log(chalk.magenta("Sorry, there was an error"));
if (e) {
console.log(e);
}
});
break;
}
default:
break
break;
}

@@ -1,52 +0,53 @@

import chalk from 'chalk'
import jira from './jira-api'
import {
getJiraToken,
getJiraHost,
} from '../config'
import chalk from "chalk";
import jira from "./jira-api";
import { getJiraToken, getJiraHost } from "../config";
function displayIssues(res) {
res.issues.forEach(({ key, fields }) => {
console.log(`${key} - ${chalk.yellow(fields.priority.name)} / ${chalk.cyan(fields.status.name)}`)
console.log(`${fields.reporter.displayName}`)
console.log('description', fields.description)
console.log('timespent', fields.timespent)
console.log('estimate', fields.timeestimate)
console.log('due', fields.duedate)
console.log(
`${key} - ${chalk.yellow(fields.priority.name)} / ${chalk.cyan(
fields.status.name
)}`
);
console.log(`${fields.reporter.displayName}`);
console.log("description", fields.description);
console.log("timespent", fields.timespent);
console.log("estimate", fields.timeestimate);
console.log("due", fields.duedate);
// console.log(`${key} - ${JSON.stringify(fields.issuetype)}`)
console.log(`${key} - ${JSON.stringify(fields.priority)}`)
console.log(`${key} - ${JSON.stringify(fields.priority)}`);
// console.log(`${key} - ${JSON.stringify(fields.status)}`)
// console.log(`${key} - ${JSON.stringify(fields.progress)}`)
})
});
}
function displayIssueCounts(res) {
console.log(Object.keys(res.issues[0].fields))
console.log(Object.keys(res.issues[0].fields));
const issueGroups = res.issues.reduce((memo, issue) => {
const { fields = {} } = issue
const { priority = {} } = fields
const { fields = {} } = issue;
const { priority = {} } = fields;
if (priority && priority.name) {
return {
...memo,
[priority.name]: (memo[priority.name] || 0) + 1,
}
[priority.name]: (memo[priority.name] || 0) + 1
};
}
return memo
}, {})
return memo;
}, {});
Object.keys(issueGroups).forEach((key) => {
console.log(`${key} - ${issueGroups[key]} issues`)
})
Object.keys(issueGroups).forEach(key => {
console.log(`${key} - ${issueGroups[key]} issues`);
});
}
function displayProjects(res) {
console.log(`${res.length} Project(s)`)
console.log('--------------------------------')
console.log(`${res.length} Project(s)`);
console.log("--------------------------------");
res.forEach(({ name, id, key }) => {
console.log(`${id} - ${name}`)
console.log(`==> ${getJiraHost()}/projects/${key}`)
console.log('--------------------------------')
})
console.log(`${id} - ${name}`);
console.log(`==> ${getJiraHost()}/projects/${key}`);
console.log("--------------------------------");
});
}

@@ -57,6 +58,6 @@

host: getJiraHost(),
token: getJiraToken(),
token: getJiraToken()
})
.getIssuesForUser()
.then(displayIssueCounts)
.then(displayIssueCounts);
}

@@ -1,5 +0,5 @@

import http from '../http'
import http from "../http";
export default function jiraAPI({ token, host } = {}, httpClient = http) {
const BASE_URL = `https://${host}/rest/api/2`
const BASE_URL = `https://${host}/rest/api/2`;

@@ -11,14 +11,14 @@ function request({ url, params = {}, method } = {}) {

headers: {
Authorization: `Basic ${token}`,
Authorization: `Basic ${token}`
},
...(method ? { method } : {}),
})
...(method ? { method } : {})
});
}
function getProjects() {
return request({ url: `${BASE_URL}/project` })
return request({ url: `${BASE_URL}/project` });
}
function getIssuesForUser() {
return request({ url: `${BASE_URL}/search?jql=assignee=currentuser()` })
return request({ url: `${BASE_URL}/search?jql=assignee=currentuser()` });
}

@@ -29,4 +29,4 @@

getIssuesForUser,
getProjects,
}
getProjects
};
}
/* eslint-disable no-console */
import chalk from 'chalk'
import chalk from "chalk";
export function logPRLink(link) {
console.log(`${chalk.cyan('==>')} ${link}`)
console.log(`${chalk.cyan("==>")} ${link}`);
}
export function logPRStatus({ state, type, url }) {
if (type === 'build') {
let buildColor = chalk.white
if (state === 'INPROGRESS') {
buildColor = chalk.yellow
} else if (state === 'SUCCESSFUL') {
buildColor = chalk.green
} else if (state === 'FAILED') {
buildColor = chalk.red
if (type === "build") {
let buildColor = chalk.white;
if (state === "INPROGRESS") {
buildColor = chalk.yellow;
} else if (state === "SUCCESSFUL") {
buildColor = chalk.green;
} else if (state === "FAILED") {
buildColor = chalk.red;
}
console.log(`Build: ${buildColor(state)} ${url}\n`)
console.log(`Build: ${buildColor(state)} ${url}\n`);
}

@@ -26,9 +26,9 @@ }

Author: ${author.display_name}
`)
`);
}
export function logPRDescription(description) {
console.log(`${chalk.yellow('Description:')}
console.log(`${chalk.yellow("Description:")}
${description}
`)
`);
}

@@ -38,6 +38,8 @@

if (approvals.length) {
console.log(`${chalk.green('\u2713')} Approved by ${approvals.join(', ')}\n`)
console.log(
`${chalk.green("\u2713")} Approved by ${approvals.join(", ")}\n`
);
} else {
console.log(`${chalk.red('\u2717')} Not yet approved \n`)
console.log(`${chalk.red("\u2717")} Not yet approved \n`);
}
}

@@ -1,9 +0,6 @@

import inquirer from 'inquirer'
import chalk from 'chalk'
import ora from 'ora'
import inquirer from "inquirer";
import chalk from "chalk";
import ora from "ora";
import {
getBitbucketUsername,
requireLogin,
} from './config'
import { getBitbucketUsername, requireLogin } from "./config";

@@ -16,4 +13,4 @@ import {

createPullRequest,
addPullRequestComment,
} from './bitbucket'
addPullRequestComment
} from "./bitbucket";

@@ -24,4 +21,4 @@ import {

pullAndRebase,
checkoutBranch,
} from './git-cli'
checkoutBranch
} from "./git-cli";

@@ -33,6 +30,6 @@ import {

logPRApprovals,
logPRLink,
} from './log'
logPRLink
} from "./log";
const CURRENT_USERNAME = getBitbucketUsername()
const CURRENT_USERNAME = getBitbucketUsername();

@@ -42,3 +39,3 @@ export function parseUserApprovals(activity) {

.filter(({ approval }) => approval)
.map(({ approval }) => approval.user.username)
.map(({ approval }) => approval.user.username);
}

@@ -48,23 +45,27 @@

try {
await requireLogin()
await requireLogin();
const [statuses, activity] = await Promise.all([
bitbucketRequest(pullrequest.links.statuses.href).then(({ values }) => values),
bitbucketRequest(pullrequest.links.activity.href).then(({ values }) => values),
])
bitbucketRequest(pullrequest.links.statuses.href).then(
({ values }) => values
),
bitbucketRequest(pullrequest.links.activity.href).then(
({ values }) => values
)
]);
logPRHeader(pullrequest)
logPRApprovals(parseUserApprovals(activity))
logPRHeader(pullrequest);
logPRApprovals(parseUserApprovals(activity));
if (statuses && statuses.length) {
statuses.forEach(logPRStatus)
statuses.forEach(logPRStatus);
}
if (pullrequest.description.trim().length) {
logPRDescription(pullrequest.description)
logPRDescription(pullrequest.description);
}
return true
return true;
} catch (e) {
throw e
throw e;
}

@@ -74,18 +75,19 @@ }

async function getPullRequestActions(pr) {
const activity = (await bitbucketRequest(pr.links.activity.href)).values
const activity = (await bitbucketRequest(pr.links.activity.href)).values;
// based on activity, setup approve or unapprove link
const hasApproved = parseUserApprovals(activity).includes(CURRENT_USERNAME)
const approvalType = hasApproved ? 'unapprove' : 'approve'
const approvalMethod = hasApproved ? 'delete' : 'post'
const hasApproved = parseUserApprovals(activity).includes(CURRENT_USERNAME);
const approvalType = hasApproved ? "unapprove" : "approve";
const approvalMethod = hasApproved ? "delete" : "post";
return {
checkout: () => pullAndRebase && checkoutBranch(pr.source.branch.name),
[approvalType]: () => bitbucketRequest(pr.links.approve.href, {}, approvalMethod),
decline: () => bitbucketRequest(pr.links.decline.href, {}, 'post'),
[approvalType]: () =>
bitbucketRequest(pr.links.approve.href, {}, approvalMethod),
decline: () => bitbucketRequest(pr.links.decline.href, {}, "post"),
// comment: () => promptComment(pr.id),
// activity: () => bitbucketRequest(pr.links.activity.href),
merge: () => bitbucketRequest(pr.links.merge.href, {}, 'post'),
quit: () => {},
}
merge: () => bitbucketRequest(pr.links.merge.href, {}, "post"),
quit: () => {}
};
}

@@ -95,40 +97,41 @@

export function promptComment() {
return inquirer.prompt({
type: 'input',
name: 'comment',
message: 'Your comment:',
validate: val => !!val,
filter: val => val.trim(),
when: () => true,
})
return inquirer
.prompt({
type: "input",
name: "comment",
message: "Your comment:",
validate: val => !!val,
filter: val => val.trim(),
when: () => true
})
.then(({ comment }) => addPullRequestComment(comment))
.catch(e => console.log(e))
.catch(e => console.log(e));
}
async function promptCreatePullRequest() {
const spinner = ora()
const spinner = ora();
try {
await requireLogin()
await requireLogin();
const currentBranch = getBranch()
const currentBranch = getBranch();
const prObj = {
source: { branch: { name: currentBranch } },
title: '',
description: '',
reviewers: [],
}
title: "",
description: "",
reviewers: []
};
const { createpr } = await inquirer.prompt({
type: 'confirm',
name: 'createpr',
type: "confirm",
name: "createpr",
message: `Would you like to create a pull request for your branch ${currentBranch}?`,
validate: val => !!val,
filter: val => val.trim(),
when: () => true,
})
when: () => true
});
if (!createpr) {
return true
return true;
}
spinner.start('Preparing pull request...')
spinner.start("Preparing pull request...");
const [repository, defaultReviewers = []] = await Promise.all([

@@ -138,6 +141,6 @@ getRepository(),

// by giving an empty list
getRepositoryDefaultReviewers().catch(() => []),
])
getRepositoryDefaultReviewers().catch(() => [])
]);
spinner.succeed('All set!')
spinner.succeed("All set!");
if (repository) {

@@ -150,45 +153,45 @@ const {

reviewers = [],
addReviewers,
addReviewers
} = await inquirer.prompt([
{
type: 'input',
name: 'destination',
message: 'What branch should this pull request merge into?',
type: "input",
name: "destination",
message: "What branch should this pull request merge into?",
default: repository.mainbranch.name,
validate: val => !!val,
filter: val => val.trim(),
when: () => true,
when: () => true
},
{
type: 'confirm',
name: 'closeBranch',
message: 'Close branch on merge?',
when: () => true,
type: "confirm",
name: "closeBranch",
message: "Close branch on merge?",
when: () => true
},
{
type: 'input',
name: 'title',
message: 'Pull request title:',
type: "input",
name: "title",
message: "Pull request title:",
default: currentBranch,
validate: val => !!val,
filter: val => val.trim(),
when: () => true,
when: () => true
},
{
type: 'confirm',
name: 'addDescription',
message: 'Add pull request description?',
when: () => true,
type: "confirm",
name: "addDescription",
message: "Add pull request description?",
when: () => true
},
{
type: 'editor',
name: 'description',
message: 'Description:',
type: "editor",
name: "description",
message: "Description:",
filter: val => val.trim(),
when: ({ addDescription }) => addDescription,
when: ({ addDescription }) => addDescription
},
{
type: 'checkbox',
name: 'reviewers',
message: 'Select your reviewers:',
type: "checkbox",
name: "reviewers",
message: "Select your reviewers:",
choices: defaultReviewers

@@ -199,22 +202,19 @@ .filter(u => u.username !== CURRENT_USERNAME)

value: i.username,
checked: true,
checked: true
})),
when: () => defaultReviewers && defaultReviewers.length,
when: () => defaultReviewers && defaultReviewers.length
},
{
type: 'input',
name: 'addReviewers',
message: 'Add reviewers? (Enter usernames as csv)',
filter: val => val.trim(),
},
])
type: "input",
name: "addReviewers",
message: "Add reviewers? (Enter usernames as csv)",
filter: val => val.trim()
}
]);
const allReviewers = [
...reviewers,
...addReviewers.split(','),
]
const allReviewers = [...reviewers, ...addReviewers.split(",")]
.filter(i => i && i.trim().length)
.map(i => ({ username: i.trim() }))
.map(i => ({ username: i.trim() }));
spinner.start('Creating your pull request...')
spinner.start("Creating your pull request...");
const pullRequest = await createPullRequest({

@@ -226,24 +226,24 @@ ...prObj,

close_source_branch: closeBranch,
reviewers: allReviewers,
})
spinner.succeed('Pull request created!')
reviewers: allReviewers
});
spinner.succeed("Pull request created!");
logPRLink(pullRequest.links.html.href)
logPRLink(pullRequest.links.html.href);
}
return { success: true }
return { success: true };
} catch (e) {
spinner.fail('Whoops!')
const { fields } = e || {}
const { source = [] } = fields || {}
spinner.fail("Whoops!");
const { fields } = e || {};
const { source = [] } = fields || {};
if (source && source.length) {
source.forEach(m => {
if (m.includes('branch not found')) {
console.log(`\n${chalk.yellow('** Did you push your branch?')}\n`)
if (m.includes("branch not found")) {
console.log(`\n${chalk.yellow("** Did you push your branch?")}\n`);
}
console.log(`${chalk.red(' Error: ' + m)}\n`)
})
console.log(`${chalk.red(" Error: " + m)}\n`);
});
}
throw e
throw e;
}

@@ -254,65 +254,75 @@ }

return inquirer.prompt({
type: 'confirm',
name: 'repeat',
message: 'See actions again?',
type: "confirm",
name: "repeat",
message: "See actions again?",
validate: val => !!val,
when: () => true,
})
when: () => true
});
}
async function runStatus() {
const spinner = ora()
const spinner = ora();
try {
await requireLogin()
await requireLogin();
spinner.start('Getting pull requests...')
const pullrequests = await getPullRequests()
spinner.start("Getting pull requests...");
const pullrequests = await getPullRequests();
if (pullrequests.length === 0) {
spinner.succeed(`${chalk.green('All clear!')}`)
console.log(chalk.cyan('No pull requests available.\n'))
return true
spinner.succeed(`${chalk.green("All clear!")}`);
console.log(chalk.cyan("No pull requests available.\n"));
return true;
}
console.log('')
spinner.succeed(`Found ${pullrequests.length} pull request(s)`)
console.log("");
spinner.succeed(`Found ${pullrequests.length} pull request(s)`);
const prGroups = await Promise.all(pullrequests.map(async (pullrequest) => {
const [prstatus, activity] = await Promise.all([
bitbucketRequest(pullrequest.links.statuses.href).then(({ values }) => values),
bitbucketRequest(pullrequest.links.activity.href).then(({ values }) => values),
])
const prGroups = await Promise.all(
pullrequests.map(async pullrequest => {
const [prstatus, activity] = await Promise.all([
bitbucketRequest(pullrequest.links.statuses.href).then(
({ values }) => values
),
bitbucketRequest(pullrequest.links.activity.href).then(
({ values }) => values
)
]);
return {
id: pullrequest.id,
pullrequest,
statuses: prstatus,
approvals: parseUserApprovals(activity),
}
}))
return {
id: pullrequest.id,
pullrequest,
statuses: prstatus,
approvals: parseUserApprovals(activity)
};
})
);
prGroups.sort(pr => pr.id).forEach(({ pullrequest, statuses, approvals }, index) => {
if (index === 0) {
console.log(chalk.dim('===================================='))
} else {
console.log('-------------------------------------')
}
prGroups
.sort(pr => pr.id)
.forEach(({ pullrequest, statuses, approvals }, index) => {
if (index === 0) {
console.log(chalk.dim("===================================="));
} else {
console.log("-------------------------------------");
}
logPRHeader(pullrequest)
logPRHeader(pullrequest);
if (approvals.length) {
console.log(`${chalk.green('\u2713')} Approved by ${approvals.join(', ')}\n`)
} else {
console.log(`${chalk.red('\u2717')} Not yet approved \n`)
}
if (statuses && statuses.length) {
statuses.forEach(logPRStatus)
}
if (approvals.length) {
console.log(
`${chalk.green("\u2713")} Approved by ${approvals.join(", ")}\n`
);
} else {
console.log(`${chalk.red("\u2717")} Not yet approved \n`);
}
if (statuses && statuses.length) {
statuses.forEach(logPRStatus);
}
logPRLink(pullrequest.links.html.href)
})
logPRLink(pullrequest.links.html.href);
});
return true
return true;
} catch (e) {
spinner.fail('Whoops, something happened!')
throw e
spinner.fail("Whoops, something happened!");
throw e;
}

@@ -322,24 +332,24 @@ }

async function promptPullRequestActions(pullrequest) {
const spinner = ora()
const spinner = ora();
try {
spinner.start()
const actions = await getPullRequestActions(pullrequest)
spinner.stop()
spinner.start();
const actions = await getPullRequestActions(pullrequest);
spinner.stop();
const { action } = await inquirer.prompt({
type: 'list',
name: 'action',
message: 'What action would you like to perform?',
type: "list",
name: "action",
message: "What action would you like to perform?",
choices: Object.keys(actions).map(a => ({
name: a,
value: actions[a],
value: actions[a]
})),
validate: val => !!val,
when: () => true,
})
when: () => true
});
if (action) {
spinner.start()
const data = await action()
spinner.succeed(`Done`)
logPRLink(pullrequest.links.html.href)
spinner.start();
const data = await action();
spinner.succeed(`Done`);
logPRLink(pullrequest.links.html.href);
if (data && data.values) {

@@ -350,6 +360,6 @@ // data.values.map((i) => console.log('i - ', JSON.stringify(i)))

return null
return null;
} catch (e) {
spinner.fail('Whoops, something happened')
throw e
spinner.fail("Whoops, something happened");
throw e;
}

@@ -359,23 +369,21 @@ }

async function promptPullRequestList() {
const spinner = ora()
const spinner = ora();
try {
await requireLogin()
await requireLogin();
spinner.start('Getting pull requests...')
const list = await getPullRequests()
spinner.start("Getting pull requests...");
const list = await getPullRequests();
if (list.length === 0) {
spinner.succeed(`${chalk.green('All clear!')}`)
console.log(chalk.cyan('No pull requests available.\n'))
return true
spinner.succeed(`${chalk.green("All clear!")}`);
console.log(chalk.cyan("No pull requests available.\n"));
return true;
}
spinner.stop()
spinner.stop();
const { pullrequest } = await inquirer.prompt({
type: 'list',
name: 'pullrequest',
message: 'Select a pull request?',
choices: list.map(({
author, state, id, title, ...pr
}) => ({
type: "list",
name: "pullrequest",
message: "Select a pull request?",
choices: list.map(({ author, state, id, title, ...pr }) => ({
name: `(${state}) #${id} by ${author.display_name} - ${title}`,

@@ -387,16 +395,16 @@ value: {

title,
...pr,
},
...pr
}
})),
validate: val => !!val,
when: () => true,
})
when: () => true
});
spinner.start('Getting summary...')
await renderPRSummary(pullrequest)
spinner.stop()
spinner.start("Getting summary...");
await renderPRSummary(pullrequest);
spinner.stop();
return await promptPullRequestActions(pullrequest)
return await promptPullRequestActions(pullrequest);
} catch (e) {
throw e
throw e;
}

@@ -406,17 +414,16 @@ }

export function promptPullRequestCommand({ create, status }) {
if (!getRemoteURL().includes('bitbucket')) {
console.log(chalk.cyan('hi pr currently supported with bitbucket only'))
return Promise.resolve(true)
if (!getRemoteURL().includes("bitbucket")) {
console.log(chalk.cyan("hi pr currently supported with bitbucket only"));
return Promise.resolve(true);
}
if (create) {
return promptCreatePullRequest()
return promptCreatePullRequest();
}
if (status) {
return runStatus()
return runStatus();
}
return promptPullRequestList()
return promptPullRequestList();
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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