testes/Modulos Angular/scripts/setup-linux-universal.sh

75 lines
2.5 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 🚀 Script de Configuração Universal - PraFrota FE
# Este script automatiza a instalação de dependências em sistemas Linux.
set -e
# Cores para output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
echo -e "${GREEN}=============================================${NC}"
echo -e "${GREEN} Iniciando Configuração do PraFrota FE ${NC}"
echo -e "${GREEN}=============================================${NC}"
# 1. Detecção do Sistema Operacional
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$ID
else
echo -e "${RED}Erro: Não foi possível detectar a distribuição Linux.${NC}"
exit 1
fi
echo -e "${YELLOW} Sistema detectado: $OS${NC}"
# 2. Instalação de Ferramentas de Sistema (Git, Curl, Build Essentials)
case $OS in
ubuntu|debian|linuxmint)
echo -e "${YELLOW}📦 Instalando dependências via APT...${NC}"
sudo apt update
sudo apt install -y git curl build-essential
;;
fedora|rhel|centos|almalinux)
echo -e "${YELLOW}📦 Instalando dependências via DNF/YUM...${NC}"
sudo dnf groupinstall -y "Development Tools"
sudo dnf install -y git curl
;;
arch|manjaro)
echo -e "${YELLOW}📦 Instalando dependências via PACMAN...${NC}"
sudo pacman -S --noconfirm base-devel git curl
;;
*)
echo -e "${RED}⚠️ Distribuição '$OS' não suportada automaticamente.${NC}"
echo -e "Por favor, instale 'git', 'curl' e ferramentas de compilação manualmente."
;;
esac
# 3. Gerenciamento do Node.js via NVM
if [ -z "$NVM_DIR" ]; then
echo -e "${YELLOW}📦 Instalando NVM (Node Version Manager)...${NC}"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
fi
echo -e "${YELLOW}📦 Instalando Node.js v20.12.0...${NC}"
nvm install 20.12.0
nvm use 20.12.0
nvm alias default 20.12.0
# 4. Configuração do Projeto
echo -e "${YELLOW}📦 Instalando dependências do projeto (npm install)...${NC}"
npm install --legacy-peer-deps
echo -e "${YELLOW}🏗️ Compilando bibliotecas internas (crítico)...${NC}"
npm run build libs
echo -e "${GREEN}=============================================${NC}"
echo -e "${GREEN} ✅ Configuração Concluída com Sucesso! ${NC}"
echo -e "${GREEN} Para iniciar o projeto: npm run start-debug${NC}"
echo -e "${GREEN}=============================================${NC}"