buildsight-collector 0.0.2 → 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.
Files changed (2) hide show
  1. package/index.js +18 -1
  2. 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
 
@@ -34,11 +35,27 @@ async function main() {
34
35
  for (const repo of data.data) {
35
36
  console.log(chalk.blue(`\n📂 Processando repositório:`), chalk.white(repo.name));
36
37
  const git = simpleGit(repo.path);
37
- const DAYS_RANGE = 180 || 1;
38
+ const DAYS_RANGE = repo.periodDays || 1;
38
39
  const sinceDate = new Date();
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({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "buildsight-collector",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "CLI do BuildSight para coleta automatizada de commits e métricas de repositórios.",
5
5
  "main": "index.js",
6
6
  "bin": {