@deinossrl/dgp-agent 1.4.38 → 1.4.39

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.
Files changed (2) hide show
  1. package/index.mjs +13 -20
  2. 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.38';
355
+ const AGENT_VERSION = '1.4.39';
356
356
  let AGENT_MODE = 'smart'; // Siempre inteligente
357
357
 
358
358
  // Configuración (prioridad: env vars > archivo config > platform config > defaults)
@@ -1235,14 +1235,17 @@ async function executeDeploy(command) {
1235
1235
  logCommand(`[1/4] Setting up repository on server...`);
1236
1236
  steps.push({ step: currentStep, status: 'running' });
1237
1237
 
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...`);
1238
+ // Intentar pull, si falla entonces clonar
1239
+ let needsClone = false;
1240
+ try {
1241
+ logInfo(`Attempting to update existing repository...`);
1242
+ const gitPullCmd = `${sshBase} "cd ${projectFolder} && git fetch origin && git checkout ${branch} && git pull origin ${branch}"`;
1243
+ await shellAsync(gitPullCmd);
1244
+ logSuccess(`Code updated on server`);
1245
+ } catch (pullError) {
1246
+ // Si falla el pull, probablemente el repo no existe
1247
+ logInfo(`Repository not found, cloning...`);
1248
+ needsClone = true;
1246
1249
 
1247
1250
  // Obtener la URL del repositorio desde el remoto local
1248
1251
  let repoUrl = '';
@@ -1256,20 +1259,10 @@ async function executeDeploy(command) {
1256
1259
 
1257
1260
  // Crear directorio padre y clonar
1258
1261
  const parentDir = projectFolder.substring(0, projectFolder.lastIndexOf('/'));
1259
- const cloneCmd = `${sshBase} "mkdir -p ${parentDir} && git clone ${repoUrl} ${projectFolder}"`;
1262
+ const cloneCmd = `${sshBase} "mkdir -p ${parentDir} && git clone ${repoUrl} ${projectFolder} && cd ${projectFolder} && git checkout ${branch}"`;
1260
1263
  await shellAsync(cloneCmd);
1261
1264
 
1262
- // Checkout de la rama correcta
1263
- const checkoutCmd = `${sshBase} "cd ${projectFolder} && git checkout ${branch}"`;
1264
- await shellAsync(checkoutCmd);
1265
-
1266
1265
  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
1266
  }
1274
1267
 
1275
1268
  steps[steps.length - 1].status = 'success';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deinossrl/dgp-agent",
3
- "version": "1.4.38",
3
+ "version": "1.4.39",
4
4
  "description": "Agente local para Despliegue-GPT - Reporta el estado del repositorio Git a la plataforma TenMinute IA",
5
5
  "main": "index.mjs",
6
6
  "bin": {