Skip to content
Open
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: 5 additions & 3 deletions src/copyProjectTemplateAndReplace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ const prompt = promptInitializer();

type ContentChangedCallbackOption = 'identical' | 'changed' | 'new' | null;

type Options = {
export type Options = {
upgrade?: boolean;
force?: boolean;
displayName?: string;
packageName?: string;
ignorePaths?: string[];
};

Expand Down Expand Up @@ -79,7 +80,7 @@ function copyProjectTemplateAndReplace(

const relativeFilePath = translateFilePath(path.relative(srcPath, absoluteSrcFilePath))
.replace(/HelloWorld/g, newProjectName)
.replace(/helloworld/g, newProjectName.toLowerCase());
.replace(/com\/helloworld/g, options.packageName || `com/${newProjectName.toLowerCase()}`);

// Templates may contain files that we don't want to copy.
// Examples:
Expand All @@ -106,7 +107,8 @@ function copyProjectTemplateAndReplace(
{
'Hello App Display Name': options.displayName || newProjectName,
HelloWorld: newProjectName,
helloworld: newProjectName.toLowerCase(),
'com.helloworld': options.packageName || `com.${newProjectName.toLowerCase()}`,
'PRODUCT_BUNDLE_IDENTIFIER = "(.*)"': `PRODUCT_BUNDLE_IDENTIFIER = "${options.packageName || newProjectName}"`
},
contentChangedCallback,
);
Expand Down
6 changes: 4 additions & 2 deletions src/eject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import fs from 'fs';
import semver from 'semver';
import { logger } from '@react-native-community/cli-tools';

import copyProjectTemplateAndReplace from './copyProjectTemplateAndReplace';
import copyProjectTemplateAndReplace, { Options } from './copyProjectTemplateAndReplace';

/**
* The eject command re-creates the `android` and `ios` native folders. Because native code can be
Expand All @@ -25,6 +25,8 @@ import copyProjectTemplateAndReplace from './copyProjectTemplateAndReplace';
*
* - `name` - The short name used for the project, should be TitleCase
* - `displayName` - The app's name on the home screen
*
* This command will use `name` from `package.json` as a package name for Android and iOS apps.
*/

const pkgJson = require(path.resolve('package.json'));
Expand Down Expand Up @@ -105,7 +107,7 @@ function eject() {
process.exit(1);
}

const templateOptions = { displayName };
const templateOptions: Options = { displayName, packageName: pkgJson.name };

if (!doesIOSExist) {
logger.info('Generating the iOS folder.');
Expand Down