Skip to content

🚀 Feature: Fail setup more gracefully if the user isn't logged into gh #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
JoshuaKGoldberg opened this issue May 3, 2023 · 0 comments · Fixed by #420
Closed
3 tasks done

🚀 Feature: Fail setup more gracefully if the user isn't logged into gh #400

JoshuaKGoldberg opened this issue May 3, 2023 · 0 comments · Fixed by #420
Labels
status: accepting prs Please, send a pull request to resolve this! type: feature New enhancement or request

Comments

@JoshuaKGoldberg
Copy link
Owner

JoshuaKGoldberg commented May 3, 2023

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Overview

Forking from #398: if the user isn't authenticated in gh when they log in, they get a rather obscure error message with lots of noise trying to run pnpm run setup.

gh auth logout
pnpm run setup

◇  ❌ Error fetching gh auth status.
│
└  Looks like there was a problem. Correct it and try again? 😕


Error: Could not fetch github auth token. 
    at withSpinner (file:///Users/josh/repos/testing-private-repo/script/setup.js:166:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///Users/josh/repos/testing-private-repo/script/setup.js:390:3 {
  [cause]: Error: Command failed with exit code 1: gh auth status
  You are not logged into any GitHub hosts. Run gh auth login to authenticate.
      at makeError (file:///Users/josh/repos/testing-private-repo/node_modules/.pnpm/[email protected]/node_modules/execa/lib/error.js:59:11)
      at handlePromise (file:///Users/josh/repos/testing-private-repo/node_modules/.pnpm/[email protected]/node_modules/execa/index.js:124:26)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async withSpinner.startText (file:///Users/josh/repos/testing-private-repo/script/setup.js:392:5)
      at async withSpinner (file:///Users/josh/repos/testing-private-repo/script/setup.js:160:4)
      at async file:///Users/josh/repos/testing-private-repo/script/setup.js:390:3 {
    shortMessage: 'Command failed with exit code 1: gh auth status',
    command: 'gh auth status',
    escapedCommand: 'gh auth status',
    exitCode: 1,
    signal: undefined,
    signalDescription: undefined,
    stdout: '',
    stderr: 'You are not logged into any GitHub hosts. Run gh auth login to authenticate.',
    failed: true,
    timedOut: false,
    isCanceled: false,
    killed: false
  }
}

...so much noise!

Instead, let's give them a more tailored error message. How about something like...

Error: Could not fetch github auth token. You are not logged into any GitHub hosts. Run gh auth login to authenticate.

(that's just a starting suggestion I haven't put much thought into - please improve it if you have any ideas!)

Additional Info

No response

@JoshuaKGoldberg JoshuaKGoldberg added type: feature New enhancement or request status: accepting prs Please, send a pull request to resolve this! labels May 3, 2023
@JoshuaKGoldberg JoshuaKGoldberg changed the title 🚀 Feature: Fail more gracefully if the user isn't logged into gh 🚀 Feature: Fail setup more gracefully if the user isn't logged into gh May 3, 2023
JoshuaKGoldberg added a commit that referenced this issue May 11, 2023
## PR Checklist

- [x] Addresses an existing open issue: fixes #400
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/template-typescript-node-package/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/template-typescript-node-package/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

Uses a `try`/`catch` with a manual `console.error`. Because this is
really part of the script setup, directly calls `process.exit(0)`
instead of throwing an error through the normal handling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepting prs Please, send a pull request to resolve this! type: feature New enhancement or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant