From faec573e172847f9a833da0c7b5e39f3ebcac82f Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Mon, 1 Jul 2024 14:41:47 -0600 Subject: [PATCH] Revert "[No QA] Fail patch-package on errors or warnings" --- ...y+react-native-live-markdown+0.1.85.patch} | 0 ...ve-keyboard-controller+1.12.2.patch.patch} | 0 scripts/applyPatches.sh | 39 ------------------- scripts/postInstall.sh | 7 +--- 4 files changed, 2 insertions(+), 44 deletions(-) rename patches/{@expensify+react-native-live-markdown+0.1.88.patch => @expensify+react-native-live-markdown+0.1.85.patch} (100%) rename patches/{react-native-keyboard-controller+1.12.2.patch => react-native-keyboard-controller+1.12.2.patch.patch} (100%) delete mode 100755 scripts/applyPatches.sh diff --git a/patches/@expensify+react-native-live-markdown+0.1.88.patch b/patches/@expensify+react-native-live-markdown+0.1.85.patch similarity index 100% rename from patches/@expensify+react-native-live-markdown+0.1.88.patch rename to patches/@expensify+react-native-live-markdown+0.1.85.patch diff --git a/patches/react-native-keyboard-controller+1.12.2.patch b/patches/react-native-keyboard-controller+1.12.2.patch.patch similarity index 100% rename from patches/react-native-keyboard-controller+1.12.2.patch rename to patches/react-native-keyboard-controller+1.12.2.patch.patch diff --git a/scripts/applyPatches.sh b/scripts/applyPatches.sh deleted file mode 100755 index 31e1b7f50e6a..000000000000 --- a/scripts/applyPatches.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -# This script is a simple wrapper around patch-package that fails if any errors or warnings are detected. -# This is useful because patch-package does not fail on errors or warnings by default, -# which means that broken patches are easy to miss, and leads to developer frustration and wasted time. - -SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}") -source "$SCRIPTS_DIR/shellUtils.sh" - -# Run patch-package and capture its output and exit code, while still displaying the original output to the terminal -# (we use `script -q /dev/null` to preserve colorization in the output) -TEMP_OUTPUT="$(mktemp)" -script -q /dev/null npx patch-package --error-on-fail 2>&1 | tee "$TEMP_OUTPUT" -EXIT_CODE=${PIPESTATUS[0]} -OUTPUT="$(cat "$TEMP_OUTPUT")" -rm -f "$TEMP_OUTPUT" - -# Check if the output contains a warning message -echo "$OUTPUT" | grep -q "Warning:" -WARNING_FOUND=$? - -printf "\n"; - -# Determine the final exit code -if [ "$EXIT_CODE" -eq 0 ]; then - if [ $WARNING_FOUND -eq 0 ]; then - # patch-package succeeded but warning was found - error "It looks like you upgraded a dependency without upgrading the patch. Please review the patch, determine if it's still needed, and port it to the new version of the dependency." - exit 1 - else - # patch-package succeeded and no warning was found - success "patch-package succeeded without errors or warnings" - exit 0 - fi -else - # patch-package failed - error "patch-package failed to apply a patch" - exit "$EXIT_CODE" -fi diff --git a/scripts/postInstall.sh b/scripts/postInstall.sh index 782c8ef5822c..339fdf25cb10 100755 --- a/scripts/postInstall.sh +++ b/scripts/postInstall.sh @@ -1,14 +1,11 @@ #!/bin/bash -# Exit immediately if any command exits with a non-zero status -set -e - # Go to project root ROOT_DIR=$(dirname "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)") cd "$ROOT_DIR" || exit 1 -# Apply packages using patch-package -scripts/applyPatches.sh +# Run patch-package +npx patch-package # Install node_modules in subpackages, unless we're in a CI/CD environment, # where the node_modules for subpackages are cached separately.