utn-cli 2.1.7 → 2.1.8
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/commands/pull.js +51 -0
- package/index.js +8 -0
- package/package.json +1 -1
package/commands/pull.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { closeReadLine } from '../utils/index.js';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
|
|
6
|
+
export async function runGlobalPull() {
|
|
7
|
+
const currentDir = process.cwd();
|
|
8
|
+
const entries = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
9
|
+
const directories = entries.filter(entry => entry.isDirectory());
|
|
10
|
+
|
|
11
|
+
if (directories.length === 0) {
|
|
12
|
+
console.log('No se encontraron directorios en la carpeta actual.');
|
|
13
|
+
closeReadLine();
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let encontroAlguno = false;
|
|
18
|
+
|
|
19
|
+
for (const dir of directories) {
|
|
20
|
+
const fullPath = path.join(currentDir, dir.name);
|
|
21
|
+
|
|
22
|
+
if (!fs.existsSync(path.join(fullPath, '.git'))) continue;
|
|
23
|
+
|
|
24
|
+
encontroAlguno = true;
|
|
25
|
+
process.chdir(fullPath);
|
|
26
|
+
|
|
27
|
+
console.log(`\n[${dir.name}] Asegurando rama 'desarrollo'...`);
|
|
28
|
+
try {
|
|
29
|
+
execSync('git checkout desarrollo', { stdio: 'inherit' });
|
|
30
|
+
} catch {
|
|
31
|
+
console.error(`[${dir.name}] Error al cambiar a la rama 'desarrollo'. Continuando...`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
console.log(`[${dir.name}] Ejecutando git pull...`);
|
|
35
|
+
try {
|
|
36
|
+
execSync('git pull', { stdio: 'inherit' });
|
|
37
|
+
} catch {
|
|
38
|
+
console.error(`[${dir.name}] Error al ejecutar git pull. Continuando...`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
process.chdir(currentDir);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!encontroAlguno) {
|
|
45
|
+
console.log('No se encontraron repositorios Git en los directorios actuales.');
|
|
46
|
+
} else {
|
|
47
|
+
console.log('\nPull finalizado en todos los repositorios.');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
closeReadLine();
|
|
51
|
+
}
|
package/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { initDb, addTableDb, showDbVersion, updateDb } from './commands/db.js';
|
|
|
8
8
|
import { initBackend, updateBackend, addServiceBackend, showBackendVersion } from './commands/backend.js';
|
|
9
9
|
import { initFrontend, updateFrontend, cloneFrontendComponent, showFrontendVersion } from './commands/frontend.js';
|
|
10
10
|
import { runGlobalUpdate } from './commands/update.js';
|
|
11
|
+
import { runGlobalPull } from './commands/pull.js';
|
|
11
12
|
import { createComponent } from './commands/createComponent.js';
|
|
12
13
|
import { runCommit } from './commands/commit.js';
|
|
13
14
|
|
|
@@ -104,6 +105,13 @@ program.command('update')
|
|
|
104
105
|
await runGlobalUpdate();
|
|
105
106
|
});
|
|
106
107
|
|
|
108
|
+
// Define 'pull' command
|
|
109
|
+
program.command('pull')
|
|
110
|
+
.description('Recorre los directorios, cambia a la rama "desarrollo" y ejecuta git pull en cada repositorio Git.')
|
|
111
|
+
.action(async () => {
|
|
112
|
+
await runGlobalPull();
|
|
113
|
+
});
|
|
114
|
+
|
|
107
115
|
// Define 'create-component' command
|
|
108
116
|
program.command('create-component')
|
|
109
117
|
.description('Crea un nuevo servicio en el backend y un componente en el frontend simultáneamente.')
|