feat(deploys): implement versions admin panel, automatic plugin compilation & production loader paths
This commit is contained in:
@@ -9,9 +9,9 @@ export interface LoadedPlugin {
|
||||
dir: string
|
||||
}
|
||||
|
||||
// Em produção: __dirname = backend/dist/core → 3 níveis acima = raiz do projeto
|
||||
// Em dev com tsx: __dirname = backend/src/core → 3 níveis acima = raiz do projeto
|
||||
const PLUGINS_DIR = path.resolve(__dirname, '../../../plugins')
|
||||
const PLUGINS_DIR = process.env.NODE_ENV === 'production'
|
||||
? '/app/plugins'
|
||||
: path.resolve(__dirname, '../../../plugins')
|
||||
|
||||
/**
|
||||
* Ordena plugins por dependências usando topological sort (Kahn's algorithm).
|
||||
|
||||
@@ -373,3 +373,20 @@ adminRouter.post('/engine', async (req: Request, res: Response) => {
|
||||
res.status(500).json({ error: 'Erro ao salvar a engine' })
|
||||
}
|
||||
})
|
||||
|
||||
// ── Rota para Disparo Manual do Deploy ──
|
||||
adminRouter.post('/deploys/trigger', async (_req: Request, res: Response) => {
|
||||
try {
|
||||
const response = await fetch('http://10.99.0.4:9000/hooks/clube67-deploy-hook', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ trigger: 'admin_panel' })
|
||||
})
|
||||
if (!response.ok) throw new Error(`Status ${response.status}`)
|
||||
res.json({ ok: true, message: 'Deploy automático iniciado na VPS 4.' })
|
||||
} catch (err: any) {
|
||||
console.error('[Admin] Falha ao disparar webhook de deploy:', err.message)
|
||||
res.status(502).json({ error: 'Não foi possível se conectar ao servidor de build' })
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user