chore: renamed react-native-codegen to @react-native/codegen (#34804)

Summary:
Renamed react-native-codegen package to react-native/codegen and updated references, without changing the folder name; part of RFC480 (https://github.com/facebook/react-native/issues/34692). Follow-up from https://github.com/facebook/react-native/pull/34578

## Changelog

[General] [Changed] - Renamed react-native-codegen package to react-native/codegen and updated references

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

Pull Request resolved: https://github.com/facebook/react-native/pull/34804

Reviewed By: cortinico

Differential Revision: D39883584

Pulled By: hoxyq

fbshipit-source-id: 0ef384b75c6edd248b31e37b8f05f64b4d39ca6f
This commit is contained in:
shivenmian
2022-11-28 08:28:51 -08:00
committed by Facebook GitHub Bot
parent e325c9505a
commit b7a85b59b5
20 changed files with 42 additions and 45 deletions
-3
View File
@@ -19,9 +19,6 @@ packages:
'@react-native/*':
access: $all
publish: $all
'react-native-codegen':
access: $all
publish: $all
'@*/*':
access: $all
publish: $authenticated
+1 -1
View File
@@ -113,7 +113,7 @@ package-lock.json
!/packages/rn-tester/Pods/__offline_mirrors_hermes__
!/packages/rn-tester/Pods/__offline_mirrors_jsc__
# react-native-codegen
# @react-native/codegen
/React/FBReactNativeSpec/FBReactNativeSpec
/packages/react-native-codegen/lib
/packages/react-native-codegen/tmp/
+1 -1
View File
@@ -641,7 +641,7 @@ react {
reactNativeDir = file("$projectDir/..")
// We search for the codegen in either one of the `node_modules` folder or in the
// root packages folder (that's for when we build from source without calling `yarn install`).
codegenDir = file(findNodeModulePath(projectDir, "react-native-codegen") ?: "../packages/react-native-codegen/")
codegenDir = file(findNodeModulePath(projectDir, "@react-native/codegen") ?: "../packages/react-native-codegen/")
}
apply plugin: "org.jetbrains.kotlin.android"
+6 -6
View File
@@ -14,14 +14,14 @@ let flowParser, typeScriptParser, RNCodegen;
const {basename} = require('path');
try {
flowParser = require('react-native-codegen/src/parsers/flow');
typeScriptParser = require('react-native-codegen/src/parsers/typescript');
RNCodegen = require('react-native-codegen/src/generators/RNCodegen');
flowParser = require('@react-native/codegen/src/parsers/flow');
typeScriptParser = require('@react-native/codegen/src/parsers/typescript');
RNCodegen = require('@react-native/codegen/src/generators/RNCodegen');
} catch (e) {
// Fallback to lib when source doesn't exit (e.g. when installed as a dev dependency)
flowParser = require('react-native-codegen/lib/parsers/flow');
typeScriptParser = require('react-native-codegen/lib/parsers/typescript');
RNCodegen = require('react-native-codegen/lib/generators/RNCodegen');
flowParser = require('@react-native/codegen/lib/parsers/flow');
typeScriptParser = require('@react-native/codegen/lib/parsers/typescript');
RNCodegen = require('@react-native/codegen/lib/generators/RNCodegen');
}
function parseFile(filename, code) {
+1 -1
View File
@@ -11,7 +11,7 @@
"index.js"
],
"dependencies": {
"react-native-codegen": "*"
"@react-native/codegen": "*"
},
"devDependencies": {
"@babel/core": "^7.14.0"
+1 -1
View File
@@ -17,10 +17,10 @@
"@babel/eslint-parser": "^7.18.2",
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
"@babel/preset-flow": "^7.17.12",
"@react-native/codegen": "*",
"flow-parser": "^0.185.0",
"make-dir": "^2.1.0",
"pirates": "^4.0.1",
"react-native-codegen": "*",
"source-map-support": "0.5.0"
},
"license": "MIT"
+6 -6
View File
@@ -26,7 +26,7 @@ let RNParserUtils;
function requireModuleParser() {
if (RNModuleParser == null || RNParserUtils == null) {
// If using this externally, we leverage react-native-codegen as published form
// If using this externally, we leverage @react-native/codegen as published form
if (!PACKAGE_USAGE) {
const config = {
only: [/react-native-codegen\/src\//],
@@ -34,18 +34,18 @@ function requireModuleParser() {
};
withBabelRegister(config, () => {
RNModuleParser = require('react-native-codegen/src/parsers/flow/modules');
RNParserUtils = require('react-native-codegen/src/parsers/utils');
RNModuleParser = require('@react-native/codegen/src/parsers/flow/modules');
RNParserUtils = require('@react-native/codegen/src/parsers/utils');
});
} else {
const config = {
only: [/react-native-codegen\/lib\//],
only: [/@react-native\/codegen\/lib\//],
plugins: [require('@babel/plugin-transform-flow-strip-types').default],
};
withBabelRegister(config, () => {
RNModuleParser = require('react-native-codegen/lib/parsers/flow/modules');
RNParserUtils = require('react-native-codegen/lib/parsers/utils');
RNModuleParser = require('@react-native/codegen/lib/parsers/flow/modules');
RNParserUtils = require('@react-native/codegen/lib/parsers/flow/utils');
});
}
}
+4 -4
View File
@@ -1,17 +1,17 @@
# react-native-codegen
# @react-native/codegen
[![Version][version-badge]][package]
## Installation
```
yarn add --dev react-native-codegen
yarn add --dev @react-native/codegen
```
*Note: We're using `yarn` to install deps. Feel free to change commands to use `npm` 3+ and `npx` if you like*
[version-badge]: https://img.shields.io/npm/v/react-native-codegen?style=flat-square
[package]: https://www.npmjs.com/package/react-native-codegen
[version-badge]: https://img.shields.io/npm/v/@react-native/codegen?style=flat-square
[package]: https://www.npmjs.com/package/@react-native/codegen
## Testing
+1 -1
View File
@@ -1,5 +1,5 @@
{
"name": "react-native-codegen",
"name": "@react-native/codegen",
"version": "0.72.0",
"description": "⚛️ Code generation tools for React Native",
"homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/react-native-codegen",
@@ -31,7 +31,7 @@ abstract class ReactExtension @Inject constructor(project: Project) {
/**
* The path to the react-native NPM package folder.
*
* Default: ${rootProject.dir}/../node_modules/react-native-codegen
* Default: ${rootProject.dir}/../node_modules/react-native
*/
val reactNativeDir: DirectoryProperty =
objects.directoryProperty().convention(root.dir("node_modules/react-native"))
@@ -121,10 +121,10 @@ abstract class ReactExtension @Inject constructor(project: Project) {
/**
* The path to the react-native-codegen NPM package folder.
*
* Default: ${rootProject.dir}/../node_modules/react-native-codegen
* Default: ${rootProject.dir}/../node_modules/@react-native/codegen
*/
val codegenDir: DirectoryProperty =
objects.directoryProperty().convention(root.dir("node_modules/react-native-codegen"))
objects.directoryProperty().convention(root.dir("node_modules/@react-native/codegen"))
/**
* The root directory for all JS files for the app.
+2 -2
View File
@@ -20,8 +20,8 @@ react {
root = file("../../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
reactNativeDir = rootDir
// The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
codegenDir = file("$rootDir/node_modules/react-native-codegen")
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
codegenDir = file("$rootDir/node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
cliFile = file("$rootDir/cli.js")
+1 -1
View File
@@ -14,6 +14,7 @@
"@babel/generator": "^7.14.0",
"@babel/plugin-transform-regenerator": "^7.0.0",
"@definitelytyped/dtslint": "^0.0.127",
"@react-native/codegen": "^0.72.0",
"@react-native/eslint-config": "*",
"@react-native/eslint-plugin": "*",
"@react-native/eslint-plugin-specs": "^0.72.0",
@@ -47,7 +48,6 @@
"mkdirp": "^0.5.1",
"prettier": "^2.4.1",
"react": "18.2.0",
"react-native-codegen": "^0.72.0",
"react-test-renderer": "18.2.0",
"shelljs": "^0.8.5",
"signedsource": "^1.0.0",
+3 -3
View File
@@ -90,7 +90,7 @@ class CodegenTests < Test::Unit::TestCase
])
assert_equal(Dir.exist_invocation_params, [
@base_path + "/"+ @prefix + "/packages/react-native-codegen",
@base_path + "/"+ @prefix + "/../react-native-codegen",
@base_path + "/"+ @prefix + "/../@react-native/codegen",
])
assert_equal(Pod::UI.collected_messages, [])
assert_equal($collected_commands, [])
@@ -147,7 +147,7 @@ class CodegenTests < Test::Unit::TestCase
def testCheckAndGenerateEmptyThirdPartyProvider_whenBothMissing_buildCodegen()
# Arrange
codegen_cli_path = @base_path + "/" + @prefix + "/../react-native-codegen"
codegen_cli_path = @base_path + "/" + @prefix + "/../@react-native/codegen"
Dir.mocked_existing_dirs([
codegen_cli_path,
])
@@ -170,7 +170,7 @@ class CodegenTests < Test::Unit::TestCase
"[Codegen] building #{codegen_cli_path}.",
"[Codegen] generating an empty RCTThirdPartyFabricComponentsProvider"
])
assert_equal($collected_commands, ["~/app/ios/../../../react-native-codegen/scripts/oss/build.sh"])
assert_equal($collected_commands, ["~/app/ios/../../../@react-native/codegen/scripts/oss/build.sh"])
assert_equal(File.open_files[0].collected_write, ["[]"])
assert_equal(File.open_files[0].fsync_invocation_count, 1)
assert_equal(Pod::Executable.executed_commands[0], {
+1 -1
View File
@@ -10,7 +10,7 @@
# @throws an error if it could not find the codegen folder.
def build_codegen!(react_native_path, relative_installation_root)
codegen_repo_path = "#{relative_installation_root}/#{react_native_path}/packages/react-native-codegen";
codegen_npm_path = "#{relative_installation_root}/#{react_native_path}/../react-native-codegen";
codegen_npm_path = "#{relative_installation_root}/#{react_native_path}/../@react-native/codegen";
codegen_cli_path = ""
if Dir.exist?(codegen_repo_path)
+2 -2
View File
@@ -12,7 +12,7 @@
/**
* Wrapper required to abstract away from the actual codegen.
* This is needed because, when running tests in Sandcastle, not everything is setup as usually.
* For example, the `react-native-codegen` lib is not present.
* For example, the `@react-native/codegen` lib is not present.
*
* Thanks to this wrapper, we are able to mock the getter for the codegen in a way that allow us to return
* a custom object which mimics the Codegen interface.
@@ -24,7 +24,7 @@ function getCodegen() {
try {
RNCodegen = require('../../packages/react-native-codegen/lib/generators/RNCodegen.js');
} catch (e) {
RNCodegen = require('react-native-codegen/lib/generators/RNCodegen.js');
RNCodegen = require('@react-native/codegen/lib/generators/RNCodegen.js');
}
if (!RNCodegen) {
throw 'RNCodegen not found.';
@@ -24,7 +24,7 @@ const path = require('path');
const RN_ROOT = path.join(__dirname, '../..');
const CODEGEN_REPO_PATH = `${RN_ROOT}/packages/react-native-codegen`;
const CODEGEN_NPM_PATH = `${RN_ROOT}/../react-native-codegen`;
const CODEGEN_NPM_PATH = `${RN_ROOT}/../@react-native/codegen`;
const CORE_LIBRARIES = new Set(['rncore', 'FBReactNativeSpec']);
const REACT_NATIVE_DEPENDENCY_NAME = 'react-native';
+1 -1
View File
@@ -13,7 +13,7 @@ let RNCodegen;
try {
RNCodegen = require('../packages/react-native-codegen/lib/generators/RNCodegen.js');
} catch (e) {
RNCodegen = require('react-native-codegen/lib/generators/RNCodegen.js');
RNCodegen = require('@react-native/codegen/lib/generators/RNCodegen.js');
if (!RNCodegen) {
throw 'RNCodegen not found.';
}
@@ -31,9 +31,9 @@ find_node () {
}
find_codegen () {
CODEGEN_CLI_PATH=$("$NODE_BINARY" --print "require('path').dirname(require.resolve('react-native-codegen/package.json'))")
CODEGEN_CLI_PATH=$("$NODE_BINARY" --print "require('path').dirname(require.resolve('@react-native/codegen/package.json'))")
if ! [ -d "$CODEGEN_CLI_PATH" ]; then
error "error: Could not determine react-native-codegen location, using node module resolution. Try running 'yarn install' or 'npm install' in your project root."
error "error: Could not determine @react-native/codegen location, using node module resolution. Try running 'yarn install' or 'npm install' in your project root."
fi
}
+3 -3
View File
@@ -121,11 +121,11 @@ packageJson.devDependencies = {
...packageJson.devDependencies,
...repoConfigJson.dependencies,
};
// Make react-native-codegen a direct dependency of react-native
delete packageJson.devDependencies['react-native-codegen'];
// Make @react-native/codegen a direct dependency of react-native
delete packageJson.devDependencies['@react-native/codegen'];
packageJson.dependencies = {
...packageJson.dependencies,
'react-native-codegen': repoConfigJson.dependencies['react-native-codegen'],
'@react-native/codegen': repoConfigJson.dependencies['@react-native/codegen'],
};
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2), 'utf-8');
+2 -2
View File
@@ -13,8 +13,8 @@ react {
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
// codegenDir = file("../node_modules/react-native-codegen")
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
// codegenDir = file("../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
// cliFile = file("../node_modules/react-native/cli.js")