Skip to content

Commit 90a0d1c

Browse files
committed
Generated by Spark: > github-copilot-usage-analyzer@1.0.0 build
> vite build vite v5.4.19 building for production... transforming... ✓ 3 modules transformed. x Build failed in 91ms error during build: [vite]: Rollup failed to resolve import "@github/spark/spark" from "/home/runner/work/github-copilot-usage/github-copilot-usage/src/main.tsx". This is most likely unintended because it can break your application at runtime. If you do want to externalize this module explicitly add it to `build.rollupOptions.external` at viteWarn (file:///home/runner/work/github-copilot-usage/github-copilot-usage/node_modules/vite/dist/node/chunks/dep-C6uTJdX2.js:65839:17) at onwarn (file:///home/runner/work/github-copilot-usage/github-copilot-usage/node_modules/@vitejs/plugin-react/dist/index.mjs:282:9) at onRollupWarning (file:///home/runner/work/github-copilot-usage/github-copilot-usage/node_modules/vite/dist/node/chunks/dep-C6uTJdX2.js:65869:5) at onwarn (file:///home/runner/work/github-copilot-usage/github-copilot-usage/node_modules/vite/dist/node/chunks/dep-C6uTJdX2.js:65534:7) at file:///home/runner/work/github-copilot-usage/github-copilot-usage/node_modules/rollup/dist/es/shared/node-entry.js:20557:13 at Object.logger [as onLog] (file:///home/runner/work/github-copilot-usage/github-copilot-usage/node_modules/rollup/dist/es/shared/node-entry.js:22286:9) at ModuleLoader.handleInvalidResolvedId (file:///home/runner/work/github-copilot-usage/github-copilot-usage/node_modules/rollup/dist/es/shared/node-entry.js:21169:26) at file:///home/runner/work/github-copilot-usage/github-copilot-usage/node_modules/rollup/dist/es/shared/node-entry.js:21127:26
1 parent fc6351a commit 90a0d1c

5 files changed

Lines changed: 154 additions & 101 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 17 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,34 @@
1-
name: Deploy to GitHub Pages
1+
name: Deploy GitHub Copilot Usage Analyzer
22

33
on:
4-
# Runs on pushes targeting the default branch
54
push:
6-
branches: ['main']
5+
branches:
6+
- main
77

8-
# Allows you to run this workflow manually from the Actions tab
9-
workflow_dispatch:
10-
11-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
128
permissions:
13-
contents: read
14-
pages: write
15-
id-token: write
16-
17-
# Allow only one concurrent deployment
18-
concurrency:
19-
group: "pages"
20-
cancel-in-progress: true
9+
contents: write
2110

2211
jobs:
23-
build:
12+
build-and-deploy:
2413
runs-on: ubuntu-latest
2514
steps:
2615
- name: Checkout
27-
uses: actions/checkout@v4
16+
uses: actions/checkout@v3
17+
2818
- name: Setup Node.js
29-
uses: actions/setup-node@v4
19+
uses: actions/setup-node@v3
3020
with:
31-
node-version: '20'
21+
node-version: 18
3222
cache: 'npm'
33-
- name: Install Dependencies
23+
24+
- name: Install dependencies
3425
run: npm ci
35-
- name: Create Github Pages Build Setup
36-
run: |
37-
# Copy the custom main file for GitHub Pages
38-
cp src/main-github-pages.tsx src/main.tsx
39-
# Create .nojekyll file
40-
touch .nojekyll
41-
# Update package.json homepage to match repository
42-
REPO_NAME="${GITHUB_REPOSITORY#*/}"
43-
USERNAME="${GITHUB_REPOSITORY_OWNER}"
44-
sed -i "s|https://github.com/pages/\[your-username\]/github-copilot-usage/|https://$USERNAME.github.io/$REPO_NAME/|" package.json
26+
4527
- name: Build
46-
run: |
47-
# Set NODE_ENV for proper base path
48-
export NODE_ENV=production
49-
npm run build
50-
- name: Upload artifact
51-
uses: actions/upload-pages-artifact@v3
52-
with:
53-
path: './dist'
54-
# Add .nojekyll file
55-
artifacts: |
56-
./dist
57-
./.nojekyll
28+
run: npm run build:pages
5829

59-
deploy:
60-
environment:
61-
name: github-pages
62-
url: ${{ steps.deployment.outputs.page_url }}
63-
runs-on: ubuntu-latest
64-
needs: build
65-
steps:
6630
- name: Deploy to GitHub Pages
67-
id: deployment
68-
uses: actions/deploy-pages@v4
31+
uses: JamesIves/github-pages-deploy-action@v4
32+
with:
33+
folder: dist
34+
branch: gh-pages

DEPLOYMENT.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Deploying GitHub Copilot Usage Analyzer to GitHub Pages
2+
3+
This document explains how to deploy the GitHub Copilot Usage Analyzer application to GitHub Pages.
4+
5+
## Automatic Deployment with GitHub Actions
6+
7+
This repository includes a GitHub Actions workflow that will automatically build and deploy the application to GitHub Pages whenever changes are pushed to the `main` branch.
8+
9+
### Setup
10+
11+
1. Make sure your repository has GitHub Pages enabled:
12+
- Go to your repository on GitHub
13+
- Navigate to Settings > Pages
14+
- For the Source, select "GitHub Actions"
15+
16+
2. Push your code to the `main` branch:
17+
```bash
18+
git add .
19+
git commit -m "Ready for deployment"
20+
git push origin main
21+
```
22+
23+
3. The GitHub Actions workflow will automatically:
24+
- Build the application using the GitHub Pages configuration
25+
- Deploy the built files to the `gh-pages` branch
26+
- Publish the site to GitHub Pages
27+
28+
4. Once deployed, your site will be available at `https://[your-username].github.io/[repo-name]/`
29+
30+
## Manual Deployment
31+
32+
You can also deploy manually using the npm scripts:
33+
34+
1. Install dependencies if you haven't already:
35+
```bash
36+
npm install
37+
```
38+
39+
2. Build and deploy:
40+
```bash
41+
npm run deploy
42+
```
43+
44+
This will:
45+
- Build the application using the GitHub Pages specific configuration
46+
- Deploy the built files to the `gh-pages` branch
47+
48+
## Configuration
49+
50+
- The application uses a special Vite configuration for GitHub Pages deployment (`vite.github-pages.config.ts`)
51+
- It uses a special version of the main.tsx file without Spark-specific dependencies
52+
- Base URL is set to `'./'` to allow relative paths on GitHub Pages
53+
54+
## Troubleshooting
55+
56+
If you encounter deployment issues:
57+
58+
1. Check the GitHub Actions workflow run for error messages
59+
2. Verify that GitHub Pages is properly configured in your repository settings
60+
3. Make sure all dependencies are properly installed
61+
4. Confirm that the GitHub Pages branch (gh-pages) is correctly set as the publishing source

README.md

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,76 @@
11
# GitHub Copilot Usage Analyzer
22

3-
A web application that visualizes GitHub Copilot premium request usage to help teams monitor and optimize their AI resource consumption.
3+
A single-page application that visualizes GitHub Copilot premium request usage data from CSV exports. This tool helps you understand your team's Copilot usage patterns.
44

55
## Features
66

7-
- Upload GitHub Copilot usage CSV exports
8-
- View stacked line graph of compliant vs. exceeding requests
9-
- See daily usage patterns by model
10-
- Analyze model-specific usage statistics
11-
- Interactive visualizations with tooltips for detailed information
7+
- Upload and parse GitHub Copilot usage CSV data
8+
- Visualize usage over time with interactive charts
9+
- See request distribution by model
10+
- Track compliant vs. exceeding quota requests
11+
- Analyze usage patterns with daily breakdown charts
1212

1313
## Getting Started
1414

15-
### Development
15+
### Prerequisites
1616

17-
1. Clone this repository
18-
2. Install dependencies: `npm install`
19-
3. Start development server: `npm run dev`
20-
4. Open your browser to http://localhost:5000
17+
- Node.js 16+ and npm
2118

22-
### Build
19+
### Installation
2320

24-
To build the application for production:
21+
1. Clone this repository:
22+
```bash
23+
git clone https://github.com/[your-username]/github-copilot-usage.git
24+
cd github-copilot-usage
25+
```
2526

26-
```bash
27-
npm run build
28-
```
29-
30-
## Deployment
31-
32-
### GitHub Pages Deployment
27+
2. Install dependencies:
28+
```bash
29+
npm install
30+
```
3331

34-
The project includes a GitHub Actions workflow that will automatically build and deploy the application to GitHub Pages whenever changes are pushed to the main branch.
32+
3. Start the development server:
33+
```bash
34+
npm run dev
35+
```
3536

36-
#### How to Deploy to GitHub Pages
37+
4. Open http://localhost:5000 in your browser
3738

38-
1. Push your changes to the `main` branch
39-
2. The GitHub Actions workflow will automatically:
40-
- Create a simplified build without Spark dependencies
41-
- Deploy to GitHub Pages
39+
## CSV Format
4240

43-
3. Alternatively, you can manually trigger the deployment:
44-
- Go to the "Actions" tab in your repository
45-
- Select "Deploy to GitHub Pages" workflow
46-
- Click "Run workflow" on the main branch
41+
The application expects a CSV export from GitHub Copilot premium requests with the following format:
4742

48-
4. Your application will be available at:
49-
`https://[your-github-username].github.io/[repo-name]/`
43+
```
44+
"Timestamp","User","Model","Requests Used","Exceeds Monthly Quota","Total Monthly Quota"
45+
"2025-06-11T05:13:27.8766440Z","UserName","gpt-4.1-2025-04-14","1","False","Unlimited"
46+
```
5047

51-
#### Setting Up GitHub Pages for Your Repository
48+
## Deployment
5249

53-
To enable GitHub Pages deployment:
50+
### GitHub Pages
5451

55-
1. Go to your repository on GitHub
56-
2. Click on "Settings"
57-
3. Navigate to "Pages" in the left sidebar
58-
4. Under "Build and deployment" > "Source", select "GitHub Actions"
52+
This project is configured for easy deployment to GitHub Pages. See [DEPLOYMENT.md](DEPLOYMENT.md) for detailed instructions.
5953

60-
For more detailed instructions and troubleshooting, see [GITHUB_PAGES_DEPLOY.md](GITHUB_PAGES_DEPLOY.md).
54+
Quick deploy:
55+
```bash
56+
npm run deploy
57+
```
6158

62-
## How It Works
59+
## Built With
6360

64-
The GitHub Pages deployment handles the fact that GitHub Spark dependencies are not available outside the Spark environment. The workflow:
61+
- React
62+
- TypeScript
63+
- Vite
64+
- Recharts
65+
- shadcn/ui components
66+
- Tailwind CSS
6567

66-
1. Creates a simplified build configuration
67-
2. Implements localStorage-based alternatives to Spark's useKV hooks
68-
3. Builds a fully client-side version of the application
69-
4. Deploys it to GitHub Pages
68+
## License
7069

71-
This approach ensures your application can be shared and accessed outside the Spark development environment.
70+
This project is licensed under the MIT License - see the LICENSE file for details.
7271

73-
## License
72+
## Acknowledgments
7473

75-
The Spark Template files and resources from GitHub are licensed under the terms of the MIT license, Copyright GitHub, Inc.
74+
- GitHub Copilot for helping with development
75+
- The shadcn/ui team for the beautiful components
76+
- Recharts for the charting library

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "github-copilot-usage-analyzer",
33
"private": true,
44
"version": "1.0.0",
5-
"homepage": "https://github.com/pages/[your-username]/github-copilot-usage/",
5+
"homepage": "./",
66
"type": "module",
77
"scripts": {
88
"dev": "vite",
@@ -11,7 +11,7 @@
1111
"lint": "eslint .",
1212
"optimize": "vite optimize",
1313
"preview": "vite preview",
14-
"build:pages": "cp src/main-github-pages.tsx src/main.tsx && vite build && git checkout src/main.tsx",
14+
"build:pages": "cp src/main-github-pages.tsx src/main.tsx && vite build --config vite.github-pages.config.ts && git checkout src/main.tsx",
1515
"predeploy": "npm run build:pages",
1616
"deploy": "gh-pages -d dist"
1717
},

vite.github-pages.config.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { defineConfig } from "vite";
2+
import tailwindcss from "@tailwindcss/vite";
3+
import react from "@vitejs/plugin-react";
4+
import { resolve } from 'path';
5+
6+
// Simple Vite config for GitHub Pages deployment
7+
export default defineConfig({
8+
plugins: [
9+
react(),
10+
tailwindcss(),
11+
],
12+
build: {
13+
outDir: 'dist',
14+
// Set external dependencies that shouldn't be bundled
15+
rollupOptions: {
16+
external: ['@github/spark/spark']
17+
}
18+
},
19+
resolve: {
20+
alias: {
21+
'@': resolve(__dirname, 'src')
22+
}
23+
},
24+
base: './' // Set base for GitHub Pages
25+
});

0 commit comments

Comments
 (0)