buildsight-collector 0.0.3 → 0.0.4
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.js +17 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import axios from "axios";
|
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
import ora from "ora";
|
|
6
6
|
import simpleGit from "simple-git";
|
|
7
|
+
import { spawn } from 'child_process';
|
|
7
8
|
|
|
8
9
|
const spinner = ora();
|
|
9
10
|
|
|
@@ -39,6 +40,22 @@ async function main() {
|
|
|
39
40
|
sinceDate.setDate(sinceDate.getDate() - DAYS_RANGE);
|
|
40
41
|
|
|
41
42
|
console.log(chalk.gray(`Buscando commits desde: ${sinceDate.toISOString()}`));
|
|
43
|
+
// Atualizar repositório antes de buscar commits
|
|
44
|
+
try {
|
|
45
|
+
// Use spawn with stdio: 'inherit' so the user can interact (enter credentials) if git requests them.
|
|
46
|
+
spinner.start('Atualizando repositório (git pull)...');
|
|
47
|
+
await new Promise((resolve, reject) => {
|
|
48
|
+
const p = spawn('git', ['pull'], { cwd: repo.path, stdio: 'inherit' });
|
|
49
|
+
p.on('error', (err) => reject(err));
|
|
50
|
+
p.on('close', (code) => {
|
|
51
|
+
if (code === 0) resolve();
|
|
52
|
+
else reject(new Error(`git pull exited with code ${code}`));
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
spinner.succeed('Repositório atualizado.');
|
|
56
|
+
} catch (pullErr) {
|
|
57
|
+
spinner.warn('Não foi possível atualizar o repositório (git pull). Usando dados locais.');
|
|
58
|
+
}
|
|
42
59
|
|
|
43
60
|
// --- 🔹 1. Commits detalhados ---
|
|
44
61
|
const log = await git.log({
|