Skip to content

Commit 436b287

Browse files
committed
fix: add react-native-community-cli dev dependency
1 parent 84430e4 commit 436b287

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

packages/create-react-native-library/src/index.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,23 @@ async function create(_argv: yargs.Arguments<any>) {
790790
examplePackageJson.dependencies['react-native'];
791791
}
792792

793-
if (arch !== 'legacy' && example === 'vanilla') {
794-
addCodegenBuildScript(folder, options.project.name);
793+
if (example === 'vanilla') {
794+
// React Native doesn't provide the community CLI as a dependency.
795+
// We have to get read the version from the example app and put to the root package json
796+
const exampleCommunityCLIVersion =
797+
examplePackageJson.devDependencies['@react-native-community/cli'];
798+
console.assert(
799+
exampleCommunityCLIVersion !== undefined,
800+
"The generated example app doesn't have community CLI installed"
801+
);
802+
803+
rootPackageJson.devDependencies = rootPackageJson.devDependencies || {};
804+
rootPackageJson.devDependencies['@react-native-community/cli'] =
805+
exampleCommunityCLIVersion;
806+
807+
if (arch !== 'legacy') {
808+
addCodegenBuildScript(folder, options.project.name);
809+
}
795810
}
796811
}
797812

packages/create-react-native-library/templates/common/$package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
"devDependencies": {
7373
"@commitlint/config-conventional": "^17.0.2",
7474
"@evilmartians/lefthook": "^1.5.0",
75+
<% if (example === 'vanilla') { -%>
76+
"@react-native-community/cli": "15.0.0-alpha.2",
77+
<% } -%>
7578
"@react-native/eslint-config": "^0.73.1",
7679
"@release-it/conventional-changelog": "^5.0.0",
7780
"@types/jest": "^29.5.5",

0 commit comments

Comments
 (0)