Files
trezor-suite/scripts/replace-imports.sh
Daniel Suchý 637ad88dcf chore(repo): mostly buildless monorepo (#11464)
* chore: buildless blockchain link

* chore: buildless connect

* chore: buildless connect-webextension

* chore: buildless transport

* chore: replace few imports from lib

* fix: icons linter error

* chore: adjust tooling to buildless setup

* fix: connect overrides

* chore: replace all imports from @trezor/*/src

* chore(lint): ban imports from @trezor/*/lib

* fix: replace imports on Linux

* chore: add safety check to replace imports script

* chore: reorder entries
2024-03-07 08:31:02 +01:00

26 lines
891 B
Bash
Executable File

#!/usr/bin/env bash
set -euxo pipefail
REGEX="s/@trezor\/([^/]+)\/src/@trezor\/\1\/lib/g"
# Determine the operating system
OS="$(uname)"
# Execute the appropriate command based on the OS
if [[ "$OS" == "Darwin" ]]; then
# macOS command with -i '' for in-place editing without backup and -E for extended regex
find "$1" -type f -exec sed -i '' -E "$REGEX" {} +
else
# Linux command with -i and -E for in-place editing without backup (GNU sed syntax) and extended regex
find "$1" -type f -exec sed -i -E "$REGEX" {} +
fi
# Safety check to ensure that all occurrences of '@trezor/*/src' have been replaced
SEARCH_PATTERN="@trezor\/[^/]+\/src"
if grep -Rl "$SEARCH_PATTERN" "$1"; then
echo "Error: Some files still contain '@trezor/*/src'. Please review the replacements."
exit 1
else
echo "All occurrences of '@trezor/*/src' have been successfully replaced."
fi