@docupace/pipeline 1.0.73 → 1.0.75

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.73",
3
+ "version": "1.0.75",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "bin": {
@@ -306,6 +306,7 @@ async function runFollowUpPhase(prepareResults, verbose = false) {
306
306
  console.log(`✅ ${result.configName}: ${action} completed`);
307
307
  } else {
308
308
  console.log(`❌ ${result.configName}: ${action} failed`);
309
+ process.exit(1);
309
310
  }
310
311
  }
311
312
  }
@@ -378,6 +379,7 @@ async function mergeAll(verbose = false) {
378
379
  if (verbose) console.log('🔍 Checking for existing automated merge PRs...');
379
380
  const existingPRs = await getExistingPRsWithDescription(
380
381
  'Automated merge with changeset',
382
+ config.repositories,
381
383
  );
382
384
 
383
385
  if (existingPRs.length > 0) {
@@ -386,7 +388,9 @@ async function mergeAll(verbose = false) {
386
388
  );
387
389
  if (verbose) {
388
390
  existingPRs.forEach((pr) => {
389
- console.log(` - PR #${pr.id}: ${pr.title} (${pr.links.html.href})`);
391
+ console.log(
392
+ ` - PR #${pr.id}: ${pr.title} in ${pr.repositoryName || 'unknown repo'} (${pr.links.html.href})`,
393
+ );
390
394
  });
391
395
  }
392
396
  process.exit(1);
package/src/merge/pr.js CHANGED
@@ -13,7 +13,84 @@ import { execSync } from 'child_process';
13
13
  * @param {string} descriptionPattern - Pattern to match in PR descriptions
14
14
  * @returns {Promise<Object[]>} - Array of matching PRs
15
15
  */
16
- export async function getExistingPRsWithDescription(descriptionPattern) {
16
+ export async function getExistingPRsWithDescription(descriptionPattern, repositories) {
17
+ // If no repositories provided, fall back to current repo behavior for backward compatibility
18
+ if (!repositories || !Array.isArray(repositories)) {
19
+ return getExistingPRsFromCurrentRepo(descriptionPattern);
20
+ }
21
+
22
+ try {
23
+ // Check for Bitbucket credentials
24
+ const username = process.env.BITBUCKET_USERNAME;
25
+ const password = process.env.BITBUCKET_APP_PASSWORD;
26
+
27
+ if (!username || !password) {
28
+ console.log(
29
+ `\n⚠️ Bitbucket credentials not found. Cannot check existing PRs.`,
30
+ );
31
+ return [];
32
+ }
33
+
34
+ const auth = Buffer.from(`${username}:${password}`).toString('base64');
35
+ const allMatchingPRs = [];
36
+
37
+ // Check each repository for matching PRs
38
+ for (const repo of repositories) {
39
+ try {
40
+ const match = repo.url.match(/bitbucket\.org[\/:]([^\/]+)\/([^\/\.]+)/);
41
+
42
+ if (!match) {
43
+ console.warn(`Could not parse repository URL: ${repo.url}`);
44
+ continue;
45
+ }
46
+
47
+ const [, workspace, repoSlug] = match;
48
+
49
+ const response = await fetch(
50
+ `https://api.bitbucket.org/2.0/repositories/${workspace}/${repoSlug}/pullrequests?state=OPEN`,
51
+ {
52
+ method: 'GET',
53
+ headers: {
54
+ Authorization: `Basic ${auth}`,
55
+ 'Content-Type': 'application/json',
56
+ },
57
+ },
58
+ );
59
+
60
+ if (!response.ok) {
61
+ const error = await response.text();
62
+ console.warn(`Bitbucket API error for ${repo.name}: ${response.status} - ${error}`);
63
+ continue;
64
+ }
65
+
66
+ const data = await response.json();
67
+ const matchingPRs = data.values.filter(pr =>
68
+ pr.description && pr.description.startsWith(descriptionPattern)
69
+ );
70
+
71
+ // Add repository info to each PR for context
72
+ matchingPRs.forEach(pr => {
73
+ pr.repositoryName = repo.name;
74
+ pr.repositoryUrl = repo.url;
75
+ });
76
+
77
+ allMatchingPRs.push(...matchingPRs);
78
+ } catch (error) {
79
+ console.warn(`Failed to check PRs for repository ${repo.name}: ${error.message}`);
80
+ }
81
+ }
82
+
83
+ return allMatchingPRs;
84
+ } catch (error) {
85
+ console.error(`Failed to get existing PRs: ${error.message}`);
86
+ return [];
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Legacy function for backward compatibility - checks PRs in current repo only
92
+ */
93
+ export async function getExistingPRsFromCurrentRepo(descriptionPattern) {
17
94
  try {
18
95
  // Get Bitbucket workspace and repo from git remote
19
96
  const remoteUrl = execSync('git config --get remote.origin.url', {