bitfab-cli 0.2.173 → 0.2.175
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/index.js +48 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9370,6 +9370,14 @@ function saveCredentials(apiKey) {
|
|
|
9370
9370
|
`);
|
|
9371
9371
|
}
|
|
9372
9372
|
function deleteCredentials() {
|
|
9373
|
+
const projectFile = findProjectFiles()?.credentialsFile;
|
|
9374
|
+
if (projectFile) {
|
|
9375
|
+
try {
|
|
9376
|
+
fs3.unlinkSync(projectFile);
|
|
9377
|
+
} catch {
|
|
9378
|
+
}
|
|
9379
|
+
return;
|
|
9380
|
+
}
|
|
9373
9381
|
try {
|
|
9374
9382
|
fs3.unlinkSync(GLOBAL_CREDENTIALS_FILE);
|
|
9375
9383
|
} catch {
|
|
@@ -11428,6 +11436,7 @@ async function verifyToken(serviceUrl, token) {
|
|
|
11428
11436
|
async function runLogin(platform2, pluginVersion, options) {
|
|
11429
11437
|
const exitOnComplete = options?.exitOnComplete ?? true;
|
|
11430
11438
|
const force = options?.force ?? process.argv.includes("--force");
|
|
11439
|
+
const embedded = options?.embedded ?? false;
|
|
11431
11440
|
const config4 = getConfig();
|
|
11432
11441
|
if (!force && hasCredentials() && config4.apiKey) {
|
|
11433
11442
|
const who = await verifyToken(config4.serviceUrl, config4.apiKey);
|
|
@@ -11469,9 +11478,15 @@ Already logged in as ${identity}${endpoint}. Run the login command with --force
|
|
|
11469
11478
|
const who = await verifyToken(config4.serviceUrl, apiKey);
|
|
11470
11479
|
const endpoint = formatNonProductionEndpointSuffix(config4.serviceUrl);
|
|
11471
11480
|
const greeting = who?.user.email ? `Logged in as ${who.user.email}${endpoint}.` : "Authentication successful.";
|
|
11472
|
-
|
|
11481
|
+
if (options?.onSuccess) {
|
|
11482
|
+
options.onSuccess(greeting);
|
|
11483
|
+
} else {
|
|
11484
|
+
console.log(embedded ? greeting : `
|
|
11473
11485
|
${greeting}`);
|
|
11474
|
-
|
|
11486
|
+
}
|
|
11487
|
+
if (!embedded) {
|
|
11488
|
+
console.log("Bitfab MCP tools are now active. (via studio)");
|
|
11489
|
+
}
|
|
11475
11490
|
}
|
|
11476
11491
|
result.abort();
|
|
11477
11492
|
if (exitOnComplete) {
|
|
@@ -31643,17 +31658,42 @@ async function runAnalyzeRepo(opts) {
|
|
|
31643
31658
|
ADAPTERS[chosen].analyzeRepo();
|
|
31644
31659
|
process.exit(1);
|
|
31645
31660
|
}
|
|
31661
|
+
await ensureAnalyzeRepoAuth();
|
|
31662
|
+
const captureOverride = await resolveCaptureOverride(opts.uploadLogs);
|
|
31663
|
+
await ADAPTERS[chosen].analyzeRepo(captureOverride, opts.limit);
|
|
31664
|
+
p6.outro("Done!");
|
|
31665
|
+
}
|
|
31666
|
+
async function ensureAnalyzeRepoAuth(canPrompt = Boolean(process.stdin.isTTY)) {
|
|
31646
31667
|
const loggedInEmail = await checkAuth();
|
|
31647
|
-
if (
|
|
31668
|
+
if (loggedInEmail) {
|
|
31669
|
+
p6.log.success(`Logged in as ${loggedInEmail}`);
|
|
31670
|
+
return;
|
|
31671
|
+
}
|
|
31672
|
+
if (!canPrompt) {
|
|
31648
31673
|
p6.cancel(
|
|
31649
|
-
"Not authenticated. Run `bitfab login` (or set BITFAB_API_KEY) before `bitfab analyze-repo`
|
|
31674
|
+
"Not authenticated. Run `bitfab login` (or set BITFAB_API_KEY) before `bitfab analyze-repo` in non-interactive environments."
|
|
31675
|
+
);
|
|
31676
|
+
process.exit(1);
|
|
31677
|
+
}
|
|
31678
|
+
p6.log.step("Signing in to Bitfab");
|
|
31679
|
+
await runLoginCommand({
|
|
31680
|
+
embedded: true,
|
|
31681
|
+
exitOnComplete: false,
|
|
31682
|
+
onSuccess: (message) => p6.log.success(message)
|
|
31683
|
+
});
|
|
31684
|
+
const refreshedLoggedInEmail = await checkAuth();
|
|
31685
|
+
if (!refreshedLoggedInEmail) {
|
|
31686
|
+
if (process.env.BITFAB_API_KEY) {
|
|
31687
|
+
p6.cancel(
|
|
31688
|
+
"Authentication completed, but BITFAB_API_KEY is set and still fails verification. Unset BITFAB_API_KEY or replace it with a valid key, then rerun `bitfab analyze-repo`."
|
|
31689
|
+
);
|
|
31690
|
+
process.exit(1);
|
|
31691
|
+
}
|
|
31692
|
+
p6.cancel(
|
|
31693
|
+
"Authentication did not complete. Run `bitfab login` and try again."
|
|
31650
31694
|
);
|
|
31651
31695
|
process.exit(1);
|
|
31652
31696
|
}
|
|
31653
|
-
p6.log.success(`Logged in as ${loggedInEmail}`);
|
|
31654
|
-
const captureOverride = await resolveCaptureOverride(opts.uploadLogs);
|
|
31655
|
-
await ADAPTERS[chosen].analyzeRepo(captureOverride, opts.limit);
|
|
31656
|
-
p6.outro("Done!");
|
|
31657
31697
|
}
|
|
31658
31698
|
async function checkAuth() {
|
|
31659
31699
|
const { apiKey, serviceUrl } = getConfig();
|