Commit d9da55f
Support GitHub Enterprise hosts in PublicGitHubRepositorySource (#214)
## Description
Fixes #185. `PublicGitHubRepositorySource` accepted any HTTPS URL via
the host-agnostic `parseGitHubUrlAndRef()` parser, but internally
`_parseGitHubUrl()` only matched `github.com` and `_buildDownloadUrl()`
always constructed `codeload.github.com` URLs. GHE URLs were silently
accepted at parse time but failed at download time.
This PR adds real GHE support:
- **Host-agnostic URL parsing**: Renamed `_parseGitHubUrl()` →
`_parseRepoUrl()` with a generic regex that returns `{ host, owner, repo
}`
- **Host-aware download URLs**: `github.com` continues to use
`codeload.github.com`; other hosts use the GHE REST API
(`https://<host>/api/v3/repos/<owner>/<repo>/zipball/<ref>`)
- **Auth token support**: New optional `token` property on
`IPublicGitHubRepositorySourceOptions`, sent as `Authorization: token
<value>` header
- **CLI integration**: `GITHUB_TOKEN` env var is read and passed to all
`PublicGitHubRepositorySource` instances
## How was this tested
- `rush build` — all 22 projects build successfully
- `cd api/spfx-template-api && heft test --clean` — 267 tests pass (14
new snapshots for GHE URL parsing, GHE download URLs, auth header, token
constructor tests)
- `cd apps/spfx-cli && heft test --clean` — 96 tests pass (5 new
snapshots for `GITHUB_TOKEN` passthrough tests)
## Type of change
- [x] New feature (non-breaking change that adds functionality)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 71adea2 commit d9da55f
13 files changed
Lines changed: 530 additions & 73 deletions
File tree
- api/spfx-template-api
- etc
- src/repositories
- test
- __snapshots__
- apps/spfx-cli
- src
- cli
- actions
- tests
- __snapshots__
- test/__snapshots__
- utilities
- common/changes/@microsoft/spfx-cli
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
74 | 81 | | |
75 | 82 | | |
76 | 83 | | |
| |||
139 | 146 | | |
140 | 147 | | |
141 | 148 | | |
142 | | - | |
| 149 | + | |
143 | 150 | | |
144 | 151 | | |
145 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
Lines changed: 41 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
113 | 121 | | |
114 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
115 | 126 | | |
116 | 127 | | |
117 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
118 | 137 | | |
119 | 138 | | |
120 | 139 | | |
| |||
136 | 155 | | |
137 | 156 | | |
138 | 157 | | |
| 158 | + | |
139 | 159 | | |
140 | 160 | | |
141 | 161 | | |
142 | | - | |
| 162 | + | |
143 | 163 | | |
144 | 164 | | |
145 | 165 | | |
| 166 | + | |
146 | 167 | | |
147 | 168 | | |
148 | 169 | | |
| |||
160 | 181 | | |
161 | 182 | | |
162 | 183 | | |
163 | | - | |
164 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
165 | 190 | | |
166 | 191 | | |
167 | | - | |
168 | | - | |
169 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
170 | 196 | | |
171 | 197 | | |
172 | 198 | | |
173 | 199 | | |
174 | | - | |
175 | | - | |
| 200 | + | |
| 201 | + | |
176 | 202 | | |
177 | 203 | | |
178 | 204 | | |
179 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
180 | 210 | | |
181 | 211 | | |
182 | 212 | | |
| |||
0 commit comments