|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +echo "=== php-facturae migration ===" |
| 5 | + |
| 6 | +# 1. Flatten src/Facturae/ → src/ |
| 7 | +if [ -d "src/Facturae" ]; then |
| 8 | + echo "Moving src/Facturae/ contents to src/..." |
| 9 | + cp -r src/Facturae/. src/ |
| 10 | + rm -rf src/Facturae |
| 11 | +else |
| 12 | + echo "src/Facturae not found — skipping" |
| 13 | +fi |
| 14 | + |
| 15 | +# 2. Flatten tests/Facturae/ → tests/ |
| 16 | +if [ -d "tests/Facturae" ]; then |
| 17 | + echo "Moving tests/Facturae/ contents to tests/..." |
| 18 | + cp -r tests/Facturae/. tests/ |
| 19 | + rm -rf tests/Facturae |
| 20 | +else |
| 21 | + echo "tests/Facturae not found — skipping" |
| 22 | +fi |
| 23 | + |
| 24 | +# 3. Replace namespaces in all PHP files |
| 25 | +echo "Updating namespaces..." |
| 26 | + |
| 27 | +find src/ -name "*.php" -exec sed -i \ |
| 28 | + -e 's/MarioDevv\\Rex\\Facturae\\/PhpFacturae\\/g' \ |
| 29 | + -e 's/MarioDevv\\\\Rex\\\\Facturae\\\\/PhpFacturae\\\\/g' \ |
| 30 | + {} + |
| 31 | + |
| 32 | +find tests/ -name "*.php" -exec sed -i \ |
| 33 | + -e 's/MarioDevv\\Rex\\Tests\\Facturae\\/PhpFacturae\\Tests\\/g' \ |
| 34 | + -e 's/MarioDevv\\\\Rex\\\\Tests\\\\Facturae\\\\/PhpFacturae\\\\Tests\\\\/g' \ |
| 35 | + -e 's/MarioDevv\\Rex\\Facturae\\/PhpFacturae\\/g' \ |
| 36 | + -e 's/MarioDevv\\\\Rex\\\\Facturae\\\\/PhpFacturae\\\\/g' \ |
| 37 | + {} + |
| 38 | + |
| 39 | +# 4. Update phpunit configs |
| 40 | +for f in phpunit.xml phpunit.local.xml; do |
| 41 | + if [ -f "$f" ]; then |
| 42 | + echo "Updating $f..." |
| 43 | + sed -i \ |
| 44 | + -e 's|tests/Facturae|tests|g' \ |
| 45 | + -e 's|src/Facturae|src|g' \ |
| 46 | + "$f" |
| 47 | + fi |
| 48 | +done |
| 49 | + |
| 50 | +echo "" |
| 51 | +echo "Done! New structure:" |
| 52 | +tree -I 'vendor|dist' src/ tests/ |
| 53 | +echo "" |
| 54 | +echo "Remember to:" |
| 55 | +echo " 1. Replace composer.json with the new one" |
| 56 | +echo " 2. Run: composer dump-autoload" |
| 57 | +echo " 3. Run: composer test" |
0 commit comments