Skip to content
Closed
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: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"rn-get-polyfills.js",
"scripts/compose-source-maps.js",
"scripts/find-node-for-xcode.sh",
"scripts/generate-artifacts.js",
"scripts/generate-codegen-artifacts.js",
"scripts/generate-provider-cli.js",
"scripts/generate-specs-cli.js",
"scripts/codegen/codegen-utils.js",
Expand Down Expand Up @@ -95,6 +95,8 @@
"test-android-instrumentation": "yarn run docker-build-android && yarn run test-android-run-instrumentation",
"test-android-unit": "yarn run docker-build-android && yarn run test-android-run-unit",
"test-android-e2e": "yarn run docker-build-android && yarn run test-android-run-e2e",
"test-e2e-local": "node ./scripts/test-e2e-local.js",
"test-e2e-local-clean": "node ./scripts/test-e2e-local-clean.js",
"test-ios": "./scripts/objc-test.sh test",
"test-typescript": "dtslint types"
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/cocoapods/__tests__/codegen_utils-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def testUseReactCodegenDiscovery_whenParametersAreGood_executeCodegen
assert_equal(Pod::Executable.executed_commands, [
{
"command" => "node",
"arguments"=> ["~/app/ios/../node_modules/react-native/scripts/generate-artifacts.js",
"arguments"=> ["~/app/ios/../node_modules/react-native/scripts/generate-codegen-artifacts.js",
"-p", "~/app",
"-o", Pod::Config.instance.installation_root,
"-e", "false",
Expand Down
6 changes: 3 additions & 3 deletions scripts/cocoapods/codegen_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ def get_react_codegen_script_phases(
end

# Generate input files for in-app libaraies which will be used to check if the script needs to be run.
# TODO: Ideally, we generate the input_files list from generate-artifacts.js and read the result here.
# Or, generate this podspec in generate-artifacts.js as well.
# TODO: Ideally, we generate the input_files list from generate-codegen-artifacts.js and read the result here.
# Or, generate this podspec in generate-codegen-artifacts.js as well.
app_package_path = File.join(app_path, 'package.json')
app_codegen_config = codegen_utils.get_codegen_config_from_file(app_package_path, config_key)
input_files = codegen_utils.get_list_of_js_specs(app_codegen_config, app_path)
Expand Down Expand Up @@ -270,7 +270,7 @@ def use_react_native_codegen_discovery!(
out = Pod::Executable.execute_command(
'node',
[
"#{relative_installation_root}/#{react_native_path}/scripts/generate-artifacts.js",
"#{relative_installation_root}/#{react_native_path}/scripts/generate-codegen-artifacts.js",
"-p", "#{app_path}",
"-o", Pod::Config.instance.installation_root,
"-e", "#{fabric_enabled}",
Expand Down
File renamed without changes.
71 changes: 7 additions & 64 deletions scripts/publish-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@
* * or otherwise `{major}.{minor}-stable`
*/

const {exec, echo, exit, env, test} = require('shelljs');
const {exec, echo, exit} = require('shelljs');
const {parseVersion} = require('./version-utils');
const {
exitIfNotOnGit,
getCurrentCommit,
isTaggedLatest,
revertFiles,
saveFiles,
} = require('./scm-utils');
const {
generateAndroidArtifacts,
saveFilesToRestore,
} = require('./release-utils');
const fs = require('fs');
const os = require('os');
const path = require('path');
Expand Down Expand Up @@ -73,22 +75,7 @@ const dryRunBuild = argv.dryRun;
const includeHermes = argv.includeHermes;
const isCommitly = nightlyBuild || dryRunBuild;

const filesToSaveAndRestore = [
'template/Gemfile',
'template/_ruby-version',
'template/package.json',
'.ruby-version',
'Gemfile.lock',
'Gemfile',
'package.json',
'ReactAndroid/gradle.properties',
'Libraries/Core/ReactNativeVersion.js',
'React/Base/RCTVersion.m',
'ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java',
'ReactCommon/cxxreact/ReactNativeVersion.h',
];

saveFiles(filesToSaveAndRestore, tmpPublishingFolder);
saveFilesToRestore(tmpPublishingFolder);

if (includeHermes) {
const HERMES_INSTALL_LOCATION = 'sdks';
Expand Down Expand Up @@ -196,51 +183,7 @@ if (isCommitly) {
}
}

// -------- Generating Android Artifacts
env.REACT_NATIVE_SKIP_PREFAB = true;
if (exec('./gradlew :ReactAndroid:installArchives').code) {
echo('Could not generate artifacts');
exit(1);
}

// -------- Generating the Hermes Engine Artifacts
env.REACT_NATIVE_HERMES_SKIP_PREFAB = true;
if (exec('./gradlew :ReactAndroid:hermes-engine:installArchives').code) {
echo('Could not generate artifacts');
exit(1);
}

// undo uncommenting javadoc setting
revertFiles(['ReactAndroid/gradle.properties'], tmpPublishingFolder);

echo('Generated artifacts for Maven');

let artifacts = [
'.module',
'.pom',
'-debug.aar',
'-release.aar',
'-debug-sources.jar',
'-release-sources.jar',
].map(suffix => {
return `react-native-${releaseVersion}${suffix}`;
});

artifacts.forEach(name => {
if (
!test(
'-e',
`./android/com/facebook/react/react-native/${releaseVersion}/${name}`,
)
) {
echo(
`Failing as expected file: \n\
android/com/facebook/react/react-native/${releaseVersion}/${name}\n\
was not correctly generated.`,
);
exit(1);
}
});
generateAndroidArtifacts(releaseVersion, tmpPublishingFolder);

if (dryRunBuild) {
echo('Skipping `npm publish` because --dry-run is set.');
Expand Down
2 changes: 1 addition & 1 deletion scripts/react_native_pods_utils/script_phases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ generateCodegenArtifactsFromSchema () {
generateArtifacts () {
describe "Generating codegen artifacts"
pushd "$RCT_SCRIPT_RN_DIR" >/dev/null || exit 1
"$NODE_BINARY" "scripts/generate-artifacts.js" --path "$RCT_SCRIPT_APP_PATH" --outputPath "$TEMP_OUTPUT_DIR" --fabricEnabled "$RCT_SCRIPT_FABRIC_ENABLED" --configFileDir "$RCT_SCRIPT_CONFIG_FILE_DIR" --nodeBinary "$NODE_BINARY"
"$NODE_BINARY" "scripts/generate-codegen-artifacts.js" --path "$RCT_SCRIPT_APP_PATH" --outputPath "$TEMP_OUTPUT_DIR" --fabricEnabled "$RCT_SCRIPT_FABRIC_ENABLED" --configFileDir "$RCT_SCRIPT_CONFIG_FILE_DIR" --nodeBinary "$NODE_BINARY"
popd >/dev/null || exit 1
}

Expand Down
85 changes: 85 additions & 0 deletions scripts/release-utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/

'use strict';

const {exec, echo, exit, test, env} = require('shelljs');
const {revertFiles, saveFiles} = require('./scm-utils');

function saveFilesToRestore(tmpPublishingFolder) {
const filesToSaveAndRestore = [
'template/Gemfile',
'template/_ruby-version',
'template/package.json',
'.ruby-version',
'Gemfile.lock',
'Gemfile',
'package.json',
'ReactAndroid/gradle.properties',
'Libraries/Core/ReactNativeVersion.js',
'React/Base/RCTVersion.m',
'ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java',
'ReactCommon/cxxreact/ReactNativeVersion.h',
];

saveFiles(filesToSaveAndRestore, tmpPublishingFolder);
}

function generateAndroidArtifacts(releaseVersion, tmpPublishingFolder) {
// -------- Generating Android Artifacts
env.REACT_NATIVE_SKIP_PREFAB = true;
if (exec('./gradlew :ReactAndroid:installArchives').code) {
echo('Could not generate artifacts');
exit(1);
}

// -------- Generating the Hermes Engine Artifacts
env.REACT_NATIVE_HERMES_SKIP_PREFAB = true;
if (exec('./gradlew :ReactAndroid:hermes-engine:installArchives').code) {
echo('Could not generate artifacts');
exit(1);
}

// undo uncommenting javadoc setting
revertFiles(['ReactAndroid/gradle.properties'], tmpPublishingFolder);

echo('Generated artifacts for Maven');

let artifacts = [
'.module',
'.pom',
'-debug.aar',
'-release.aar',
'-debug-sources.jar',
'-release-sources.jar',
].map(suffix => {
return `react-native-${releaseVersion}${suffix}`;
});

artifacts.forEach(name => {
if (
!test(
'-e',
`./android/com/facebook/react/react-native/${releaseVersion}/${name}`,
)
) {
echo(
`Failing as expected file: \n\
android/com/facebook/react/react-native/${releaseVersion}/${name}\n\
was not correctly generated.`,
);
exit(1);
}
});
}

module.exports = {
generateAndroidArtifacts,
saveFilesToRestore,
};
72 changes: 72 additions & 0 deletions scripts/test-e2e-local-clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/

'use strict';

/*
* This script, paired with test-e2e-local.js, is the full suite of
* tooling needed for a successful local testing experience.
* This script is an helper to clean up the environment fully
* before running the test suite.
*
* You should use this when switching between branches.
*
* It will:
* - clean up node modules
* - clean up the build folder (derived data, gradlew cleanAll)
* - clean up the pods folder for RNTester (pod install) (and Podfile.lock too)
* - kill all packagers
* - remove RNTestProject folder
*
* an improvements to consider:
* - an option to uninstall the apps (RNTester, RNTestProject) from emulators
*/

const {exec, exit} = require('shelljs');

const {isPackagerRunning} = require('./testing-utils');

console.info('\n** Starting the clean up process **\n');

// let's check if Metro is already running, if it is let's kill it and start fresh
if (isPackagerRunning() === 'running') {
exec("lsof -i :8081 | grep LISTEN | /usr/bin/awk '{print $2}' | xargs kill");
console.info('\n** Killed Metro **\n');
}

// Android
console.info('\n** Cleaning Gradle build artifacts **\n');
exec('./gradlew cleanAll');

// iOS
console.info('\n** Nuking the derived data folder **\n');
exec('rm -rf ~/Library/Developer/Xcode/DerivedData');

// RNTester Pods
console.info('\n** Removing the RNTester Pods **\n');
exec('rm -rf packages/rn-tester/Pods');

// I'm not sure we want to also remove the lock file
// exec('rm -rf packages/rn-tester/Podfile.lock');

// RNTestProject
console.info('\n** Removing the RNTestProject folder **\n');
exec('rm -rf /tmp/RNTestProject');

// final clean up
console.info('\n** Final git level wipe **\n');
// clean unstaged changes from git
exec('git checkout -- .');
// remove all the untracked files
exec('git clean -fdx');

console.info(
'\n** Clean up process completed\nPlease remember to run yarn install if you are planning to test again\n',
);
exit(0);
Loading