Created
November 28, 2024 00:22
-
-
Save lucien-loua/d78585a2fd94167f0e6a1822cca11a00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Vérifier si les arguments requis sont fournis | |
| if [ "$#" -ne 2 ]; then | |
| echo "Usage: $0 <ancien_package> <nouveau_package>" | |
| echo "Exemple: $0 @ouest-labs/env @tools/env" | |
| exit 1 | |
| fi | |
| ANCIEN_PACKAGE=$1 | |
| NOUVEAU_PACKAGE=$2 | |
| # Remplacer dans tous les fichiers sauf les fichiers de lock et les fichiers générés | |
| find . -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.json" -o -name "*.yaml" \) \ | |
| ! -name "pnpm-lock.yaml" \ | |
| ! -name "lock.yaml" \ | |
| ! -name ".modules.yaml" \ | |
| ! -path "*/node_modules/*" \ | |
| ! -path "*/.next/*" \ | |
| -exec sed -i '' "s|${ANCIEN_PACKAGE}|${NOUVEAU_PACKAGE}|g" {} + | |
| # Afficher un message de confirmation | |
| echo "Remplacement de '${ANCIEN_PACKAGE}' par '${NOUVEAU_PACKAGE}' terminé" | |
| echo "Fichiers exclus : pnpm-lock.yaml, lock.yaml, .modules.yaml, node_modules/*, .next/*" | |
| # Option: Afficher les fichiers modifiés | |
| echo "Fichiers modifiés :" | |
| grep -r "${NOUVEAU_PACKAGE}" . | grep -v "node_modules" | grep -v ".next" | grep -v "lock.yaml" | grep -v ".modules.yaml" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment