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

Fix typos and update initial commit message #823

Merged
merged 2 commits into from
Jun 12, 2020
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ Once you're up and running with Create React Native App, visit [this tutorial](h

### Templates

By default you create a [bare-workflow React](https://docs.expo.io/bare/exploring-bare-workflow/) project with support for iOS, Android, and web. You can opt to use an example project instead by selecting the "Templates from ..." option. Custom templates can be used with `--template <Example Name or Github URL>` option.
By default you create a [bare-workflow React](https://docs.expo.io/bare/exploring-bare-workflow/) project with support for iOS, Android, and web. You can opt to use an example project instead by selecting the "Templates from ..." option. Custom templates can be used with `--template <Example Name or GitHub URL>` option.

- Use an [example](https://github.com/expo/examples): `npx create-react-native-app -t with-typescript`
- Use a custom template: `npx create-react-native-app --template https://github.com/someone/my-react-starter` -- Only works with Github repos on the master branch.
- Use a custom template: `npx create-react-native-app --template https://github.com/someone/my-react-starter` -- Only works with GitHub repos on the master branch.
- All examples can be modified in the [expo/examples](https://github.com/expo/examples) repo.

## Sections
Expand Down
13 changes: 8 additions & 5 deletions src/Template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const pipeline = promisify(Stream.pipeline);

const isMacOS = process.platform === 'darwin';

const packageJSON = require('../package.json');

export type PackageManagerName = 'yarn' | 'npm';

/**
Expand Down Expand Up @@ -77,10 +79,10 @@ export async function initGitRepoAsync(
// let's see if we're in a git tree
try {
await spawnAsync('git', ['rev-parse', '--is-inside-work-tree'], { stdio: 'ignore', cwd: root });
!flags.silent && Logger.gray('New project is already inside of a git repo, skipping git init.');
!flags.silent && Logger.gray('New project is already inside of a Git repo, skipping git init.');
} catch (e) {
if (e.errno === 'ENOENT') {
!flags.silent && Logger.gray('Unable to initialize git repo. `git` not in PATH.');
!flags.silent && Logger.gray('Unable to initialize Git repo. `git` not in PATH.');
return false;
}
}
Expand All @@ -89,12 +91,13 @@ export async function initGitRepoAsync(
try {
await spawnAsync('git', ['init'], { stdio: 'ignore', cwd: root });
await spawnAsync('git', ['add', '-A'], { stdio: 'ignore', cwd: root });
await spawnAsync('git', ['commit', '-m', '"Initial commit via create-react-native-app"'], {
const commitMsg = `Initial commit\n\nGenerated by ${packageJSON.name} ${packageJSON.version}.`;
await spawnAsync('git', ['commit', '-m', commitMsg], {
stdio: 'ignore',
cwd: root,
});

!flags.silent && Logger.gray('Initialized a git repository.');
!flags.silent && Logger.gray('Initialized a Git repository.');
return true;
} catch (e) {
// no-op -- this is just a convenience and we don't care if it fails
Expand Down Expand Up @@ -240,7 +243,7 @@ async function getNpmUrlAsync(packageName: string): Promise<string> {
const url = (await spawnAsync('npm', ['v', packageName, 'dist.tarball'])).stdout;

if (!url) {
throw new Error(`Could not get NPM url for package "${packageName}"`);
throw new Error(`Could not get npm url for package "${packageName}"`);
}

return url;
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ const program = new Command(packageJSON.name)
.description('Creates a new React Native project')
.option('--use-npm', 'Use npm to install dependencies. (default when Yarn is not installed)')
.option('-y, --yes', 'Use the default options for creating a project')
.option('--no-install', 'Skip installing NPM packages or CocoaPods.')
.option('--no-install', 'Skip installing npm packages or CocoaPods.')
.option(
'-t, --template [template|url]',
'The name of a template from expo/examples or URL to a github repo that contains an example.'
'The name of a template from expo/examples or URL to a GitHub repo that contains an example.'
)
.option('--template-path [name]', 'The path inside of a github repo where the example lives.')
.option('--template-path [name]', 'The path inside of a GitHub repo where the example lives.')
.allowUnknownOption()
.action(projectRoot => (inputPath = projectRoot))
.parse(process.argv);
Expand Down