Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #8166
Closed
Open
Issue created Dec 12, 2019 by Administrator@rootContributor

`--template` cannot load a GItHub repository

Created by: JasonEtco

Describe the bug

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.

Environment

[email protected]

Steps to reproduce

  1. Run npx create-react-app wheeler-mode --template iansu/cra-template-wheeler-mode

Any owner/repo string should work in the same way!

  1. 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://[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.

Assignee
Assign to
Time tracking