Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: use template from react-native #84

Merged
merged 5 commits into from
Jan 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions packages/global-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,7 @@ const semver = require('semver');
const options = require('minimist')(process.argv.slice(2));

const getCliPath = function() {
return path.resolve(
process.cwd(),
'node_modules',
'react-native',
'local-cli',
'cli.js'
);
return path.resolve(process.cwd(), 'node_modules', 'react-native', 'cli.js');
};

const getRNPkgJsonPath = function() {
Expand Down
9 changes: 5 additions & 4 deletions packages/local-cli/generator/copyProjectTemplateAndReplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ function copyProjectTemplateAndReplace(
}
}

const relativeFilePath = path.relative(srcPath, absoluteSrcFilePath);
const relativeRenamedPath = translateFilePath(relativeFilePath)
const relativeFilePath = translateFilePath(
path.relative(srcPath, absoluteSrcFilePath)
)
.replace(/HelloWorld/g, newProjectName)
.replace(/helloworld/g, newProjectName.toLowerCase());

Expand All @@ -89,13 +90,13 @@ function copyProjectTemplateAndReplace(
contentChangedCallback = (_, contentChanged) =>
upgradeFileContentChangedCallback(
absoluteSrcFilePath,
relativeRenamedPath,
relativeFilePath,
contentChanged
);
}
copyAndReplace(
absoluteSrcFilePath,
path.resolve(destPath, relativeRenamedPath),
path.resolve(destPath, relativeFilePath),
{
'Hello App Display Name': options.displayName || newProjectName,
HelloWorld: newProjectName,
Expand Down
14 changes: 5 additions & 9 deletions packages/local-cli/generator/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,17 @@ function createProjectFromTemplate(
template,
yarnVersion
) {
// Expand the basic 'HelloWorld' template
copyProjectTemplateAndReplace(
path.resolve(__dirname, '../templates/HelloWorld'),
destPath,
newProjectName
);
const templatePath = require.resolve('react-native/template');
copyProjectTemplateAndReplace(templatePath, destPath, newProjectName);

if (template === undefined) {
// No specific template, use just the HelloWorld template above
// No specific template, use just the react-native template above
return;
}

// Keep the files from the 'HelloWorld' template, and overwrite some of them
// Keep the files from the react-native template, and overwrite some of them
// with the specified project template.
// The 'HelloWorld' template contains the native files (these are used by
// The react-native template contains the native files (these are used by
// all templates) and every other template only contains additional JS code.
// Reason:
// This way we don't have to duplicate the native files in every template.
Expand Down
2 changes: 1 addition & 1 deletion packages/local-cli/init/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function init(projectDir, argsOrName) {
* @param options Command line arguments parsed by minimist.
*/
function generateProject(destinationRoot, newProjectName, options) {
const reactNativePackageJson = require.resolve('react-native/package.json');
const reactNativePackageJson = require('react-native/package.json');
const { peerDependencies } = reactNativePackageJson;
if (!peerDependencies) {
console.error(
Expand Down
50 changes: 0 additions & 50 deletions packages/local-cli/templates/HelloWorld/App.js

This file was deleted.

15 changes: 0 additions & 15 deletions packages/local-cli/templates/HelloWorld/__tests__/App-test.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/local-cli/templates/HelloWorld/_babelrc

This file was deleted.

6 changes: 0 additions & 6 deletions packages/local-cli/templates/HelloWorld/_buckconfig

This file was deleted.

70 changes: 0 additions & 70 deletions packages/local-cli/templates/HelloWorld/_flowconfig

This file was deleted.

1 change: 0 additions & 1 deletion packages/local-cli/templates/HelloWorld/_gitattributes

This file was deleted.

56 changes: 0 additions & 56 deletions packages/local-cli/templates/HelloWorld/_gitignore

This file was deleted.

1 change: 0 additions & 1 deletion packages/local-cli/templates/HelloWorld/_watchmanconfig

This file was deleted.

55 changes: 0 additions & 55 deletions packages/local-cli/templates/HelloWorld/android/app/_BUCK

This file was deleted.

Loading