Skip to content

Commit 784cafd

Browse files
committed
fix: add bob to devDependencies during init
1 parent aac51c8 commit 784cafd

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,24 @@ The difference from [create-react-native-module](https://github.com/brodybits/cr
5757

5858
### Configuring an existing project
5959

60-
First, install Bob in your project. Open a Terminal in your project, and run:
60+
#### Automatic configuration
6161

62-
```sh
63-
yarn add --dev react-native-builder-bob
62+
To automatically configure your project to use Bob, open a Terminal and run:
63+
64+
```js
65+
npx react-native-builder-bob init
6466
```
6567

66-
To configure your project to use Bob, open a Terminal and run `yarn bob init` for automatic configuration.
68+
#### Manual configuration
6769

6870
To configure your project manually, follow these steps:
6971

72+
1. First, install Bob in your project. Open a Terminal in your project, and run:
73+
74+
```sh
75+
yarn add --dev react-native-builder-bob
76+
```
77+
7078
1. In your `package.json`, specify the targets to build for:
7179

7280
```json
@@ -84,15 +92,15 @@ To configure your project manually, follow these steps:
8492

8593
See options below for more details.
8694

87-
2. Add `bob` to your `prepare` step:
95+
1. Add `bob` to your `prepare` step:
8896

8997
```js
9098
"scripts": {
9199
"prepare": "bob build"
92100
}
93101
```
94102

95-
3. Configure the appropriate entry points:
103+
1. Configure the appropriate entry points:
96104

97105
```json
98106
"main": "lib/commonjs/index.js",
@@ -109,16 +117,16 @@ To configure your project manually, follow these steps:
109117

110118
It's usually good to point to your source code with the `react-native` field to make debugging easier. Metro already supports compiling a lot of new syntaxes including JSX, Flow and TypeScript and it will use this field if present.
111119

112-
If you're building TypeScript definition files, also make sure that the `types` field points to a correct path. Depending on the project configuration, the path can be different for you than the example snippet.
120+
If you're building TypeScript definition files, also make sure that the `types` field points to a correct path. Depending on the project configuration, the path can be different for you than the example snippet (e.g. `lib/typescript/index.d.ts` if you have only the `src` directory).
113121

114-
4. Add the output directory to `.gitignore` and `.eslintignore`
122+
1. Add the output directory to `.gitignore` and `.eslintignore`
115123

116124
```gitignore
117125
# generated files by bob
118126
lib/
119127
```
120128

121-
5. Add the output directory to `jest.modulePathIgnorePatterns` if you use [Jest](https://jestjs.io)
129+
1. Add the output directory to `jest.modulePathIgnorePatterns` if you use [Jest](https://jestjs.io)
122130

123131
```json
124132
"modulePathIgnorePatterns": ["<rootDir>/lib/"]

src/cli.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from 'path';
22
import fs from 'fs-extra';
33
import chalk from 'chalk';
4+
import dedent from 'dedent';
45
import yargs from 'yargs';
56
import { cosmiconfigSync } from 'cosmiconfig';
67
import isGitDirty from 'is-git-dirty';
@@ -14,7 +15,7 @@ import buildTypescript from './targets/typescript';
1415
import type { Options } from './types';
1516

1617
// eslint-disable-next-line import/no-commonjs
17-
const { name } = require('../package.json');
18+
const { name, version } = require('../package.json');
1819

1920
const root = process.cwd();
2021
const explorer = cosmiconfigSync(name, {
@@ -74,6 +75,14 @@ yargs
7475
}
7576

7677
const pkg = JSON.parse(await fs.readFile(pak, 'utf-8'));
78+
79+
pkg.devDependencies = Object.fromEntries(
80+
[
81+
...Object.entries(pkg.devDependencies || {}),
82+
[name, `^${version}`],
83+
].sort(([a], [b]) => a.localeCompare(b))
84+
);
85+
7786
const questions: PromptObject[] = [
7887
{
7988
type: 'text',
@@ -309,7 +318,17 @@ yargs
309318
}
310319
}
311320

312-
logger.success('Your project is configured!');
321+
console.log(
322+
dedent(chalk`
323+
Project {yellow ${pkg.name}} configured successfully!
324+
325+
{magenta {bold Perform last steps} by running}{gray :}
326+
327+
{gray $} yarn
328+
329+
{yellow Good luck!}
330+
`)
331+
);
313332
})
314333
.command('build', 'build files for publishing', {}, async (argv) => {
315334
const result = explorer.search();

0 commit comments

Comments
 (0)