Files
react-native/scripts/test-e2e-local-clean.js
T
Nicola Corti 01100a2fc8 Rename cleanAll to clean and refine it (#36832)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36832

We used to use `cleanAll` instead of `clean` to do cleaning of everything due to a bug on AGP on how clean was performed.
The bug is resolved, so we can now use `clean` properly.
Moreover, we have sporadic failures when the codegen/lib/ folder is not cleaned up. This fixes it.

Changelog:
[Internal] [Changed] - Rename cleanAll to clean and refine it

Reviewed By: cipolleschi

Differential Revision: D44745849

fbshipit-source-id: 4da5d34bcb0ee5c9f6b0e0f4e5b919bcc3171270
2023-04-06 05:54:15 -07:00

77 lines
2.3 KiB
JavaScript

/**
* 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 clean)
* - 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 clean');
exec('rm -rf /tmp/maven-local');
// iOS
console.info('\n** Nuking the derived data folder **\n');
exec('rm -rf ~/Library/Developer/Xcode/DerivedData');
console.info('\n** Removing the hermes-engine pod cache **\n');
exec('rm -rf ~/Library/Caches/CocoaPods/Pods/External/hermes-engine');
// 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);