@bragduck/cli 2.18.1 → 2.20.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/dist/bin/bragduck.js +86 -21
- package/dist/bin/bragduck.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/bragduck.js
CHANGED
|
@@ -4688,6 +4688,21 @@ async function promptSelectOrganisation(organisations) {
|
|
|
4688
4688
|
});
|
|
4689
4689
|
return selected === "none" ? null : selected;
|
|
4690
4690
|
}
|
|
4691
|
+
async function promptSelectOrganisationWithDefault(organisations, defaultOrgId) {
|
|
4692
|
+
if (defaultOrgId) {
|
|
4693
|
+
const defaultOrg = organisations.find((org) => org.id === defaultOrgId);
|
|
4694
|
+
if (defaultOrg) {
|
|
4695
|
+
const useDefault = await confirm({
|
|
4696
|
+
message: `Use your default company "${defaultOrg.name}"?`,
|
|
4697
|
+
default: true
|
|
4698
|
+
});
|
|
4699
|
+
if (useDefault) {
|
|
4700
|
+
return defaultOrgId;
|
|
4701
|
+
}
|
|
4702
|
+
}
|
|
4703
|
+
}
|
|
4704
|
+
return await promptSelectOrganisation(organisations);
|
|
4705
|
+
}
|
|
4691
4706
|
async function promptReviewBrags(refinedBrags, selectedCommits) {
|
|
4692
4707
|
const acceptedBrags = [];
|
|
4693
4708
|
console.log("\n" + theme.info("Review each brag before creation:") + "\n");
|
|
@@ -4913,7 +4928,7 @@ async function promptSelectService() {
|
|
|
4913
4928
|
});
|
|
4914
4929
|
return selected;
|
|
4915
4930
|
}
|
|
4916
|
-
async function syncSingleService(sourceType, options, TOTAL_STEPS) {
|
|
4931
|
+
async function syncSingleService(sourceType, options, TOTAL_STEPS, sharedDays, sharedOrgId) {
|
|
4917
4932
|
const adapter = AdapterFactory.getAdapter(sourceType);
|
|
4918
4933
|
const repoSpinner = createStepSpinner(2, TOTAL_STEPS, "Validating repository");
|
|
4919
4934
|
repoSpinner.start();
|
|
@@ -4943,7 +4958,7 @@ async function syncSingleService(sourceType, options, TOTAL_STEPS) {
|
|
|
4943
4958
|
failStepSpinner(repoSpinner, 2, TOTAL_STEPS, "Validation failed");
|
|
4944
4959
|
throw error;
|
|
4945
4960
|
}
|
|
4946
|
-
let days = options.days;
|
|
4961
|
+
let days = sharedDays || options.days;
|
|
4947
4962
|
if (!days && options.today) {
|
|
4948
4963
|
days = 1;
|
|
4949
4964
|
logger.debug("Using --today flag: scanning last 24 hours (1 day)");
|
|
@@ -5077,17 +5092,19 @@ async function syncSingleService(sourceType, options, TOTAL_STEPS) {
|
|
|
5077
5092
|
return { created: 0, skipped: duplicates.length };
|
|
5078
5093
|
}
|
|
5079
5094
|
logger.log("");
|
|
5080
|
-
let selectedOrgId = null;
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5095
|
+
let selectedOrgId = sharedOrgId !== void 0 ? sharedOrgId : null;
|
|
5096
|
+
if (sharedOrgId === void 0) {
|
|
5097
|
+
const userInfo = authService.getUserInfo();
|
|
5098
|
+
if (userInfo?.id) {
|
|
5099
|
+
try {
|
|
5100
|
+
const orgsResponse = await apiService.listUserOrganisations(userInfo.id);
|
|
5101
|
+
if (orgsResponse.items.length > 0) {
|
|
5102
|
+
selectedOrgId = await promptSelectOrganisation(orgsResponse.items);
|
|
5103
|
+
logger.log("");
|
|
5104
|
+
}
|
|
5105
|
+
} catch {
|
|
5106
|
+
logger.debug("Failed to fetch organisations, skipping org selection");
|
|
5088
5107
|
}
|
|
5089
|
-
} catch {
|
|
5090
|
-
logger.debug("Failed to fetch organisations, skipping org selection");
|
|
5091
5108
|
}
|
|
5092
5109
|
}
|
|
5093
5110
|
const createSpinner2 = createStepSpinner(
|
|
@@ -5161,16 +5178,28 @@ async function syncAllAuthenticatedServices(options) {
|
|
|
5161
5178
|
let servicesToSync = authenticatedServices.filter(
|
|
5162
5179
|
(service) => service !== "bragduck" && allServices.includes(service)
|
|
5163
5180
|
);
|
|
5181
|
+
let detectedGitService = null;
|
|
5164
5182
|
try {
|
|
5165
5183
|
const { detected } = await sourceDetector.detectSources();
|
|
5166
5184
|
logger.debug(`Detected ${detected.length} git source(s) from repository`);
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5185
|
+
const gitSource = detected.find(
|
|
5186
|
+
(source) => ["github", "gitlab", "bitbucket", "atlassian"].includes(source.type)
|
|
5187
|
+
);
|
|
5188
|
+
if (gitSource) {
|
|
5189
|
+
detectedGitService = gitSource.type;
|
|
5190
|
+
logger.debug(`Current repository is ${detectedGitService}, will sync only this git service`);
|
|
5191
|
+
if (!servicesToSync.includes(detectedGitService)) {
|
|
5192
|
+
servicesToSync.push(detectedGitService);
|
|
5193
|
+
logger.debug(`Added local ${detectedGitService} repo to sync list`);
|
|
5194
|
+
}
|
|
5195
|
+
const otherGitServices = ["github", "gitlab", "bitbucket", "atlassian"];
|
|
5196
|
+
servicesToSync = servicesToSync.filter(
|
|
5197
|
+
(service) => service === detectedGitService || !otherGitServices.includes(service)
|
|
5198
|
+
// Keep non-git services like Jira/Confluence
|
|
5199
|
+
);
|
|
5200
|
+
logger.debug(
|
|
5201
|
+
`Filtered out other git services, keeping only ${detectedGitService} for git sync`
|
|
5202
|
+
);
|
|
5174
5203
|
}
|
|
5175
5204
|
} catch {
|
|
5176
5205
|
logger.debug("No local git repository detected");
|
|
@@ -5188,10 +5217,40 @@ async function syncAllAuthenticatedServices(options) {
|
|
|
5188
5217
|
}
|
|
5189
5218
|
logger.info(
|
|
5190
5219
|
theme.highlight(
|
|
5191
|
-
`Syncing ${servicesToSync.length}
|
|
5220
|
+
`Syncing ${servicesToSync.length} service${servicesToSync.length > 1 ? "s" : ""}...`
|
|
5192
5221
|
)
|
|
5193
5222
|
);
|
|
5194
5223
|
logger.log("");
|
|
5224
|
+
let sharedDays = options.days;
|
|
5225
|
+
if (!sharedDays && options.today) {
|
|
5226
|
+
sharedDays = 1;
|
|
5227
|
+
logger.debug("Using --today flag: scanning last 24 hours (1 day)");
|
|
5228
|
+
}
|
|
5229
|
+
if (!sharedDays && !options.turbo) {
|
|
5230
|
+
const defaultDays = storageService.getConfig("defaultCommitDays");
|
|
5231
|
+
sharedDays = await promptDaysToScan(defaultDays);
|
|
5232
|
+
logger.log("");
|
|
5233
|
+
}
|
|
5234
|
+
if (!sharedDays && options.turbo) {
|
|
5235
|
+
sharedDays = storageService.getConfig("defaultCommitDays") || 30;
|
|
5236
|
+
logger.debug(`Turbo mode: using default ${sharedDays} days`);
|
|
5237
|
+
}
|
|
5238
|
+
let sharedOrgId = null;
|
|
5239
|
+
if (!options.turbo) {
|
|
5240
|
+
const userInfo = authService.getUserInfo();
|
|
5241
|
+
if (userInfo?.id) {
|
|
5242
|
+
try {
|
|
5243
|
+
const orgsResponse = await apiService.listUserOrganisations(userInfo.id);
|
|
5244
|
+
if (orgsResponse.items.length > 0) {
|
|
5245
|
+
const defaultOrgId = storageService.getConfig("defaultCompany");
|
|
5246
|
+
sharedOrgId = await promptSelectOrganisationWithDefault(orgsResponse.items, defaultOrgId);
|
|
5247
|
+
logger.log("");
|
|
5248
|
+
}
|
|
5249
|
+
} catch {
|
|
5250
|
+
logger.debug("Failed to fetch organisations, skipping org selection");
|
|
5251
|
+
}
|
|
5252
|
+
}
|
|
5253
|
+
}
|
|
5195
5254
|
const results = [];
|
|
5196
5255
|
for (let i = 0; i < servicesToSync.length; i++) {
|
|
5197
5256
|
const service = servicesToSync[i];
|
|
@@ -5202,7 +5261,13 @@ async function syncAllAuthenticatedServices(options) {
|
|
|
5202
5261
|
);
|
|
5203
5262
|
logger.log("");
|
|
5204
5263
|
try {
|
|
5205
|
-
const result = await syncSingleService(
|
|
5264
|
+
const result = await syncSingleService(
|
|
5265
|
+
service,
|
|
5266
|
+
options,
|
|
5267
|
+
TOTAL_STEPS,
|
|
5268
|
+
sharedDays,
|
|
5269
|
+
sharedOrgId
|
|
5270
|
+
);
|
|
5206
5271
|
results.push({ service, created: result.created, skipped: result.skipped });
|
|
5207
5272
|
logger.log("");
|
|
5208
5273
|
} catch (error) {
|