Some checks failed
Atualiza docs/SETUP.md e scripts/setup-dev.sh com: - Instrucoes para configurar chave SSH - Opcao de usar Personal Access Token (PAT) - Comandos para clonar/configurar via SSH ou HTTPS - Script setup-dev.sh agora aceita --ssh para repo privado 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
252 lines
5.4 KiB
Markdown
252 lines
5.4 KiB
Markdown
# Setup em Novo Computador
|
|
|
|
Guia rapido para configurar o ambiente de desenvolvimento em uma nova maquina.
|
|
|
|
## Pre-requisitos
|
|
|
|
- **Git** instalado
|
|
- **Bun** 1.3+ ([bun.sh](https://bun.sh))
|
|
- **Docker** (para PostgreSQL local)
|
|
- **Node.js** 20+ (opcional, para algumas ferramentas)
|
|
|
|
### Instalar Bun (se ainda nao tiver)
|
|
|
|
```bash
|
|
# Linux/macOS/WSL
|
|
curl -fsSL https://bun.sh/install | bash
|
|
|
|
# Windows (PowerShell)
|
|
powershell -c "irm bun.sh/install.ps1 | iex"
|
|
```
|
|
|
|
## Configurar Autenticacao (Repositorio Privado)
|
|
|
|
Se o repositorio for privado, configure autenticacao SSH antes de clonar.
|
|
|
|
### Opcao 1: SSH Key (Recomendado)
|
|
|
|
```bash
|
|
# 1. Gerar chave SSH (se nao tiver)
|
|
ssh-keygen -t ed25519 -C "seu-email@exemplo.com"
|
|
# Pressione Enter para aceitar o local padrao
|
|
# Defina uma senha ou deixe em branco
|
|
|
|
# 2. Copiar a chave publica
|
|
# Linux/macOS/WSL:
|
|
cat ~/.ssh/id_ed25519.pub
|
|
|
|
# Windows (PowerShell):
|
|
Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub
|
|
|
|
# Windows (CMD):
|
|
type %USERPROFILE%\.ssh\id_ed25519.pub
|
|
```
|
|
|
|
**Adicionar a chave nos servicos:**
|
|
- **GitHub:** Settings > SSH and GPG keys > New SSH key
|
|
- **Forgejo:** Settings > SSH / GPG Keys > Add Key
|
|
|
|
### Opcao 2: Personal Access Token (PAT)
|
|
|
|
1. **GitHub:** Settings > Developer settings > Personal access tokens > Tokens (classic)
|
|
2. Gerar token com permissao `repo`
|
|
3. Usar o token como senha quando o git pedir
|
|
|
|
Para salvar o token (nao precisar digitar toda vez):
|
|
```bash
|
|
git config --global credential.helper store
|
|
# Proximo push/pull vai pedir usuario e token, e salvar
|
|
```
|
|
|
|
## Setup Rapido
|
|
|
|
### 1. Clonar o repositorio
|
|
|
|
**Repositorio publico (HTTPS):**
|
|
```bash
|
|
git clone https://github.com/esdrasrenan/sistema-de-chamados.git
|
|
cd sistema-de-chamados
|
|
```
|
|
|
|
**Repositorio privado (SSH):**
|
|
```bash
|
|
git clone git@github.com:esdrasrenan/sistema-de-chamados.git
|
|
cd sistema-de-chamados
|
|
```
|
|
|
|
Ou se ja tiver o repositorio:
|
|
```bash
|
|
cd sistema-de-chamados
|
|
git pull origin main
|
|
```
|
|
|
|
### 2. Configurar remotes (para CI/CD)
|
|
|
|
**Repositorio publico (HTTPS):**
|
|
```bash
|
|
git remote add forgejo https://git.esdrasrenan.com.br/esdras/sistema-de-chamados.git
|
|
```
|
|
|
|
**Repositorio privado (SSH):**
|
|
```bash
|
|
# Mudar origin para SSH (se clonou via HTTPS)
|
|
git remote set-url origin git@github.com:esdrasrenan/sistema-de-chamados.git
|
|
|
|
# Adicionar forgejo via SSH (porta 2222)
|
|
git remote add forgejo ssh://git@git.esdrasrenan.com.br:2222/esdras/sistema-de-chamados.git
|
|
```
|
|
|
|
**Verificar remotes:**
|
|
```bash
|
|
git remote -v
|
|
# Deve mostrar (exemplo com SSH):
|
|
# origin git@github.com:esdrasrenan/sistema-de-chamados.git (fetch)
|
|
# origin git@github.com:esdrasrenan/sistema-de-chamados.git (push)
|
|
# forgejo ssh://git@git.esdrasrenan.com.br:2222/esdras/sistema-de-chamados.git (fetch)
|
|
# forgejo ssh://git@git.esdrasrenan.com.br:2222/esdras/sistema-de-chamados.git (push)
|
|
```
|
|
|
|
### 3. Instalar dependencias
|
|
|
|
```bash
|
|
bun install
|
|
```
|
|
|
|
### 4. Configurar banco de dados
|
|
|
|
```bash
|
|
# Subir PostgreSQL via Docker
|
|
docker run -d \
|
|
--name postgres-dev \
|
|
-p 5432:5432 \
|
|
-e POSTGRES_PASSWORD=dev \
|
|
-e POSTGRES_DB=sistema_chamados \
|
|
postgres:16
|
|
|
|
# Criar arquivo .env
|
|
cp .env.example .env
|
|
```
|
|
|
|
Edite o `.env` e configure:
|
|
|
|
```env
|
|
DATABASE_URL=postgresql://postgres:dev@localhost:5432/sistema_chamados
|
|
BETTER_AUTH_SECRET=sua-chave-secreta-aqui
|
|
NEXT_PUBLIC_APP_URL=http://localhost:3000
|
|
BETTER_AUTH_URL=http://localhost:3000
|
|
```
|
|
|
|
### 5. Inicializar o banco
|
|
|
|
```bash
|
|
# Gerar cliente Prisma
|
|
bun run prisma:generate
|
|
|
|
# Criar tabelas no banco
|
|
bunx prisma db push
|
|
|
|
# Popular dados iniciais
|
|
bun run auth:seed
|
|
```
|
|
|
|
### 6. Rodar o projeto
|
|
|
|
```bash
|
|
bun run dev:bun
|
|
```
|
|
|
|
Acesse: http://localhost:3000
|
|
|
|
**Credenciais padrao:** `admin@sistema.dev` / `admin123`
|
|
|
|
## Comandos Uteis
|
|
|
|
| Comando | Descricao |
|
|
|---------|-----------|
|
|
| `bun run dev:bun` | Iniciar servidor de desenvolvimento |
|
|
| `bun run build:bun` | Build de producao |
|
|
| `bun run lint` | Verificar codigo (ESLint) |
|
|
| `bun test` | Rodar testes |
|
|
| `bun run prisma:generate` | Gerar cliente Prisma |
|
|
| `bunx prisma studio` | Interface visual do banco |
|
|
|
|
## Fluxo de Trabalho com Git
|
|
|
|
### Push para ambos os remotes (recomendado)
|
|
|
|
```bash
|
|
# Fazer alteracoes
|
|
git add .
|
|
git commit -m "sua mensagem"
|
|
|
|
# Push para GitHub (backup) e Forgejo (CI/CD)
|
|
git push origin main && git push forgejo main
|
|
```
|
|
|
|
### Configurar alias para push duplo (opcional)
|
|
|
|
```bash
|
|
# Criar alias
|
|
git config alias.push-all '!git push origin main && git push forgejo main'
|
|
|
|
# Usar
|
|
git push-all
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### Erro: "bun: command not found"
|
|
|
|
```bash
|
|
# Adicionar Bun ao PATH
|
|
export PATH="$HOME/.bun/bin:$PATH"
|
|
|
|
# Adicionar permanentemente ao ~/.bashrc ou ~/.zshrc
|
|
echo 'export PATH="$HOME/.bun/bin:$PATH"' >> ~/.bashrc
|
|
source ~/.bashrc
|
|
```
|
|
|
|
### Erro: Prisma "P2021" / tabelas nao existem
|
|
|
|
```bash
|
|
bunx prisma db push
|
|
bun run auth:seed
|
|
```
|
|
|
|
### Erro: Lockfile desatualizado
|
|
|
|
```bash
|
|
bun install
|
|
```
|
|
|
|
### PostgreSQL nao conecta
|
|
|
|
```bash
|
|
# Verificar se o container esta rodando
|
|
docker ps
|
|
|
|
# Se nao estiver, iniciar
|
|
docker start postgres-dev
|
|
|
|
# Ou recriar
|
|
docker rm -f postgres-dev
|
|
docker run -d --name postgres-dev -p 5432:5432 -e POSTGRES_PASSWORD=dev -e POSTGRES_DB=sistema_chamados postgres:16
|
|
```
|
|
|
|
## Convex (Backend de Tempo Real)
|
|
|
|
Para desenvolvimento com Convex local:
|
|
|
|
```bash
|
|
# Terminal 1: Convex dev server
|
|
bun run convex:dev:bun
|
|
|
|
# Terminal 2: Next.js
|
|
bun run dev:bun
|
|
```
|
|
|
|
## Mais Informacoes
|
|
|
|
- **Desenvolvimento detalhado:** `docs/DEV.md`
|
|
- **Deploy e operacoes:** `docs/DEPLOY-RUNBOOK.md`
|
|
- **CI/CD Forgejo:** `docs/FORGEJO-CI-CD.md`
|