Skip to content

Commit 2752e25

Browse files
authored
Merge pull request #13 from KebanFiru/feat/ui
Feat/UI
2 parents 8ef988c + 4caf714 commit 2752e25

24 files changed

Lines changed: 1921 additions & 315 deletions

README.md

Lines changed: 51 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,39 @@
33
<!-- Badges -->
44
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
55
[![VS Code](https://img.shields.io/badge/VS%20Code-1.108.2+-blue)](https://code.visualstudio.com/)
6+
[![VS Marketplace](https://img.shields.io/visual-studio-marketplace/v/KebanFiru.CodeLineCounter?label=VS%20Marketplace&color=0078d7)](https://marketplace.visualstudio.com/items?itemName=KebanFiru.CodeLineCounter)
67
[![TypeScript](https://img.shields.io/badge/TypeScript-5.9+-blue)](https://www.typescriptlang.org/)
78

8-
> Quickly analyze your project's codebase by counting lines of code, comments, and get insights organized by file types.
9+
> Quickly analyze your project's codebase with comprehensive metrics, Git analytics, and interactive dashboards.
910
1011
## Overview
1112

12-
**CodeCount** is a powerful VS Code extension that provides comprehensive code metrics for your projects. Instantly see how many lines of code, comments, and blank lines your workspace contains. Get detailed breakdowns by file type, understand code distribution, and track your project's scale.
13-
14-
Perfect for developers, project managers, and teams who need quick insights into codebase size and complexity.
13+
**CodeCount** is a powerful VS Code extension that provides deep insights into your codebase. Get instant metrics on lines of code, understand contributor activity, track commit trends, and visualize language distribution. Perfect for developers, project managers, and teams who need comprehensive codebase analytics.
1514

1615
## Features
1716

18-
- **Workspace Analysis** - Get total line counts for your entire project
19-
- **File-by-File Breakdown** - See statistics for individual files
20-
- **Extension-Based Statistics** - Analyze code distribution across file types (TypeScript, JavaScript, Python, etc.)
21-
- **Comment Detection** - Identify and count comment lines separately
22-
- **Real-Time Refresh** - Update stats anytime with a single click
23-
- **Sidebar Integration** - Dedicated panel in VS Code's Activity Bar
24-
- **Gitignore Support** - Respects your `.gitignore` patterns automatically
25-
- **⏱Performance Optimized** - Fast analysis even for large projects
26-
27-
## 📋 Commands
17+
### Code Metrics
18+
- **Workspace Analysis** - Total line counts for entire projects
19+
- **File-by-File Breakdown** - Statistics for individual files
20+
- **Language Distribution** - Analyze code across file types with expandable lists
21+
- **Comment Detection** - Separate counts for comment and blank lines
22+
- **Gitignore Support** - Automatically respects `.gitignore` patterns
23+
24+
### Git Analytics (Repository View)
25+
- **Contributor Statistics** - Track contributions with added/deleted line counts
26+
- **Commit Trends** - Visualize commits, additions, and deletions over time
27+
- **Monthly Activity** - Monitor development activity by month
28+
- **Work Patterns** - Understand coding patterns by weekday and hour
29+
- **Repository Metrics** - Total contributors, commits, and lines changed
30+
31+
### Interactive Dashboard
32+
- **Real-Time Statistics Panel** - View metrics in VS Code sidebar
33+
- **Expandable Lists** - Top 3 preview with "Show all" toggle for contributors and languages
34+
- **Responsive Charts** - Full-width visualizations using Chart.js v4.4.0
35+
- **Dark Mode Support** - Optimized for VS Code themes with white text on dark backgrounds
36+
- **Performance Optimized** - Instant analysis even for large projects
37+
38+
## Commands
2839

2940
Access CodeCount commands via the Command Palette (`Ctrl+Shift+P` / `Cmd+Shift+P`):
3041

@@ -35,81 +46,49 @@ Access CodeCount commands via the Command Palette (`Ctrl+Shift+P` / `Cmd+Shift+P
3546
| `CodeCount: Count Lines of Code by Extension` | Get breakdown by file type |
3647
| `CodeCount: Refresh CodeCount Stats` | Refresh sidebar statistics |
3748

38-
## 📦 Requirements
49+
## Requirements
3950

4051
- **VS Code:** 1.108.2 or newer
41-
- **Git:** Required for repository recognition (optional, but recommended)
42-
43-
## 🚀 Quick Start
44-
45-
### Installation
46-
47-
1. Open VS Code
48-
2. Go to Extensions (`Ctrl+Shift+X` / `Cmd+Shift+X`)
49-
3. Search for "CodeCount"
50-
4. Click **Install**
51-
5. Reload VS Code if prompted
52+
- **Git:** Required for repository analytics and contributor tracking
5253

5354
### Usage
5455

55-
#### Method 1: Using Commands
56+
#### Method 1: Using Sidebar
57+
- Click the **CodeCount** icon in the Activity Bar (left sidebar)
58+
- View comprehensive statistics including:
59+
- Stats overview grid
60+
- Language distribution with breakdown
61+
- Top contributors and their contributions
62+
- Repository analytics and commit history
63+
64+
#### Method 2: Using Commands
5665
- Open Command Palette (`Ctrl+Shift+P` / `Cmd+Shift+P`)
5766
- Type "CodeCount" to see available commands
5867
- Select the command you want to run
5968

60-
#### Method 2: Using Sidebar
61-
- Click the **CodeCount** icon in the Activity Bar (left sidebar)
62-
- View current statistics
63-
- Click the refresh button to update
64-
65-
#### Example Output
66-
```
67-
Total lines in workspace (145 files): 25,847
68-
Comment lines: 3,421
69-
```
69+
#### Dashboard Features
70+
- **Expandable Lists** - Click "Show all" to expand contributors or languages
71+
- **Interactive Charts** - Hover over visualizations for detailed information
72+
- **Full-Width Analytics** - View commit trends, monthly activity, and work patterns
73+
- **Real-Time Updates** - Click refresh to update statistics
7074

71-
## 🛠️ Development
75+
## Architecture
7276

73-
### Prerequisites
74-
- Node.js 18+
75-
- pnpm (recommended) or npm
77+
### Technology Stack
78+
- **Frontend:** HTML/CSS/JavaScript in VS Code Webview
79+
- **Charts:** Chart.js v4.4.0
80+
- **Language:** TypeScript with strict mode
81+
- **Styling:** CSS Grid layout with responsive design
82+
- **Git Integration:** Child process execution for git commands
7683

77-
### Setup
78-
79-
## 📚 Configuration
84+
## Configuration
8085

8186
CodeCount respects your project's `.gitignore` file, automatically excluding:
8287
- `node_modules/`
8388
- `dist/` and `build/`
8489
- `.git/` directories
8590
- And any patterns defined in `.gitignore`
8691

87-
## 🤝 Contributing
88-
89-
We welcome contributions! Here's how to help:
90-
91-
### Getting Started
92-
1. **Fork** the repository
93-
2. **Create** a feature branch: `git checkout -b feature/amazing-feature`
94-
3. **Make** your changes
95-
4. **Test** thoroughly
96-
5. **Commit** with clear messages: `git commit -m 'Add amazing feature'`
97-
6. **Push** to your branch: `git push origin feature/amazing-feature`
98-
7. **Open** a Pull Request
99-
100-
### Development Guidelines
101-
- Follow TypeScript best practices
102-
- Keep code clean and well-documented
103-
- Run `pnpm run lint` before committing
104-
- Write meaningful commit messages
105-
- Test changes in the Extension Development Host
106-
107-
### Code Style
108-
- Use TypeScript with strict mode enabled
109-
- Follow ESLint rules (run `pnpm run lint`)
110-
- Use descriptive variable and function names
111-
- Add comments for complex logic
112-
11392
## License
11493

11594
This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.
@@ -126,15 +105,9 @@ Please include:
126105
- Steps to reproduce (for bugs)
127106
- Expected vs actual behavior
128107
- VS Code version and OS
108+
- Extension version
129109

130-
## 📊Project Statistics
131-
132-
- **Language:** TypeScript
133-
- **VS Code API:** 1.108.2+
134-
- **License:** MIT
135-
- **Status:** Active Development
136-
137-
## 💬 Questions?
110+
## Questions?
138111

139112
Have questions? Feel free to:
140113
- Open a [Discussion](https://github.com/KebanFiru/CodeCount/discussions)

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "CodeLineCounter",
33
"displayName": "CodeLineCounter",
44
"description": "A tool for learn how much line of code your project contains",
5-
"version": "1.0.2",
5+
"version": "2.0.0",
66
"publisher": "KebanFiru",
77
"license": "MIT",
88
"homepage": "https://github.com/KebanFiru/CodeCount#readme",
@@ -63,6 +63,10 @@
6363
"command": "codecount.refreshStats",
6464
"title": "Refresh CodeCount Stats"
6565
},
66+
{
67+
"command": "codecount.openAnalytics",
68+
"title": "Open Analytics Dashboard"
69+
},
6670
{
6771
"command": "codecount.gitRepoMissing",
6872
"title": "Git Repo Missing"

src/extension.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { WorkspaceLineCounter } from './services/WorkspaceLineCounter';
66
import { LineCounterByFileFormat } from './services/LineCounterByFileFormat';
77
import { StatsTreeProvider } from './views/StatsTreeProvider';
88
import { StatsService } from './services/StatsService';
9+
import { StatsWebviewPanel } from './views/StatsWebviewPanel';
910

1011
export function activate(context: vscode.ExtensionContext) {
1112
const lineCounter = new LineCounter();
@@ -15,6 +16,45 @@ export function activate(context: vscode.ExtensionContext) {
1516
const statsService = new StatsService(lineCounter, gitignoreService);
1617
const statsProvider = new StatsTreeProvider(statsService);
1718

19+
let branchRefreshTimer: ReturnType<typeof setTimeout> | undefined;
20+
const scheduleBranchRefresh = () => {
21+
if (branchRefreshTimer) {
22+
clearTimeout(branchRefreshTimer);
23+
}
24+
branchRefreshTimer = setTimeout(() => {
25+
gitignoreService.clearCache();
26+
statsProvider.refresh();
27+
StatsWebviewPanel.refreshIfOpen();
28+
branchRefreshTimer = undefined;
29+
}, 150);
30+
};
31+
32+
void (async () => {
33+
const gitDirPath = await statsService.getGitDirPath();
34+
if (!gitDirPath) {
35+
return;
36+
}
37+
38+
const gitRoot = await statsService.getGitRootPath();
39+
if (!gitRoot) {
40+
return;
41+
}
42+
43+
const watchers = [
44+
vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(gitRoot, '.git/HEAD')),
45+
vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(gitRoot, '.git/refs/heads/**')),
46+
vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(gitRoot, '.git/packed-refs')),
47+
vscode.workspace.createFileSystemWatcher('**/.gitignore')
48+
];
49+
50+
for (const watcher of watchers) {
51+
watcher.onDidChange(scheduleBranchRefresh, undefined, context.subscriptions);
52+
watcher.onDidCreate(scheduleBranchRefresh, undefined, context.subscriptions);
53+
watcher.onDidDelete(scheduleBranchRefresh, undefined, context.subscriptions);
54+
context.subscriptions.push(watcher);
55+
}
56+
})();
57+
1858
const fileline = vscode.commands.registerCommand('codecount.countLines', () => {
1959
const editor = vscode.window.activeTextEditor;
2060
if (!editor) {
@@ -73,6 +113,11 @@ export function activate(context: vscode.ExtensionContext) {
73113

74114
const refreshStats = vscode.commands.registerCommand('codecount.refreshStats', () => {
75115
statsProvider.refresh();
116+
StatsWebviewPanel.refreshIfOpen();
117+
});
118+
119+
const openAnalytics = vscode.commands.registerCommand('codecount.openAnalytics', () => {
120+
StatsWebviewPanel.createOrShow(context.extensionUri, statsService);
76121
});
77122

78123
const gitRepoMissing = vscode.commands.registerCommand('codecount.gitRepoMissing', () => {
@@ -149,6 +194,7 @@ export function activate(context: vscode.ExtensionContext) {
149194
context.subscriptions.push(fileslines);
150195
context.subscriptions.push(fileslinesByExtension);
151196
context.subscriptions.push(refreshStats);
197+
context.subscriptions.push(openAnalytics);
152198
context.subscriptions.push(gitRepoMissing);
153199
context.subscriptions.push(openContributorFile);
154200
context.subscriptions.push(

0 commit comments

Comments
 (0)