Hey folks 👋 I'm not positive that this is a bug, talking with @iansu this seems to be more of a feature that doesn't (yet!) exist. I was wondering if --template owner/repo would work in the same way as npm i owner/repo, where it looks for a package on GitHub. For example:
npm install -g facebook/create-react-app
Would grab the code, as-is, from master of this repo.
[email protected]
npx create-react-app wheeler-mode --template iansu/cra-template-wheeler-modeAny owner/repo string should work in the same way!
I'd expect yarn to resolve the template similar to how it grabs it from npm, when given an owner/repo string that maps to a GitHub repository. Aside from being able to function similar to yarn under the hood, this even enables _private_ templates by implementing existing git credentials 🙌 🔒
❯ npx create-react-app wheeler-mode --template iansu/cra-template-wheeler-mode
Here's the output:
Creating a new React app in /Users/jasonetco/dev/wheeler-mode.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template-iansu/cra-template-wheeler-mode...
yarn add v1.17.3
[1/4] 🔍 Resolving packages...
error Command failed.
Exit code: 128
Command: git
Arguments: ls-remote --tags --heads ssh://[email protected]/cra-template-iansu/cra-template-wheeler-mode.git
Directory: /Users/jasonetco/dev/wheeler-mode
Output:
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Aborting installation.
yarnpkg add --exact react react-dom react-scripts cra-template-iansu/cra-template-wheeler-mode --cwd /Users/jasonetco/dev/wheeler-mode has failed.
Deleting generated file... package.json
Deleting generated file... yarn.lock
Deleting wheeler-mode/ from /Users/jasonetco/dev
Done.
Worth noting that yarn tried to clone the GitHub repo, but got the SSH URL wrong:
ssh://[email protected]/cra-template-iansu/cra-template-wheeler-mode.git
Should be:
- ssh://[email protected]/cra-template-iansu/cra-template-wheeler-mode.git
+ ssh://[email protected]/iansu/cra-template-wheeler-mode.git
Let me know how I can help! If y'all are open to a PR here, my first inclination would be to look for / in the provided template string and just not prepend cra-template before giving it over to yarn.
We’re definitely interested in a PR to fix this! I think your proposed change makes sense. We already leave the template name alone if it starts with cra-template so this would probably just be another check in that same function.
Looks like that's here:
PR incoming 💪
@iansu / @ianschmitz any interest in picking this back up? Looks like the PR was opened and just never reviewed. Was automatically closed due to inactivity? I'd really like to use the result of the PR (#8167) if possible. Even happy to jump in and open a new PR if you think it will end up getting merged. Let me know!
Most helpful comment
We’re definitely interested in a PR to fix this! I think your proposed change makes sense. We already leave the template name alone if it starts with
cra-templateso this would probably just be another check in that same function.