Skip to content

Commit ba9715f

Browse files
committed
docs: offer a read-only fine-grained token in the CLI walkthrough
The token prompt only described the classic `repo` path, which is read+write. Add the read-only fine-grained alternative (Contents, Pull requests, Administration, Dependabot alerts) to both the gh and PAT instructions, and note that the CLI only ever reads.
1 parent 15545d7 commit ba9715f

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/interactive/tokenWalkthrough.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ describe('interactiveResolveToken', () => {
4343
expect(note?.message).toContain('gh auth login --scopes');
4444
expect(note?.message).toContain('repo,read:org,security_events');
4545
expect(note?.message).not.toContain('github.com/settings/tokens');
46+
// also offers the read-only fine-grained alternative
47+
expect(note?.message).toContain('fine-grained');
48+
expect(note?.message).toContain('Dependabot alerts');
4649
});
4750

4851
test('shows PAT instructions matching the GitHub UI when gh is not installed', async () => {
@@ -64,6 +67,9 @@ describe('interactiveResolveToken', () => {
6467
expect(note?.message).toContain('[x] read:org');
6568
expect(note?.message).toContain('Generate token');
6669
expect(note?.message).toContain('export GITHUB_TOKEN=ghp_');
70+
// also offers the read-only fine-grained alternative
71+
expect(note?.message).toContain('settings/personal-access-tokens/new');
72+
expect(note?.message).toContain('Dependabot alerts');
6773
});
6874

6975
test('user declines the retry prompt: returns cancelled', async () => {

src/interactive/tokenWalkthrough.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,23 @@ function defaultHasGhCli(): boolean {
6161

6262
function ghInstructions(): string {
6363
return [
64-
"We need a GitHub token to read your org's Dependabot data.",
64+
"We need a GitHub token to read your org's Dependabot data. The CLI only reads; it never writes.",
6565
'',
6666
'I see the gh CLI installed. In another terminal, run:',
6767
'',
6868
' gh auth login --scopes "repo,read:org,security_events"',
6969
'',
7070
'Pick GitHub.com → HTTPS → "Login with a web browser" and follow the prompts.',
71+
'',
72+
'Want least privilege? A read-only fine-grained token works too. Grant these',
73+
'repository permissions, all Read-only: Contents, Pull requests, Administration,',
74+
'and Dependabot alerts, then export GITHUB_TOKEN.',
7175
].join('\n');
7276
}
7377

7478
function patInstructions(): string {
7579
return [
76-
"We need a GitHub token to read your org's Dependabot data.",
80+
"We need a GitHub token to read your org's Dependabot data. The CLI only reads; it never writes.",
7781
'',
7882
'1. Open https://github.com/settings/tokens/new',
7983
" (You'll be asked to confirm your password.)",
@@ -97,6 +101,11 @@ function patInstructions(): string {
97101
' Copy it, then in this terminal run:',
98102
'',
99103
' export GITHUB_TOKEN=ghp_...',
104+
'',
105+
'Prefer least privilege? A read-only fine-grained token works too, at',
106+
'https://github.com/settings/personal-access-tokens/new — grant these repository',
107+
'permissions, all Read-only: Contents, Pull requests, Administration, and',
108+
'Dependabot alerts. Your org must allow fine-grained tokens.',
100109
].join('\n');
101110
}
102111

0 commit comments

Comments
 (0)