@deinossrl/dgp-agent 1.4.37 → 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.
- package/index.mjs +33 -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.39';
|
|
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,42 @@ 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
|
+
// 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;
|
|
1249
|
+
|
|
1250
|
+
// Obtener la URL del repositorio desde el remoto local
|
|
1251
|
+
let repoUrl = '';
|
|
1252
|
+
try {
|
|
1253
|
+
repoUrl = shellSync('git config --get remote.origin.url').trim();
|
|
1254
|
+
} catch (e) {
|
|
1255
|
+
throw new Error('Cannot get repository URL from local git config');
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
logInfo(`Cloning from: ${repoUrl}`);
|
|
1259
|
+
|
|
1260
|
+
// Crear directorio padre y clonar
|
|
1261
|
+
const parentDir = projectFolder.substring(0, projectFolder.lastIndexOf('/'));
|
|
1262
|
+
const cloneCmd = `${sshBase} "mkdir -p ${parentDir} && git clone ${repoUrl} ${projectFolder} && cd ${projectFolder} && git checkout ${branch}"`;
|
|
1263
|
+
await shellAsync(cloneCmd);
|
|
1264
|
+
|
|
1265
|
+
logSuccess(`Repository cloned successfully`);
|
|
1266
|
+
}
|
|
1240
1267
|
|
|
1241
1268
|
steps[steps.length - 1].status = 'success';
|
|
1242
|
-
logSuccess(`Code updated on server`);
|
|
1243
1269
|
|
|
1244
1270
|
// Step 2: Install dependencies on server
|
|
1245
1271
|
currentStep = 'npm_install_server';
|