@bragduck/cli 2.9.3 → 2.9.7
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/dist/bin/bragduck.js +89 -15
- package/dist/bin/bragduck.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/bragduck.js
CHANGED
|
@@ -3420,16 +3420,41 @@ var JiraService = class {
|
|
|
3420
3420
|
"issuetype"
|
|
3421
3421
|
];
|
|
3422
3422
|
const allIssues = [];
|
|
3423
|
+
const seenIssueKeys = /* @__PURE__ */ new Set();
|
|
3423
3424
|
let startAt = 0;
|
|
3424
3425
|
const maxResults = 100;
|
|
3426
|
+
const maxIterations = 1e3;
|
|
3427
|
+
let iterations = 0;
|
|
3425
3428
|
while (true) {
|
|
3429
|
+
iterations++;
|
|
3430
|
+
if (iterations > maxIterations) {
|
|
3431
|
+
logger.warning(
|
|
3432
|
+
`Reached maximum iteration limit (${maxIterations}). Stopping pagination to prevent infinite loop.`
|
|
3433
|
+
);
|
|
3434
|
+
break;
|
|
3435
|
+
}
|
|
3426
3436
|
const endpoint = `/rest/api/2/search?jql=${encodeURIComponent(jql)}&startAt=${startAt}&maxResults=${maxResults}&fields=${fields.join(",")}`;
|
|
3427
3437
|
try {
|
|
3428
3438
|
const response = await this.request(endpoint);
|
|
3429
|
-
|
|
3439
|
+
if (response.issues.length === 0) {
|
|
3440
|
+
logger.debug("No more results returned, stopping pagination");
|
|
3441
|
+
break;
|
|
3442
|
+
}
|
|
3443
|
+
let newIssuesCount = 0;
|
|
3444
|
+
for (const issue of response.issues) {
|
|
3445
|
+
if (!seenIssueKeys.has(issue.key)) {
|
|
3446
|
+
seenIssueKeys.add(issue.key);
|
|
3447
|
+
allIssues.push(issue);
|
|
3448
|
+
newIssuesCount++;
|
|
3449
|
+
}
|
|
3450
|
+
}
|
|
3430
3451
|
logger.debug(
|
|
3431
|
-
`Fetched ${
|
|
3452
|
+
`Fetched ${newIssuesCount} new issues (total: ${allIssues.length} of ${response.total})${startAt + maxResults < response.total ? ", fetching next page..." : ""}`
|
|
3432
3453
|
);
|
|
3454
|
+
if (newIssuesCount === 0) {
|
|
3455
|
+
logger.debug("All results are duplicates, stopping pagination");
|
|
3456
|
+
break;
|
|
3457
|
+
}
|
|
3433
3458
|
if (startAt + maxResults >= response.total) {
|
|
3434
3459
|
break;
|
|
3435
3460
|
}
|
|
@@ -3447,7 +3472,10 @@ var JiraService = class {
|
|
|
3447
3472
|
break;
|
|
3448
3473
|
}
|
|
3449
3474
|
if (startAt === 0) {
|
|
3450
|
-
|
|
3475
|
+
logger.warning(
|
|
3476
|
+
"No accessible issues found. Some resources may be deleted, archived, or you may not have permission to view them."
|
|
3477
|
+
);
|
|
3478
|
+
return [];
|
|
3451
3479
|
}
|
|
3452
3480
|
startAt += maxResults;
|
|
3453
3481
|
continue;
|
|
@@ -3696,9 +3724,19 @@ var ConfluenceService = class {
|
|
|
3696
3724
|
async getPages(options = {}) {
|
|
3697
3725
|
const cql = this.buildCQL(options);
|
|
3698
3726
|
const allPages = [];
|
|
3727
|
+
const seenPageIds = /* @__PURE__ */ new Set();
|
|
3699
3728
|
let start = 0;
|
|
3700
3729
|
const limit = 100;
|
|
3730
|
+
const maxIterations = 1e3;
|
|
3731
|
+
let iterations = 0;
|
|
3701
3732
|
while (true) {
|
|
3733
|
+
iterations++;
|
|
3734
|
+
if (iterations > maxIterations) {
|
|
3735
|
+
logger.warning(
|
|
3736
|
+
`Reached maximum iteration limit (${maxIterations}). Stopping pagination to prevent infinite loop.`
|
|
3737
|
+
);
|
|
3738
|
+
break;
|
|
3739
|
+
}
|
|
3702
3740
|
const params = {
|
|
3703
3741
|
type: "page",
|
|
3704
3742
|
status: "current",
|
|
@@ -3711,18 +3749,54 @@ var ConfluenceService = class {
|
|
|
3711
3749
|
}
|
|
3712
3750
|
const queryString = Object.entries(params).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&");
|
|
3713
3751
|
const endpoint = `/wiki/rest/api/content?${queryString}`;
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3752
|
+
try {
|
|
3753
|
+
const response = await this.request(endpoint);
|
|
3754
|
+
if (response.results.length === 0) {
|
|
3755
|
+
logger.debug("No more results returned, stopping pagination");
|
|
3756
|
+
break;
|
|
3757
|
+
}
|
|
3758
|
+
let newPagesCount = 0;
|
|
3759
|
+
for (const page of response.results) {
|
|
3760
|
+
if (!seenPageIds.has(page.id)) {
|
|
3761
|
+
seenPageIds.add(page.id);
|
|
3762
|
+
allPages.push(page);
|
|
3763
|
+
newPagesCount++;
|
|
3764
|
+
}
|
|
3765
|
+
}
|
|
3766
|
+
logger.debug(
|
|
3767
|
+
`Fetched ${newPagesCount} new pages (total: ${allPages.length}, duplicates: ${response.results.length - newPagesCount})${response.size === limit ? ", fetching next page..." : ""}`
|
|
3768
|
+
);
|
|
3769
|
+
if (newPagesCount === 0) {
|
|
3770
|
+
logger.debug("All results are duplicates, stopping pagination");
|
|
3771
|
+
break;
|
|
3772
|
+
}
|
|
3773
|
+
if (response.size === 0 || response.size < limit) {
|
|
3774
|
+
break;
|
|
3775
|
+
}
|
|
3776
|
+
if (options.limit && allPages.length >= options.limit) {
|
|
3777
|
+
return allPages.slice(0, options.limit).map((page) => this.transformPageToCommit(page));
|
|
3778
|
+
}
|
|
3779
|
+
start += limit;
|
|
3780
|
+
} catch (error) {
|
|
3781
|
+
if (error instanceof ConfluenceError && error.message.includes("no longer available")) {
|
|
3782
|
+
logger.warning(`Skipping unavailable Confluence resource: ${error.message}`);
|
|
3783
|
+
if (allPages.length > 0) {
|
|
3784
|
+
logger.info(
|
|
3785
|
+
`Returning ${allPages.length} available pages (some resources were unavailable)`
|
|
3786
|
+
);
|
|
3787
|
+
break;
|
|
3788
|
+
}
|
|
3789
|
+
if (start === 0) {
|
|
3790
|
+
logger.warning(
|
|
3791
|
+
"No accessible pages found. Some resources may be deleted, archived, or you may not have permission to view them."
|
|
3792
|
+
);
|
|
3793
|
+
return [];
|
|
3794
|
+
}
|
|
3795
|
+
start += limit;
|
|
3796
|
+
continue;
|
|
3797
|
+
}
|
|
3798
|
+
throw error;
|
|
3724
3799
|
}
|
|
3725
|
-
start += limit;
|
|
3726
3800
|
}
|
|
3727
3801
|
return allPages.map((page) => this.transformPageToCommit(page));
|
|
3728
3802
|
}
|
|
@@ -4638,7 +4712,7 @@ async function syncAllAuthenticatedServices(options) {
|
|
|
4638
4712
|
} catch (error) {
|
|
4639
4713
|
const err = error;
|
|
4640
4714
|
logger.log("");
|
|
4641
|
-
logger.
|
|
4715
|
+
logger.warning(`Failed to sync ${serviceLabel}: ${err.message}`);
|
|
4642
4716
|
logger.log("");
|
|
4643
4717
|
results.push({ service, created: 0, skipped: 0, error: err.message });
|
|
4644
4718
|
}
|