@thestarware/atlascli-jira 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),core_1=require("@oclif/core"),enquirer_1=require("enquirer"),node_fetch_1=tslib_1.__importDefault(require("node-fetch")),atlascli_common_1=require("@thestarware/atlascli-common"),uuid_1=require("uuid"),chalk_1=tslib_1.__importDefault(require("chalk"));class ConfigAdd extends atlascli_common_1.Command{async run(){var e=(await this.parse(ConfigAdd))["flags"],t=await this.getSiteURL(e),r=await this.getAlias(e);let
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),core_1=require("@oclif/core"),enquirer_1=require("enquirer"),node_fetch_1=tslib_1.__importDefault(require("node-fetch")),atlascli_common_1=require("@thestarware/atlascli-common"),uuid_1=require("uuid"),chalk_1=tslib_1.__importDefault(require("chalk"));class ConfigAdd extends atlascli_common_1.Command{async run(){var e=(await this.parse(ConfigAdd))["flags"],t=await this.getSiteURL(e),r=await this.getAlias(e);let i;var s=await ConfigAdd.getServerInfo(t),s=(i="Cloud"!==s.deploymentType?await this.runJiraServer(t,e,s):await this.runJiraCloud(t,e),await this.addSite(r,i),this.conf.get("sites"));1===Object.keys(s).length&&this.conf.set("defaultSite",r)}async getAlias(e){let t=null;for(;null===t;){t=e.alias||await this.promptUser("text","alias","Alias for the site?");var r=0<Object.keys(this.sites).filter(e=>e===t).length;if(r)if(!(await(0,enquirer_1.prompt)({type:"confirm",name:"override",message:`'${t}' already exist. Do you want to override?`})).override)throw new Error("Alias already exist")}return t}static async getServerInfo(e){return core_1.CliUx.ux.action.start("Checking site..."),e.toString().endsWith("/")||(e=new URL(e+"/")),(0,node_fetch_1.default)(e+"rest/api/2/serverInfo").then(async e=>e.json()).then(e=>(core_1.CliUx.ux.action.stop(chalk_1.default.green("Done")),e)).catch(e=>{throw core_1.CliUx.ux.action.stop(chalk_1.default.red("Failed")),e})}async runJiraCloud(e,t){var r=await this.getEmail(t),i=await this.getToken(t),s=await this.getWebTriggerURL(t),e={cloud:!0,uuid:(0,uuid_1.v4)(),site:e.toString(),webTriggerURL:s,email:r,token:i};if(200!=(await(0,node_fetch_1.default)(s+"?id="+e.uuid)).status)throw new Error("invalid webtrigger url");r=this.getJira(e,t);return await r.doFetch(r.makeUri("/serverInfo")),e}async runJiraServer(e,t,r){var i=await this.getUsername(t);let s,a;(8<r.versionNumbers[0]||8===r.versionNumbers[0]&&14<=r.versionNumbers[1]?await(0,enquirer_1.prompt)({type:"confirm",name:"useToken",initial:!0,message:"Do you want to use token instead of password (recommended)?"}):{useToken:!1}).useToken?a=await this.getToken(t):s=await this.getPassword(t);r={cloud:!1,uuid:(0,uuid_1.v4)(),site:e.toString(),username:i,password:s,token:a},e=this.getJira(r,t);return await e.doFetch(e.makeUri("/serverInfo")),r}async getUsername(e){return e.username||process.env.ATLASCLI_USERNAME||this.promptUser("text","username","Username?")}async getEmail(e){return e.email||process.env.ATLASCLI_EMAIL||this.promptUser("text","email","E-mail?")}async getToken(e){return e.token||process.env.ATLASCLI_TOKEN||this.promptUser("password","token","OAuth Token?")}async getWebTriggerURL(e){return e.webTriggerURL||this.promptUser("text","webTriggerURL","Web Trigger? https://bit.ly/3nGExBi")}async getPassword(e){return e.password||process.env.ATLASCLI_PASSWORD||this.promptUser("password","password","Password?")}async getSiteURL(e){let t=e.site||await this.promptUser("text","site","Site URL?");return t.startsWith("http://")||t.startsWith("https://")||(t="https://"+t),new URL(t)}}(exports.default=ConfigAdd).description="Adds a new Jira site configuration.",ConfigAdd.flags=Object.assign(Object.assign({},atlascli_common_1.Command.flags),{site:core_1.Flags.string({char:"s",description:"URL of Jira site"}),username:core_1.Flags.string({char:"u",description:"username for username/password authentication",exclusive:["email"],dependsOn:["password"]}),password:core_1.Flags.string({char:"p",description:"password for username/password authentication",dependsOn:["username"]}),email:core_1.Flags.string({char:"e",description:"e-mail for authentication",exclusive:["username"],dependsOn:["email"]}),token:core_1.Flags.string({char:"t",description:"oauth authentication token associated with e-mail",dependsOn:["email"]}),webTriggerURL:core_1.Flags.string({char:"t",description:"Install the corresponding Forge add-on and run webtrigger on the terminal. After that, copy & paste the complete URL here.",dependsOn:["email"]}),alias:core_1.Flags.string({char:"a",description:"alias for the site"}),help:core_1.Flags.help({char:"h"})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),core_1=require("@oclif/core"),base_command_1=tslib_1.__importDefault(require("@thestarware/atlascli-common/lib/commands/base-command"));class Delete extends base_command_1.default{async run(){var{flags:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),core_1=require("@oclif/core"),base_command_1=tslib_1.__importDefault(require("@thestarware/atlascli-common/lib/commands/base-command"));class Delete extends base_command_1.default{async run(){var e,{flags:t,args:s}=await this.parse(Delete),t=t.site||s.site;t?(s=this.conf.get("sites"),e=Object.keys(s)[0],await this.getSite(t)?(t==this.conf.get("defaultSite")&&1<Object.keys(s).length&&this.conf.set("defaultSite",e),delete this.sites[t],this.conf.set("sites",this.sites)):this.error(t+" is not defined!")):this.error("site alias is required either as a flag or argument!")}}(exports.default=Delete).description="Deletes site with given alias.",Delete.flags=Object.assign(Object.assign({},base_command_1.default.flags),{site:core_1.Flags.string({char:"s",description:"Alias of the site"})}),Delete.args=[{name:"site",description:"Alias of the site"}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isSimpleRequest=exports.getSimpleRequestFlags=exports.richTextSampleData=void 0;const tslib_1=require("tslib"),atlascli_common_1=require("@thestarware/atlascli-common"),mapper_utils_1=require("@thestarware/atlascli-common/lib/util/mapper-utils"),core_1=require("@oclif/core"),get_create_metadata_1=tslib_1.__importStar(require("./get-create-metadata")),skippedFields=(exports.richTextSampleData={type:"doc",version:1,content:[{type:"paragraph",content:[{text:"Sample paragraph.",type:"text"}]}]},["com.pyxis.greenhopper.jira:gh-sprint","com.pyxis.greenhopper.jira:jsw-issue-color"]),richTextFields=["description","environment","com.atlassian.jira.plugin.system.customfieldtypes:textarea"];function getSimpleRequestFlags(){return{assignee:core_1.Flags.string({description:"Assignee ID."}),reporter:core_1.Flags.string({description:"Reporter ID."}),security:core_1.Flags.string({description:"Security level ID"}),priority:core_1.Flags.string({description:"Issue priority ID."}),components:core_1.Flags.string({description:"Component IDs. This flag allows comma seperated values.",parse:async e=>e.split(",")}),versions:core_1.Flags.string({description:"Version IDs. This flag allows comma-seperated values.",parse:async e=>e.split(",")}),fixVersions:core_1.Flags.string({description:"Fix version IDs. This flag allows comma-seperated values.",parse:async e=>e.split(",")}),description:core_1.Flags.string({description:"Description of the issue."}),summary:core_1.Flags.string({description:"Summary of the issue."}),environment:core_1.Flags.string({description:"Issue environment."}),labels:core_1.Flags.string({description:"Labels of the issue. This flag allows comma seperated values.",parse:async e=>e.split(",")}),duedate:core_1.Flags.string({description:"Due date of the issue."}),parent:core_1.Flags.string({description:"Parent issue key or ID."}),customFields:core_1.Flags.string({description:'Issue customfields.\nExample usage: --customFields=customfield_10000="My Value",customfield_10001="My Value2"',parse:async e=>(0,mapper_utils_1.commaSeperatedListOfKeyValuePairsToJsonObjectArrayMapper)(e,"customFields")[0]})}}function isSimpleRequest(e,s){const t=Object.keys(Object.assign(Object.assign({},getSimpleRequestFlags()),get_create_metadata_1.metadataFlags));var a=Object.keys(e).filter(e=>t.includes(e)).length;return!(e.issueBody||s.issueBody||!a)}exports.getSimpleRequestFlags=getSimpleRequestFlags,exports.isSimpleRequest=isSimpleRequest;class CreateIssue extends atlascli_common_1.CommandWithSite{async runWithSite(e){var{flags:s,args:t}=await this.parse(CreateIssue),a=this.getJira(e,s);s.show?(this.modifyFlags(s),await this.showSampleCreateRequest(s,a,e)):isSimpleRequest(s,t)?await this.runCreateIssueSimple(s,a,e):await this.runCreateIssue(s,t,a,e)}async runCreateIssueSimple(e,s,t){if(!e.issueType||!e.project)throw new Error("Please provide issueType and project flags.");this.modifyFlags(e);var a=this.removeFlagsFromBase(e),i=a["updateHistory"],a=tslib_1.__rest(a,["updateHistory"]),s=await s.issueManager.createIssueSimple(a,i);this.display(e,s)}async runCreateIssue(e,s,t,a){let i=e.issueBody||s.issueBody;if(!(i=void 0===i?await(0,atlascli_common_1.readStdin)():i)||0===i.length)throw new Error("You should provide a valid JSON for the issue! You can use `jira issue:create --show --pKey=project_key --issueType=Type_Name` command to generate a valid JSON body.");s=await t.issueManager.createIssue(JSON.parse(i),e.updateHistory);this.display(e,[s])}async showSampleCreateRequest(e,s,t){e.output="json";var a=this.getEmptyCreationRequest();if(t.cloud){var i,r=(await s.issueManager.getCreateIssueMetadata(e.pId,e.pKey,e.issueTypeId,e.issueTypeName)).projects[0],o=r.issuetypes[0];for(const c in o.fields)Object.prototype.hasOwnProperty.call(o.fields,c)&&(i=o.fields[c],this.processField(a,i,o,r,t));var l=await this.findAssignableUserForJsonTemplate(s,r.key);l&&null!=(p=a.fields)&&p.assignee&&(a.fields.assignee.id=l)}else{var n,u=await get_create_metadata_1.default.getIssueTypeInfo(e.issueTypeName||e.issueTypeId,s),p=await s.issueManager.getCreateIssueMetadataForIssueTypes(e.pId||e.pKey,u.id.toString(),{});const d={};p.values.forEach(e=>d[e.fieldId]=e);for(const m in d)Object.prototype.hasOwnProperty.call(d,m)&&(n=d[m],this.processField(a,n,{name:u.name},{key:e.pKey[0]},t))}this.display(e,a)}getEmptyCreationRequest(){var e={fields:{project:{id:0},issuetype:{id:0}}};return e}processField(e,s,t,a,i){t=this.getSampleValueForField(s,t,a,i);t&&((a=s.key||s.fieldId)?e.fields[a]=t:console.error("Unknown fieldId for ",s))}getSampleValueForField(e,s,t,a){return 0<e.operations.length&&-1===e.operations.indexOf("set")?null:this.getSampleValueForType(e.schema.type,e,s,t,a)}getSampleValueForType(e,s,t,a,i){if(s.hasDefaultValue)return CreateIssue.getValue(s.defaultValue);if(s.schema.custom&&-1<skippedFields.indexOf(s.schema.custom))return null;var r=s.schema.system||s.schema.custom||"";switch(e){case"string":return"labels"===r?"label_value":-1<richTextFields.indexOf(r)&&i.cloud?exports.richTextSampleData:"Put a simple string here";case"date":case"votes":return"2029-01-20";case"datetime":return"2029-01-20T18:45:42.967+0000";case"issuetype":return{name:t.name};case"project":return{key:a.key};case"option":case"option-with-child":return this.getFirstAllowedValue(s);case"user":return i.cloud?{id:"5b10a2844c20165700ede21g"}:{name:"admin"};case"component":case"version":case"priority":return this.getFirstAllowedValue(s);case"any":return s.required?"":null;case"attachment":case"issuelinks":return null;case"timetracking":return{originalEstimate:"1d 2h",remainingEstimate:"3h 25m"};case"array":var o=this.getSampleValueForType(s.schema.items,s,t,a,i);return o?[o]:null;default:return null}}static getValue(t){if(null===t)return null;if(Array.isArray(t))return t.map(e=>this.getValue(e));if("object"!=typeof t)return t;{if("doc"===t.type)return t;let e=null,s=null;if(Array.isArray(t.children)&&0<t.length?s={child:this.getValue(t.children[0])}:void 0!==t.child&&(s={child:this.getValue(t.child)}),void 0!==t.value)e={value:t.value};else if(void 0!==t.name)e={name:t.name};else if(void 0!==t.id)e={id:t.id};else{if(void 0!==t.votes)return t.votes;if(void 0!==t.timeSpent)return`${t.timeSpentSeconds} (${t.timeSpent})`;if(void 0!==t.watchCount)return t.watchCount;if(void 0!==t.displayName)return t.displayName+"/"+(t.name||t.accountId);if(void 0!==t.progress&&void 0!==t.total)return`${t.progress}/${t.total}/`+t.percent}return Object.assign(Object.assign({},e),s)}}getFirstAllowedValue(e){return e.allowedValues&&0<e.allowedValues.length?(e=e.allowedValues[0],CreateIssue.getValue(e)):null}modifyFlags(e){Array.isArray(e.issueType)||(e.issueType=[e.issueType]),Number.isNaN(Number.parseInt(e.issueType[0],10))?e.issueTypeName=e.issueType[0]:e.issueTypeId=e.issueType[0],Number.isNaN(Number.parseInt(e.project[0],10))?e.pKey=e.project[0]:e.pId=e.project[0],delete e.project,delete e.issueType}async findAssignableUserForJsonTemplate(e,s){e=await e.userSearchManager.findAssignableUsers(void 0,s);if(0<e.length)return e[0].accountId}}(exports.default=CreateIssue).description="Creates an issue or, where the option to create subtasks is enabled in Jira, a subtask. You can also provide issue body using STDIN.",CreateIssue.flags=Object.assign(Object.assign(Object.assign({show:core_1.Flags.boolean({description:"Prepare a sample JSON output for issue creation.",dependsOn:["issueType","project"]}),issueBody:core_1.Flags.string({description:"Issue creation request in JSON format."}),updateHistory:core_1.Flags.boolean({allowNo:!0,description:"Update issue history",default:!1})},get_create_metadata_1.metadataFlags),getSimpleRequestFlags()),atlascli_common_1.CommandWithSite.flags),CreateIssue.args=[{name:"issueBody",description:"Issue creation request in JSON format."}];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),core_1=require("@oclif/core"),atlascli_common_1=require("@thestarware/atlascli-common");class AssociateSecurityScheme extends atlascli_common_1.BaseCommandWithCloudSite{async runWithCloudSite(e,s){var i=(await this.parse(AssociateSecurityScheme))["flags"],i=tslib_1.__rest(await this.removeFlagsFromBase(i),[]);i.oldToNewSecurityLevelMappings=[{newLevelId:i.newLevelId,oldLevelId:i.oldLevelId}],delete i.oldLevelId,delete i.newLevelId,await s.issueSecuritySchemeManager.associateSecurityScheme(i)}}(exports.default=AssociateSecurityScheme).description="Associates an issue security scheme with a project and remaps security levels of issues to the new levels, if provided.",AssociateSecurityScheme.flags=Object.assign({newLevelId:core_1.Flags.string({char:"n",description:"The new issue security level ID. Providing null will clear the assigned old level from issues."}),oldLevelId:core_1.Flags.string({char:"o",description:"The old issue security level ID. Providing null will remap all issues without any assigned levels."}),projectId:core_1.Flags.string({char:"p",description:"The ID of the project.",required:!0}),schemeId:core_1.Flags.string({char:"s",description:"The ID of the issue security scheme. Providing null will clear the association with the issue security scheme.",required:!0}),silent:core_1.Flags.boolean({description:"If you activate this flag progress bar will not be shown."})},atlascli_common_1.BaseCommandWithCloudSite.flags);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),atlascli_common_1=require("@thestarware/atlascli-common"),core_1=require("@oclif/core"),worklogs_1=require("@thestarware/atlassian-typescript-client/lib/jira/common/worklogs"),get_1=tslib_1.__importDefault(require("./get"));class Add extends atlascli_common_1.CommandWithSite{async runWithSite(e){var t=(await this.parse(Add))["flags"],s=this.getJira(e,t);if(t.adjustEstimate===worklogs_1.AdjustEstimate.NEW&&void 0===t.newEstimate)throw new Error("--newEstimate is required when --adjustEstime=new!");if(t.adjustEstimate===worklogs_1.AdjustEstimate.MANUAL&&void 0===t.reduceBy)throw new Error("--reduceBy is required when --adjustEstime=manual!");if(void 0===t.timeSpent&&void 0===t.timeSpentSeconds)throw new Error("Either --timeSpent or --timeSpentSeconds is required!");var i=Add.flagsToWorklogRequest(t,e.cloud),s=await s.worklogManager.addWorklog(t.issue,i,t.adjustEstimate,t.newEstimate,t.reduceBy,t.notifyUsers);this.displayAlternativeForTable(t,s,get_1.default.mapWorklog(s,e.cloud))}static flagsToWorklogRequest(e,t){return{comment:void 0!==e.comment?(0,atlascli_common_1.getComment)(e.comment,t):void 0,visibility:(0,atlascli_common_1.getVisibility)(e),started:e.started,timeSpent:e.timeSpent,timeSpentSeconds:e.timeSpentSeconds,properties:null==(t=e.property)?void 0:t.map(e=>e.split("/")).map(e=>({key:e[0],value:e[1]}))}}}(exports.default=Add).description="Adds a worklog to an issue.",Add.requestBodyFlags=Object.assign(Object.assign({comment:core_1.Flags.string({description:"A
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),atlascli_common_1=require("@thestarware/atlascli-common"),core_1=require("@oclif/core"),worklogs_1=require("@thestarware/atlassian-typescript-client/lib/jira/common/worklogs"),get_1=tslib_1.__importDefault(require("./get"));class Add extends atlascli_common_1.CommandWithSite{async runWithSite(e){var t=(await this.parse(Add))["flags"],s=this.getJira(e,t);if(t.adjustEstimate===worklogs_1.AdjustEstimate.NEW&&void 0===t.newEstimate)throw new Error("--newEstimate is required when --adjustEstime=new!");if(t.adjustEstimate===worklogs_1.AdjustEstimate.MANUAL&&void 0===t.reduceBy)throw new Error("--reduceBy is required when --adjustEstime=manual!");if(void 0===t.timeSpent&&void 0===t.timeSpentSeconds)throw new Error("Either --timeSpent or --timeSpentSeconds is required!");var i=Add.flagsToWorklogRequest(t,e.cloud),s=await s.worklogManager.addWorklog(t.issue,i,t.adjustEstimate,t.newEstimate,t.reduceBy,t.notifyUsers);this.displayAlternativeForTable(t,s,get_1.default.mapWorklog(s,e.cloud))}static flagsToWorklogRequest(e,t){return{comment:void 0!==e.comment?(0,atlascli_common_1.getComment)(e.comment,t):void 0,visibility:(0,atlascli_common_1.getVisibility)(e),started:e.started,timeSpent:e.timeSpent,timeSpentSeconds:e.timeSpentSeconds,properties:null==(t=e.property)?void 0:t.map(e=>e.split("/")).map(e=>({key:e[0],value:e[1]}))}}}(exports.default=Add).description="Adds a worklog to an issue.",Add.requestBodyFlags=Object.assign(Object.assign({comment:core_1.Flags.string({description:"A a comment about worklog. In ADF for Cloud and simple string for Server/DC. "})},(0,atlascli_common_1.getVisibilityFlags)()),{started:core_1.Flags.string({description:"The datetime on which the worklog effort was started. Example: 2014-03-19T18:45:42.000+0200"}),timeSpent:core_1.Flags.string({exclusive:["timeSpentSeconds"],description:"The time spent working on the issue as days (#d), hours (#h), or minutes (#m or #). Cannot be provided if timeSpentSecond is provided. "}),timeSpentSeconds:core_1.Flags.integer({exclusive:["timeSpent"],description:"The time in seconds spent working on the issue. Cannot be provided if timeSpent is provided. "}),property:core_1.Flags.string({multiple:!0,description:"An entity property in the form of key/value. This parameter can be repeated."})}),Add.flags=Object.assign(Object.assign(Object.assign({issue:core_1.Flags.string({required:!0,description:"Issue ID or key."})},Add.requestBodyFlags),{adjustEstimate:core_1.Flags.string({description:"Defines how to update the issue's time estimate. Defaults to 'auto'.",options:["new","leave","manual","auto"]}),newEstimate:core_1.Flags.string({dependsOn:["adjustEstimate"],description:"The value to set as the issue's remaining time estimate, as days (#d), hours (#h), or minutes (#m or #). For example, 2d. Required when adjustEstimate is new."}),reduceBy:core_1.Flags.string({dependsOn:["adjustEstimate"],description:"The amount to reduce the issue's remaining estimate by, as days (#d), hours (#h), or minutes (#m). For example, 2d. Required when adjustEstimate is manual."}),notifyUsers:core_1.Flags.boolean({description:"notifyUsers Whether users watching the issue are notified by email. This parameter is only for Jira Cloud."})}),atlascli_common_1.CommandWithSite.flags);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thestarware/atlascli-jira",
|
|
3
3
|
"description": "ATLAS CLI for Jira: Command Line Tool",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.2",
|
|
5
5
|
"buildOrder": 3,
|
|
6
6
|
"author": "deniz@thestarware.com",
|
|
7
7
|
"bin": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@oclif/plugin-help": "^5",
|
|
17
17
|
"@oclif/plugin-plugins": "^2.1.2",
|
|
18
18
|
"@oclif/plugin-update": "^2.2.0",
|
|
19
|
-
"@thestarware/atlascli-common": "1.1
|
|
19
|
+
"@thestarware/atlascli-common": "1.2.1",
|
|
20
20
|
"@types/node-fetch": "^2.5.7",
|
|
21
21
|
"node-fetch": "^2.6.1",
|
|
22
22
|
"tslib": "^2.3.1",
|