function createFromRemoteTemplate(template, destPath, newProjectName, yarnVersion) {
  let installPackage;
  let templateName;
  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;
  }

  // Check if the template exists
  console.log(`Fetching template ${installPackage}...`);
  try {
    if (yarnVersion) {
      execSync(`yarn add ${installPackage} --ignore-scripts`, {stdio: 'inherit'});
    } else {
      execSync(`npm install ${installPackage} --save --save-exact --ignore-scripts`, {stdio: 'inherit'});
    }
    const templatePath = path.resolve(
      'node_modules', templateName
    );
    copyProjectTemplateAndReplace(
      templatePath,
      destPath,
      newProjectName,
      {
        // Every template contains a dummy package.json file included
        // only for publishing the template to npm.
        // We want to ignore this dummy file, otherwise it would overwrite
        // our project's package.json file.
        ignorePaths: ['package.json', 'dependencies.json'],
      }
    );
    installTemplateDependencies(templatePath, yarnVersion);
  } finally {
    // Clean up the temp files
    try {
      if (yarnVersion) {
        execSync(`yarn remove ${templateName} --ignore-scripts`);
      } else {
        execSync(`npm uninstall ${templateName} --ignore-scripts`);
      }
    } catch (err) {
      // Not critical but we still want people to know and report
      // if this the clean up fails.
      console.warn(
        `Failed to clean up template temp files in node_modules/${templateName}. ` +
        'This is not a critical error, you can work on your app.'
      );
    }
  }
}
The following formats are supported for the template:
- 'demo' -> Fetch the package react-native-template-demo from npm
- git://..., http://..., file://... or any other URL supported by npm