github-contribution-art 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 RadosavAntonio
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.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # github-contribution-art
2
+
3
+ Fill your GitHub contribution graph with pixel art — each year's graph spells out that year's number in dark green squares on a light green background.
4
+
5
+ ```
6
+ 2019 → "2019" in dark green
7
+ 2020 → "2020" in dark green
8
+ ...
9
+ ```
10
+
11
+ ## Prerequisites
12
+
13
+ 1. **Node.js 18+** — [nodejs.org](https://nodejs.org)
14
+ 2. **Git** — [git-scm.com](https://git-scm.com)
15
+ 3. **A public GitHub repo** — create one at [github.com/new](https://github.com/new) (name it `contributions`, leave it empty)
16
+ 4. **Git identity configured** — must match your GitHub account email:
17
+ ```bash
18
+ git config --global user.name "Your Name"
19
+ git config --global user.email "you@example.com"
20
+ ```
21
+ 5. **Verified email on GitHub** — go to [github.com/settings/emails](https://github.com/settings/emails) and confirm the email matches your git config
22
+
23
+ ## Usage
24
+
25
+ ```bash
26
+ npx github-contribution-art
27
+ ```
28
+
29
+ The CLI will ask you:
30
+
31
+ 1. **Which years to fill** — multiselect from 2015 to current year (2019–2025 pre-selected)
32
+ 2. **GitHub repo URL** — e.g. `https://github.com/yourname/contributions.git`
33
+ 3. **Confirmation** — shows total commit count before doing anything destructive
34
+
35
+ Then it creates backdated commits locally and force-pushes to your repo. Takes ~20–30 minutes. Your GitHub graph updates within a few minutes of the push.
36
+
37
+ ## How it works
38
+
39
+ - **Light green squares** = 3 commits/day (background fill)
40
+ - **Dark green squares** = 15 commits/day (year number pixels)
41
+ - Uses a 5×7 pixel font centred in the 52-week contribution graph
42
+ - Commits use `GIT_AUTHOR_DATE` / `GIT_COMMITTER_DATE` to backdate
43
+
44
+ ## Notes
45
+
46
+ - The local working repo is created at `~/contributions-filler` and is reset on every run (it is disposable — the real output is on GitHub)
47
+ - Force-push overwrites whatever is on the remote's `main` branch — use a dedicated repo
48
+ - GitHub counts contributions from commits where the author email matches a verified account email
49
+
50
+ ---
51
+
52
+ Made with ❤️ in UK
package/bin/cli.js ADDED
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { checkbox, input, confirm } from '@inquirer/prompts'
4
+ import { homedir } from 'os'
5
+ import { join } from 'path'
6
+ import { buildSchedule } from '../src/art.js'
7
+ import { checkIdentity, initRepo, makeCommit, setRemote, push } from '../src/git.js'
8
+
9
+ const currentYear = new Date().getFullYear()
10
+
11
+ async function main() {
12
+ console.log('\ngithub-contribution-art\n')
13
+
14
+ const identity = checkIdentity()
15
+ console.log(`Git identity: ${identity.name} <${identity.email}>\n`)
16
+
17
+ const years = await checkbox({
18
+ message: 'Which years to fill? (space to select, enter to confirm)',
19
+ choices: Array.from({ length: currentYear - 2015 + 1 }, (_, i) => {
20
+ const y = 2015 + i
21
+ return { name: String(y), value: y, checked: y >= 2019 && y <= currentYear - 1 }
22
+ }),
23
+ validate: v => v.length > 0 || 'Select at least one year',
24
+ })
25
+
26
+ const repoUrl = await input({
27
+ message: 'GitHub repo URL (e.g. https://github.com/you/contributions.git):',
28
+ validate: v => {
29
+ if (!v.includes('github.com')) return 'Enter a valid GitHub URL'
30
+ if (v.includes('username/')) return 'Replace "username" with your actual GitHub username'
31
+ return true
32
+ },
33
+ })
34
+
35
+ const repoDir = join(homedir(), 'contributions-filler')
36
+
37
+ console.log('\nBuilding schedule...')
38
+ const schedule = buildSchedule(years)
39
+ const dates = [...schedule.keys()].sort()
40
+ const total = [...schedule.values()].reduce((a, b) => a + b, 0)
41
+ console.log(`${dates.length} days | ${total} commits`)
42
+
43
+ const ok = await confirm({
44
+ message: `Create ${total} commits and force-push to ${repoUrl}?`,
45
+ default: true,
46
+ })
47
+ if (!ok) { console.log('Aborted.'); process.exit(0) }
48
+
49
+ console.log('\nInitialising repo...')
50
+ initRepo(repoDir)
51
+ setRemote(repoDir, repoUrl)
52
+
53
+ console.log('Creating commits (this takes ~20–30 min)...\n')
54
+ let done = 0
55
+ for (let i = 0; i < dates.length; i++) {
56
+ const d = dates[i]
57
+ const n = schedule.get(d)
58
+ for (let h = 0; h < n; h++) {
59
+ makeCommit(repoDir, d, 8 + (h % 10), Math.floor(h / 10))
60
+ done++
61
+ }
62
+ if (i % 50 === 0 || i === dates.length - 1) {
63
+ const pct = ((i + 1) / dates.length * 100).toFixed(1)
64
+ process.stdout.write(`\r ${pct.padStart(5)}% day ${String(i + 1).padStart(4)}/${dates.length} commits ${String(done).padStart(6)}/${total}`)
65
+ }
66
+ }
67
+
68
+ console.log('\n\nPushing to GitHub...')
69
+ push(repoDir)
70
+ console.log('\nDone! Your contribution graph will update in a few minutes.')
71
+ console.log(`\nMake sure ${identity.email} is verified on your GitHub account:`)
72
+ console.log(' github.com/settings/emails')
73
+ }
74
+
75
+ main().catch(err => {
76
+ console.error('\nError:', err.message)
77
+ process.exit(1)
78
+ })
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "github-contribution-art",
3
+ "version": "1.0.0",
4
+ "description": "Fill your GitHub contribution graph with pixel art year numbers",
5
+ "type": "module",
6
+ "bin": {
7
+ "github-contribution-art": "./bin/cli.js"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "src"
12
+ ],
13
+ "dependencies": {
14
+ "@inquirer/prompts": "^7.4.0"
15
+ },
16
+ "engines": {
17
+ "node": ">=18"
18
+ },
19
+ "keywords": [
20
+ "github",
21
+ "contributions",
22
+ "pixel-art",
23
+ "cli",
24
+ "git"
25
+ ],
26
+ "license": "MIT",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/RadosavAntonio/github-contribution-art.git"
30
+ },
31
+ "homepage": "https://github.com/RadosavAntonio/github-contribution-art#readme"
32
+ }
package/src/art.js ADDED
@@ -0,0 +1,84 @@
1
+ const DIGITS = {
2
+ '0': ['01110','10001','10001','10001','10001','10001','01110'],
3
+ '1': ['00100','01100','00100','00100','00100','00100','01110'],
4
+ '2': ['01110','10001','00001','00110','01000','10000','11111'],
5
+ '3': ['11110','00001','00001','01110','00001','00001','11110'],
6
+ '4': ['10001','10001','10001','11111','00001','00001','00001'],
7
+ '5': ['11111','10000','10000','11110','00001','00001','11110'],
8
+ '6': ['01111','10000','10000','11110','10001','10001','01110'],
9
+ '7': ['11111','00001','00010','00100','01000','01000','01000'],
10
+ '8': ['01110','10001','10001','01110','10001','10001','01110'],
11
+ '9': ['01110','10001','10001','01111','00001','00010','01100'],
12
+ }
13
+
14
+ const LIGHT = 3
15
+ const DARK = 15
16
+
17
+ function addDays(date, n) {
18
+ const d = new Date(date)
19
+ d.setUTCDate(d.getUTCDate() + n)
20
+ return d
21
+ }
22
+
23
+ function dateStr(d) {
24
+ return d.toISOString().slice(0, 10)
25
+ }
26
+
27
+ function pixelColumns(text) {
28
+ const cols = []
29
+ for (let i = 0; i < text.length; i++) {
30
+ if (i > 0) cols.push(new Array(7).fill(0))
31
+ const rows = DIGITS[text[i]]
32
+ for (let c = 0; c < 5; c++) {
33
+ cols.push(Array.from({ length: 7 }, (_, r) => parseInt(rows[r][c])))
34
+ }
35
+ }
36
+ return cols
37
+ }
38
+
39
+ function yearArtDates(year) {
40
+ const pcols = pixelColumns(String(year))
41
+ const startCol = Math.floor((52 - pcols.length) / 2)
42
+
43
+ const jan1 = new Date(Date.UTC(year, 0, 1))
44
+ const firstSunday = addDays(jan1, -jan1.getUTCDay())
45
+
46
+ const art = new Map()
47
+ for (let ci = 0; ci < pcols.length; ci++) {
48
+ const vc = startCol + ci
49
+ for (let row = 0; row < 7; row++) {
50
+ if (!pcols[ci][row]) continue
51
+ const d = addDays(firstSunday, vc * 7 + row)
52
+ if (d.getUTCFullYear() === year) {
53
+ art.set(dateStr(d), DARK)
54
+ }
55
+ }
56
+ }
57
+ return art
58
+ }
59
+
60
+ export function buildSchedule(years) {
61
+ const schedule = new Map()
62
+
63
+ for (const year of years) {
64
+ for (const [d, count] of yearArtDates(year)) {
65
+ schedule.set(d, count)
66
+ }
67
+ }
68
+
69
+ const today = dateStr(new Date())
70
+ const currentYear = new Date().getUTCFullYear()
71
+
72
+ // Fill background only for selected years
73
+ for (const year of years) {
74
+ const endStr = year === currentYear ? today : `${year}-12-31`
75
+ let d = new Date(Date.UTC(year, 0, 1))
76
+ while (dateStr(d) <= endStr) {
77
+ const key = dateStr(d)
78
+ if (!schedule.has(key)) schedule.set(key, LIGHT)
79
+ d = addDays(d, 1)
80
+ }
81
+ }
82
+
83
+ return schedule
84
+ }
package/src/git.js ADDED
@@ -0,0 +1,43 @@
1
+ import { execSync } from 'child_process'
2
+ import { existsSync, mkdirSync, rmSync } from 'fs'
3
+ import { join } from 'path'
4
+
5
+ function run(cmd, opts = {}) {
6
+ execSync(cmd, { stdio: 'pipe', ...opts })
7
+ }
8
+
9
+ export function checkIdentity() {
10
+ try {
11
+ const email = execSync('git config user.email', { stdio: 'pipe' }).toString().trim()
12
+ const name = execSync('git config user.name', { stdio: 'pipe' }).toString().trim()
13
+ if (!email || !name) throw new Error('missing')
14
+ return { email, name }
15
+ } catch {
16
+ console.error('\nGit identity not set. Run:\n git config --global user.email "you@example.com"\n git config --global user.name "Your Name"')
17
+ process.exit(1)
18
+ }
19
+ }
20
+
21
+ export function initRepo(dir) {
22
+ mkdirSync(dir, { recursive: true })
23
+ // always start fresh — local repo is disposable, remote gets force-pushed
24
+ if (existsSync(join(dir, '.git'))) {
25
+ rmSync(join(dir, '.git'), { recursive: true, force: true })
26
+ }
27
+ run('git init -b main', { cwd: dir })
28
+ }
29
+
30
+ export function makeCommit(dir, date, hour, minute) {
31
+ const ts = `${date}T${String(hour).padStart(2, '0')}:${String(minute).padStart(2, '0')}:00`
32
+ const env = { ...process.env, GIT_AUTHOR_DATE: ts, GIT_COMMITTER_DATE: ts }
33
+ execSync('git commit --allow-empty -m "update"', { cwd: dir, env, stdio: 'pipe' })
34
+ }
35
+
36
+ export function setRemote(dir, url) {
37
+ try { run('git remote remove origin', { cwd: dir }) } catch {}
38
+ run(`git remote add origin ${url}`, { cwd: dir })
39
+ }
40
+
41
+ export function push(dir) {
42
+ execSync('git push -u origin main --force', { cwd: dir, stdio: 'inherit' })
43
+ }