@deinossrl/dgp-agent 1.4.35 → 1.4.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +31 -41
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -346,7 +346,7 @@ function getPlinkPath() {
|
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
// Versión del agente
|
|
349
|
-
const AGENT_VERSION = '1.4.
|
|
349
|
+
const AGENT_VERSION = '1.4.36';
|
|
350
350
|
let AGENT_MODE = 'smart'; // Siempre inteligente
|
|
351
351
|
|
|
352
352
|
// Configuración (prioridad: env vars > archivo config > platform config > defaults)
|
|
@@ -1192,66 +1192,56 @@ async function executeDeploy(command) {
|
|
|
1192
1192
|
// Mark as running
|
|
1193
1193
|
await updateCommandStatus(id, 'running');
|
|
1194
1194
|
|
|
1195
|
-
//
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
await shellAsync(`git fetch origin`);
|
|
1201
|
-
await shellAsync(`git checkout ${branch}`);
|
|
1202
|
-
await shellAsync(`git pull origin ${branch}`);
|
|
1195
|
+
// Determinar carpeta de proyecto en el servidor
|
|
1196
|
+
const projectFolder = params?.project_path || (environment === 'production'
|
|
1197
|
+
? '/var/www/tenminuteia-prod/'
|
|
1198
|
+
: '/var/www/tenminuteia-staging/');
|
|
1203
1199
|
|
|
1204
|
-
|
|
1205
|
-
|
|
1200
|
+
// Construir base del comando SSH
|
|
1201
|
+
const sshBase = sshKeyPath
|
|
1202
|
+
? `ssh -i ${sshKeyPath} -o StrictHostKeyChecking=no ${ssh_user}@${server_host}`
|
|
1203
|
+
: `ssh ${ssh_user}@${server_host}`;
|
|
1206
1204
|
|
|
1207
|
-
// Step
|
|
1208
|
-
currentStep = '
|
|
1209
|
-
logCommand(`[
|
|
1205
|
+
// Step 1: Git pull on server
|
|
1206
|
+
currentStep = 'git_pull_server';
|
|
1207
|
+
logCommand(`[1/4] Pulling latest code on server (${branch})...`);
|
|
1210
1208
|
steps.push({ step: currentStep, status: 'running' });
|
|
1211
1209
|
|
|
1212
|
-
|
|
1210
|
+
const gitPullCmd = `${sshBase} "cd ${projectFolder} && git fetch origin && git checkout ${branch} && git pull origin ${branch}"`;
|
|
1211
|
+
await shellAsync(gitPullCmd);
|
|
1213
1212
|
|
|
1214
1213
|
steps[steps.length - 1].status = 'success';
|
|
1215
|
-
logSuccess(`
|
|
1214
|
+
logSuccess(`Code updated on server`);
|
|
1216
1215
|
|
|
1217
|
-
// Step
|
|
1218
|
-
currentStep = '
|
|
1219
|
-
logCommand(`[
|
|
1216
|
+
// Step 2: Install dependencies on server
|
|
1217
|
+
currentStep = 'npm_install_server';
|
|
1218
|
+
logCommand(`[2/4] Installing dependencies on server...`);
|
|
1220
1219
|
steps.push({ step: currentStep, status: 'running' });
|
|
1221
1220
|
|
|
1222
|
-
|
|
1221
|
+
const npmInstallCmd = `${sshBase} "cd ${projectFolder} && npm ci"`;
|
|
1222
|
+
await shellAsync(npmInstallCmd);
|
|
1223
1223
|
|
|
1224
1224
|
steps[steps.length - 1].status = 'success';
|
|
1225
|
-
logSuccess(`
|
|
1225
|
+
logSuccess(`Dependencies installed on server`);
|
|
1226
1226
|
|
|
1227
|
-
// Step
|
|
1228
|
-
currentStep = '
|
|
1229
|
-
logCommand(`[4
|
|
1227
|
+
// Step 3: Build on server
|
|
1228
|
+
currentStep = 'npm_build_server';
|
|
1229
|
+
logCommand(`[3/4] Building application on server...`);
|
|
1230
1230
|
steps.push({ step: currentStep, status: 'running' });
|
|
1231
1231
|
|
|
1232
|
-
const
|
|
1233
|
-
|
|
1234
|
-
: '/var/www/tenminuteia-staging/';
|
|
1235
|
-
|
|
1236
|
-
// Rsync the dist folder (con SSH key si disponible)
|
|
1237
|
-
const rsyncCmd = sshOptions
|
|
1238
|
-
? `rsync -avz --delete ${sshOptions} dist/ ${ssh_user}@${server_host}:${deployFolder}`
|
|
1239
|
-
: `rsync -avz --delete dist/ ${ssh_user}@${server_host}:${deployFolder}`;
|
|
1240
|
-
await shellAsync(rsyncCmd);
|
|
1232
|
+
const npmBuildCmd = `${sshBase} "cd ${projectFolder} && npm run build"`;
|
|
1233
|
+
await shellAsync(npmBuildCmd);
|
|
1241
1234
|
|
|
1242
1235
|
steps[steps.length - 1].status = 'success';
|
|
1243
|
-
logSuccess(`
|
|
1236
|
+
logSuccess(`Build completed on server`);
|
|
1244
1237
|
|
|
1245
|
-
// Step
|
|
1238
|
+
// Step 4: Reload nginx
|
|
1246
1239
|
currentStep = 'reload_nginx';
|
|
1247
|
-
logCommand(`[
|
|
1240
|
+
logCommand(`[4/4] Reloading Nginx...`);
|
|
1248
1241
|
steps.push({ step: currentStep, status: 'running' });
|
|
1249
1242
|
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
? `ssh -i ${sshKeyPath} -o StrictHostKeyChecking=no ${ssh_user}@${server_host} "sudo nginx -t && sudo systemctl reload nginx"`
|
|
1253
|
-
: `ssh ${ssh_user}@${server_host} "sudo nginx -t && sudo systemctl reload nginx"`;
|
|
1254
|
-
await shellAsync(sshCmd);
|
|
1243
|
+
const reloadNginxCmd = `${sshBase} "sudo nginx -t && sudo systemctl reload nginx"`;
|
|
1244
|
+
await shellAsync(reloadNginxCmd);
|
|
1255
1245
|
|
|
1256
1246
|
steps[steps.length - 1].status = 'success';
|
|
1257
1247
|
logSuccess(`Nginx reloaded`);
|