`--template` cannot load a GItHub repository
Created by: JasonEtco
Describe the bug
Hey folks --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.
Environment
create-react-app@3.3.0
Steps to reproduce
- Run
npx create-react-app wheeler-mode --template iansu/cra-template-wheeler-mode
Any owner/repo
string should work in the same way!
- Observe the error message as shown below!
Expected behavior
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
Actual behavior
❯ 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://git@github.com/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://git@github.com/cra-template-iansu/cra-template-wheeler-mode.git
Should be:
- ssh://git@github.com/cra-template-iansu/cra-template-wheeler-mode.git
+ ssh://git@github.com/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
.