@bragduck/cli 2.22.0 → 2.24.2
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 +68 -22
- package/dist/bin/bragduck.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/bragduck.js
CHANGED
|
@@ -1907,12 +1907,23 @@ var execAsync2 = promisify2(exec2);
|
|
|
1907
1907
|
var GitHubService = class {
|
|
1908
1908
|
MAX_BODY_LENGTH = 5e3;
|
|
1909
1909
|
PR_SEARCH_FIELDS = "number,title,body,author,mergedAt,additions,deletions,changedFiles,url,labels";
|
|
1910
|
+
/**
|
|
1911
|
+
* Execute a gh CLI command with clean environment
|
|
1912
|
+
* Unsets GITHUB_TOKEN and GH_TOKEN to prevent .envrc tokens from interfering
|
|
1913
|
+
* with gh CLI's own authentication
|
|
1914
|
+
*/
|
|
1915
|
+
async execGhCommand(command) {
|
|
1916
|
+
const env = { ...process.env };
|
|
1917
|
+
delete env.GITHUB_TOKEN;
|
|
1918
|
+
delete env.GH_TOKEN;
|
|
1919
|
+
return execAsync2(command, { env });
|
|
1920
|
+
}
|
|
1910
1921
|
/**
|
|
1911
1922
|
* Check if GitHub CLI is installed and available
|
|
1912
1923
|
*/
|
|
1913
1924
|
async checkGitHubCLI() {
|
|
1914
1925
|
try {
|
|
1915
|
-
await
|
|
1926
|
+
await this.execGhCommand("command gh --version");
|
|
1916
1927
|
return true;
|
|
1917
1928
|
} catch {
|
|
1918
1929
|
return false;
|
|
@@ -1934,7 +1945,7 @@ var GitHubService = class {
|
|
|
1934
1945
|
*/
|
|
1935
1946
|
async checkAuthentication() {
|
|
1936
1947
|
try {
|
|
1937
|
-
await
|
|
1948
|
+
await this.execGhCommand("command gh auth status");
|
|
1938
1949
|
return true;
|
|
1939
1950
|
} catch {
|
|
1940
1951
|
return false;
|
|
@@ -1971,7 +1982,7 @@ var GitHubService = class {
|
|
|
1971
1982
|
await this.ensureGitHubCLI();
|
|
1972
1983
|
await this.ensureAuthentication();
|
|
1973
1984
|
await gitService.validateRepository();
|
|
1974
|
-
const { stdout } = await
|
|
1985
|
+
const { stdout } = await this.execGhCommand("command gh repo view --json url");
|
|
1975
1986
|
const data = JSON.parse(stdout);
|
|
1976
1987
|
if (!data.url) {
|
|
1977
1988
|
throw new GitHubError("This repository is not hosted on GitHub", {
|
|
@@ -2003,7 +2014,7 @@ var GitHubService = class {
|
|
|
2003
2014
|
async getRepositoryInfo() {
|
|
2004
2015
|
try {
|
|
2005
2016
|
await this.ensureGitHubCLI();
|
|
2006
|
-
const { stdout } = await
|
|
2017
|
+
const { stdout } = await this.execGhCommand(
|
|
2007
2018
|
"command gh repo view --json owner,name,url,nameWithOwner"
|
|
2008
2019
|
);
|
|
2009
2020
|
const data = JSON.parse(stdout);
|
|
@@ -2028,7 +2039,7 @@ var GitHubService = class {
|
|
|
2028
2039
|
*/
|
|
2029
2040
|
async getCurrentGitHubUser() {
|
|
2030
2041
|
try {
|
|
2031
|
-
const { stdout } = await
|
|
2042
|
+
const { stdout } = await this.execGhCommand("command gh api user --jq .login");
|
|
2032
2043
|
return stdout.trim() || null;
|
|
2033
2044
|
} catch {
|
|
2034
2045
|
logger.debug("Failed to get GitHub user");
|
|
@@ -2054,7 +2065,7 @@ var GitHubService = class {
|
|
|
2054
2065
|
const limitArg = limit ? `--limit ${limit}` : "";
|
|
2055
2066
|
const command = `command gh pr list --state merged --json ${this.PR_SEARCH_FIELDS} --search "${searchQuery}" ${limitArg}`;
|
|
2056
2067
|
logger.debug(`Running: ${command}`);
|
|
2057
|
-
const { stdout } = await
|
|
2068
|
+
const { stdout } = await this.execGhCommand(command);
|
|
2058
2069
|
const prs = JSON.parse(stdout);
|
|
2059
2070
|
logger.debug(`Found ${prs.length} merged PRs`);
|
|
2060
2071
|
return prs;
|
|
@@ -4490,6 +4501,9 @@ import terminalLink from "terminal-link";
|
|
|
4490
4501
|
init_esm_shims();
|
|
4491
4502
|
var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
4492
4503
|
function formatDate(dateString) {
|
|
4504
|
+
if (!dateString || typeof dateString === "string" && dateString.trim() === "") {
|
|
4505
|
+
return "No date";
|
|
4506
|
+
}
|
|
4493
4507
|
const date = typeof dateString === "string" ? new Date(dateString) : dateString;
|
|
4494
4508
|
if (isNaN(date.getTime())) {
|
|
4495
4509
|
return "Invalid date";
|
|
@@ -4916,6 +4930,8 @@ function failStepSpinner(spinner, currentStep, totalSteps, text) {
|
|
|
4916
4930
|
|
|
4917
4931
|
// src/commands/sync.ts
|
|
4918
4932
|
async function promptSelectService() {
|
|
4933
|
+
const nonGitServices = ["atlassian", "jira", "confluence"];
|
|
4934
|
+
const authenticatedServices = await storageService.getAuthenticatedServices();
|
|
4919
4935
|
const allServices = [
|
|
4920
4936
|
"github",
|
|
4921
4937
|
"gitlab",
|
|
@@ -4924,22 +4940,26 @@ async function promptSelectService() {
|
|
|
4924
4940
|
"jira",
|
|
4925
4941
|
"confluence"
|
|
4926
4942
|
];
|
|
4927
|
-
const authenticatedServices = await storageService.getAuthenticatedServices();
|
|
4928
4943
|
const authenticatedSyncServices = authenticatedServices.filter(
|
|
4929
4944
|
(service) => service !== "bragduck" && allServices.includes(service)
|
|
4930
4945
|
);
|
|
4931
|
-
const serviceChoices =
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4946
|
+
const serviceChoices = [
|
|
4947
|
+
{
|
|
4948
|
+
name: "Git Contributions (current dir)",
|
|
4949
|
+
value: "git",
|
|
4950
|
+
description: "Sync from your local repository (GitHub, GitLab, or Bitbucket)"
|
|
4951
|
+
}
|
|
4952
|
+
];
|
|
4953
|
+
for (const service of nonGitServices) {
|
|
4954
|
+
const isAuth = await storageService.isServiceAuthenticated(service);
|
|
4955
|
+
const indicator = isAuth ? "\u2713" : "\u2717";
|
|
4956
|
+
const serviceLabel = service.charAt(0).toUpperCase() + service.slice(1);
|
|
4957
|
+
serviceChoices.push({
|
|
4958
|
+
name: `${indicator} ${serviceLabel}`,
|
|
4959
|
+
value: service,
|
|
4960
|
+
description: isAuth ? "Authenticated" : "Not authenticated"
|
|
4961
|
+
});
|
|
4962
|
+
}
|
|
4943
4963
|
if (authenticatedSyncServices.length > 0) {
|
|
4944
4964
|
const serviceNames = authenticatedSyncServices.map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(", ");
|
|
4945
4965
|
serviceChoices.push({
|
|
@@ -5146,7 +5166,7 @@ async function syncSingleService(sourceType, options, TOTAL_STEPS, sharedDays, s
|
|
|
5146
5166
|
description: refined.refined_description,
|
|
5147
5167
|
tags: refined.suggested_tags,
|
|
5148
5168
|
repository: repoInfo.url,
|
|
5149
|
-
date: originalCommit?.date ||
|
|
5169
|
+
date: originalCommit?.date || (/* @__PURE__ */ new Date()).toISOString(),
|
|
5150
5170
|
commit_url: originalCommit?.url || "",
|
|
5151
5171
|
impact_score: refined.suggested_impactLevel,
|
|
5152
5172
|
impact_description: refined.impact_description,
|
|
@@ -5188,7 +5208,7 @@ async function syncSingleService(sourceType, options, TOTAL_STEPS, sharedDays, s
|
|
|
5188
5208
|
}
|
|
5189
5209
|
const createdBrags = createResponse.brags.map((brag) => ({
|
|
5190
5210
|
title: brag.title,
|
|
5191
|
-
date: brag.
|
|
5211
|
+
date: brag.date,
|
|
5192
5212
|
source: sourceType
|
|
5193
5213
|
}));
|
|
5194
5214
|
return { created: createResponse.created, skipped: duplicates.length, createdBrags };
|
|
@@ -5408,7 +5428,33 @@ async function syncCommand(options = {}) {
|
|
|
5408
5428
|
} else {
|
|
5409
5429
|
const detectionSpinner = createStepSpinner(1, TOTAL_STEPS, "Preparing sync");
|
|
5410
5430
|
detectionSpinner.start();
|
|
5411
|
-
|
|
5431
|
+
if (selectedSource === "git") {
|
|
5432
|
+
try {
|
|
5433
|
+
const { detected } = await sourceDetector.detectSources();
|
|
5434
|
+
const gitSource = detected.find(
|
|
5435
|
+
(source) => ["github", "gitlab", "bitbucket", "atlassian"].includes(source.type)
|
|
5436
|
+
);
|
|
5437
|
+
if (!gitSource) {
|
|
5438
|
+
failStepSpinner(detectionSpinner, 1, TOTAL_STEPS, "Not a git repository");
|
|
5439
|
+
logger.log("");
|
|
5440
|
+
logger.error("No git repository detected in current directory");
|
|
5441
|
+
logger.log("");
|
|
5442
|
+
logger.info("Navigate to a git repository or select a different service");
|
|
5443
|
+
return;
|
|
5444
|
+
}
|
|
5445
|
+
sourceType = gitSource.type;
|
|
5446
|
+
logger.debug(`Detected git service: ${sourceType}`);
|
|
5447
|
+
} catch (error) {
|
|
5448
|
+
logger.debug(`Git detection error: ${error}`);
|
|
5449
|
+
failStepSpinner(detectionSpinner, 1, TOTAL_STEPS, "Failed to detect git service");
|
|
5450
|
+
logger.log("");
|
|
5451
|
+
logger.error("Could not detect git repository");
|
|
5452
|
+
logger.log("");
|
|
5453
|
+
return;
|
|
5454
|
+
}
|
|
5455
|
+
} else {
|
|
5456
|
+
sourceType = selectedSource;
|
|
5457
|
+
}
|
|
5412
5458
|
if (sourceType === "jira" || sourceType === "confluence") {
|
|
5413
5459
|
const creds = await storageService.getServiceCredentials(sourceType);
|
|
5414
5460
|
const envInstance = loadEnvConfig()[`${sourceType}Instance`];
|