@docupace/pipeline 1.0.85 → 1.0.87

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.
@@ -2,7 +2,7 @@ import { execSync } from 'child_process';
2
2
  import { createBitbucketPR } from './pr.js';
3
3
  import { autoResolveConflicts } from './cli-resolve.js';
4
4
  import { getPackageNames } from '../changeset/package-util.js';
5
- import { writeChangesetFile } from '../changeset/create.js';
5
+ import { writeChangesetFile } from '../changeset/create-simple.js';
6
6
  import { BuildResults } from './common.js';
7
7
 
8
8
  /**
@@ -83,7 +83,7 @@ function attemptMerge(sourceBranch, targetBranch, verbose = false) {
83
83
  if (verbose) console.log('✅ Merge completed with changes, no conflicts');
84
84
  return { hasConflicts: false, hasChanges: true };
85
85
  }
86
- } catch (error) {
86
+ } catch {
87
87
  if (verbose) console.log('⚠️ Merge conflicts detected');
88
88
  return { hasConflicts: true, hasChanges: true };
89
89
  }
@@ -141,7 +141,7 @@ function runBuild(buildScript, verbose = false) {
141
141
  });
142
142
  if (verbose) console.log('✅ Build passed');
143
143
  return true;
144
- } catch (error) {
144
+ } catch {
145
145
  if (verbose) console.log('❌ Build failed');
146
146
  return false;
147
147
  }
@@ -283,7 +283,7 @@ function cleanupFailedMerge(verbose = false) {
283
283
  try {
284
284
  execSync('git merge --abort', { stdio: 'pipe' });
285
285
  if (verbose) console.log('🧹 Cleaned up failed merge');
286
- } catch (cleanupError) {
286
+ } catch {
287
287
  // Ignore cleanup errors
288
288
  }
289
289
  }
@@ -72,7 +72,7 @@ export function mergeChangelogFile(filePath) {
72
72
  try {
73
73
  execSync(`git add ${filePath}`);
74
74
  console.log('📝 File added to git staging area');
75
- } catch (error) {
75
+ } catch {
76
76
  console.log(
77
77
  '⚠️ Could not add file to git (may not be in a git repository)',
78
78
  );
package/src/merge/pr.js CHANGED
@@ -40,7 +40,7 @@ export async function getExistingPRsWithDescription(
40
40
  // Check each repository for matching PRs
41
41
  for (const repo of repositories) {
42
42
  try {
43
- const match = repo.url.match(/bitbucket\.org[\/:]([^\/]+)\/([^\/\.]+)/);
43
+ const match = repo.url.match(/bitbucket\.org[/:]([^/]+)\/([^/.]+)/);
44
44
 
45
45
  if (!match) {
46
46
  console.warn(`Could not parse repository URL: ${repo.url}`);
@@ -104,7 +104,7 @@ export async function getExistingPRsFromCurrentRepo(descriptionPattern) {
104
104
  const remoteUrl = execSync('git config --get remote.origin.url', {
105
105
  encoding: 'utf-8',
106
106
  }).trim();
107
- const match = remoteUrl.match(/bitbucket\.org[\/:]([^\/]+)\/([^\/\.]+)/);
107
+ const match = remoteUrl.match(/bitbucket\.org[/:]([^/]+)\/([^/.]+)/);
108
108
 
109
109
  if (!match) {
110
110
  throw new Error(
@@ -165,7 +165,7 @@ export async function createBitbucketPR(
165
165
  const remoteUrl = execSync('git config --get remote.origin.url', {
166
166
  encoding: 'utf-8',
167
167
  }).trim();
168
- const match = remoteUrl.match(/bitbucket\.org[\/:]([^\/]+)\/([^\/\.]+)/);
168
+ const match = remoteUrl.match(/bitbucket\.org[/:]([^/]+)\/([^/.]+)/);
169
169
 
170
170
  if (!match) {
171
171
  throw new Error(
@@ -2,7 +2,6 @@ import 'zx/globals'; // npm i zx
2
2
  import fs from 'fs-extra';
3
3
  import path from 'path';
4
4
  import { $ } from 'zx';
5
- import { getAuth0Metadata } from '../auth0/metadata.js';
6
5
  import { getVaultSecrets } from '../auth0/vault.js';
7
6
 
8
7
  process.env.COMMON_VAULT_PATH =
@@ -12,14 +11,6 @@ process.env.CONNECT_DIR = process.env.CONNECT_DIR || 'connect';
12
11
  const vaultToken = process.env.VAULT_TOKEN;
13
12
  const vaultAddr = process.env.VAULT_ADDR;
14
13
 
15
- const connectUIEnvMap = {
16
- dev: 'dev',
17
- qa: 'preprod',
18
- stage: 'stg',
19
- uat: 'uat',
20
- prod: 'prod-www3',
21
- };
22
-
23
14
  const siteSettingsEnvMap = {
24
15
  dev: 'dev',
25
16
  preprod: 'preprod',
@@ -306,14 +306,14 @@ export async function getDeployTag(prefix = 'v') {
306
306
  }
307
307
 
308
308
  function getDeploymentTargets(tag, config) {
309
- const semverRegex = /^v?(\d+)\.(\d+)\.(\d+)(?:-([\w.\-]+))?$/;
309
+ const semverRegex = /^v?(\d+)\.(\d+)\.(\d+)(?:-([\w.-]+))?$/;
310
310
  const match = tag.match(semverRegex);
311
311
 
312
312
  if (!match) {
313
313
  throw new Error(`Invalid tag format: ${tag}`);
314
314
  }
315
315
 
316
- const [_, major, minor, patch, preRelease] = match;
316
+ const [major, minor, preRelease] = match;
317
317
  const isAlpha = preRelease && preRelease.toLowerCase().includes('alpha');
318
318
 
319
319
  return config
@@ -564,7 +564,14 @@ export async function deployFromSite(
564
564
  `Deploying changes from ${fromSite} in ${fromEnv} to ${toSite} in ${toEnv}${jiraTicket ? ` approved by JIRA ticket ${jiraTicket}` : ''}`,
565
565
  );
566
566
 
567
- if (jiraTicket) {
567
+ if (toEnv === 'prod') {
568
+ if (!jiraTicket) {
569
+ console.error(
570
+ 'The deployment to prod environment requires a JIRA ticket to be provided',
571
+ );
572
+ process.exit(1);
573
+ }
574
+
568
575
  try {
569
576
  const response = await makeJiraRequest(`/rest/api/2/issue/${jiraTicket}`);
570
577
  const docupacecInstance = response.fields.customfield_10045.value;
@@ -595,34 +602,59 @@ export async function deployFromSite(
595
602
  process.exit(1);
596
603
  }
597
604
 
598
- if (toEnv === 'prod') {
599
- if (docupacecInstance !== 'Production') {
600
- console.error(
601
- `The deployment to prod environment requires Docupace Instance to be "Production", but got "${docupacecInstance}"`,
602
- );
603
- console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
604
- process.exit(1);
605
- }
606
-
607
- if (fromSite !== toSite) {
608
- console.error(
609
- `The deployment to prod environment requires fromSite and toSite to be equal, but fromSite: "${fromSite}", toSite: "${toSite}"`,
610
- );
611
- console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
612
- process.exit(1);
613
- }
614
-
615
- console.log('Production deployment validations passed');
605
+ if (docupacecInstance !== 'Production') {
606
+ console.error(
607
+ `The deployment to prod environment requires Docupace Instance to be "Production", but got "${docupacecInstance}"`,
608
+ );
609
+ console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
610
+ process.exit(1);
611
+ }
612
+
613
+ if (fromSite !== toSite) {
614
+ console.error(
615
+ `The deployment to prod environment requires fromSite and toSite to be equal, but fromSite: "${fromSite}", toSite: "${toSite}"`,
616
+ );
617
+ console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
618
+ process.exit(1);
619
+ }
620
+
621
+ console.log('Production deployment validations passed');
622
+ } catch (error) {
623
+ console.error(`Failed to make a Jira request: ${error.message}`);
624
+ process.exit(1);
625
+ }
626
+ } else if (jiraTicket) {
627
+ try {
628
+ const response = await makeJiraRequest(`/rest/api/2/issue/${jiraTicket}`);
629
+ const siteUrl = response.fields.customfield_10041;
630
+ const status = response.fields.status.name;
631
+ const jiraBaseUrl = response.self.split('/rest/api')[0];
632
+ const jiraTicketUrl = `${jiraBaseUrl}/browse/${response.key}`;
633
+
634
+ console.log(`Docupace Site URL: ${siteUrl}`);
635
+ console.log(`JIRA Ticket Status: ${status}`);
636
+ console.log(`JIRA Ticket URL: ${jiraTicketUrl}`);
637
+
638
+ const allowedStatuses = ['To Do', 'In Progress'];
639
+ if (!allowedStatuses.includes(status)) {
640
+ console.error(
641
+ `The JIRA ticket status must be "To Do" or "In Progress", but got "${status}"`,
642
+ );
643
+ console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
644
+ process.exit(1);
645
+ }
646
+
647
+ if (!siteUrl.includes(toSite)) {
648
+ console.error(
649
+ `The toSite "${toSite}" must be present in the Docupace Site URL: "${siteUrl}"`,
650
+ );
651
+ console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
652
+ process.exit(1);
616
653
  }
617
654
  } catch (error) {
618
655
  console.error(`Failed to make a Jira request: ${error.message}`);
619
656
  process.exit(1);
620
657
  }
621
- } else if (toEnv === 'prod') {
622
- console.error(
623
- 'The deployment to prod environment requires a JIRA ticket to be provided',
624
- );
625
- process.exit(1);
626
658
  }
627
659
 
628
660
  if (isDeployCore === 'true') {
package/src/next/jira.js CHANGED
@@ -12,6 +12,57 @@ const jiraClient = axios.create({
12
12
  },
13
13
  });
14
14
 
15
+ export async function getJiraReleaseNotes(issueKey) {
16
+ try {
17
+ const response = await jiraClient.get(
18
+ `/rest/api/2/issue/${issueKey}?fields=customfield_10108,customfield_11625`,
19
+ );
20
+
21
+ const releaseNotesField = response.data.fields.customfield_10108;
22
+ const url = response.data.fields.customfield_11625;
23
+
24
+ // Extract text from the document structure
25
+
26
+ return { summary: releaseNotesField, url };
27
+ } catch (error) {
28
+ console.error(
29
+ `Error getting Jira release notes for ${issueKey}: ${error.message}`,
30
+ );
31
+ throw error;
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Updates the release notes in the Jira issue's custom field
37
+ * @param {string} issueKey - The Jira issue key
38
+ * @param {string} text - The release notes text to set
39
+ */
40
+ export async function updateJiraReleaseNotes(
41
+ issueKey,
42
+ text,
43
+ url,
44
+ jiraVersions,
45
+ ) {
46
+ try {
47
+ const payload = {
48
+ fields: {
49
+ customfield_10108: text,
50
+ customfield_11625: url,
51
+ fixVersions: jiraVersions.map((version) => ({ name: version })),
52
+ },
53
+ };
54
+
55
+ await jiraClient.put(`/rest/api/2/issue/${issueKey}`, payload);
56
+
57
+ console.log(`Updated release notes for ${issueKey}`);
58
+ } catch (error) {
59
+ console.error(
60
+ `Error updating Jira release notes for ${issueKey}: ${error.message}`,
61
+ );
62
+ throw error;
63
+ }
64
+ }
65
+
15
66
  /**
16
67
  * Updates the component version custom field in Jira
17
68
  * @param {string} issueKey - The Jira issue key
package/src/next/util.js CHANGED
@@ -85,7 +85,7 @@ export async function getChangedAppPackages() {
85
85
  }
86
86
 
87
87
  export async function setGitInfo() {
88
- if (!process.env.IS_DEV) {
88
+ if (process.env.SET_GITOPS_USER) {
89
89
  await $`git config --global user.email "gitops@docupace.com"`;
90
90
  await $`git config --global user.name "Gitops"`;
91
91
  const repoUrl = `git@bitbucket.org:dp-cloud/${process.env.BITBUCKET_REPO_SLUG}.git`;
package/testCanny.sh ADDED
@@ -0,0 +1,4 @@
1
+
2
+
3
+ curl https://canny.io/api/v1/tags/list -X POST \
4
+ -d apiKey=c2aa36c6-8789-aac0-2f22-cbcfdf488b4c