Skip to content

Commit 098fffc

Browse files
committed
feat: initial implementation of social preview generator
Node.js CLI tool that generates branded 1280x640 social preview images for GitHub repositories using Satori and uploads via GitHub API. Features: - Stats sidebar (stars, forks, commits, contributors) - Watermark background with full logo - Calvin mascot avatar - Repo name, description, topics as hashtags - Full URL footer - Single repo or batch org processing
0 parents  commit 098fffc

16 files changed

Lines changed: 6812 additions & 0 deletions

.github/workflows/build.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [main]
7+
paths:
8+
- 'src/**'
9+
- '__tests__/**'
10+
- 'package.json'
11+
- 'package-lock.json'
12+
- 'tsconfig.json'
13+
- '.github/workflows/build.yml'
14+
push:
15+
branches: [main]
16+
paths:
17+
- 'src/**'
18+
- '__tests__/**'
19+
- 'package.json'
20+
- 'package-lock.json'
21+
- 'tsconfig.json'
22+
- '.github/workflows/build.yml'
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Setup Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version-file: .node-version
36+
cache: npm
37+
38+
- name: Install dependencies
39+
run: npm ci
40+
41+
- name: Check formatting
42+
run: npm run format:check
43+
44+
- name: Lint
45+
run: npm run lint
46+
47+
- name: Test
48+
run: npm test
49+
50+
- name: Build
51+
run: npm run build

.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Dependency directory
2+
node_modules
3+
4+
# Logs
5+
logs
6+
*.log
7+
npm-debug.log*
8+
9+
# Coverage
10+
coverage
11+
*.lcov
12+
.nyc_output
13+
14+
# TypeScript cache
15+
*.tsbuildinfo
16+
17+
# Build output
18+
dist
19+
20+
# Environment
21+
.env
22+
.env.test
23+
24+
# OS metadata
25+
.DS_Store
26+
Thumbs.db
27+
28+
# IDE
29+
.idea
30+
.vscode
31+
*.code-workspace
32+
33+
# Test output
34+
__tests__/runner/*
35+
36+
# Generated images (for local testing)
37+
*.generated.png
38+
test-preview.png

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
21.6.2

.prettierrc.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": false,
6+
"singleQuote": true,
7+
"quoteProps": "as-needed",
8+
"jsxSingleQuote": false,
9+
"trailingComma": "none",
10+
"bracketSpacing": true,
11+
"bracketSameLine": true,
12+
"arrowParens": "avoid",
13+
"proseWrap": "always",
14+
"htmlWhitespaceSensitivity": "css",
15+
"endOfLine": "lf"
16+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Calvin Allen / Coding With Calvin
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# 🖼️ GH-SocialPreviewGenerator
2+
3+
> ✨ Automagically generate stunning social preview images for all your GitHub repositories!
4+
5+
Give every repo in your organization a polished, branded first impression. No more boring auto-generated previews!
6+
7+
## 🎨 What It Does
8+
9+
This CLI tool generates beautiful **1280x640** social preview images featuring:
10+
11+
- 📊 **Live Stats** - Stars, forks, commits, and contributors
12+
- 📝 **Repo Info** - Name, description, and topics as hashtags
13+
- 🔗 **Full URL** - Easy to find your project
14+
- 🎭 **Custom Branding** - Your logo and mascot
15+
- 🌊 **Watermark Background** - Subtle branded backdrop
16+
17+
## 🚀 Quick Start
18+
19+
```bash
20+
# Install dependencies
21+
npm install
22+
23+
# Build
24+
npm run build
25+
26+
# Generate a preview (dry run)
27+
node dist/index.js generate CodingWithCalvin MyAwesomeRepo --dry-run
28+
29+
# Generate and upload to GitHub
30+
node dist/index.js generate CodingWithCalvin MyAwesomeRepo --token ghp_xxx
31+
```
32+
33+
## 📖 Usage
34+
35+
### Single Repository
36+
37+
```bash
38+
# Generate and upload
39+
node dist/index.js generate <owner> <repo> --token ghp_xxx
40+
41+
# Dry run (save locally without uploading)
42+
node dist/index.js generate <owner> <repo> --dry-run
43+
44+
# Specify output path
45+
node dist/index.js generate <owner> <repo> --dry-run --output preview.png
46+
```
47+
48+
### All Repositories in Org 🏢
49+
50+
```bash
51+
# Generate and upload all public repos
52+
node dist/index.js generate-all <owner> --token ghp_xxx
53+
54+
# Dry run all
55+
node dist/index.js generate-all <owner> --dry-run --output-dir ./previews
56+
```
57+
58+
## ⚙️ Configuration
59+
60+
### Environment Variables
61+
62+
| Variable | Description |
63+
|----------|-------------|
64+
| `GITHUB_TOKEN` | GitHub token (alternative to `--token` flag) |
65+
66+
### Token Permissions 🔐
67+
68+
Your GitHub token needs the `admin:repo` scope to upload social previews.
69+
70+
## 🛠️ Development
71+
72+
```bash
73+
# Install dependencies
74+
npm install
75+
76+
# Build
77+
npm run build
78+
79+
# Run all checks (format, lint, test, build)
80+
npm run all
81+
```
82+
83+
## 🤖 Automated Updates
84+
85+
A weekly workflow runs every **Sunday at midnight UTC** to refresh all social previews across the organization - keeping your stats up to date!
86+
87+
## 📄 License
88+
89+
MIT License - See [LICENSE](LICENSE) for details.
90+
91+
---
92+
93+
Made with 💙 by [Coding With Calvin](https://codingwithcalvin.net)

assets/infographic-calvin.png

477 KB
Loading

assets/logo-full.png

35.5 KB
Loading

assets/logo.png

6.08 KB
Loading

0 commit comments

Comments
 (0)