From 845c04d1f6dc484e5677adb2a112a4f28f019265 Mon Sep 17 00:00:00 2001 From: Lalit Jolania Date: Thu, 28 Nov 2019 09:46:35 +0100 Subject: [PATCH] Added custom port configuration --- src/config.js | 21 ++++++++++++++++++++- src/issues.js | 3 ++- src/jira.js | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/config.js b/src/config.js index 3d8d834..84c7edc 100644 --- a/src/config.js +++ b/src/config.js @@ -71,13 +71,19 @@ export default class Config { type: 'confirm', name: 'protocol', message: 'Enable HTTPS Protocol?' + }, + { + type: ' input', + name: 'port', + message: 'Provide your jira port: ', + default: 'https:443|http:80' } ]; return inquirer.prompt(questions).then(function (answers) { const protocol = answers.protocol ? 'https' : 'http'; - + const config = { protocol: protocol.trim(), host: answers.host.trim(), @@ -87,6 +93,9 @@ export default class Config { strictSSL: true }; + const port = !isNaN(answers.port.trim()) ? answers.port.trim() : (answers.protocol ? '443' : '80'); + config.port = port; + return fs.writeFile(filePath, JSON.stringify(config), 'utf8') .then(function(){ console.log(''); @@ -153,6 +162,16 @@ export default class Config { } else { this.defaults.host = val; + this.updateConfigFile(); + } + } else if ( cmd == 'port' ) { + if ( typeof val === 'undefined' ) { + console.log( '' ); + console.log( ' Current port: ' + color.blue.bold(this.defaults.port) ); + console.log( '' ); + } else { + this.defaults.port = val; + this.updateConfigFile(); } } else if ( cmd == 'password' ) { diff --git a/src/issues.js b/src/issues.js index 2c13ce7..2b8899f 100644 --- a/src/issues.js +++ b/src/issues.js @@ -206,9 +206,10 @@ export default class JiraIssues { openIssue( issue ) { const _this = this; let config = jira.config.defaults; + let portUrlPart = config.port ? ':'+ config.port : ''; jira.api.findIssue( issue ).then(function(){ - opn( config.protocol + '://' + config.host + '/browse/' + issue, {wait: false}); + opn( config.protocol + '://' + config.host + portUrlPart + '/browse/' + issue, {wait: false}); }).catch(function( res ){ jira.showErrors( res ); process.exit(); diff --git a/src/jira.js b/src/jira.js index 9421cb4..23ffe11 100644 --- a/src/jira.js +++ b/src/jira.js @@ -157,7 +157,7 @@ class JiraCLI { // Remove config file if ( cmd == 'remove' ){ this.config.removeConfigFile(); - } else if ( cmd == 'host' || cmd == 'username' || cmd == 'password' || cmd == 'board' || cmd == 'proxy'){ + } else if ( cmd == 'host' || cmd == 'username' || cmd == 'password' || cmd == 'board' || cmd == 'proxy' || cmd == 'port'){ const val = process.argv.slice(4)[0];