Skip to content
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
20 changes: 18 additions & 2 deletions packages/create-react-native-library/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import dedent from 'dedent';
import kleur from 'kleur';
import yargs from 'yargs';
import ora from 'ora';
import assert from 'node:assert';
import validateNpmPackage from 'validate-npm-package-name';
import githubUsername from 'github-username';
import prompts, { type PromptObject } from './utils/prompts';
Expand Down Expand Up @@ -790,8 +791,23 @@ async function create(_argv: yargs.Arguments<any>) {
examplePackageJson.dependencies['react-native'];
}

if (arch !== 'legacy' && example === 'vanilla') {
addCodegenBuildScript(folder, options.project.name);
if (example === 'vanilla') {
// React Native doesn't provide the community CLI as a dependency.
// We have to get read the version from the example app and put to the root package json
const exampleCommunityCLIVersion =
examplePackageJson.devDependencies['@react-native-community/cli'];
assert(
exampleCommunityCLIVersion !== undefined,
"The generated example app doesn't have community CLI installed"
);

rootPackageJson.devDependencies = rootPackageJson.devDependencies || {};
rootPackageJson.devDependencies['@react-native-community/cli'] =
exampleCommunityCLIVersion;

if (arch !== 'legacy') {
addCodegenBuildScript(folder, options.project.name);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
"devDependencies": {
"@commitlint/config-conventional": "^17.0.2",
"@evilmartians/lefthook": "^1.5.0",
<% if (example === 'vanilla') { -%>
"@react-native-community/cli": "15.0.0-alpha.2",
<% } -%>
"@react-native/eslint-config": "^0.73.1",
"@release-it/conventional-changelog": "^5.0.0",
"@types/jest": "^29.5.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-builder-bob/src/targets/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default async function build({ root, report }: Options) {
}

try {
await spawn('npx', ['react-native', 'codegen'], {
await spawn('npx', ['@react-native-community/cli', 'codegen'], {
stdio: 'ignore',
});

Expand Down
Loading