@anxin233/gitviz 1.0.3 → 1.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/dist/cli.cjs +15 -1
- package/package.json +1 -1
- package/dist/cli/index.js +0 -67
- package/dist/cli.js +0 -11943
- package/dist/core/analyzer.js +0 -99
- package/dist/core/git-parser.js +0 -53
- package/dist/core/types.js +0 -1
- package/dist/visualizers/html-generator.js +0 -292
package/dist/cli.cjs
CHANGED
|
@@ -11478,7 +11478,21 @@ var GitParser = class {
|
|
|
11478
11478
|
});
|
|
11479
11479
|
const commits = [];
|
|
11480
11480
|
for (const commit of log.all) {
|
|
11481
|
-
|
|
11481
|
+
let diffSummary;
|
|
11482
|
+
try {
|
|
11483
|
+
diffSummary = await this.git.diffSummary([`${commit.hash}^`, commit.hash]);
|
|
11484
|
+
} catch {
|
|
11485
|
+
try {
|
|
11486
|
+
diffSummary = await this.git.diffSummary(["4b825dc642cb6eb9a060e54bf8d69288fbee4904", commit.hash]);
|
|
11487
|
+
} catch {
|
|
11488
|
+
diffSummary = {
|
|
11489
|
+
files: [],
|
|
11490
|
+
insertions: 0,
|
|
11491
|
+
deletions: 0,
|
|
11492
|
+
changed: 0
|
|
11493
|
+
};
|
|
11494
|
+
}
|
|
11495
|
+
}
|
|
11482
11496
|
commits.push({
|
|
11483
11497
|
hash: commit.hash,
|
|
11484
11498
|
author: commit.author_name || "Unknown",
|
package/package.json
CHANGED
package/dist/cli/index.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Command } from 'commander';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import ora from 'ora';
|
|
5
|
-
import { writeFileSync } from 'fs';
|
|
6
|
-
import { join } from 'path';
|
|
7
|
-
import { GitParser } from '../core/git-parser.js';
|
|
8
|
-
import { Analyzer } from '../core/analyzer.js';
|
|
9
|
-
import { generateHTML } from '../visualizers/html-generator.js';
|
|
10
|
-
const program = new Command();
|
|
11
|
-
program
|
|
12
|
-
.name('gitviz')
|
|
13
|
-
.description('🎨 Beautiful, interactive Git repository visualizations')
|
|
14
|
-
.version('1.0.0');
|
|
15
|
-
program
|
|
16
|
-
.command('analyze')
|
|
17
|
-
.description('Analyze a Git repository and generate visualizations')
|
|
18
|
-
.option('-p, --path <path>', 'Path to Git repository', '.')
|
|
19
|
-
.option('-o, --output <file>', 'Output HTML file', 'gitviz-report.html')
|
|
20
|
-
.option('-l, --limit <number>', 'Limit number of commits to analyze', '1000')
|
|
21
|
-
.action(async (options) => {
|
|
22
|
-
const spinner = ora('Initializing GitViz...').start();
|
|
23
|
-
try {
|
|
24
|
-
const parser = new GitParser(options.path);
|
|
25
|
-
spinner.text = 'Checking if directory is a Git repository...';
|
|
26
|
-
const isRepo = await parser.isGitRepository();
|
|
27
|
-
if (!isRepo) {
|
|
28
|
-
spinner.fail(chalk.red('Error: Not a Git repository'));
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
spinner.text = 'Parsing Git commits...';
|
|
32
|
-
const commits = await parser.parseCommits(parseInt(options.limit));
|
|
33
|
-
if (commits.length === 0) {
|
|
34
|
-
spinner.fail(chalk.red('Error: No commits found'));
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
|
-
spinner.text = `Analyzing ${commits.length} commits...`;
|
|
38
|
-
const analyzer = new Analyzer();
|
|
39
|
-
const analysis = analyzer.analyze(commits);
|
|
40
|
-
spinner.text = 'Generating visualization data...';
|
|
41
|
-
const vizData = analyzer.generateVisualizationData(analysis);
|
|
42
|
-
spinner.text = 'Creating HTML report...';
|
|
43
|
-
const repoName = options.path === '.' ? 'Current Repository' : options.path;
|
|
44
|
-
const html = generateHTML(vizData, repoName);
|
|
45
|
-
const outputPath = join(process.cwd(), options.output);
|
|
46
|
-
writeFileSync(outputPath, html, 'utf-8');
|
|
47
|
-
spinner.succeed(chalk.green('✨ Visualization generated successfully!'));
|
|
48
|
-
console.log('\n' + chalk.bold('📊 Repository Statistics:'));
|
|
49
|
-
console.log(chalk.cyan(` Total Commits: ${analysis.totalCommits}`));
|
|
50
|
-
console.log(chalk.cyan(` Contributors: ${analysis.totalContributors}`));
|
|
51
|
-
console.log(chalk.cyan(` Files Changed: ${analysis.files.size}`));
|
|
52
|
-
console.log(chalk.cyan(` Date Range: ${analysis.dateRange.start.toLocaleDateString()} - ${analysis.dateRange.end.toLocaleDateString()}`));
|
|
53
|
-
console.log('\n' + chalk.bold(`📁 Output: ${outputPath}`));
|
|
54
|
-
console.log(chalk.gray(`\nOpen the file in your browser to view the interactive visualization.\n`));
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
spinner.fail(chalk.red('Error: ' + error.message));
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
program
|
|
62
|
-
.command('quick')
|
|
63
|
-
.description('Quick analysis of current directory')
|
|
64
|
-
.action(async () => {
|
|
65
|
-
program.parse(['node', 'gitviz', 'analyze']);
|
|
66
|
-
});
|
|
67
|
-
program.parse();
|