@docupace/pipeline 1.0.39-matttest.39 → 1.0.39-matttest.40

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docupace/pipeline",
3
- "version": "1.0.39-matttest.39",
3
+ "version": "1.0.39-matttest.40",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -4,7 +4,7 @@ import { zodResponseFormat } from 'openai/helpers/zod';
4
4
  import fs from 'fs';
5
5
  import path from 'path';
6
6
  import inquirer from 'inquirer';
7
- import { getMainPackage, getPackage } from './util.js';
7
+ import { getMainPackage, getPackage, findJiraTicketId } from './util.js';
8
8
  import { getPackageNames } from './package-util.js';
9
9
  import { execSync } from 'child_process';
10
10
 
@@ -40,11 +40,11 @@ async function getCurrentBranch() {
40
40
  * Extracts a Jira ticket ID from a branch name
41
41
  */
42
42
  function extractJiraTicketId(branchName) {
43
- const jiraTicketMatch = branchName.match(/([A-Z]+-\d+)/);
44
- if (!jiraTicketMatch) {
43
+ const jiraTicketId = findJiraTicketId(branchName);
44
+ if (!jiraTicketId) {
45
45
  throw new Error('No Jira ticket found in the branch name.');
46
46
  }
47
- return jiraTicketMatch[0];
47
+ return jiraTicketId;
48
48
  }
49
49
 
50
50
  /**
@@ -66,7 +66,7 @@ async function fetchJiraTicketData(jiraTicketId) {
66
66
 
67
67
  if (!jiraResponse.ok) {
68
68
  throw new Error(
69
- `Failed to fetch Jira ticket. Status: ${jiraResponse.status}`,
69
+ `Failed to fetch Jira ticket ${jiraTicketId}. Status: ${jiraResponse.status}, Ticket URL: ${jiraUrl}`,
70
70
  );
71
71
  }
72
72
 
@@ -121,7 +121,7 @@ ${packageEntries}
121
121
  ---
122
122
 
123
123
  ${summary} [${jiraTicketId}]
124
- `;
124
+ `;
125
125
  const changesetFile = `./.changeset/${jiraTicketId}.md`;
126
126
 
127
127
  await createChangesetDirectory();
@@ -25,3 +25,19 @@ export async function getPackage(mainModulePath) {
25
25
  }
26
26
  throw new Error('Main package.json not found');
27
27
  }
28
+
29
+ /**
30
+ * Locates and extracts a JIRA Ticket ID from a given string.
31
+ * <p>
32
+ * The JIRA Ticket ID is expected to follow the pattern of uppercase letters (at least two) followed by a hyphen and digits (e.g., DC-1234, INFP-9).
33
+ * @param str the string to search for a JIRA ticket ID
34
+ * @returns {JIRA-TicketID|null}
35
+ */
36
+ export function findJiraTicketId(str) {
37
+ if (!str) {
38
+ return null;
39
+ }
40
+ const regex = /([A-Z]{2,}-\d+)/;
41
+ const matches = str.match(regex);
42
+ return matches ? matches[0] : null;
43
+ }
@@ -2,6 +2,7 @@ import { setGitInfo } from '../next/util.js';
2
2
  import { $ } from 'zx';
3
3
  import fs from 'fs';
4
4
  import { updateComponentVersion } from '../next/jira.js';
5
+ import { findJiraTicketId } from "./util.js";
5
6
 
6
7
  const changeSetPackage = `{
7
8
  "name": "changeset-package",
@@ -65,8 +66,7 @@ export async function updateJiraWithVersion(releases) {
65
66
  const lastCommit = (await $`git log -1 --pretty=%B`).stdout.trim();
66
67
  console.log(`Last commit '${lastCommit}' being processed to get Jira ticket`);
67
68
 
68
- const jiraTicketMatch = lastCommit.match(/([A-Z]+-\d+)/);
69
- const jiraTicketId = jiraTicketMatch ? jiraTicketMatch[0] : null;
69
+ const jiraTicketId = findJiraTicketId(lastCommit);
70
70
 
71
71
  // If we have all the necessary data, update the component version in Jira
72
72
  if (jiraTicketId) {
package/src/next/jira.js CHANGED
@@ -15,7 +15,7 @@ const jiraClient = axios.create({
15
15
  /**
16
16
  * Updates the component version custom field in Jira
17
17
  * @param {string} issueKey - The Jira issue key
18
- * @param {string} component - The component name
18
+ * @param {string} packageName - The package name
19
19
  * @param {string} version - The version to set
20
20
  */
21
21
  export async function updateComponentVersion(issueKey, packageName, version) {