gitskins 0.1.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 +21 -0
- package/README.md +173 -0
- package/action.yml +69 -0
- package/bin/gitskins.js +101 -0
- package/package.json +56 -0
- package/src/commands/init.js +120 -0
- package/src/commands/portrait.js +58 -0
- package/src/commands/render.js +71 -0
- package/src/constants.js +73 -0
- package/src/gitignore.js +47 -0
- package/src/portrait.js +157 -0
- package/src/render.js +146 -0
- package/src/util.js +103 -0
- package/templates/workflow.yml +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GitSkins
|
|
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,173 @@
|
|
|
1
|
+
# gitskins
|
|
2
|
+
|
|
3
|
+
**Self-updating GitHub profile widgets, committed to your repo.**
|
|
4
|
+
|
|
5
|
+
Most profile-widget services (including plain GitSkins image URLs) hot-link an
|
|
6
|
+
image on every README view. That means a broken image whenever the service is
|
|
7
|
+
slow or down, render traffic that scales with *your* popularity, and animations
|
|
8
|
+
that GitHub's sanitizer strips out.
|
|
9
|
+
|
|
10
|
+
This CLI takes the opposite approach — the same one that makes build-time SVG
|
|
11
|
+
tools reliable: it **renders your GitSkins widgets to static files and commits
|
|
12
|
+
them into your repo**, then a GitHub Action refreshes them on a schedule. Your
|
|
13
|
+
README points at local files, so it always loads instantly and never breaks.
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx gitskins init
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`init` will:
|
|
22
|
+
|
|
23
|
+
1. Ask for your GitHub username and theme.
|
|
24
|
+
2. Write a `.gitskins.json` config.
|
|
25
|
+
3. Add a GitHub Action at `.github/workflows/gitskins.yml`.
|
|
26
|
+
4. Render your widgets once into `.gitskins/`.
|
|
27
|
+
5. Print a Markdown snippet to paste into your README.
|
|
28
|
+
|
|
29
|
+
Commit the config, the `.gitskins/` folder, and the workflow, then push. The
|
|
30
|
+
Action re-renders your widgets **daily** (and whenever you edit the config) and
|
|
31
|
+
commits the updated images automatically.
|
|
32
|
+
|
|
33
|
+
> On GitHub, enable **Settings → Actions → General → Workflow permissions →
|
|
34
|
+
> Read and write** so the Action can commit refreshed widgets.
|
|
35
|
+
|
|
36
|
+
`init` also scaffolds the workflow pinned to the CLI version that generated it
|
|
37
|
+
(reproducible runs) and, if your `.gitignore` would exclude the output folder,
|
|
38
|
+
adds a negation rule so the generated widgets stay tracked.
|
|
39
|
+
|
|
40
|
+
### Using the composite Action instead
|
|
41
|
+
|
|
42
|
+
If you'd rather not manage the workflow yourself, the package also ships a
|
|
43
|
+
composite Action:
|
|
44
|
+
|
|
45
|
+
```yaml
|
|
46
|
+
name: GitSkins
|
|
47
|
+
on:
|
|
48
|
+
schedule: [{ cron: "0 6 * * *" }]
|
|
49
|
+
workflow_dispatch:
|
|
50
|
+
permissions:
|
|
51
|
+
contents: write
|
|
52
|
+
jobs:
|
|
53
|
+
refresh:
|
|
54
|
+
runs-on: ubuntu-latest
|
|
55
|
+
steps:
|
|
56
|
+
- uses: actions/checkout@v4
|
|
57
|
+
- uses: gitskins/gitskins/cli@v0.1.0
|
|
58
|
+
with:
|
|
59
|
+
version: "0.1.0" # npm version of the CLI to run
|
|
60
|
+
strict: "false" # fail the job on any widget error
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
It exposes a `changed` output (`true`/`false`) so you can chain steps.
|
|
64
|
+
|
|
65
|
+
### Resilience
|
|
66
|
+
|
|
67
|
+
Widget renders are fetched with retries. If GitSkins is briefly unreachable
|
|
68
|
+
during a scheduled run, the CLI **keeps the previously committed image** for
|
|
69
|
+
that widget instead of failing — your README never breaks, and the run stays
|
|
70
|
+
green. Pass `--strict` (or `strict: "true"` in the Action) to fail loudly
|
|
71
|
+
instead. A first run with no cached copy and no successful render exits non-zero.
|
|
72
|
+
|
|
73
|
+
## Commands
|
|
74
|
+
|
|
75
|
+
| Command | What it does |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| `gitskins init` | Scaffold config + Action and render once |
|
|
78
|
+
| `gitskins render` | Re-render the widgets in `.gitskins.json` |
|
|
79
|
+
| `gitskins portrait <image>` | Convert a local photo to an ASCII-art SVG |
|
|
80
|
+
| `gitskins help` | Show help |
|
|
81
|
+
|
|
82
|
+
### `init` options
|
|
83
|
+
|
|
84
|
+
| Flag | Default | Description |
|
|
85
|
+
| --- | --- | --- |
|
|
86
|
+
| `--username <name>` | *(prompted)* | GitHub username |
|
|
87
|
+
| `--theme <name>` | `github-dark` | Theme id (e.g. `satan`, `neon`, `dracula`) |
|
|
88
|
+
| `--output-dir <dir>` | `.gitskins` | Where widget files are written |
|
|
89
|
+
| `--base-url <url>` | `https://gitskins.com` | GitSkins instance to render from |
|
|
90
|
+
| `--skip-render` | | Scaffold without rendering |
|
|
91
|
+
| `--force` | | Overwrite an existing config |
|
|
92
|
+
|
|
93
|
+
### `render` options
|
|
94
|
+
|
|
95
|
+
`--username`, `--theme`, and `--base-url` override the config for a single run
|
|
96
|
+
(useful in CI). Add `--snippet` to also print the README Markdown, or `--strict`
|
|
97
|
+
to fail the run on any widget error even when a cached copy was kept.
|
|
98
|
+
|
|
99
|
+
### `gitskins portrait`
|
|
100
|
+
|
|
101
|
+
Turns a local photo into a clean, monochrome **ASCII-art SVG** that types itself
|
|
102
|
+
in like a terminal — the subject isolated on a dark terminal window. It commits
|
|
103
|
+
as a static file, so nothing is hot-linked.
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
npx gitskins portrait me.jpg --remove-bg --out .gitskins/portrait.svg
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Quality comes from three things, in order: **background removal** (so a busy
|
|
110
|
+
background doesn't become ASCII noise), **CLAHE local contrast** (lifts a flatly
|
|
111
|
+
lit face out of a grey blob), and a single ink color with a good density ramp.
|
|
112
|
+
|
|
113
|
+
For the cutout you have two options:
|
|
114
|
+
|
|
115
|
+
- **`--remove-bg`** runs a background-removal model locally (first run downloads
|
|
116
|
+
it, ~a minute), or
|
|
117
|
+
- **pass a transparent PNG** you cut out yourself — its alpha channel is used
|
|
118
|
+
directly as the mask.
|
|
119
|
+
|
|
120
|
+
Without either, the whole frame is rendered, so use a plain background.
|
|
121
|
+
|
|
122
|
+
| Flag | Default | Description |
|
|
123
|
+
| --- | --- | --- |
|
|
124
|
+
| `<image>` | *(required)* | Photo to convert (first argument) |
|
|
125
|
+
| `--remove-bg` | | Isolate the subject with the background-removal model |
|
|
126
|
+
| `--cols` / `--rows` | `96` / `51` | Grid size |
|
|
127
|
+
| `--invert` | | For light subjects on dark backgrounds |
|
|
128
|
+
| `--out <file>` | `portrait.svg` | Output path |
|
|
129
|
+
| `--title <text>` | `me@github: ~$ ./portrait.sh` | Terminal title line |
|
|
130
|
+
| `--ink <hex>` | `#c9d1d9` | ASCII color |
|
|
131
|
+
|
|
132
|
+
The image tools are heavy and only used here, so they're **optional** — install
|
|
133
|
+
them when you want the command:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
npm install -g sharp @imgly/background-removal-node
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`sharp` is required; `@imgly/background-removal-node` is only needed for
|
|
140
|
+
`--remove-bg`. (Prefer the always-available hosted version? The web app renders
|
|
141
|
+
one from your GitHub avatar at `/api/section/portrait?username=<you>`.)
|
|
142
|
+
|
|
143
|
+
## Configuration
|
|
144
|
+
|
|
145
|
+
`.gitskins.json`:
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"username": "torvalds",
|
|
150
|
+
"theme": "satan",
|
|
151
|
+
"outputDir": ".gitskins",
|
|
152
|
+
"widgets": ["card", "languages", "streak", "stats"]
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Available widgets: `card`, `languages`, `streak`, `stats`.
|
|
157
|
+
|
|
158
|
+
## How it compares to hot-linking
|
|
159
|
+
|
|
160
|
+
| | Hot-linked image URL | Committed via this CLI |
|
|
161
|
+
| --- | --- | --- |
|
|
162
|
+
| README load when GitSkins is slow/down | Broken image | Loads instantly (local file) |
|
|
163
|
+
| Render traffic | Every viewer hits the API | Once per scheduled refresh |
|
|
164
|
+
| Freshness | Live, but rate-limited | Refreshed daily by the Action |
|
|
165
|
+
| Works offline / in forks | No | Yes |
|
|
166
|
+
|
|
167
|
+
## Requirements
|
|
168
|
+
|
|
169
|
+
Node.js 18+. No dependencies.
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
MIT
|
package/action.yml
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
name: 'GitSkins'
|
|
2
|
+
description: 'Render themed GitHub profile widgets to committed files so your README never hot-links gitskins.com.'
|
|
3
|
+
author: 'gitskins'
|
|
4
|
+
|
|
5
|
+
branding:
|
|
6
|
+
icon: 'image'
|
|
7
|
+
color: 'purple'
|
|
8
|
+
|
|
9
|
+
inputs:
|
|
10
|
+
version:
|
|
11
|
+
description: 'Version of the gitskins npm package to run (e.g. 0.1.0, or "latest").'
|
|
12
|
+
required: false
|
|
13
|
+
default: 'latest'
|
|
14
|
+
strict:
|
|
15
|
+
description: 'Fail the job if any widget fails, even when a cached copy is kept.'
|
|
16
|
+
required: false
|
|
17
|
+
default: 'false'
|
|
18
|
+
base_url:
|
|
19
|
+
description: 'GitSkins instance to render from.'
|
|
20
|
+
required: false
|
|
21
|
+
default: ''
|
|
22
|
+
commit_message:
|
|
23
|
+
description: 'Commit message for the auto-commit.'
|
|
24
|
+
required: false
|
|
25
|
+
default: 'chore(gitskins): refresh profile widgets'
|
|
26
|
+
auto_commit:
|
|
27
|
+
description: 'Whether to auto-commit and push refreshed widgets.'
|
|
28
|
+
required: false
|
|
29
|
+
default: 'true'
|
|
30
|
+
|
|
31
|
+
outputs:
|
|
32
|
+
changed:
|
|
33
|
+
description: 'Whether any widget file changed (true/false).'
|
|
34
|
+
value: ${{ steps.commit.outputs.changed }}
|
|
35
|
+
|
|
36
|
+
runs:
|
|
37
|
+
using: 'composite'
|
|
38
|
+
steps:
|
|
39
|
+
- name: Setup Node.js
|
|
40
|
+
uses: actions/setup-node@v4
|
|
41
|
+
with:
|
|
42
|
+
node-version: '20'
|
|
43
|
+
|
|
44
|
+
- name: Render widgets
|
|
45
|
+
shell: bash
|
|
46
|
+
run: |
|
|
47
|
+
npx --yes gitskins@${{ inputs.version }} render \
|
|
48
|
+
${{ inputs.strict == 'true' && '--strict' || '' }} \
|
|
49
|
+
${{ inputs.base_url != '' && format('--base-url "{0}"', inputs.base_url) || '' }}
|
|
50
|
+
|
|
51
|
+
- name: Commit and push changes
|
|
52
|
+
id: commit
|
|
53
|
+
if: inputs.auto_commit == 'true'
|
|
54
|
+
shell: bash
|
|
55
|
+
run: |
|
|
56
|
+
git config user.name "github-actions[bot]"
|
|
57
|
+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
58
|
+
|
|
59
|
+
# Stage everything the CLI may have written (the output dir lives in the config).
|
|
60
|
+
git add -A
|
|
61
|
+
|
|
62
|
+
if git diff --cached --quiet; then
|
|
63
|
+
echo "No widget changes."
|
|
64
|
+
echo "changed=false" >> "$GITHUB_OUTPUT"
|
|
65
|
+
else
|
|
66
|
+
git commit -m "${{ inputs.commit_message }}"
|
|
67
|
+
git push
|
|
68
|
+
echo "changed=true" >> "$GITHUB_OUTPUT"
|
|
69
|
+
fi
|
package/bin/gitskins.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* GitSkins CLI
|
|
4
|
+
*
|
|
5
|
+
* Commit self-updating, themed GitHub profile widgets to your repo instead of
|
|
6
|
+
* hot-linking gitskins.com in your README.
|
|
7
|
+
*
|
|
8
|
+
* npx gitskins init scaffold config + GitHub Action, render once
|
|
9
|
+
* npx gitskins render refresh the committed widget files
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { initCommand } from '../src/commands/init.js';
|
|
13
|
+
import { renderCommand } from '../src/commands/render.js';
|
|
14
|
+
import { portraitCommand } from '../src/commands/portrait.js';
|
|
15
|
+
import { log } from '../src/util.js';
|
|
16
|
+
|
|
17
|
+
const HELP = `
|
|
18
|
+
${log.bold('gitskins')} — self-updating GitHub profile widgets
|
|
19
|
+
|
|
20
|
+
${log.bold('Usage')}
|
|
21
|
+
npx gitskins <command> [options]
|
|
22
|
+
|
|
23
|
+
${log.bold('Commands')}
|
|
24
|
+
init Scaffold .gitskins.json + a GitHub Action, then render once
|
|
25
|
+
render Re-render the widgets defined in .gitskins.json
|
|
26
|
+
portrait Render a local photo to an ASCII-art SVG (subject on dark)
|
|
27
|
+
help Show this help
|
|
28
|
+
|
|
29
|
+
${log.bold('init options')}
|
|
30
|
+
--username <name> GitHub username (prompted if omitted)
|
|
31
|
+
--theme <name> Theme id (default: github-dark)
|
|
32
|
+
--output-dir <dir> Where to write widgets (default: .gitskins)
|
|
33
|
+
--base-url <url> GitSkins instance (default: https://gitskins.com)
|
|
34
|
+
--skip-render Scaffold without the first render
|
|
35
|
+
--force Overwrite an existing .gitskins.json
|
|
36
|
+
|
|
37
|
+
${log.bold('render options')}
|
|
38
|
+
--username / --theme / --base-url Override the config for this run
|
|
39
|
+
--snippet Also print the README markdown snippet
|
|
40
|
+
--strict Exit non-zero if any widget fails, even if a
|
|
41
|
+
previously committed copy was kept
|
|
42
|
+
|
|
43
|
+
${log.bold('portrait options')}
|
|
44
|
+
<image> Photo to convert (first argument, required)
|
|
45
|
+
--remove-bg Isolate the subject with the background-removal model
|
|
46
|
+
--cols / --rows Grid size (default 96×51)
|
|
47
|
+
--invert For light photos on dark backgrounds
|
|
48
|
+
--out <file> Output path (default: portrait.svg)
|
|
49
|
+
--title <text> Terminal title line
|
|
50
|
+
Needs the optional deps: npm i -g sharp @imgly/background-removal-node
|
|
51
|
+
|
|
52
|
+
${log.bold('Examples')}
|
|
53
|
+
npx gitskins init --username torvalds --theme satan
|
|
54
|
+
npx gitskins render --snippet
|
|
55
|
+
npx gitskins portrait me.jpg --remove-bg --out .gitskins/portrait.svg
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
async function main() {
|
|
59
|
+
const [command, ...argv] = process.argv.slice(2);
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
switch (command) {
|
|
63
|
+
case 'init':
|
|
64
|
+
await initCommand(argv);
|
|
65
|
+
break;
|
|
66
|
+
case 'render':
|
|
67
|
+
case 'refresh':
|
|
68
|
+
await renderCommand(argv);
|
|
69
|
+
break;
|
|
70
|
+
case 'portrait':
|
|
71
|
+
await portraitCommand(argv);
|
|
72
|
+
break;
|
|
73
|
+
case undefined:
|
|
74
|
+
case 'help':
|
|
75
|
+
case '--help':
|
|
76
|
+
case '-h':
|
|
77
|
+
console.log(HELP);
|
|
78
|
+
break;
|
|
79
|
+
case '--version':
|
|
80
|
+
case '-v': {
|
|
81
|
+
const { readFile } = await import('node:fs/promises');
|
|
82
|
+
const { fileURLToPath } = await import('node:url');
|
|
83
|
+
const { resolve, dirname } = await import('node:path');
|
|
84
|
+
const pkg = JSON.parse(
|
|
85
|
+
await readFile(resolve(dirname(fileURLToPath(import.meta.url)), '../package.json'), 'utf8')
|
|
86
|
+
);
|
|
87
|
+
console.log(pkg.version);
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
default:
|
|
91
|
+
log.error(`Unknown command: ${command}`);
|
|
92
|
+
console.log(HELP);
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
} catch (err) {
|
|
96
|
+
log.error(err?.message || String(err));
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gitskins",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Commit self-updating, themed GitHub profile widgets to your repo — no more hot-linking. Renders GitSkins cards to static SVG/PNG files via a GitHub Action.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"gitskins": "bin/gitskins.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "node --test",
|
|
11
|
+
"prepublishOnly": "node --test"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=18"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"bin",
|
|
18
|
+
"src",
|
|
19
|
+
"templates",
|
|
20
|
+
"action.yml",
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE"
|
|
23
|
+
],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"github",
|
|
26
|
+
"readme",
|
|
27
|
+
"profile",
|
|
28
|
+
"svg",
|
|
29
|
+
"widget",
|
|
30
|
+
"gitskins",
|
|
31
|
+
"github-action",
|
|
32
|
+
"cli"
|
|
33
|
+
],
|
|
34
|
+
"homepage": "https://gitskins.com",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/asamassekou10/GitSkins.git",
|
|
38
|
+
"directory": "cli"
|
|
39
|
+
},
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/asamassekou10/GitSkins/issues"
|
|
42
|
+
},
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"sharp": "^0.34.0",
|
|
46
|
+
"@imgly/background-removal-node": "^1.4.5"
|
|
47
|
+
},
|
|
48
|
+
"peerDependenciesMeta": {
|
|
49
|
+
"sharp": {
|
|
50
|
+
"optional": true
|
|
51
|
+
},
|
|
52
|
+
"@imgly/background-removal-node": {
|
|
53
|
+
"optional": true
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/** `gitskins init` — scaffold config + GitHub Action, print the README snippet. */
|
|
2
|
+
|
|
3
|
+
import { readFile, writeFile, mkdir } from 'node:fs/promises';
|
|
4
|
+
import { existsSync } from 'node:fs';
|
|
5
|
+
import { resolve, dirname } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
import { createInterface } from 'node:readline/promises';
|
|
9
|
+
import { log, writeConfig, configExists, parseFlags } from '../util.js';
|
|
10
|
+
import { DEFAULT_THEME, DEFAULT_OUTPUT_DIR, DEFAULT_WIDGETS, DEFAULT_BASE_URL, WIDGETS } from '../constants.js';
|
|
11
|
+
import { renderAll, markdownSnippet } from '../render.js';
|
|
12
|
+
import { auditGitignore } from '../gitignore.js';
|
|
13
|
+
|
|
14
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
const WORKFLOW_TEMPLATE = resolve(here, '../../templates/workflow.yml');
|
|
16
|
+
const { version: CLI_VERSION } = createRequire(import.meta.url)('../../package.json');
|
|
17
|
+
|
|
18
|
+
async function prompt(question, fallback) {
|
|
19
|
+
if (!process.stdin.isTTY) return fallback;
|
|
20
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
21
|
+
try {
|
|
22
|
+
const suffix = fallback ? ` (${fallback})` : '';
|
|
23
|
+
const answer = (await rl.question(`${question}${suffix}: `)).trim();
|
|
24
|
+
return answer || fallback;
|
|
25
|
+
} finally {
|
|
26
|
+
rl.close();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function writeWorkflow(cwd) {
|
|
31
|
+
const dest = resolve(cwd, '.github/workflows/gitskins.yml');
|
|
32
|
+
if (existsSync(dest)) {
|
|
33
|
+
log.warn('.github/workflows/gitskins.yml already exists — left untouched.');
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
await mkdir(dirname(dest), { recursive: true });
|
|
37
|
+
const template = (await readFile(WORKFLOW_TEMPLATE, 'utf8')).replaceAll(
|
|
38
|
+
'__CLI_VERSION__',
|
|
39
|
+
CLI_VERSION,
|
|
40
|
+
);
|
|
41
|
+
await writeFile(dest, template);
|
|
42
|
+
log.ok('Added GitHub Action → .github/workflows/gitskins.yml');
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function initCommand(argv) {
|
|
47
|
+
const flags = parseFlags(argv);
|
|
48
|
+
const cwd = process.cwd();
|
|
49
|
+
|
|
50
|
+
if (configExists(cwd) && !flags.force) {
|
|
51
|
+
log.warn('.gitskins.json already exists. Re-run with --force to overwrite.');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
log.info(log.bold('\nGitSkins — set up self-updating profile widgets\n'));
|
|
56
|
+
|
|
57
|
+
const username =
|
|
58
|
+
flags.username || (await prompt('GitHub username', ''));
|
|
59
|
+
if (!username) {
|
|
60
|
+
log.error('A GitHub username is required. Pass --username <name>.');
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
const theme = flags.theme || (await prompt('Theme', DEFAULT_THEME));
|
|
64
|
+
|
|
65
|
+
const config = {
|
|
66
|
+
username,
|
|
67
|
+
theme,
|
|
68
|
+
outputDir: flags['output-dir'] || DEFAULT_OUTPUT_DIR,
|
|
69
|
+
baseUrl: flags['base-url'] || DEFAULT_BASE_URL,
|
|
70
|
+
widgets: DEFAULT_WIDGETS,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const path = await writeConfig(config, cwd);
|
|
74
|
+
log.ok(`Wrote config → ${path.replace(cwd + '/', '')}`);
|
|
75
|
+
|
|
76
|
+
await writeWorkflow(cwd);
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
const added = await auditGitignore(config.outputDir, cwd);
|
|
80
|
+
if (added) log.ok(`Un-ignored generated widgets in .gitignore (${added})`);
|
|
81
|
+
} catch (err) {
|
|
82
|
+
log.warn(`Could not audit .gitignore: ${err.message}`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (flags['skip-render']) {
|
|
86
|
+
log.dim('\nSkipping first render (--skip-render).');
|
|
87
|
+
printNextSteps(config, []);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
log.step(`\nRendering ${config.widgets.length} widgets from ${config.baseUrl} …`);
|
|
92
|
+
const results = await renderAll(config, cwd);
|
|
93
|
+
reportResults(results);
|
|
94
|
+
printNextSteps(config, results);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function reportResults(results) {
|
|
98
|
+
for (const r of results) {
|
|
99
|
+
if (r.ok) log.ok(`${r.label} → ${r.file}`);
|
|
100
|
+
else if (r.cached) log.warn(`${r.label}: ${r.error} — kept existing ${r.file}`);
|
|
101
|
+
else log.error(`${r.label || r.id}: ${r.error}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function printNextSteps(config, results) {
|
|
106
|
+
const snippet = markdownSnippet(results) ||
|
|
107
|
+
config.widgets
|
|
108
|
+
.filter((id) => WIDGETS[id])
|
|
109
|
+
.map((id) => `![${WIDGETS[id].alt.replace('%USER%', config.username)}](${config.outputDir}/${id}.${WIDGETS[id].defaultExt})`)
|
|
110
|
+
.join('\n');
|
|
111
|
+
|
|
112
|
+
log.info('\n' + log.bold('Paste this into your README.md:\n'));
|
|
113
|
+
console.log('```markdown');
|
|
114
|
+
console.log(snippet);
|
|
115
|
+
console.log('```\n');
|
|
116
|
+
log.info(log.bold('Next steps:'));
|
|
117
|
+
log.info(' 1. Commit .gitskins.json, the .gitskins/ folder, and the workflow.');
|
|
118
|
+
log.info(' 2. Push to GitHub — the Action refreshes widgets daily.');
|
|
119
|
+
log.dim(' (Settings → Actions → General → Workflow permissions → Read and write.)\n');
|
|
120
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** `gitskins portrait <image>` — render a local photo to an ASCII-art SVG. */
|
|
2
|
+
|
|
3
|
+
import { writeFile, mkdir } from 'node:fs/promises';
|
|
4
|
+
import { existsSync } from 'node:fs';
|
|
5
|
+
import { resolve, dirname, relative } from 'node:path';
|
|
6
|
+
import { log, parseFlags } from '../util.js';
|
|
7
|
+
import { buildPortraitRows, portraitSvg } from '../portrait.js';
|
|
8
|
+
|
|
9
|
+
export async function portraitCommand(argv) {
|
|
10
|
+
const flags = parseFlags(argv);
|
|
11
|
+
const cwd = process.cwd();
|
|
12
|
+
|
|
13
|
+
// Image path is the first positional argument.
|
|
14
|
+
const image = argv.find((a) => !a.startsWith('--'));
|
|
15
|
+
if (!image) {
|
|
16
|
+
log.error('Usage: gitskins portrait <image> [options]');
|
|
17
|
+
log.dim(' e.g. gitskins portrait me.jpg --remove-bg --out .gitskins/portrait.svg');
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
const imagePath = resolve(cwd, image);
|
|
21
|
+
if (!existsSync(imagePath)) {
|
|
22
|
+
log.error(`Image not found: ${image}`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const cols = flags.cols ? Math.max(24, Math.min(200, Number(flags.cols))) : 96;
|
|
27
|
+
const rows = flags.rows ? Math.max(12, Math.min(120, Number(flags.rows))) : 51;
|
|
28
|
+
const removeBg = Boolean(flags['remove-bg']);
|
|
29
|
+
const invert = Boolean(flags.invert);
|
|
30
|
+
const title = flags.title || `${flags.username || 'me'}@github: ~$ ./portrait.sh`;
|
|
31
|
+
const ink = flags.ink || '#c9d1d9';
|
|
32
|
+
const outPath = resolve(cwd, flags.out || 'portrait.svg');
|
|
33
|
+
|
|
34
|
+
log.step(`Rendering ASCII portrait from ${image}${removeBg ? ' (removing background…)' : ''}`);
|
|
35
|
+
if (removeBg) log.dim(' First run downloads the background-removal model; this can take a moment.');
|
|
36
|
+
|
|
37
|
+
let grid;
|
|
38
|
+
try {
|
|
39
|
+
grid = await buildPortraitRows(imagePath, { cols, rows, removeBg, invert });
|
|
40
|
+
} catch (err) {
|
|
41
|
+
log.error(err.message);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const svg = portraitSvg(grid, { title, ink });
|
|
46
|
+
await mkdir(dirname(outPath), { recursive: true });
|
|
47
|
+
await writeFile(outPath, svg);
|
|
48
|
+
|
|
49
|
+
const rel = relative(cwd, outPath);
|
|
50
|
+
log.ok(`Wrote ${rel} (${(svg.length / 1024).toFixed(1)} KB, ${cols}×${rows})`);
|
|
51
|
+
if (!removeBg) {
|
|
52
|
+
log.dim(' Tip: add --remove-bg for a clean cutout, or pass a transparent PNG.');
|
|
53
|
+
}
|
|
54
|
+
log.info('\n' + log.bold('README snippet:'));
|
|
55
|
+
console.log('```markdown');
|
|
56
|
+
console.log(``);
|
|
57
|
+
console.log('```');
|
|
58
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** `gitskins render` — refresh committed widget files from the config. */
|
|
2
|
+
|
|
3
|
+
import { log, loadConfig, parseFlags } from '../util.js';
|
|
4
|
+
import { renderAll, markdownSnippet } from '../render.js';
|
|
5
|
+
|
|
6
|
+
export async function renderCommand(argv) {
|
|
7
|
+
const flags = parseFlags(argv);
|
|
8
|
+
const cwd = process.cwd();
|
|
9
|
+
|
|
10
|
+
let config;
|
|
11
|
+
try {
|
|
12
|
+
config = await loadConfig(cwd);
|
|
13
|
+
} catch (err) {
|
|
14
|
+
log.error(err.message);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// CLI flags override config (handy in CI / one-off runs).
|
|
19
|
+
if (flags.username) config.username = flags.username;
|
|
20
|
+
if (flags.theme) config.theme = flags.theme;
|
|
21
|
+
if (flags['base-url']) config.baseUrl = flags['base-url'].replace(/\/+$/, '');
|
|
22
|
+
|
|
23
|
+
log.step(`Rendering ${config.widgets.length} widgets for @${config.username} (${config.theme})`);
|
|
24
|
+
|
|
25
|
+
const results = await renderAll(config, cwd);
|
|
26
|
+
|
|
27
|
+
let rendered = 0;
|
|
28
|
+
let cached = 0;
|
|
29
|
+
let lost = 0; // failed with no committed copy to fall back to
|
|
30
|
+
for (const r of results) {
|
|
31
|
+
if (r.ok) {
|
|
32
|
+
rendered++;
|
|
33
|
+
log.ok(`${r.label} → ${r.file} (${(r.bytes / 1024).toFixed(1)} KB)`);
|
|
34
|
+
} else if (r.cached) {
|
|
35
|
+
cached++;
|
|
36
|
+
log.warn(`${r.label}: ${r.error} — kept existing ${r.file}`);
|
|
37
|
+
} else {
|
|
38
|
+
lost++;
|
|
39
|
+
log.error(`${r.label || r.id}: ${r.error}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (flags.snippet) {
|
|
44
|
+
const snippet = markdownSnippet(results);
|
|
45
|
+
if (snippet) {
|
|
46
|
+
log.info('\n' + log.bold('README snippet:'));
|
|
47
|
+
console.log('```markdown');
|
|
48
|
+
console.log(snippet);
|
|
49
|
+
console.log('```');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Exit-code policy, tuned for unattended scheduled runs:
|
|
54
|
+
// --strict → any failure (even one covered by a cached copy) fails.
|
|
55
|
+
// default → fail only when a widget produced no file at all
|
|
56
|
+
// (nothing fresh and nothing cached to fall back to).
|
|
57
|
+
const anyFailure = cached + lost > 0;
|
|
58
|
+
if (flags.strict && anyFailure) {
|
|
59
|
+
log.error(`\n${cached + lost} widget(s) failed (--strict).`);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
if (lost > 0) {
|
|
63
|
+
log.error(`\n${lost} widget(s) failed with no cached copy to keep.`);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
if (cached > 0) {
|
|
67
|
+
log.warn(`\nDone with warnings — ${rendered} refreshed, ${cached} kept from cache.`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
log.ok(`\nDone — ${rendered} widgets up to date.`);
|
|
71
|
+
}
|
package/src/constants.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared constants and widget catalog for the GitSkins CLI.
|
|
3
|
+
*
|
|
4
|
+
* A "widget" is an endpoint under `${baseUrl}/api/<endpoint>` that renders an
|
|
5
|
+
* image. The CLI fetches each one and commits the bytes into the user's repo so
|
|
6
|
+
* their README references a local, self-updating file instead of hot-linking
|
|
7
|
+
* gitskins.com on every view.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const CONFIG_FILENAME = '.gitskins.json';
|
|
11
|
+
export const DEFAULT_BASE_URL = 'https://gitskins.com';
|
|
12
|
+
export const DEFAULT_OUTPUT_DIR = '.gitskins';
|
|
13
|
+
export const DEFAULT_THEME = 'github-dark';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Catalog of renderable widgets, keyed by the id used in `.gitskins.json`.
|
|
17
|
+
* `endpoint` is the path under /api. `label` is used in printed snippets.
|
|
18
|
+
* `alt` is the alt text baked into the generated README markdown.
|
|
19
|
+
*/
|
|
20
|
+
export const WIDGETS = {
|
|
21
|
+
card: {
|
|
22
|
+
endpoint: 'premium-card',
|
|
23
|
+
label: 'Profile Card',
|
|
24
|
+
alt: "%USER%'s GitHub profile",
|
|
25
|
+
// Default extension used only for the pre-render snippet; the actual
|
|
26
|
+
// extension always comes from the response content-type.
|
|
27
|
+
defaultExt: 'svg',
|
|
28
|
+
},
|
|
29
|
+
languages: {
|
|
30
|
+
endpoint: 'languages',
|
|
31
|
+
label: 'Top Languages',
|
|
32
|
+
alt: "%USER%'s most used languages",
|
|
33
|
+
defaultExt: 'png',
|
|
34
|
+
},
|
|
35
|
+
streak: {
|
|
36
|
+
endpoint: 'streak',
|
|
37
|
+
label: 'Contribution Streak',
|
|
38
|
+
alt: "%USER%'s contribution streak",
|
|
39
|
+
defaultExt: 'png',
|
|
40
|
+
},
|
|
41
|
+
stats: {
|
|
42
|
+
endpoint: 'stats',
|
|
43
|
+
label: 'GitHub Stats',
|
|
44
|
+
alt: "%USER%'s GitHub stats",
|
|
45
|
+
defaultExt: 'png',
|
|
46
|
+
},
|
|
47
|
+
portrait: {
|
|
48
|
+
endpoint: 'section/portrait',
|
|
49
|
+
label: 'ASCII Portrait',
|
|
50
|
+
alt: "%USER%'s avatar as an ASCII-art portrait",
|
|
51
|
+
defaultExt: 'svg',
|
|
52
|
+
},
|
|
53
|
+
wordmark: {
|
|
54
|
+
endpoint: 'section/wordmark',
|
|
55
|
+
label: '3D ASCII Wordmark',
|
|
56
|
+
alt: "%USER% as a rotating 3D ASCII wordmark",
|
|
57
|
+
defaultExt: 'svg',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** Widgets included by default when a config is scaffolded. */
|
|
62
|
+
export const DEFAULT_WIDGETS = ['card', 'languages', 'streak', 'stats'];
|
|
63
|
+
|
|
64
|
+
/** Map a response content-type to a file extension. */
|
|
65
|
+
export function extensionForContentType(contentType) {
|
|
66
|
+
if (!contentType) return 'png';
|
|
67
|
+
if (contentType.includes('svg')) return 'svg';
|
|
68
|
+
if (contentType.includes('png')) return 'png';
|
|
69
|
+
if (contentType.includes('jpeg') || contentType.includes('jpg')) return 'jpg';
|
|
70
|
+
if (contentType.includes('gif')) return 'gif';
|
|
71
|
+
if (contentType.includes('webp')) return 'webp';
|
|
72
|
+
return 'png';
|
|
73
|
+
}
|
package/src/gitignore.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensure the generated-widget directory isn't excluded from git.
|
|
3
|
+
*
|
|
4
|
+
* If a repo's .gitignore has a broad rule (e.g. `.g*`, `*skins*`, or an explicit
|
|
5
|
+
* entry) that would drop the output dir, the GitHub Action would render files
|
|
6
|
+
* that never get committed. We detect that with `git check-ignore` and append a
|
|
7
|
+
* negation rule so the widgets are tracked.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { execFileSync } from 'node:child_process';
|
|
11
|
+
import { readFile, writeFile, appendFile } from 'node:fs/promises';
|
|
12
|
+
import { existsSync } from 'node:fs';
|
|
13
|
+
import { resolve } from 'node:path';
|
|
14
|
+
|
|
15
|
+
/** True if `path` is ignored by git in `cwd`. Returns false when git is absent. */
|
|
16
|
+
export function isIgnored(path, cwd = process.cwd()) {
|
|
17
|
+
try {
|
|
18
|
+
execFileSync('git', ['check-ignore', '-q', path], { cwd, stdio: 'ignore' });
|
|
19
|
+
return true; // exit 0 → the path is ignored
|
|
20
|
+
} catch {
|
|
21
|
+
return false; // exit 1 (not ignored) or git missing
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* If `outputDir` is git-ignored, append a negation rule to .gitignore.
|
|
27
|
+
* Returns the rule that was added, or null if nothing needed changing.
|
|
28
|
+
*/
|
|
29
|
+
export async function auditGitignore(outputDir, cwd = process.cwd()) {
|
|
30
|
+
// A representative file path inside the dir, so check-ignore evaluates it even
|
|
31
|
+
// when the dir itself is empty.
|
|
32
|
+
const probe = `${outputDir.replace(/\/+$/, '')}/card.svg`;
|
|
33
|
+
if (!isIgnored(probe, cwd)) return null;
|
|
34
|
+
|
|
35
|
+
const rule = `!/${outputDir.replace(/^\.?\/+/, '').replace(/\/+$/, '')}/`;
|
|
36
|
+
const gitignorePath = resolve(cwd, '.gitignore');
|
|
37
|
+
|
|
38
|
+
if (existsSync(gitignorePath)) {
|
|
39
|
+
const current = await readFile(gitignorePath, 'utf8');
|
|
40
|
+
if (current.split(/\r?\n/).some((line) => line.trim() === rule)) return null;
|
|
41
|
+
const sep = current.endsWith('\n') || current.length === 0 ? '' : '\n';
|
|
42
|
+
await appendFile(gitignorePath, `${sep}\n# Keep GitSkins-generated widgets tracked\n${rule}\n`);
|
|
43
|
+
} else {
|
|
44
|
+
await writeFile(gitignorePath, `# Keep GitSkins-generated widgets tracked\n${rule}\n`);
|
|
45
|
+
}
|
|
46
|
+
return rule;
|
|
47
|
+
}
|
package/src/portrait.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ASCII portrait pipeline for the `gitskins portrait` command.
|
|
3
|
+
*
|
|
4
|
+
* Turns a local photo into a clean, monochrome ASCII-art SVG that "types" itself
|
|
5
|
+
* in like a terminal, then holds — the AVIVASHISHTA make_ascii_svg.py look.
|
|
6
|
+
*
|
|
7
|
+
* The quality comes from three things, in order of importance:
|
|
8
|
+
* 1. Background removal, so a busy background doesn't become ASCII noise. We
|
|
9
|
+
* use the input's own alpha channel as a mask: a pre-cut transparent PNG
|
|
10
|
+
* works directly, and `--remove-bg` runs @imgly's model to create one.
|
|
11
|
+
* 2. CLAHE local contrast, which lifts a flatly-lit face out of a grey blob.
|
|
12
|
+
* 3. A single ink color + a good density ramp — per-character color is what
|
|
13
|
+
* makes ASCII portraits look noisy, so this stays deliberately monochrome.
|
|
14
|
+
*
|
|
15
|
+
* sharp and @imgly/background-removal-node are heavy and only needed here, so
|
|
16
|
+
* they are optional deps loaded on demand; init/render never touch them.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const RAMP = ' .`:-=+*cs#%@'; // bright(sparse) -> dark(dense)
|
|
20
|
+
const GAMMA = 1.18; // >1 pushes mids to the sparse end so faces stay light
|
|
21
|
+
const WHITE_FLOOR = 0.82; // luminance above this (within the subject) reads blank
|
|
22
|
+
|
|
23
|
+
const TERM = { bg: '#0b0e14', bg2: '#111722', bar: '#161b22', border: '#2a3038', muted: '#8b949e' };
|
|
24
|
+
const MONO = "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
|
|
25
|
+
const CELL_W = 8;
|
|
26
|
+
const CELL_H = 15;
|
|
27
|
+
const PAD = 18;
|
|
28
|
+
const TITLEBAR = 34;
|
|
29
|
+
const ROW_DUR = 0.11;
|
|
30
|
+
const STAGGER = 0.11; // == ROW_DUR -> one cursor sweeping top to bottom
|
|
31
|
+
|
|
32
|
+
async function loadSharp() {
|
|
33
|
+
try {
|
|
34
|
+
const mod = await import('sharp');
|
|
35
|
+
return mod.default || mod;
|
|
36
|
+
} catch {
|
|
37
|
+
throw new Error(
|
|
38
|
+
'The portrait command needs "sharp". Install it:\n npm install -g sharp\n' +
|
|
39
|
+
'(or add it to the project you are running gitskins in).',
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Run @imgly background removal, returning a PNG buffer with alpha. */
|
|
45
|
+
async function removeBackground(input) {
|
|
46
|
+
let removeBg;
|
|
47
|
+
try {
|
|
48
|
+
({ removeBackground: removeBg } = await import('@imgly/background-removal-node'));
|
|
49
|
+
} catch {
|
|
50
|
+
throw new Error(
|
|
51
|
+
'The --remove-bg option needs "@imgly/background-removal-node". Install it:\n' +
|
|
52
|
+
' npm install -g @imgly/background-removal-node\n' +
|
|
53
|
+
'Or pre-cut the photo yourself and pass a transparent PNG (its alpha is used as the mask).',
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
const blob = await removeBg(input);
|
|
57
|
+
return Buffer.from(await blob.arrayBuffer());
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Decode `input` (a file path or Buffer) into ASCII rows.
|
|
62
|
+
* Options: { cols, rows, removeBg, invert }.
|
|
63
|
+
*/
|
|
64
|
+
export async function buildPortraitRows(input, options = {}) {
|
|
65
|
+
const cols = options.cols ?? 96;
|
|
66
|
+
const rows = options.rows ?? 51;
|
|
67
|
+
const sharp = await loadSharp();
|
|
68
|
+
|
|
69
|
+
let source = input;
|
|
70
|
+
if (options.removeBg) source = await removeBackground(input);
|
|
71
|
+
|
|
72
|
+
// sharp applies only one resize per pipeline (before clahe), so to run CLAHE
|
|
73
|
+
// at a real resolution we do it in its own pass, then downsample separately.
|
|
74
|
+
// Stage 1: normalise to a working height and apply local contrast.
|
|
75
|
+
const WORK_H = 420;
|
|
76
|
+
const win = 46; // CLAHE window; comfortably smaller than WORK_H
|
|
77
|
+
let stage1 = sharp(source).flatten({ background: '#ffffff' }).greyscale().resize({ height: WORK_H });
|
|
78
|
+
let contrasted;
|
|
79
|
+
try {
|
|
80
|
+
contrasted = await stage1.clahe({ width: win, height: win, maxSlope: 3 }).normalise().png().toBuffer();
|
|
81
|
+
} catch {
|
|
82
|
+
// window-too-large or unsupported input — fall back to global contrast only
|
|
83
|
+
contrasted = await sharp(source).flatten({ background: '#ffffff' }).greyscale().resize({ height: WORK_H }).normalise().png().toBuffer();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Stage 2: downsample the contrasted image to the character grid.
|
|
87
|
+
const { data: lum } = await sharp(contrasted)
|
|
88
|
+
.resize(cols, rows, { fit: 'fill' })
|
|
89
|
+
.toColourspace('b-w')
|
|
90
|
+
.raw()
|
|
91
|
+
.toBuffer({ resolveWithObject: true });
|
|
92
|
+
|
|
93
|
+
// Pass 2: the alpha mask (all-opaque when the source has no transparency).
|
|
94
|
+
const { data: alpha } = await sharp(source)
|
|
95
|
+
.ensureAlpha()
|
|
96
|
+
.resize(cols, rows, { fit: 'fill' })
|
|
97
|
+
.extractChannel(3)
|
|
98
|
+
.raw()
|
|
99
|
+
.toBuffer({ resolveWithObject: true });
|
|
100
|
+
|
|
101
|
+
const lines = [];
|
|
102
|
+
for (let y = 0; y < rows; y++) {
|
|
103
|
+
let s = '';
|
|
104
|
+
for (let x = 0; x < cols; x++) {
|
|
105
|
+
const i = y * cols + x;
|
|
106
|
+
if (alpha[i] < 128) { s += ' '; continue; } // background -> blank
|
|
107
|
+
let l = lum[i] / 255;
|
|
108
|
+
if (options.invert) l = 1 - l;
|
|
109
|
+
l = Math.pow(l, GAMMA);
|
|
110
|
+
if (l >= WHITE_FLOOR) { s += ' '; continue; }
|
|
111
|
+
const idx = Math.max(0, Math.min(RAMP.length - 1, Math.round((1 - l) * (RAMP.length - 1))));
|
|
112
|
+
s += RAMP[idx];
|
|
113
|
+
}
|
|
114
|
+
lines.push(s.replace(/\s+$/, ''));
|
|
115
|
+
}
|
|
116
|
+
return { lines, cols, rows };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function esc(v) {
|
|
120
|
+
return String(v).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Emit the terminal-window SVG with a top-to-bottom row-wipe reveal. */
|
|
124
|
+
export function portraitSvg({ lines, cols }, { title = 'portrait', ink = '#c9d1d9' } = {}) {
|
|
125
|
+
const rowCount = lines.length;
|
|
126
|
+
const artW = cols * CELL_W;
|
|
127
|
+
const artH = rowCount * CELL_H;
|
|
128
|
+
const width = Math.round(artW + PAD * 2);
|
|
129
|
+
const height = Math.round(TITLEBAR + artH + PAD);
|
|
130
|
+
const fontSize = (CELL_H * 0.92).toFixed(1);
|
|
131
|
+
const artTop = TITLEBAR + PAD * 0.4;
|
|
132
|
+
|
|
133
|
+
const body = lines
|
|
134
|
+
.map((line, r) => {
|
|
135
|
+
if (!line.trim()) return '';
|
|
136
|
+
const rowY = artTop + r * CELL_H;
|
|
137
|
+
const textY = (rowY + CELL_H * 0.76).toFixed(1);
|
|
138
|
+
const delay = (r * STAGGER).toFixed(3);
|
|
139
|
+
const off = (r * STAGGER + ROW_DUR).toFixed(3);
|
|
140
|
+
const textEl = `<text xml:space="preserve" x="${PAD}" y="${textY}" font-family="${MONO}" font-size="${fontSize}" fill="${ink}">${esc(line)}</text>`;
|
|
141
|
+
return `<clipPath id="pr${r}"><rect x="${PAD}" y="${rowY.toFixed(1)}" height="${CELL_H}" width="0"><animate attributeName="width" from="0" to="${artW}" begin="${delay}s" dur="${ROW_DUR}s" fill="freeze"/></rect></clipPath>` +
|
|
142
|
+
`<g clip-path="url(#pr${r})">${textEl}</g>` +
|
|
143
|
+
`<rect y="${(rowY + 1).toFixed(1)}" width="${CELL_W}" height="${CELL_H - 2}" fill="${ink}" opacity="0"><animate attributeName="x" from="${PAD}" to="${PAD + artW}" begin="${delay}s" dur="${ROW_DUR}s" fill="freeze"/><set attributeName="opacity" to="0.85" begin="${delay}s"/><set attributeName="opacity" to="0" begin="${off}s"/></rect>`;
|
|
144
|
+
})
|
|
145
|
+
.join('');
|
|
146
|
+
|
|
147
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
148
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" role="img" aria-label="ASCII portrait">
|
|
149
|
+
<defs><linearGradient id="prbg" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="${TERM.bg2}"/><stop offset="1" stop-color="${TERM.bg}"/></linearGradient></defs>
|
|
150
|
+
<rect x="0.5" y="0.5" width="${width - 1}" height="${height - 1}" rx="12" fill="url(#prbg)" stroke="${TERM.border}"/>
|
|
151
|
+
<path d="M0.5 12 a11 11 0 0 1 11 -11 h${width - 23} a11 11 0 0 1 11 11 v22 h-${width - 1} z" fill="${TERM.bar}"/>
|
|
152
|
+
<rect x="0.5" y="${TITLEBAR}" width="${width - 1}" height="1" fill="${TERM.border}"/>
|
|
153
|
+
<circle cx="22" cy="17.5" r="6" fill="#ff5f56"/><circle cx="42" cy="17.5" r="6" fill="#ffbd2e"/><circle cx="62" cy="17.5" r="6" fill="#27c93f"/>
|
|
154
|
+
<text x="${width / 2}" y="22" text-anchor="middle" font-family="${MONO}" font-size="12.5" fill="${TERM.muted}">${esc(title)}</text>
|
|
155
|
+
${body}
|
|
156
|
+
</svg>`;
|
|
157
|
+
}
|
package/src/render.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/** Fetch widgets from a GitSkins instance and write them as committed files. */
|
|
2
|
+
|
|
3
|
+
import { mkdir, writeFile, readdir } from 'node:fs/promises';
|
|
4
|
+
import { resolve, relative } from 'node:path';
|
|
5
|
+
import { WIDGETS, extensionForContentType } from './constants.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Find an already-committed file for a widget id in `outDir`, regardless of
|
|
9
|
+
* extension (e.g. a prior run wrote `card.svg`). Returns the filename or null.
|
|
10
|
+
*/
|
|
11
|
+
async function findExistingWidgetFile(outDir, id) {
|
|
12
|
+
let entries;
|
|
13
|
+
try {
|
|
14
|
+
entries = await readdir(outDir);
|
|
15
|
+
} catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const prefix = `${id}.`;
|
|
19
|
+
return entries.find((name) => name.startsWith(prefix)) ?? null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Read at call time (not module load) so tests and runtime overrides apply.
|
|
23
|
+
// Defaults are unchanged from the documented behavior.
|
|
24
|
+
function retryConfig() {
|
|
25
|
+
return {
|
|
26
|
+
maxAttempts: Number(process.env.GITSKINS_MAX_ATTEMPTS) || 3,
|
|
27
|
+
retryDelayMs:
|
|
28
|
+
process.env.GITSKINS_RETRY_MS !== undefined ? Number(process.env.GITSKINS_RETRY_MS) : 1500,
|
|
29
|
+
timeoutMs: Number(process.env.GITSKINS_TIMEOUT_MS) || 20000,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
34
|
+
|
|
35
|
+
function widgetUrl(baseUrl, endpoint, username, theme) {
|
|
36
|
+
const u = new URL(`${baseUrl}/api/${endpoint}`);
|
|
37
|
+
u.searchParams.set('username', username);
|
|
38
|
+
u.searchParams.set('theme', theme);
|
|
39
|
+
return u.toString();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function fetchOnce(url, timeoutMs) {
|
|
43
|
+
const controller = new AbortController();
|
|
44
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
45
|
+
try {
|
|
46
|
+
const res = await fetch(url, {
|
|
47
|
+
signal: controller.signal,
|
|
48
|
+
headers: { 'user-agent': 'gitskins-cli', accept: 'image/*' },
|
|
49
|
+
});
|
|
50
|
+
if (!res.ok) {
|
|
51
|
+
const detail = await res.text().catch(() => '');
|
|
52
|
+
throw new Error(`HTTP ${res.status}${detail ? ` — ${detail.slice(0, 160)}` : ''}`);
|
|
53
|
+
}
|
|
54
|
+
const contentType = res.headers.get('content-type') || '';
|
|
55
|
+
if (!contentType.startsWith('image/')) {
|
|
56
|
+
throw new Error(`expected an image, got "${contentType || 'unknown'}"`);
|
|
57
|
+
}
|
|
58
|
+
const bytes = Buffer.from(await res.arrayBuffer());
|
|
59
|
+
if (bytes.length === 0) throw new Error('empty response body');
|
|
60
|
+
return { bytes, contentType };
|
|
61
|
+
} finally {
|
|
62
|
+
clearTimeout(timer);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Fetch a single widget with retries. Returns { bytes, ext }. */
|
|
67
|
+
export async function fetchWidget({ baseUrl, endpoint, username, theme }) {
|
|
68
|
+
const url = widgetUrl(baseUrl, endpoint, username, theme);
|
|
69
|
+
const { maxAttempts, retryDelayMs, timeoutMs } = retryConfig();
|
|
70
|
+
let lastErr;
|
|
71
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
72
|
+
try {
|
|
73
|
+
const { bytes, contentType } = await fetchOnce(url, timeoutMs);
|
|
74
|
+
return { bytes, ext: extensionForContentType(contentType), url };
|
|
75
|
+
} catch (err) {
|
|
76
|
+
lastErr = err;
|
|
77
|
+
if (attempt < maxAttempts) await sleep(retryDelayMs * attempt);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
throw new Error(`${url}: ${lastErr.message}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Render every configured widget to `outputDir`.
|
|
85
|
+
*
|
|
86
|
+
* Each result has: { id, label, ok, file?, bytes?, alt?, error?, cached? }.
|
|
87
|
+
* On a fetch failure where a previously-committed file already exists, the old
|
|
88
|
+
* file is left in place and the result is marked `cached: true` (ok: false) —
|
|
89
|
+
* so a transient outage during a scheduled run never wipes good output.
|
|
90
|
+
*/
|
|
91
|
+
export async function renderAll(config, cwd = process.cwd()) {
|
|
92
|
+
const outDir = resolve(cwd, config.outputDir);
|
|
93
|
+
await mkdir(outDir, { recursive: true });
|
|
94
|
+
|
|
95
|
+
const results = [];
|
|
96
|
+
for (const id of config.widgets) {
|
|
97
|
+
const widget = WIDGETS[id];
|
|
98
|
+
if (!widget) {
|
|
99
|
+
results.push({ id, ok: false, error: `unknown widget "${id}"` });
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const alt = widget.alt.replace('%USER%', config.username);
|
|
103
|
+
try {
|
|
104
|
+
const { bytes, ext } = await fetchWidget({
|
|
105
|
+
baseUrl: config.baseUrl,
|
|
106
|
+
endpoint: widget.endpoint,
|
|
107
|
+
username: config.username,
|
|
108
|
+
theme: config.theme,
|
|
109
|
+
});
|
|
110
|
+
const absPath = resolve(outDir, `${id}.${ext}`);
|
|
111
|
+
await writeFile(absPath, bytes);
|
|
112
|
+
results.push({
|
|
113
|
+
id,
|
|
114
|
+
label: widget.label,
|
|
115
|
+
ok: true,
|
|
116
|
+
file: relative(cwd, absPath),
|
|
117
|
+
bytes: bytes.length,
|
|
118
|
+
alt,
|
|
119
|
+
});
|
|
120
|
+
} catch (err) {
|
|
121
|
+
const existing = await findExistingWidgetFile(outDir, id);
|
|
122
|
+
results.push({
|
|
123
|
+
id,
|
|
124
|
+
label: widget.label,
|
|
125
|
+
ok: false,
|
|
126
|
+
error: err.message,
|
|
127
|
+
cached: Boolean(existing),
|
|
128
|
+
file: existing ? relative(cwd, resolve(outDir, existing)) : undefined,
|
|
129
|
+
alt,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return results;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Build the README markdown snippet from render results.
|
|
138
|
+
* Includes any widget that has a file on disk — freshly rendered or a retained
|
|
139
|
+
* cached copy — since both are valid to reference from the README.
|
|
140
|
+
*/
|
|
141
|
+
export function markdownSnippet(results) {
|
|
142
|
+
return results
|
|
143
|
+
.filter((r) => r.file)
|
|
144
|
+
.map((r) => ``)
|
|
145
|
+
.join('\n');
|
|
146
|
+
}
|
package/src/util.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/** Tiny logging + config helpers, kept dependency-free. */
|
|
2
|
+
|
|
3
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { existsSync } from 'node:fs';
|
|
5
|
+
import { resolve } from 'node:path';
|
|
6
|
+
import { CONFIG_FILENAME, DEFAULT_BASE_URL, DEFAULT_OUTPUT_DIR, DEFAULT_THEME, DEFAULT_WIDGETS } from './constants.js';
|
|
7
|
+
|
|
8
|
+
const colors = {
|
|
9
|
+
reset: '\x1b[0m',
|
|
10
|
+
dim: '\x1b[2m',
|
|
11
|
+
bold: '\x1b[1m',
|
|
12
|
+
red: '\x1b[31m',
|
|
13
|
+
green: '\x1b[32m',
|
|
14
|
+
yellow: '\x1b[33m',
|
|
15
|
+
cyan: '\x1b[36m',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const useColor = process.stdout.isTTY && process.env.NO_COLOR === undefined;
|
|
19
|
+
const paint = (c, s) => (useColor ? `${colors[c]}${s}${colors.reset}` : s);
|
|
20
|
+
|
|
21
|
+
export const log = {
|
|
22
|
+
info: (m) => console.log(m),
|
|
23
|
+
step: (m) => console.log(`${paint('cyan', '›')} ${m}`),
|
|
24
|
+
ok: (m) => console.log(`${paint('green', '✓')} ${m}`),
|
|
25
|
+
warn: (m) => console.warn(`${paint('yellow', '!')} ${m}`),
|
|
26
|
+
error: (m) => console.error(`${paint('red', '✗')} ${m}`),
|
|
27
|
+
dim: (m) => console.log(paint('dim', m)),
|
|
28
|
+
bold: (m) => paint('bold', m),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export function fail(message) {
|
|
32
|
+
log.error(message);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function configPath(cwd = process.cwd()) {
|
|
37
|
+
return resolve(cwd, CONFIG_FILENAME);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function configExists(cwd = process.cwd()) {
|
|
41
|
+
return existsSync(configPath(cwd));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Load and normalize `.gitskins.json`, applying defaults. Throws if missing. */
|
|
45
|
+
export async function loadConfig(cwd = process.cwd()) {
|
|
46
|
+
const path = configPath(cwd);
|
|
47
|
+
if (!existsSync(path)) {
|
|
48
|
+
throw new Error(`No ${CONFIG_FILENAME} found. Run \`npx gitskins init\` first.`);
|
|
49
|
+
}
|
|
50
|
+
let raw;
|
|
51
|
+
try {
|
|
52
|
+
raw = JSON.parse(await readFile(path, 'utf8'));
|
|
53
|
+
} catch (err) {
|
|
54
|
+
throw new Error(`Could not parse ${CONFIG_FILENAME}: ${err.message}`);
|
|
55
|
+
}
|
|
56
|
+
if (!raw.username || typeof raw.username !== 'string') {
|
|
57
|
+
throw new Error(`${CONFIG_FILENAME} is missing a "username".`);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
username: raw.username.trim(),
|
|
61
|
+
theme: (raw.theme || DEFAULT_THEME).trim(),
|
|
62
|
+
outputDir: (raw.outputDir || DEFAULT_OUTPUT_DIR).trim(),
|
|
63
|
+
baseUrl: (raw.baseUrl || DEFAULT_BASE_URL).trim().replace(/\/+$/, ''),
|
|
64
|
+
widgets: Array.isArray(raw.widgets) && raw.widgets.length ? raw.widgets : DEFAULT_WIDGETS,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function writeConfig(config, cwd = process.cwd()) {
|
|
69
|
+
const path = configPath(cwd);
|
|
70
|
+
const body = {
|
|
71
|
+
username: config.username,
|
|
72
|
+
theme: config.theme,
|
|
73
|
+
outputDir: config.outputDir,
|
|
74
|
+
widgets: config.widgets,
|
|
75
|
+
};
|
|
76
|
+
if (config.baseUrl && config.baseUrl !== DEFAULT_BASE_URL) {
|
|
77
|
+
body.baseUrl = config.baseUrl;
|
|
78
|
+
}
|
|
79
|
+
await writeFile(path, JSON.stringify(body, null, 2) + '\n');
|
|
80
|
+
return path;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Parse `--key value` / `--key=value` / `--flag` args into an object. */
|
|
84
|
+
export function parseFlags(argv) {
|
|
85
|
+
const flags = {};
|
|
86
|
+
for (let i = 0; i < argv.length; i++) {
|
|
87
|
+
const arg = argv[i];
|
|
88
|
+
if (!arg.startsWith('--')) continue;
|
|
89
|
+
const eq = arg.indexOf('=');
|
|
90
|
+
if (eq !== -1) {
|
|
91
|
+
flags[arg.slice(2, eq)] = arg.slice(eq + 1);
|
|
92
|
+
} else {
|
|
93
|
+
const next = argv[i + 1];
|
|
94
|
+
if (next && !next.startsWith('--')) {
|
|
95
|
+
flags[arg.slice(2)] = next;
|
|
96
|
+
i++;
|
|
97
|
+
} else {
|
|
98
|
+
flags[arg.slice(2)] = true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return flags;
|
|
103
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: GitSkins
|
|
2
|
+
|
|
3
|
+
# Re-renders your GitSkins profile widgets into committed files so your README
|
|
4
|
+
# never hot-links gitskins.com (no broken images when the site is busy, and the
|
|
5
|
+
# widgets refresh on a schedule instead of on every viewer's page load).
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
# Refresh once a day so stats stay current.
|
|
9
|
+
schedule:
|
|
10
|
+
- cron: "0 6 * * *"
|
|
11
|
+
# Also refresh when you edit the config.
|
|
12
|
+
push:
|
|
13
|
+
branches: [main]
|
|
14
|
+
paths:
|
|
15
|
+
- ".gitskins.json"
|
|
16
|
+
# Allow manual runs from the Actions tab.
|
|
17
|
+
workflow_dispatch:
|
|
18
|
+
|
|
19
|
+
permissions:
|
|
20
|
+
contents: write
|
|
21
|
+
|
|
22
|
+
concurrency:
|
|
23
|
+
group: gitskins
|
|
24
|
+
cancel-in-progress: true
|
|
25
|
+
|
|
26
|
+
jobs:
|
|
27
|
+
refresh:
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v4
|
|
31
|
+
|
|
32
|
+
- uses: actions/setup-node@v4
|
|
33
|
+
with:
|
|
34
|
+
node-version: 20
|
|
35
|
+
|
|
36
|
+
- name: Render widgets
|
|
37
|
+
# Pinned for reproducible runs; bump when you want new CLI features.
|
|
38
|
+
run: npx --yes gitskins@__CLI_VERSION__ render
|
|
39
|
+
|
|
40
|
+
- name: Commit refreshed widgets
|
|
41
|
+
run: |
|
|
42
|
+
git config user.name "github-actions[bot]"
|
|
43
|
+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
44
|
+
git add .gitskins
|
|
45
|
+
if git diff --cached --quiet; then
|
|
46
|
+
echo "No widget changes."
|
|
47
|
+
else
|
|
48
|
+
git commit -m "chore(gitskins): refresh profile widgets"
|
|
49
|
+
git push
|
|
50
|
+
fi
|