unjs / giget

✨ Download templates and git repositories with pleasure!
MIT License
425 stars 37 forks source link

Try using `gh` cli token as fallback when cloning github sources #142

Open cpreston321 opened 6 months ago

cpreston321 commented 6 months ago

Describe the feature

Github already provides this locally if you auth with gh in this case it can cover most private repo cases without creating a new token . This can used by trying to run it with execa fallbacks to undefined

E.g

options.auth = options.auth || (await execa('gh', ['auth', 'token']).then(r => r.stdout).catch(() => undefined))

Maybe it can be a CLI param like --use-gh-auth that enables this function to that might be more viable.

Additional information

pi0 commented 4 months ago

Hi thanks for this tip. We can also read the file directly from known path: https://github.com/unjs/changelogen/blob/main/src/github.ts#L120

Feel free to make a PR for this 👍🏼