@bragduck/cli 2.3.2 → 2.3.3
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 +55 -1
- package/dist/bin/bragduck.js.map +1 -1
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/bragduck.js
CHANGED
|
@@ -60,6 +60,9 @@ var init_constants = __esm({
|
|
|
60
60
|
SUBSCRIPTION: {
|
|
61
61
|
STATUS: "/v1/subscriptions/status"
|
|
62
62
|
},
|
|
63
|
+
ORGANISATIONS: {
|
|
64
|
+
LIST: "/v1/users/{userId}/organisations"
|
|
65
|
+
},
|
|
63
66
|
VERSION: "/v1/cli/version",
|
|
64
67
|
/**
|
|
65
68
|
* @deprecated Use BRAGS.REFINE instead
|
|
@@ -1211,11 +1214,13 @@ var init_api_service = __esm({
|
|
|
1211
1214
|
*/
|
|
1212
1215
|
async createBrags(request) {
|
|
1213
1216
|
logger.debug(`Creating ${request.brags.length} brags`);
|
|
1217
|
+
logger.debug(`Request body: ${JSON.stringify(request, null, 2)}`);
|
|
1214
1218
|
try {
|
|
1215
1219
|
const response = await this.makeRequest(API_ENDPOINTS.BRAGS.CREATE, {
|
|
1216
1220
|
method: "POST",
|
|
1217
1221
|
body: request
|
|
1218
1222
|
});
|
|
1223
|
+
logger.debug(`Response: ${JSON.stringify(response, null, 2)}`);
|
|
1219
1224
|
logger.debug(`Successfully created ${response.created} brags`);
|
|
1220
1225
|
return response;
|
|
1221
1226
|
} catch (_error) {
|
|
@@ -1253,6 +1258,23 @@ var init_api_service = __esm({
|
|
|
1253
1258
|
throw _error;
|
|
1254
1259
|
}
|
|
1255
1260
|
}
|
|
1261
|
+
/**
|
|
1262
|
+
* List user's organisations
|
|
1263
|
+
*/
|
|
1264
|
+
async listUserOrganisations(userId) {
|
|
1265
|
+
logger.debug(`Listing organisations for user: ${userId}`);
|
|
1266
|
+
try {
|
|
1267
|
+
const url = API_ENDPOINTS.ORGANISATIONS.LIST.replace("{userId}", userId);
|
|
1268
|
+
const response = await this.makeRequest(url, {
|
|
1269
|
+
method: "GET"
|
|
1270
|
+
});
|
|
1271
|
+
logger.debug(`Successfully fetched ${response.items.length} organisations`);
|
|
1272
|
+
return response;
|
|
1273
|
+
} catch (_error) {
|
|
1274
|
+
logger.debug("Failed to list organisations");
|
|
1275
|
+
throw _error;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1256
1278
|
/**
|
|
1257
1279
|
* Get user's subscription status
|
|
1258
1280
|
*/
|
|
@@ -2310,6 +2332,21 @@ async function promptSortOption() {
|
|
|
2310
2332
|
default: "date"
|
|
2311
2333
|
});
|
|
2312
2334
|
}
|
|
2335
|
+
async function promptSelectOrganisation(organisations) {
|
|
2336
|
+
const choices = [
|
|
2337
|
+
{ name: "No company", value: "none" },
|
|
2338
|
+
...organisations.map((org) => ({
|
|
2339
|
+
name: org.name,
|
|
2340
|
+
value: org.id
|
|
2341
|
+
}))
|
|
2342
|
+
];
|
|
2343
|
+
const selected = await select({
|
|
2344
|
+
message: "Attach brags to which company?",
|
|
2345
|
+
choices,
|
|
2346
|
+
default: "none"
|
|
2347
|
+
});
|
|
2348
|
+
return selected === "none" ? null : selected;
|
|
2349
|
+
}
|
|
2313
2350
|
async function promptReviewBrags(refinedBrags, selectedCommits) {
|
|
2314
2351
|
const acceptedBrags = [];
|
|
2315
2352
|
console.log("\n" + theme.info("Review each brag before creation:") + "\n");
|
|
@@ -2451,6 +2488,9 @@ async function ensureAuthenticated() {
|
|
|
2451
2488
|
}
|
|
2452
2489
|
}
|
|
2453
2490
|
|
|
2491
|
+
// src/commands/scan.ts
|
|
2492
|
+
init_auth_service();
|
|
2493
|
+
|
|
2454
2494
|
// src/ui/spinners.ts
|
|
2455
2495
|
init_esm_shims();
|
|
2456
2496
|
import ora3 from "ora";
|
|
@@ -2673,6 +2713,19 @@ async function scanCommand(options = {}) {
|
|
|
2673
2713
|
return;
|
|
2674
2714
|
}
|
|
2675
2715
|
logger.log("");
|
|
2716
|
+
let selectedOrgId = null;
|
|
2717
|
+
const userInfo = authService.getUserInfo();
|
|
2718
|
+
if (userInfo?.id) {
|
|
2719
|
+
try {
|
|
2720
|
+
const orgsResponse = await apiService.listUserOrganisations(userInfo.id);
|
|
2721
|
+
if (orgsResponse.items.length > 0) {
|
|
2722
|
+
selectedOrgId = await promptSelectOrganisation(orgsResponse.items);
|
|
2723
|
+
logger.log("");
|
|
2724
|
+
}
|
|
2725
|
+
} catch {
|
|
2726
|
+
logger.debug("Failed to fetch organisations, skipping org selection");
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2676
2729
|
const createSpinner2 = createStepSpinner(
|
|
2677
2730
|
4,
|
|
2678
2731
|
TOTAL_STEPS,
|
|
@@ -2692,7 +2745,8 @@ async function scanCommand(options = {}) {
|
|
|
2692
2745
|
commit_url: originalCommit?.url || "",
|
|
2693
2746
|
impact_score: refined.suggested_impactLevel,
|
|
2694
2747
|
impact_description: refined.impact_description,
|
|
2695
|
-
attachments: originalCommit?.url ? [originalCommit.url] : []
|
|
2748
|
+
attachments: originalCommit?.url ? [originalCommit.url] : [],
|
|
2749
|
+
orgId: selectedOrgId || void 0
|
|
2696
2750
|
};
|
|
2697
2751
|
})
|
|
2698
2752
|
};
|