asciidoctor-jira 3.1.2 → 3.2.0

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.
package/lib/Jira.js CHANGED
@@ -2,11 +2,9 @@ const request = require('sync-request')
2
2
  const path = require('path')
3
3
 
4
4
  class Jira {
5
- constructor (doc) {
5
+ constructor (doc, jiraUserName, jiraApiToken, jiraBaseUrl) {
6
6
  this.doc = doc
7
-
8
- const jiraUserName = this.doc.getAttribute('jira-username') || process.env.JIRA_USERNAME
9
- const jiraApiToken = this.doc.getAttribute('jira-apitoken') || process.env.JIRA_APITOKEN
7
+ this.jiraBaseUrl = jiraBaseUrl
10
8
  const auth = 'Basic ' + Buffer.from(jiraUserName + ':' + jiraApiToken).toString('base64')
11
9
  this.headers = {
12
10
  authorization: auth
@@ -55,16 +53,22 @@ class Jira {
55
53
  const data = { jql, fields }
56
54
  let issues
57
55
  try {
58
- const jiraBaseUrl = this.doc.getAttribute('jira-baseurl') || process.env.JIRA_BASEURL
59
- const jiraRestApiSearchEndpoint = jiraBaseUrl + '/rest/api/2/search'
56
+ const jiraRestApiSearchEndpoint = this.jiraBaseUrl + '/rest/api/2/search'
60
57
  const res = request('GET', jiraRestApiSearchEndpoint, {
61
58
  headers: this.headers,
62
59
  qs: data
63
60
  })
64
- issues = JSON.parse(res.getBody('utf-8')).issues
61
+ if (res.statusCode === 200) {
62
+ if (res.headers['x-seraph-loginreason'] === 'AUTHENTICATED_FAILED') {
63
+ this.doc.getLogger().error(`Authentication failed for jira instance ${this.jiraBaseUrl}.`)
64
+ issues = []
65
+ } else {
66
+ issues = JSON.parse(res.getBody('utf-8')).issues
67
+ }
68
+ }
65
69
  } catch (err) {
66
70
  this.doc.getLogger().error(`Unexpected error occurs on requesting jira instance for issues. ${JSON.stringify(err)}`)
67
- issues = null
71
+ issues = []
68
72
  }
69
73
  return issues
70
74
  }
@@ -73,16 +77,20 @@ class Jira {
73
77
  const data = { jql: 'issueKey=' + issueKey, fields }
74
78
  let result
75
79
  try {
76
- const jiraBaseUrl = this.doc.getAttribute('jira-baseurl') || process.env.JIRA_BASEURL
77
- const jiraRestApiSearchEndpoint = jiraBaseUrl + '/rest/api/2/search'
80
+ const jiraRestApiSearchEndpoint = this.jiraBaseUrl + '/rest/api/2/search'
78
81
  const res = request('GET', jiraRestApiSearchEndpoint, {
79
82
  headers: this.headers,
80
83
  qs: data
81
84
  })
82
- result = JSON.parse(res.getBody('utf-8')).issues[0]
85
+ if (res.statusCode === 200) {
86
+ if (res.headers['x-seraph-loginreason'] === 'AUTHENTICATED_FAILED') {
87
+ this.doc.getLogger().error(`Authentication failed for jira instance ${this.jiraBaseUrl}.`)
88
+ } else {
89
+ result = JSON.parse(res.getBody('utf-8')).issues[0]
90
+ }
91
+ }
83
92
  } catch (err) {
84
93
  this.doc.getLogger().error(`Unexpected error occurs on requesting jira instance for issue ${issueKey}. ${JSON.stringify(err)}`)
85
- result = null
86
94
  }
87
95
  return result
88
96
  }
@@ -7,7 +7,8 @@ const plantumlEncoder = require('plantuml-encoder')
7
7
  const Jira = require('./Jira.js')
8
8
  require('dotenv').config()
9
9
  const _ = require('lodash')
10
- const JIRA = require("./Jira");
10
+ const JIRA = require('./Jira')
11
+ const rusha = require('rusha')
11
12
 
12
13
  function jiraIssuesBlockMacro (context) {
13
14
  return function () {
@@ -20,7 +21,7 @@ function jiraIssuesBlockMacro (context) {
20
21
  const jql = attrs.jql || (jiraProject === undefined ? 'resolution="Unresolved" ORDER BY priority DESC, key ASC, duedate ASC' : `project = ${jiraProject} AND resolution="Unresolved" ORDER BY priority DESC, key ASC, duedate ASC`)
21
22
  const customFields = attrs.customFieldIds || 'priority,created,assignee,issuetype,summary'
22
23
  const customFieldIds = customFields.split(',').map(customField => customField.split('.')[0])
23
- const jiraClient = new Jira(doc)
24
+ const jiraClient = new Jira(doc, doc.getAttribute('jira-username') || process.env.JIRA_USERNAME, doc.getAttribute('jira-apitoken') || process.env.JIRA_APITOKEN, doc.getAttribute('jira-baseurl') || process.env.JIRA_BASEURL)
24
25
  const issues = jiraClient.searchIssues(jql, customFieldIds)
25
26
  const logger = context.logger
26
27
 
@@ -97,7 +98,7 @@ function jiraIssueInlineMacro (context) {
97
98
  const doc = parent.getDocument()
98
99
  const displayFormat = attrs.format || doc.getAttribute('jira-inline-format') || 'short'
99
100
  const issueKey = target
100
- const jiraClient = new Jira(doc)
101
+ const jiraClient = new Jira(doc, doc.getAttribute('jira-username') || process.env.JIRA_USERNAME, doc.getAttribute('jira-apitoken') || process.env.JIRA_APITOKEN, doc.getAttribute('jira-baseurl') || process.env.JIRA_BASEURL)
101
102
  const issue = jiraClient.searchIssue(issueKey)
102
103
  let title = issueKey
103
104
  if (displayFormat === 'long') {
@@ -116,31 +117,21 @@ function roadmapBlockMacro (name, context) {
116
117
  self.positionalAttributes(['year', 'categories', 'release-date'])
117
118
  self.process((parent, target, attrs) => {
118
119
  const vfs = context.vfs
120
+ const config = require('./roadmap/config').createConfig(name, parent, target, attrs, parent.getDocument().getLogger())
119
121
  const doc = parent.getDocument()
120
- const jiraProject = parent.applySubstitutions(target, ['attributes'])
121
-
122
- const categories = (attrs.categories || doc.getAttribute(`${name}-categories`) || 'maintenance,feature,security,infrastructure,deprecated,migration').split(',').map(it => it.trim())
123
- const year = (attrs.year || doc.getAttribute(`${name}-year`) || new Date().toLocaleDateString('en-US', { year: 'numeric' }))
124
-
125
- const lastRoadmapReleaseDate = attrs['release-date'] || doc.getAttribute(`${name}-release-date`)
126
122
 
127
- const plantUmlServerUrl = doc.getAttribute('roadmap-plantuml-server-url') || 'https://kroki.io/plantuml'
128
- const jiraBaseUrl = doc.getAttribute(`${jiraProject.toLowerCase()}-roadmap-jira-baseurl`) || doc.getAttribute('roadmap-jira-baseurl')
129
- const theme = attrs[`${name}-theme`] || doc.getAttribute(`${name}-theme`) || 'hacker'
130
- const legendForStatus = (attrs[`${name}-legend-for-status`] || doc.getAttribute(`${name}-legend-for-status`) || 'Open,In Progress,Closed').split(',').map(it => it.trim())
131
- const jiraStatusClosed = (attrs[`${name}-closed-status`] || doc.getAttribute(`${name}-closed-status`) || 'Closed,Resolved').split(',').map(it => it.trim())
123
+ const jiraProject = config.projectKey
124
+ const categories = config.categories
125
+ const year = config.year
126
+ const jiraBaseUrl = config.jiraBaseUrl
127
+ const jiraFields = config.jiraFields
128
+ const plantUmlServerUrl = config.plantumlServerUrl
129
+ const jiraStatusClosed = config.closedStatus
130
+ const theme = config.plantumlTheme
131
+ const lastRoadmapReleaseDate = config.lastRoadmapReleaseDate
132
+ const legendForStatus = config.legendForStatus
132
133
 
133
- const jiraClient = new JIRA(doc)
134
-
135
- const jiraFields = {
136
- epicName: 'customfield_10004',
137
- summary: 'summary',
138
- status: 'status',
139
- issueType: 'issuetype',
140
- resolutionDate: 'resolutiondate',
141
- dueDate: 'duedate',
142
- created: 'created'
143
- }
134
+ const jiraClient = new JIRA(doc, config.jiraUsername, config.jiraPassword, config.jiraBaseUrl)
144
135
 
145
136
  const content = []
146
137
  content.push('@startgantt', 'printscale monthly zoom 3', 'language de', `Project starts the 1st of january ${year}`, 'hide footbox')
@@ -160,11 +151,10 @@ function roadmapBlockMacro (name, context) {
160
151
  </style>`)
161
152
 
162
153
  for (const catIndex in categories) {
163
- const category = categories[catIndex]
164
- const categoryLabel = doc.getAttribute(`roadmap-${category}-label`, `${category}`)
165
- const jql = `project = ${jiraProject} and labels in (Roadmap) and labels in ('${year}') and labels in (${category})`
154
+ const categoryLabel = config.getCategoryLabel(catIndex)
155
+ const jql = config.getCategoryJQL(catIndex)
166
156
 
167
- const issues = jiraClient.searchIssues(jql, Object.keys(jiraFields).map(it => it.value).join(','))
157
+ const issues = jiraClient.searchIssues(jql, Object.keys(jiraFields).map(it => jiraFields[it]).join(','))
168
158
 
169
159
  if (issues != null && issues.length > 0) {
170
160
  // add category label as separator
@@ -227,7 +217,7 @@ function roadmapBlockMacro (name, context) {
227
217
  doc.getLogger().debug(`${content.join('\n')}`)
228
218
 
229
219
  const downloadUrl = `${plantUmlServerUrl}/svg/${plantumlEncoder.encode(content.join('\n'))} `
230
- const diagramName = `roadmap-${target}-${year}.svg`
220
+ const diagramName = `roadmap-${jiraProject}-${year}-${rusha.createHash().update(content).digest('hex')}.svg`
231
221
  require('./common/fetch.js').save(diagramName, downloadUrl, doc, 'svg', vfs)
232
222
 
233
223
  self.parseContent(parent, `image::${diagramName}[opts=interactive]`, Opal.hash(attrs))
@@ -250,12 +240,12 @@ module.exports.register = function register (registry, context = {}) {
250
240
  if (typeof registry.register === 'function') {
251
241
  registry.register(function () {
252
242
  this.blockMacro(jiraIssuesBlockMacro(context))
253
- this.blockMacro(roadmapBlockMacro('roadmap',context))
243
+ this.blockMacro(roadmapBlockMacro('roadmap', context))
254
244
  this.inlineMacro(jiraIssueInlineMacro(context))
255
245
  })
256
246
  } else if (typeof registry.block === 'function') {
257
247
  registry.blockMacro(jiraIssuesBlockMacro(context))
258
- registry.blockMacro(roadmapBlockMacro('roadmap',context))
248
+ registry.blockMacro(roadmapBlockMacro('roadmap', context))
259
249
  registry.inlineMacro(jiraIssueInlineMacro(context))
260
250
  }
261
251
  return registry
@@ -0,0 +1,616 @@
1
+ // *** WARNING: DO NOT MODIFY *** This is a generated JavaScript source code!
2
+ //
3
+ // Generated by LF-ET 2.2.1 (230906a), https://www.lohrfink.de/lfet
4
+ // From decision table
5
+ // "/opt/data/github/asciidoctor/asciidoctor-jira/lfet/roadmap/config.lfet"
6
+ // 25.09.2023 16:43
7
+ //
8
+ // Changes to this code resulting from refactorings can be synchronised
9
+ // with LF-ET using the function "Scrapbook Import".
10
+ //
11
+ // Prolog Decision Table ---->
12
+ function config (name, parent, target, attrs, logger) {
13
+ let _step = 1
14
+ let _exit = false
15
+ const config = {
16
+ toJSON: function () {
17
+ const result = {}
18
+ for (const x in this) {
19
+ if (x !== 'jiraUsername' && x !== 'jiraPassword') {
20
+ result[x] = this[x]
21
+ } else {
22
+ if (x === 'jiraUsername' || x === 'jiraPassword') {
23
+ result[x] = this[x].replace(/./g, '*')
24
+ }
25
+ }
26
+ }
27
+ return result
28
+ },
29
+ jiraFields: {
30
+ epicName: 'customfield_10004',
31
+ summary: 'summary',
32
+ status: 'status',
33
+ issueType: 'issuetype',
34
+ resolutionDate: 'resolutiondate',
35
+ dueDate: 'duedate',
36
+ created: 'created'
37
+ },
38
+ getCategoryLabel: function (_catIndex) {
39
+ return this[`${this.categories[_catIndex]}Label`]
40
+ },
41
+ getCategoryJQL: function (_catIndex) {
42
+ return this[`${this.categories[_catIndex]}JQL`]
43
+ }
44
+ }
45
+ let catIndex = -1
46
+ const doc = parent.getDocument()
47
+ do {
48
+ _exit = true
49
+ // $$BasicIndentLevel=2
50
+ // Prolog Decision Table <----
51
+ // Condition C01/01: Step / 1 / jira project key information
52
+ if (_step === 1) {
53
+ // Condition C02: jira project key information is set
54
+ if (target !== undefined) {
55
+ // Rule R01 ---->
56
+ // Trace ---->
57
+ logger.info(`config - 20230925.164323 - 1 / 44 - ${JSON.stringify(config)}`)
58
+ // Trace <----
59
+ // Action A02: set jira project
60
+ config.projectKey = parent.applySubstitutions(target, ['attributes'])
61
+ // Action A15/01: next step / + / next step
62
+ _step++
63
+ _exit = false
64
+ // Rule R01 <----
65
+ } else {
66
+ // Rule R02 ---->
67
+ // Trace ---->
68
+ logger.info(`config - 20230925.164323 - 2 / 44 - ${JSON.stringify(config)}`)
69
+ // Trace <----
70
+ // Action A14/01: log mandatory information is missing / JIRA PROJECT / Jira project key is missing
71
+ logger.error('Jira project key is missing')
72
+ // Action A15/03: next step / E / Exit
73
+ _exit = true
74
+ // Rule R02 <----
75
+ }
76
+ // Condition C01/02: Step / 2 / jira base url information
77
+ } else if (_step === 2) {
78
+ // Condition C03/01: jira base url is set / ATTR / via macro attributes
79
+ if (attrs.jiraBaseUrl) {
80
+ // Rule R03 ---->
81
+ // Trace ---->
82
+ logger.info(`config - 20230925.164323 - 3 / 44 - ${JSON.stringify(config)}`)
83
+ // Trace <----
84
+ // Action A01/01: set jira base url / ATTR / via macro attributes
85
+ config.jiraBaseUrl = attrs.jiraBaseUrl
86
+ // Action A15/01: next step / + / next step
87
+ _step++
88
+ _exit = false
89
+ // Rule R03 <----
90
+ // Condition C03/02: jira base url is set / JIRA_PRJ / via doc attribute and jira project key suffix
91
+ } else if (doc.getAttribute(`${config.projectKey.toLowerCase()}-${name.toLowerCase()}-jira-baseurl`)) {
92
+ // Rule R04 ---->
93
+ // Trace ---->
94
+ logger.info(`config - 20230925.164323 - 4 / 44 - ${JSON.stringify(config)}`)
95
+ // Trace <----
96
+ // Action A01/03: set jira base url / JIRA_PRJ / via doc attribute and jira project key suffix
97
+ config.jiraBaseUrl = doc.getAttribute(`${config.projectKey.toLowerCase()}.${name}-jira-baseurl`)
98
+ // Action A15/01: next step / + / next step
99
+ _step++
100
+ _exit = false
101
+ // Rule R04 <----
102
+ // Condition C03/03: jira base url is set / DOC / via doc attribute
103
+ } else if (doc.getAttribute(`${name.toLowerCase()}-jira-baseurl`)) {
104
+ // Rule R05 ---->
105
+ // Trace ---->
106
+ logger.info(`config - 20230925.164323 - 5 / 44 - ${JSON.stringify(config)}`)
107
+ // Trace <----
108
+ // Action A01/02: set jira base url / DOC / via doc attribute
109
+ config.jiraBaseUrl = doc.getAttribute(`${name}-jira-baseurl`)
110
+ // Action A15/01: next step / + / next step
111
+ _step++
112
+ _exit = false
113
+ // Rule R05 <----
114
+ } else {
115
+ // Rule R06 ---->
116
+ // Trace ---->
117
+ logger.info(`config - 20230925.164323 - 6 / 44 - ${JSON.stringify(config)}`)
118
+ // Trace <----
119
+ // Action A14/02: log mandatory information is missing / BASE_URL / Jira base url is missing
120
+ logger.error('Jira base url is missing')
121
+ // Action A15/03: next step / E / Exit
122
+ _exit = true
123
+ // Rule R06 <----
124
+ }
125
+ // Condition C01/03: Step / 3 / jira username information
126
+ } else if (_step === 3) {
127
+ // Condition C04/01: jira username is set / DOC_PRJ / via doc attribute and jira project key praefix
128
+ if (doc.getAttribute(`${config.projectKey.toLowerCase()}-${name.toLowerCase()}-jira-username`)) {
129
+ // Rule R07 ---->
130
+ // Trace ---->
131
+ logger.info(`config - 20230925.164323 - 7 / 44 - ${JSON.stringify(config)}`)
132
+ // Trace <----
133
+ // Action A03/02: set jira username / DOC_PRJ / via doc attribute and jira project key praefix
134
+ config.jiraUsername = doc.getAttribute(`${config.projectKey.toLowerCase()}-${name}-jira-username`)
135
+ // Action A15/01: next step / + / next step
136
+ _step++
137
+ _exit = false
138
+ // Rule R07 <----
139
+ // Condition C04/02: jira username is set / DOC / via doc attribute
140
+ } else if (doc.getAttribute(`${name.toLowerCase()}-jira-username`)) {
141
+ // Rule R08 ---->
142
+ // Trace ---->
143
+ logger.info(`config - 20230925.164323 - 8 / 44 - ${JSON.stringify(config)}`)
144
+ // Trace <----
145
+ // Action A03/01: set jira username / DOC / via doc attribute
146
+ config.jiraUsername = doc.getAttribute(`${name}-jira-username`)
147
+ // Action A15/01: next step / + / next step
148
+ _step++
149
+ _exit = false
150
+ // Rule R08 <----
151
+ // Condition C04/03: jira username is set / ENV_PRJ / via env and jira project key praefix
152
+ } else if (process.env[`${config.projectKey.toUpperCase()}_${name.toUpperCase()}_JIRA_USERNAME`]) {
153
+ // Rule R09 ---->
154
+ // Trace ---->
155
+ logger.info(`config - 20230925.164323 - 9 / 44 - ${JSON.stringify(config)}`)
156
+ // Trace <----
157
+ // Action A03/04: set jira username / ENV_PRJ / via env and jira project key praefix
158
+ config.jiraUsername = process.env[`${config.projectKey.toUpperCase()}_${name.toUpperCase()}_JIRA_USERNAME`]
159
+ // Action A15/01: next step / + / next step
160
+ _step++
161
+ _exit = false
162
+ // Rule R09 <----
163
+ // Condition C04/04: jira username is set / ENV / via env
164
+ } else if (process.env[`${name.toUpperCase()}_JIRA_USERNAME`]) {
165
+ // Rule R10 ---->
166
+ // Trace ---->
167
+ logger.info(`config - 20230925.164323 - 10 / 44 - ${JSON.stringify(config)}`)
168
+ // Trace <----
169
+ // Action A03/03: set jira username / ENV / via env
170
+ config.jiraUsername = process.env[`${name.toUpperCase()}_JIRA_USERNAME`]
171
+ // Action A15/01: next step / + / next step
172
+ _step++
173
+ _exit = false
174
+ // Rule R10 <----
175
+ } else {
176
+ // Rule R11 ---->
177
+ // Trace ---->
178
+ logger.info(`config - 20230925.164323 - 11 / 44 - ${JSON.stringify(config)}`)
179
+ // Trace <----
180
+ // Action A14/03: log mandatory information is missing / JIRA_USR / Jira username is missing
181
+ logger.error('Jira username is missing')
182
+ // Action A15/03: next step / E / Exit
183
+ _exit = true
184
+ // Rule R11 <----
185
+ }
186
+ // Condition C01/04: Step / 4 / jira password / apitoken information
187
+ } else if (_step === 4) {
188
+ // Condition C05/01: jira password / apitoken is set / DOC_PRJ / via doc attribute and jira project key praefix
189
+ if (doc.getAttribute(`${config.projectKey.toLowerCase()}-${name.toLowerCase()}-jira-password`)) {
190
+ // Rule R12 ---->
191
+ // Trace ---->
192
+ logger.info(`config - 20230925.164323 - 12 / 44 - ${JSON.stringify(config)}`)
193
+ // Trace <----
194
+ // Action A04/02: set jira password / apitoken / DOC_PRJ / via doc attribute and jira project key praefix
195
+ config.jiraPassword = doc.getAttribute(`${config.projectKey.toLowerCase()}-${name}-jira-password`)
196
+ // Action A15/01: next step / + / next step
197
+ _step++
198
+ _exit = false
199
+ // Rule R12 <----
200
+ // Condition C05/02: jira password / apitoken is set / DOC / via doc attribute
201
+ } else if (doc.getAttribute(`${name.toLowerCase()}-jira-password`)) {
202
+ // Rule R13 ---->
203
+ // Trace ---->
204
+ logger.info(`config - 20230925.164323 - 13 / 44 - ${JSON.stringify(config)}`)
205
+ // Trace <----
206
+ // Action A04/01: set jira password / apitoken / DOC / via doc attribute
207
+ config.jiraPassword = doc.getAttribute(`${name}-jira-password`)
208
+ // Action A15/01: next step / + / next step
209
+ _step++
210
+ _exit = false
211
+ // Rule R13 <----
212
+ // Condition C05/03: jira password / apitoken is set / ENV_PRJ / via env and jira project key praefix
213
+ } else if (process.env[`${config.projectKey.toUpperCase()}_${name.toUpperCase()}_JIRA_PASSWORD`]) {
214
+ // Rule R14 ---->
215
+ // Trace ---->
216
+ logger.info(`config - 20230925.164323 - 14 / 44 - ${JSON.stringify(config)}`)
217
+ // Trace <----
218
+ // Action A04/04: set jira password / apitoken / ENV_PRJ / via env and jira project key praefix
219
+ config.jiraPassword = process.env[`${config.projectKey.toUpperCase()}_${name.toUpperCase()}_JIRA_PASSWORD`]
220
+ // Action A15/01: next step / + / next step
221
+ _step++
222
+ _exit = false
223
+ // Rule R14 <----
224
+ // Condition C05/04: jira password / apitoken is set / ENV / via env
225
+ } else if (process.env[`${name.toUpperCase()}_JIRA_PASSWORD`]) {
226
+ // Rule R15 ---->
227
+ // Trace ---->
228
+ logger.info(`config - 20230925.164323 - 15 / 44 - ${JSON.stringify(config)}`)
229
+ // Trace <----
230
+ // Action A04/03: set jira password / apitoken / ENV / via env
231
+ config.jiraPassword = process.env[`${name.toUpperCase()}_JIRA_PASSWORD`]
232
+ // Action A15/01: next step / + / next step
233
+ _step++
234
+ _exit = false
235
+ // Rule R15 <----
236
+ } else {
237
+ // Rule R16 ---->
238
+ // Trace ---->
239
+ logger.info(`config - 20230925.164323 - 16 / 44 - ${JSON.stringify(config)}`)
240
+ // Trace <----
241
+ // Action A14/04: log mandatory information is missing / JIRA_PWD / Jira password / apitoken is missing
242
+ logger.error('Jira password / apitoken is missing')
243
+ // Action A15/03: next step / E / Exit
244
+ _exit = true
245
+ // Rule R16 <----
246
+ }
247
+ // Condition C01/05: Step / 5 / year information
248
+ } else if (_step === 5) {
249
+ // Condition C06/01: year information is set / ATTR / via macro attributes
250
+ if (attrs.year) {
251
+ // Rule R17 ---->
252
+ // Trace ---->
253
+ logger.info(`config - 20230925.164323 - 17 / 44 - ${JSON.stringify(config)}`)
254
+ // Trace <----
255
+ // Action A05/01: set year / ATTR / via macro attributes
256
+ config.year = attrs.year
257
+ // Action A15/01: next step / + / next step
258
+ _step++
259
+ _exit = false
260
+ // Rule R17 <----
261
+ // Condition C06/02: year information is set / DOC / via doc attribute
262
+ } else if (doc.getAttribute(`${name.toLowerCase()}-year`)) {
263
+ // Rule R18 ---->
264
+ // Trace ---->
265
+ logger.info(`config - 20230925.164323 - 18 / 44 - ${JSON.stringify(config)}`)
266
+ // Trace <----
267
+ // Action A05/02: set year / DOC / via doc attribute
268
+ config.year = doc.getAttribute(`${name}-year`)
269
+ // Action A15/01: next step / + / next step
270
+ _step++
271
+ _exit = false
272
+ // Rule R18 <----
273
+ } else {
274
+ // Rule R19 ---->
275
+ // Trace ---->
276
+ logger.info(`config - 20230925.164323 - 19 / 44 - ${JSON.stringify(config)}`)
277
+ // Trace <----
278
+ // Action A05/03: set year / DEF / current year
279
+ config.year = new Date().toLocaleDateString('en-US', { year: 'numeric' })
280
+ // Action A15/01: next step / + / next step
281
+ _step++
282
+ _exit = false
283
+ // Rule R19 <----
284
+ }
285
+ // Condition C01/06: Step / 6 / category information
286
+ } else if (_step === 6) {
287
+ // Condition C07/01: category information is set / ATTR / category information via macro attribute
288
+ if (attrs.categories) {
289
+ // Rule R20 ---->
290
+ // Trace ---->
291
+ logger.info(`config - 20230925.164323 - 20 / 44 - ${JSON.stringify(config)}`)
292
+ // Trace <----
293
+ // Action A06/01: set categories / ATTR / via macro attributes
294
+ config.categories = attrs.categories.split(',').map(it => it.trim())
295
+ // Action A15/01: next step / + / next step
296
+ _step++
297
+ _exit = false
298
+ // Rule R20 <----
299
+ // Condition C07/02: category information is set / DOC / category information via doc attribute
300
+ } else if (doc.getAttribute(`${name.toLowerCase()}-categories`)) {
301
+ // Rule R21 ---->
302
+ // Trace ---->
303
+ logger.info(`config - 20230925.164323 - 21 / 44 - ${JSON.stringify(config)}`)
304
+ // Trace <----
305
+ // Action A06/02: set categories / DOC / via doc attribute
306
+ config.categories = doc.getAttribute(`${name}-categories`).split(',').map(it => it.trim())
307
+ // Action A15/01: next step / + / next step
308
+ _step++
309
+ _exit = false
310
+ // Rule R21 <----
311
+ } else {
312
+ // Rule R22 ---->
313
+ // Trace ---->
314
+ logger.info(`config - 20230925.164323 - 22 / 44 - ${JSON.stringify(config)}`)
315
+ // Trace <----
316
+ // Action A06/03: set categories / DEF / maintenance,feature,security,infrastructure,deprecated,migration
317
+ config.categories = 'maintenance,feature,security,infrastructure,deprecated,migration'.split(',').map(it => it.trim())
318
+ // Action A15/01: next step / + / next step
319
+ _step++
320
+ _exit = false
321
+ // Rule R22 <----
322
+ }
323
+ // Condition C01/07: Step / 7 / plantuml-server base url information
324
+ } else if (_step === 7) {
325
+ // Condition C08: plantuml server url is set
326
+ if (doc.getAttribute(`${name.toLowerCase()}-plantuml-server-url`)) {
327
+ // Rule R23 ---->
328
+ // Trace ---->
329
+ logger.info(`config - 20230925.164323 - 23 / 44 - ${JSON.stringify(config)}`)
330
+ // Trace <----
331
+ // Action A07/01: set plantuml-server base url / SET / set value from doc attribute
332
+ config.plantumlServerUrl = doc.getAttribute(`${name.toLowerCase()}-plantuml-server-url`)
333
+ // Action A15/01: next step / + / next step
334
+ _step++
335
+ _exit = false
336
+ // Rule R23 <----
337
+ } else {
338
+ // Rule R24 ---->
339
+ // Trace ---->
340
+ logger.info(`config - 20230925.164323 - 24 / 44 - ${JSON.stringify(config)}`)
341
+ // Trace <----
342
+ // Action A07/02: set plantuml-server base url / DEF / https://kroki.io/plantuml
343
+ config.plantumlServerUrl = 'https://kroki.io/plantuml'
344
+ // Action A15/01: next step / + / next step
345
+ _step++
346
+ _exit = false
347
+ // Rule R24 <----
348
+ }
349
+ // Condition C01/08: Step / 8 / which status should act for closed issues
350
+ } else if (_step === 8) {
351
+ // Condition C09/01: which status should act for closed issues / ATTR / via block macro attributes
352
+ if (attrs['closed-status']) {
353
+ // Rule R25 ---->
354
+ // Trace ---->
355
+ logger.info(`config - 20230925.164323 - 25 / 44 - ${JSON.stringify(config)}`)
356
+ // Trace <----
357
+ // Action A08/01: set closed status / ATTR / via block macro attribute
358
+ config.closedStatus = attrs[`${name.toLowerCase()}-closed-status`].split(',').map(it => it.trim())
359
+ // Action A15/01: next step / + / next step
360
+ _step++
361
+ _exit = false
362
+ // Rule R25 <----
363
+ // Condition C09/02: which status should act for closed issues / DOC / via doc attribute
364
+ } else if (doc.getAttribute(`${name.toLowerCase()}-closed-status`)) {
365
+ // Rule R26 ---->
366
+ // Trace ---->
367
+ logger.info(`config - 20230925.164323 - 26 / 44 - ${JSON.stringify(config)}`)
368
+ // Trace <----
369
+ // Action A08/02: set closed status / DOC / via doc attribute
370
+ config.closedStatus = doc.getAttribute(`${name.toLowerCase()}-closed-status`).split(',').map(it => it.trim())
371
+ // Action A15/01: next step / + / next step
372
+ _step++
373
+ _exit = false
374
+ // Rule R26 <----
375
+ } else {
376
+ // Rule R27 ---->
377
+ // Trace ---->
378
+ logger.info(`config - 20230925.164323 - 27 / 44 - ${JSON.stringify(config)}`)
379
+ // Trace <----
380
+ // Action A08/03: set closed status / DEF / Closed,Resolved
381
+ config.closedStatus = 'Closed,Resolved'.split(',')
382
+ // Action A15/01: next step / + / next step
383
+ _step++
384
+ _exit = false
385
+ // Rule R27 <----
386
+ }
387
+ // Condition C01/09: Step / 9 / plantuml theme option
388
+ } else if (_step === 9) {
389
+ // Condition C10/01: plantuml theme option is set / ATTR / via block macro attr
390
+ if (attrs.theme) {
391
+ // Rule R28 ---->
392
+ // Trace ---->
393
+ logger.info(`config - 20230925.164323 - 28 / 44 - ${JSON.stringify(config)}`)
394
+ // Trace <----
395
+ // Action A09/02: set plantuml theme option / ATTR / via block macro attribute
396
+ config.plantumlTheme = attrs.theme
397
+ // Action A15/01: next step / + / next step
398
+ _step++
399
+ _exit = false
400
+ // Rule R28 <----
401
+ // Condition C10/02: plantuml theme option is set / DOC / via doc attribute
402
+ } else if (doc.getAttribute(`${name.toLowerCase()}-theme`)) {
403
+ // Rule R29 ---->
404
+ // Trace ---->
405
+ logger.info(`config - 20230925.164323 - 29 / 44 - ${JSON.stringify(config)}`)
406
+ // Trace <----
407
+ // Action A09/03: set plantuml theme option / DOC / via doc attribute
408
+ config.plantumlTheme = doc.getAttribute(`${name.toLowerCase()}-theme`)
409
+ // Action A15/01: next step / + / next step
410
+ _step++
411
+ _exit = false
412
+ // Rule R29 <----
413
+ } else {
414
+ // Rule R30 ---->
415
+ // Trace ---->
416
+ logger.info(`config - 20230925.164323 - 30 / 44 - ${JSON.stringify(config)}`)
417
+ // Trace <----
418
+ // Action A09/01: set plantuml theme option / DEF / hacker
419
+ config.plantumlTheme = 'hacker'
420
+ // Action A15/01: next step / + / next step
421
+ _step++
422
+ _exit = false
423
+ // Rule R30 <----
424
+ }
425
+ // Condition C01/10: Step / 10 / lastRoadmapReleaseDate
426
+ } else if (_step === 10) {
427
+ // Condition C11/01: last roadmap release date is set / ATTR / via blockmacro attr
428
+ if (attrs['release-date']) {
429
+ // Rule R31 ---->
430
+ // Trace ---->
431
+ logger.info(`config - 20230925.164323 - 31 / 44 - ${JSON.stringify(config)}`)
432
+ // Trace <----
433
+ // Action A10/01: set last roadmap release date / ATTR / via blockmacro attribute
434
+ config.lastRoadmapReleaseDate = attrs['release-date']
435
+ // Action A15/01: next step / + / next step
436
+ _step++
437
+ _exit = false
438
+ // Rule R31 <----
439
+ // Condition C11/02: last roadmap release date is set / DOC / via doc attribute
440
+ } else if (doc.getAttribute(`${name.toLowerCase()}-release-date`)) {
441
+ // Rule R32 ---->
442
+ // Trace ---->
443
+ logger.info(`config - 20230925.164323 - 32 / 44 - ${JSON.stringify(config)}`)
444
+ // Trace <----
445
+ // Action A10/02: set last roadmap release date / DOC / via doc attribute
446
+ config.lastRoadmapReleaseDate = doc.getAttribute(`${name.toLowerCase()}-release-date`)
447
+ // Action A15/01: next step / + / next step
448
+ _step++
449
+ _exit = false
450
+ // Rule R32 <----
451
+ } else {
452
+ // Rule R33 ---->
453
+ // Trace ---->
454
+ logger.info(`config - 20230925.164323 - 33 / 44 - ${JSON.stringify(config)}`)
455
+ // Trace <----
456
+ // Action A10/03: set last roadmap release date / UDEF / not set
457
+ config.lastRoadmapReleaseDate = undefined
458
+ // Action A15/01: next step / + / next step
459
+ _step++
460
+ _exit = false
461
+ // Rule R33 <----
462
+ }
463
+ // Condition C01/11: Step / 11 / legend for status
464
+ } else if (_step === 11) {
465
+ // Condition C12/01: legend for status is set / ATTR / via block macro attribute
466
+ if (attrs['legend-for-status']) {
467
+ // Rule R34 ---->
468
+ // Trace ---->
469
+ logger.info(`config - 20230925.164323 - 34 / 44 - ${JSON.stringify(config)}`)
470
+ // Trace <----
471
+ // Action A11/02: set legend for status / ATTR / via block macro attribute
472
+ config.legendForStatus = attrs['legend-for-status'].split(',').map(it => it.trim())
473
+ // Action A15/01: next step / + / next step
474
+ _step++
475
+ _exit = false
476
+ // Rule R34 <----
477
+ // Condition C12/02: legend for status is set / DOC / via doc attribute
478
+ } else if (doc.getAttribute(`${name.toLowerCase()}-legend-for-status`)) {
479
+ // Rule R35 ---->
480
+ // Trace ---->
481
+ logger.info(`config - 20230925.164323 - 35 / 44 - ${JSON.stringify(config)}`)
482
+ // Trace <----
483
+ // Action A11/03: set legend for status / DOC / via doc attribute
484
+ config.legendForStatus = doc.getAttribute(`${name.toLowerCase()}-legend-for-status`).split(',').map(it => it.trim())
485
+ // Action A15/01: next step / + / next step
486
+ _step++
487
+ _exit = false
488
+ // Rule R35 <----
489
+ } else {
490
+ // Rule R36 ---->
491
+ // Trace ---->
492
+ logger.info(`config - 20230925.164323 - 36 / 44 - ${JSON.stringify(config)}`)
493
+ // Trace <----
494
+ // Action A11/01: set legend for status / DEF / Open,In Progress,Closed
495
+ config.legendForStatus = 'Open,In Progress,Closed'.split(',').map(it => it.trim())
496
+ // Action A15/01: next step / + / next step
497
+ _step++
498
+ _exit = false
499
+ // Rule R36 <----
500
+ }
501
+ // Condition C01/12: Step / 12 / check for more categories to process
502
+ } else if (_step === 12) {
503
+ // Prolog Condition C13 ---->
504
+ catIndex++
505
+ // Prolog Condition C13 <----
506
+ // Condition C13: one more category to process
507
+ if (catIndex < config.categories.length) {
508
+ // Rule R37 ---->
509
+ // Trace ---->
510
+ logger.info(`config - 20230925.164323 - 37 / 44 - ${JSON.stringify(config)}`)
511
+ // Trace <----
512
+ // Action A15/01: next step / + / next step
513
+ _step++
514
+ _exit = false
515
+ // Rule R37 <----
516
+ } else {
517
+ // Rule R38 ---->
518
+ // Trace ---->
519
+ logger.info(`config - 20230925.164323 - 38 / 44 - ${JSON.stringify(config)}`)
520
+ // Trace <----
521
+ // Action A15/03: next step / E / Exit
522
+ _exit = true
523
+ // Rule R38 <----
524
+ }
525
+ // Condition C01/13: Step / 12a / label for category
526
+ } else if (_step === 13) {
527
+ // Condition C14/01: label for category is set / ATTR / via block macro attribute
528
+ if (attrs[`${config.categories[catIndex]}-label`]) {
529
+ // Rule R39 ---->
530
+ // Trace ---->
531
+ logger.info(`config - 20230925.164323 - 39 / 44 - ${JSON.stringify(config)}`)
532
+ // Trace <----
533
+ // Action A12/01: set category label / ATTR / via block macro attribute
534
+ config[`${config.categories[catIndex]}Label`] = attrs[`${config.categories[catIndex]}-label`]
535
+ // Action A15/01: next step / + / next step
536
+ _step++
537
+ _exit = false
538
+ // Rule R39 <----
539
+ // Condition C14/02: label for category is set / DOC / via doc attribute
540
+ } else if (doc.getAttribute(`${name.toLowerCase()}-${config.categories[catIndex]}-label`)) {
541
+ // Rule R40 ---->
542
+ // Trace ---->
543
+ logger.info(`config - 20230925.164323 - 40 / 44 - ${JSON.stringify(config)}`)
544
+ // Trace <----
545
+ // Action A12/02: set category label / DOC / via doc attribute
546
+ config[`${config.categories[catIndex]}Label`] = doc.getAttribute(`${name.toLowerCase()}-${config.categories[catIndex]}-label`)
547
+ // Action A15/01: next step / + / next step
548
+ _step++
549
+ _exit = false
550
+ // Rule R40 <----
551
+ } else {
552
+ // Rule R41 ---->
553
+ // Trace ---->
554
+ logger.info(`config - 20230925.164323 - 41 / 44 - ${JSON.stringify(config)}`)
555
+ // Trace <----
556
+ // Action A12/03: set category label / DEF / set category as default label
557
+ config[`${config.categories[catIndex]}Label`] = config.categories[catIndex]
558
+ // Action A15/01: next step / + / next step
559
+ _step++
560
+ _exit = false
561
+ // Rule R41 <----
562
+ }
563
+ } else {
564
+ // Condition C15/01: jql for category is set / ATTR / via block macro attribute
565
+ if (attrs[`${config.categories[catIndex]}-jql`]) {
566
+ // Rule R42 ---->
567
+ // Trace ---->
568
+ logger.info(`config - 20230925.164323 - 42 / 44 - ${JSON.stringify(config)}`)
569
+ // Trace <----
570
+ // Action A13/01: set category jql / ATTR / via block macro attribute
571
+ const categoryJQLSuffixPart = attrs[`${config.categories[catIndex]}-jql`]
572
+ config[`${config.categories[catIndex]}JQL`] = `project = ${config.projectKey} and labels in (Roadmap) and labels in ('${config.year}') and labels in (${config.categories[catIndex]}) and ${categoryJQLSuffixPart}`
573
+ // Action A15/02: next step / 12 / check for more categories to process
574
+ _step = 12
575
+ _exit = false
576
+ // Rule R42 <----
577
+ // Condition C15/02: jql for category is set / DOC / via doc attribute
578
+ } else if (doc.getAttribute(`${name.toLowerCase()}-${config.categories[catIndex]}-jql`)) {
579
+ // Rule R43 ---->
580
+ // Trace ---->
581
+ logger.info(`config - 20230925.164323 - 43 / 44 - ${JSON.stringify(config)}`)
582
+ // Trace <----
583
+ // Action A13/02: set category jql / DOC / via doc attribute
584
+ const categoryJQLSuffixPart = doc.getAttribute(`${name.toLowerCase()}-${config.categories[catIndex]}-jql`)
585
+ config[`${config.categories[catIndex]}JQL`] = `project = ${config.projectKey} and labels in (Roadmap) and labels in ('${config.year}') and labels in (${config.categories[catIndex]}) and ${categoryJQLSuffixPart}`
586
+ // Action A15/02: next step / 12 / check for more categories to process
587
+ _step = 12
588
+ _exit = false
589
+ // Rule R43 <----
590
+ } else {
591
+ // Rule R44 ---->
592
+ // Trace ---->
593
+ logger.info(`config - 20230925.164323 - 44 / 44 - ${JSON.stringify(config)}`)
594
+ // Trace <----
595
+ // Action A13/03: set category jql / DEF / set category as default label
596
+ config[`${config.categories[catIndex]}JQL`] = `project = ${config.projectKey} and labels in (Roadmap) and labels in ('${config.year}') and labels in (${config.categories[catIndex]})`
597
+ // Action A15/02: next step / 12 / check for more categories to process
598
+ _step = 12
599
+ _exit = false
600
+ // Rule R44 <----
601
+ }
602
+ }
603
+ // Epilog Decision Table ---->
604
+ } while (_exit === false)
605
+ return config
606
+ }
607
+
608
+ module.exports = {
609
+ createConfig: (name, parent, target, attrs, logger) => {
610
+ return config(name, parent, target, attrs, logger)
611
+ }
612
+ }
613
+ // Epilog Decision Table <----
614
+
615
+ // End of generated JavaScript source code
616
+ // Generated by LF-ET 2.2.1 (230906a), https://www.lohrfink.de/lfet
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "asciidoctor-jira",
3
3
  "author": "Constantin Krüger (https://github.com/uniqueck)",
4
4
  "license": "MIT",
5
- "version": "3.1.2",
5
+ "version": "3.2.0",
6
6
  "bugs": {
7
7
  "url": "https://github.com/doctoolchain/asciidoctor-jira/issues"
8
8
  },
@@ -21,7 +21,8 @@
21
21
  "mkdirp": "^3.0.1",
22
22
  "sync-request": "^6.1.0",
23
23
  "plantuml-encoder": "^1.4.0",
24
- "unxhr": "1.2.0"
24
+ "unxhr": "1.2.0",
25
+ "rusha": "^0.8"
25
26
  },
26
27
  "devDependencies": {
27
28
  "@antora/site-generator-default": "^3.1.4",
@@ -43,11 +44,12 @@
43
44
  "@asciidoctor/core": "^2.2.6"
44
45
  },
45
46
  "scripts": {
47
+ "lfet:GenSrc": "exec java -classpath \"/opt/lfet/lib/*\" lohrfink.lfet.Application -gs \"$INIT_CWD/lfet/\" -rec -fnp \"*.lfet\" -sku -src \"JavaScript\"",
46
48
  "test": "npm run test:antora && npm run test:node",
47
49
  "test:antora": "mocha test/antora/**.spec.js",
48
50
  "test:node": "mocha test/**.spec.js",
49
- "lint": "eslint lib/**/*.js test/**/*.js",
50
- "lint:fix": "eslint lib/**/*.js test/**/*.js --fix",
51
+ "lint": "eslint \"./lib/**/*.js\" \"./test/**/*.js\"",
52
+ "lint:fix": "eslint \"./lib/**/*.js\" \"./test/**/*.js\" --fix",
51
53
  "clean": "shx rm -rf dist/*",
52
54
  "release": "semantic-release"
53
55
  },