1/** 2 * Copyright (c) Meta Platforms, Inc. and affiliates. 3 * 4 * This source code is licensed under the MIT license found in the 5 * LICENSE file in the root directory of this source tree. 6 * 7 * @format 8 */ 9 10'use strict'; 11 12/* 13 * This script, paired with test-e2e-local.js, is the full suite of 14 * tooling needed for a successful local testing experience. 15 * This script is an helper to clean up the environment fully 16 * before running the test suite. 17 * 18 * You should use this when switching between branches. 19 * 20 * It will: 21 * - clean up node modules 22 * - clean up the build folder (derived data, gradlew cleanAll) 23 * - clean up the pods folder for RNTester (pod install) (and Podfile.lock too) 24 * - kill all packagers 25 * - remove RNTestProject folder 26 * 27 * an improvements to consider: 28 * - an option to uninstall the apps (RNTester, RNTestProject) from emulators 29 */ 30 31const {exec, exit} = require('shelljs'); 32 33const {isPackagerRunning} = require('./testing-utils'); 34 35console.info('\n** Starting the clean up process **\n'); 36 37// let's check if Metro is already running, if it is let's kill it and start fresh 38if (isPackagerRunning() === 'running') { 39 exec("lsof -i :8081 | grep LISTEN | /usr/bin/awk '{print $2}' | xargs kill"); 40 console.info('\n** Killed Metro **\n'); 41} 42 43// Android 44console.info('\n** Cleaning Gradle build artifacts **\n'); 45exec('./gradlew cleanAll'); 46exec('rm -rf /tmp/maven-local'); 47 48// iOS 49console.info('\n** Nuking the derived data folder **\n'); 50exec('rm -rf ~/Library/Developer/Xcode/DerivedData'); 51 52console.info('\n** Removing the hermes-engine pod cache **\n'); 53exec('rm -rf ~/Library/Caches/CocoaPods/Pods/External/hermes-engine'); 54 55// RNTester Pods 56console.info('\n** Removing the RNTester Pods **\n'); 57exec('rm -rf packages/rn-tester/Pods'); 58 59// I'm not sure we want to also remove the lock file 60// exec('rm -rf packages/rn-tester/Podfile.lock'); 61 62// RNTestProject 63console.info('\n** Removing the RNTestProject folder **\n'); 64exec('rm -rf /tmp/RNTestProject'); 65 66// final clean up 67console.info('\n** Final git level wipe **\n'); 68// clean unstaged changes from git 69exec('git checkout -- .'); 70// remove all the untracked files 71exec('git clean -fdx'); 72 73console.info( 74 '\n** Clean up process completed\nPlease remember to run yarn install if you are planning to test again\n', 75); 76exit(0); 77