Skip to content

Improve install of templates from places other than npm registry #18973

Closed
@piranna

Description

@piranna

When trying to install a project template from other place than published as a npm package (github forks, local filesystem, local tarfile, http server...) I can't be able to do it due to several problems. Debuging them, I get to the conclussion the problem is at

if (template.includes('://')) {
// URL, e.g. git://, file://
installPackage = template;
templateName = template.substr(template.lastIndexOf('/') + 1);
} else {
// e.g 'demo'
installPackage = 'react-native-template-' + template;
templateName = installPackage;
}
, not processing the template name correctly. Problems I've found in this code snippet are:

  • lack of support to download a git project subpath (seems a problem in npm not supporting mono-repos)
  • templateName gets not cleaned, file extension should be removed
  • templateName can't be different of the package name at the template package.json file, correct name should be extracted once the template is installed
  • when installed from npm, installPackage is just a concatenation of the string react-native-template- and the provided template name, not allowing to use scoped packages as templates. Provided template should be checked and splitted, and the scoped prefixed to the generated templateName

Environment

Environment:
  OS: Linux 4.13
  Node: 9.11.1
  Yarn: Not Found
  npm: 5.6.0
  Watchman: 4.9.0
  Xcode: N/A
  Android Studio: 3.1 AI-173.4697961

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
  react-native: 0.55.2 => 0.55.2

Steps to Reproduce

Try to init a React Native project using a template from a git mono-repo, or from a local filesystem folder, or from a tarfile on the local filesystem or a web server, or from a scoped npm package.

Expected Behavior

All the provided methods should be able to correctly install the provided template.

Actual Behavior

All of them fails.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions