Skip to content

Commit b741675

Browse files
committed
style: fix prettier formatting
1 parent 098fffc commit b741675

5 files changed

Lines changed: 65 additions & 30 deletions

File tree

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# 🖼️ GH-SocialPreviewGenerator
22

3-
> ✨ Automagically generate stunning social preview images for all your GitHub repositories!
3+
> ✨ Automagically generate stunning social preview images for all your GitHub
4+
> repositories!
45
5-
Give every repo in your organization a polished, branded first impression. No more boring auto-generated previews!
6+
Give every repo in your organization a polished, branded first impression. No
7+
more boring auto-generated previews!
68

79
## 🎨 What It Does
810

@@ -59,8 +61,8 @@ node dist/index.js generate-all <owner> --dry-run --output-dir ./previews
5961

6062
### Environment Variables
6163

62-
| Variable | Description |
63-
|----------|-------------|
64+
| Variable | Description |
65+
| -------------- | -------------------------------------------- |
6466
| `GITHUB_TOKEN` | GitHub token (alternative to `--token` flag) |
6567

6668
### Token Permissions 🔐
@@ -82,7 +84,8 @@ npm run all
8284

8385
## 🤖 Automated Updates
8486

85-
A weekly workflow runs every **Sunday at midnight UTC** to refresh all social previews across the organization - keeping your stats up to date!
87+
A weekly workflow runs every **Sunday at midnight UTC** to refresh all social
88+
previews across the organization - keeping your stats up to date!
8689

8790
## 📄 License
8891

package.json

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,29 @@
4747
"verbose": true,
4848
"clearMocks": true,
4949
"testEnvironment": "node",
50-
"moduleFileExtensions": ["js", "ts", "tsx"],
51-
"testMatch": ["**/*.test.ts"],
52-
"testPathIgnorePatterns": ["/node_modules/", "/dist/"],
50+
"moduleFileExtensions": [
51+
"js",
52+
"ts",
53+
"tsx"
54+
],
55+
"testMatch": [
56+
"**/*.test.ts"
57+
],
58+
"testPathIgnorePatterns": [
59+
"/node_modules/",
60+
"/dist/"
61+
],
5362
"transform": {
5463
"^.+\\.tsx?$": "ts-jest"
5564
},
56-
"coverageReporters": ["json-summary", "text", "lcov"],
65+
"coverageReporters": [
66+
"json-summary",
67+
"text",
68+
"lcov"
69+
],
5770
"collectCoverage": true,
58-
"collectCoverageFrom": ["./src/**"]
71+
"collectCoverageFrom": [
72+
"./src/**"
73+
]
5974
}
6075
}

src/generator.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ function loadAssets(): { logo: string; logoFull: string; calvin: string } {
6060
const assetsDir = getAssetsDir()
6161
cachedLogo = loadImageAsBase64(path.join(assetsDir, 'logo.png'))
6262
cachedLogoFull = loadImageAsBase64(path.join(assetsDir, 'logo-full.png'))
63-
cachedCalvin = loadImageAsBase64(path.join(assetsDir, 'infographic-calvin.png'))
63+
cachedCalvin = loadImageAsBase64(
64+
path.join(assetsDir, 'infographic-calvin.png')
65+
)
6466

6567
return { logo: cachedLogo, logoFull: cachedLogoFull, calvin: cachedCalvin }
6668
}

src/github.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,13 @@ export class GitHubClient {
112112
): Promise<void> {
113113
// The social preview upload endpoint requires a multipart form upload
114114
// Using the undocumented but stable endpoint
115-
await this.octokit.request(
116-
'PUT /repos/{owner}/{repo}/social-preview',
117-
{
118-
owner,
119-
repo,
120-
headers: {
121-
'content-type': 'image/png'
122-
},
123-
data: imageBuffer
124-
}
125-
)
115+
await this.octokit.request('PUT /repos/{owner}/{repo}/social-preview', {
116+
owner,
117+
repo,
118+
headers: {
119+
'content-type': 'image/png'
120+
},
121+
data: imageBuffer
122+
})
126123
}
127124
}

src/index.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ const program = new Command()
88

99
program
1010
.name('social-preview')
11-
.description('Generate branded social preview images for CodingWithCalvin repositories')
11+
.description(
12+
'Generate branded social preview images for CodingWithCalvin repositories'
13+
)
1214
.version('1.0.0')
1315

1416
program
@@ -18,12 +20,17 @@ program
1820
.argument('<repo>', 'Repository name')
1921
.option('-t, --token <token>', 'GitHub token (or use GITHUB_TOKEN env var)')
2022
.option('-d, --dry-run', 'Generate image locally without uploading', false)
21-
.option('-o, --output <path>', 'Output path for dry-run (default: <repo>.png)')
23+
.option(
24+
'-o, --output <path>',
25+
'Output path for dry-run (default: <repo>.png)'
26+
)
2227
.action(async (owner: string, repo: string, options) => {
2328
const token = options.token || process.env.GITHUB_TOKEN
2429

2530
if (!token && !options.dryRun) {
26-
console.error('Error: GitHub token required. Use --token or set GITHUB_TOKEN env var.')
31+
console.error(
32+
'Error: GitHub token required. Use --token or set GITHUB_TOKEN env var.'
33+
)
2734
process.exit(1)
2835
}
2936

@@ -54,16 +61,23 @@ program
5461

5562
program
5663
.command('generate-all')
57-
.description('Generate and upload social previews for all repositories in an org')
64+
.description(
65+
'Generate and upload social previews for all repositories in an org'
66+
)
5867
.argument('<owner>', 'Organization or user name')
5968
.option('-t, --token <token>', 'GitHub token (or use GITHUB_TOKEN env var)')
6069
.option('-d, --dry-run', 'Generate images locally without uploading', false)
61-
.option('-o, --output-dir <dir>', 'Output directory for dry-run (default: ./previews)')
70+
.option(
71+
'-o, --output-dir <dir>',
72+
'Output directory for dry-run (default: ./previews)'
73+
)
6274
.action(async (owner: string, options) => {
6375
const token = options.token || process.env.GITHUB_TOKEN
6476

6577
if (!token) {
66-
console.error('Error: GitHub token required. Use --token or set GITHUB_TOKEN env var.')
78+
console.error(
79+
'Error: GitHub token required. Use --token or set GITHUB_TOKEN env var.'
80+
)
6781
process.exit(1)
6882
}
6983

@@ -96,12 +110,16 @@ program
96110
}
97111
successCount++
98112
} catch (error) {
99-
console.error(` Error: ${error instanceof Error ? error.message : error}`)
113+
console.error(
114+
` Error: ${error instanceof Error ? error.message : error}`
115+
)
100116
errorCount++
101117
}
102118
}
103119

104-
console.log(`\nCompleted: ${successCount} successful, ${errorCount} failed`)
120+
console.log(
121+
`\nCompleted: ${successCount} successful, ${errorCount} failed`
122+
)
105123

106124
if (errorCount > 0) {
107125
process.exit(1)

0 commit comments

Comments
 (0)