@deinossrl/dgp-agent 1.4.37 → 1.4.38
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 +40 -7
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -352,7 +352,7 @@ function getPlinkPath() {
|
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
// Versión del agente
|
|
355
|
-
const AGENT_VERSION = '1.4.
|
|
355
|
+
const AGENT_VERSION = '1.4.38';
|
|
356
356
|
let AGENT_MODE = 'smart'; // Siempre inteligente
|
|
357
357
|
|
|
358
358
|
// Configuración (prioridad: env vars > archivo config > platform config > defaults)
|
|
@@ -1230,16 +1230,49 @@ async function executeDeploy(command) {
|
|
|
1230
1230
|
? `ssh -i ${sshKeyPath} -o StrictHostKeyChecking=no ${ssh_user}@${server_host}`
|
|
1231
1231
|
: `ssh ${ssh_user}@${server_host}`;
|
|
1232
1232
|
|
|
1233
|
-
// Step 1: Git pull on server
|
|
1234
|
-
currentStep = '
|
|
1235
|
-
logCommand(`[1/4]
|
|
1233
|
+
// Step 1: Git clone/pull on server
|
|
1234
|
+
currentStep = 'git_setup_server';
|
|
1235
|
+
logCommand(`[1/4] Setting up repository on server...`);
|
|
1236
1236
|
steps.push({ step: currentStep, status: 'running' });
|
|
1237
1237
|
|
|
1238
|
-
|
|
1239
|
-
|
|
1238
|
+
// Verificar si el directorio existe
|
|
1239
|
+
const checkDirCmd = `${sshBase} "test -d ${projectFolder} && echo EXISTS || echo NOT_EXISTS"`;
|
|
1240
|
+
const dirCheck = await shellAsync(checkDirCmd);
|
|
1241
|
+
const dirExists = dirCheck.stdout.trim() === 'EXISTS';
|
|
1242
|
+
|
|
1243
|
+
if (!dirExists) {
|
|
1244
|
+
// El directorio no existe - clonar el repositorio
|
|
1245
|
+
logInfo(`Repository directory doesn't exist, cloning...`);
|
|
1246
|
+
|
|
1247
|
+
// Obtener la URL del repositorio desde el remoto local
|
|
1248
|
+
let repoUrl = '';
|
|
1249
|
+
try {
|
|
1250
|
+
repoUrl = shellSync('git config --get remote.origin.url').trim();
|
|
1251
|
+
} catch (e) {
|
|
1252
|
+
throw new Error('Cannot get repository URL from local git config');
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
logInfo(`Cloning from: ${repoUrl}`);
|
|
1256
|
+
|
|
1257
|
+
// Crear directorio padre y clonar
|
|
1258
|
+
const parentDir = projectFolder.substring(0, projectFolder.lastIndexOf('/'));
|
|
1259
|
+
const cloneCmd = `${sshBase} "mkdir -p ${parentDir} && git clone ${repoUrl} ${projectFolder}"`;
|
|
1260
|
+
await shellAsync(cloneCmd);
|
|
1261
|
+
|
|
1262
|
+
// Checkout de la rama correcta
|
|
1263
|
+
const checkoutCmd = `${sshBase} "cd ${projectFolder} && git checkout ${branch}"`;
|
|
1264
|
+
await shellAsync(checkoutCmd);
|
|
1265
|
+
|
|
1266
|
+
logSuccess(`Repository cloned successfully`);
|
|
1267
|
+
} else {
|
|
1268
|
+
// El directorio existe - hacer pull
|
|
1269
|
+
logInfo(`Repository exists, pulling latest changes...`);
|
|
1270
|
+
const gitPullCmd = `${sshBase} "cd ${projectFolder} && git fetch origin && git checkout ${branch} && git pull origin ${branch}"`;
|
|
1271
|
+
await shellAsync(gitPullCmd);
|
|
1272
|
+
logSuccess(`Code updated on server`);
|
|
1273
|
+
}
|
|
1240
1274
|
|
|
1241
1275
|
steps[steps.length - 1].status = 'success';
|
|
1242
|
-
logSuccess(`Code updated on server`);
|
|
1243
1276
|
|
|
1244
1277
|
// Step 2: Install dependencies on server
|
|
1245
1278
|
currentStep = 'npm_install_server';
|