@bragduck/cli 2.22.0 → 2.23.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.
@@ -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 execAsync2("command gh --version");
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 execAsync2("command gh auth status");
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 execAsync2("command gh repo view --json url");
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 execAsync2(
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 execAsync2("command gh api user --jq .login");
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 execAsync2(command);
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;