utn-cli 2.1.36 → 2.1.37

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.
@@ -6,7 +6,16 @@ import { updateDb } from './db.js';
6
6
  import { closeReadLine, hacerPreguntaTrim } from '../utils/index.js';
7
7
  import { execSync } from 'child_process';
8
8
 
9
- export async function runGlobalUpdate() {
9
+ function resolverRamaPrincipal(fullPath) {
10
+ try {
11
+ const ramas = execSync('git branch -r', { cwd: fullPath }).toString();
12
+ if (ramas.includes('origin/main')) return 'main';
13
+ if (ramas.includes('origin/master')) return 'master';
14
+ } catch (_) {}
15
+ return 'main';
16
+ }
17
+
18
+ export async function runGlobalUpdate({ usarPrincipal = false } = {}) {
10
19
  const currentDir = process.cwd();
11
20
  const entries = fs.readdirSync(currentDir, { withFileTypes: true });
12
21
 
@@ -37,11 +46,12 @@ export async function runGlobalUpdate() {
37
46
  // Ignorar si no se puede obtener la URL
38
47
  }
39
48
 
40
- console.log(`[${dir.name}] Asegurando rama 'desarrollo'...`);
49
+ const rama = usarPrincipal ? resolverRamaPrincipal(fullPath) : 'desarrollo';
50
+ console.log(`[${dir.name}] Asegurando rama '${rama}'...`);
41
51
  try {
42
- execSync('git checkout desarrollo', { stdio: 'inherit' });
52
+ execSync(`git checkout ${rama}`, { stdio: 'inherit' });
43
53
  } catch (error) {
44
- console.error(`Error al cambiar a la rama 'desarrollo' en ${dir.name}. Continuando...`);
54
+ console.error(`Error al cambiar a la rama '${rama}' en ${dir.name}. Continuando...`);
45
55
  }
46
56
 
47
57
  console.log(`[${dir.name}] Ejecutando git pull...`);
package/index.js CHANGED
@@ -102,8 +102,9 @@ program.command('frontend')
102
102
  // Define 'update' command
103
103
  program.command('update')
104
104
  .description('Recorre los directorios y actualiza proyectos de backend (si el nombre contiene "back") y frontend (si el nombre contiene "front").')
105
- .action(async () => {
106
- await runGlobalUpdate();
105
+ .option('--principal', 'Usa la rama principal (main/master) en lugar de desarrollo.')
106
+ .action(async (options) => {
107
+ await runGlobalUpdate({ usarPrincipal: !!options.principal });
107
108
  });
108
109
 
109
110
  // Define 'pull' command
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utn-cli",
3
- "version": "2.1.36",
3
+ "version": "2.1.37",
4
4
  "description": "Herramienta CLI unificada para la gestión de plantillas en SIGU.",
5
5
  "main": "index.js",
6
6
  "type": "module",