@ondrejbelza/semantic-release-jira 1.7.1 → 1.8.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/README.md CHANGED
@@ -63,11 +63,11 @@ interface Config {
63
63
  jiraHost: string;
64
64
 
65
65
  /**
66
- * A prefixe to match when looking for tickets in commits.
66
+ * A list of prefixes to match when looking for tickets in commits.
67
67
  *
68
- * ie. 'TEST' would match `TEST-123` and `TEST-456`
68
+ * ie. ['TEST'] would match `TEST-123` and `TEST-456`
69
69
  */
70
- ticketPrefix: string;
70
+ ticketPrefixes: string[];
71
71
 
72
72
  /**
73
73
  * The id or key for the project releases will be created in
package/dist/consts.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare const DEFAULT_VERSION_TEMPLATE = "v${version}";
2
- export declare const DEFAULT_RELEASE_DESCRIPTION_TEMPLATE = "# Release notes - {{version}}\n\n## Issues\n{{#each issues}}\n - [{{type}}] [{{ key }}]({{ link }}) {{ title }}\n - Short description: {{ description }}\n - Assigned to: {{ assignee }}\n\n{{/each}}\n\nRelease notes were automatically generated";
2
+ export declare const DEFAULT_RELEASE_DESCRIPTION_TEMPLATE = "# Release notes - {{version}}\n\n\n## Issues:\n{{#each issues}}\n - [{{type}}] [{{ key }}]({{ link }}) {{ title }}\n - Short description: {{ description }}\n - Assigned to: {{ assignee }}\n\n{{/each}}\n\n\n## Commits not relevant to any Issue:\n{{#each commits}}\n - {{ message }}\n - Committed by: {{ author }}\n\n{{/each}}\n\nRelease notes were automatically generated";
package/dist/consts.js CHANGED
@@ -4,7 +4,8 @@ exports.DEFAULT_RELEASE_DESCRIPTION_TEMPLATE = exports.DEFAULT_VERSION_TEMPLATE
4
4
  exports.DEFAULT_VERSION_TEMPLATE = "v${version}";
5
5
  exports.DEFAULT_RELEASE_DESCRIPTION_TEMPLATE = `# Release notes - {{version}}
6
6
 
7
- ## Issues
7
+
8
+ ## Issues:
8
9
  {{#each issues}}
9
10
  - [{{type}}] [{{ key }}]({{ link }}) {{ title }}
10
11
  - Short description: {{ description }}
@@ -12,4 +13,12 @@ exports.DEFAULT_RELEASE_DESCRIPTION_TEMPLATE = `# Release notes - {{version}}
12
13
 
13
14
  {{/each}}
14
15
 
16
+
17
+ ## Commits not relevant to any Issue:
18
+ {{#each commits}}
19
+ - {{ message }}
20
+ - Committed by: {{ author }}
21
+
22
+ {{/each}}
23
+
15
24
  Release notes were automatically generated`;
package/dist/success.js CHANGED
@@ -58,20 +58,38 @@ async function getIssueMetadata(c, issueKey, jiraHost, logger) {
58
58
  type: issue.fields.issuetype?.name || "unknown",
59
59
  };
60
60
  }
61
- async function getMentionedTickets(c, ticketPrefix, jiraHost, commits, logger) {
61
+ async function getContributions(c, ticketPrefixes, jiraHost, commits, logger) {
62
62
  const tickets = new Set();
63
- const pattern = new RegExp(`\\b${(0, utils_1.escapeRegExp)(ticketPrefix)}-(\\d+)\\b`, "giu");
63
+ const releaseCommits = new Set();
64
+ const patterns = [];
65
+ for (const prefix of ticketPrefixes) {
66
+ const pattern = new RegExp(`\\b${(0, utils_1.escapeRegExp)(prefix)}-(\\d+)\\b`, "giu");
67
+ patterns.push(pattern);
68
+ }
64
69
  for (const commit of commits) {
65
- const matches = commit.message.match(pattern);
66
- if (matches) {
67
- for (const match of matches) {
68
- logger.info(`Found matching ticket it commit ${match} in ${commit.commit.short}`);
69
- const issue = await getIssueMetadata(c, match, jiraHost, logger);
70
- tickets.add(issue);
70
+ var found = false;
71
+ for (const pattern of patterns) {
72
+ const matches = commit.message.match(pattern);
73
+ if (matches) {
74
+ found = true;
75
+ for (const match of matches) {
76
+ logger.info(`Found matching ticket it commit ${match} in ${commit.commit.short}`);
77
+ const issue = await getIssueMetadata(c, match, jiraHost, logger);
78
+ tickets.add(issue);
79
+ }
71
80
  }
72
81
  }
82
+ if (!found) {
83
+ releaseCommits.add({
84
+ author: commit.author.name,
85
+ message: commit.message,
86
+ });
87
+ }
73
88
  }
74
- return [...tickets];
89
+ return {
90
+ commits: [...releaseCommits],
91
+ issues: [...tickets],
92
+ };
75
93
  }
76
94
  async function findOrCreateVersion(c, projectIdOrKey, newVersionName, newVersionDescription, logger) {
77
95
  const versions = await c.projectVersions.getProjectVersions({
@@ -107,7 +125,7 @@ async function findOrCreateVersion(c, projectIdOrKey, newVersionName, newVersion
107
125
  }
108
126
  }
109
127
  async function editIssueFixVersions(c, ticket, versionId, logger) {
110
- logger.info(`Adding issue '${ticket}' to a release '${versionId}'`);
128
+ logger.info(`Adding issue '${ticket.key}' to a release '${versionId}'`);
111
129
  c.issues
112
130
  .editIssue({
113
131
  issueIdOrKey: ticket.key,
@@ -140,20 +158,21 @@ async function editIssueFixVersions(c, ticket, versionId, logger) {
140
158
  }
141
159
  })
142
160
  .then(() => {
143
- logger.complete(`Issue '${ticket}' was successfully added to a release.`);
161
+ logger.complete(`Issue '${ticket.key}' was successfully added to a release.`);
144
162
  });
145
163
  }
146
164
  async function success(config, context) {
147
165
  const { env, logger, commits, nextRelease } = context;
148
- const { jiraHost, project: projectKey, ticketPrefix, versionTemplate: definedVersionTemplate, } = config;
166
+ const { jiraHost, project: projectKey, ticketPrefixes, versionTemplate: definedVersionTemplate, } = config;
149
167
  const c = (0, jira_client_1.CreateJiraClient)(logger, jiraHost, env.JIRA_EMAIL, env.JIRA_TOKEN);
150
- const tickets = await getMentionedTickets(c, ticketPrefix, jiraHost, commits, logger);
168
+ const contributions = await getContributions(c, ticketPrefixes, jiraHost, commits, logger);
151
169
  const versionTemplate = _.template(definedVersionTemplate || consts_1.DEFAULT_VERSION_TEMPLATE);
152
170
  const descriptionTemplate = handlebars_1.default.compile(consts_1.DEFAULT_RELEASE_DESCRIPTION_TEMPLATE);
153
171
  const newVersionName = versionTemplate({ version: nextRelease.version });
154
172
  const newVersionDescription = descriptionTemplate({
155
173
  version: newVersionName,
156
- issues: tickets,
174
+ issues: contributions.issues,
175
+ commits: contributions.commits,
157
176
  });
158
177
  logger.info(`Using jira release '${newVersionName}'`);
159
178
  logger.info(`using jira description '${consts_1.DEFAULT_RELEASE_DESCRIPTION_TEMPLATE}'`);
@@ -165,7 +184,7 @@ async function success(config, context) {
165
184
  const version = await findOrCreateVersion(c, project.id, newVersionName, newVersionDescription, logger);
166
185
  const concurrentLimit = (0, p_limit_1.default)(10);
167
186
  const edits = [];
168
- for (const ticket of tickets) {
187
+ for (const ticket of contributions.issues) {
169
188
  edits.push(concurrentLimit(() => editIssueFixVersions(c, ticket, version.id || "", logger)));
170
189
  }
171
190
  await Promise.all(edits);
package/dist/types.d.ts CHANGED
@@ -1,9 +1,13 @@
1
1
  export interface PluginConfig {
2
2
  jiraHost: string;
3
3
  project: string;
4
- ticketPrefix: string;
4
+ ticketPrefixes: string[];
5
5
  versionTemplate: string;
6
6
  }
7
+ export interface ReleaseCommit {
8
+ author: string;
9
+ message: string;
10
+ }
7
11
  export interface JiraIssue {
8
12
  title: string;
9
13
  key: string;
@@ -12,3 +16,7 @@ export interface JiraIssue {
12
16
  description: string;
13
17
  link: string;
14
18
  }
19
+ export interface ReleaseContributions {
20
+ commits: ReleaseCommit[];
21
+ issues: JiraIssue[];
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ondrejbelza/semantic-release-jira",
3
- "version": "1.7.1",
3
+ "version": "1.8.0",
4
4
  "description": "semantic release jira releases plugin",
5
5
  "homepage": "https://github.com/mailstepcz/semantic-release-jira#readme",
6
6
  "bugs": {