gitskins 0.1.0 → 0.3.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/README.md +58 -2
- package/bin/gitskins.js +30 -0
- package/package.json +2 -2
- package/src/commands/portfolio.js +142 -0
- package/src/commands/template.js +145 -0
- package/src/constants.js +6 -0
- package/src/render.js +32 -6
- package/src/template.js +170 -0
- package/src/util.js +7 -0
- package/templates/examples/founder-log.json +31 -0
- package/templates/examples/green-screen.json +34 -0
- package/templates/examples/hire-me-brief.json +30 -0
- package/templates/examples/maintainers-desk.json +31 -0
- package/templates/examples/quiet-pastel.json +28 -0
- package/templates/examples/study-hall.json +33 -0
package/README.md
CHANGED
|
@@ -77,6 +77,7 @@ instead. A first run with no cached copy and no successful render exits non-zero
|
|
|
77
77
|
| `gitskins init` | Scaffold config + Action and render once |
|
|
78
78
|
| `gitskins render` | Re-render the widgets in `.gitskins.json` |
|
|
79
79
|
| `gitskins portrait <image>` | Convert a local photo to an ASCII-art SVG |
|
|
80
|
+
| `gitskins template <action>` | Build, validate and preview a community README template |
|
|
80
81
|
| `gitskins help` | Show help |
|
|
81
82
|
|
|
82
83
|
### `init` options
|
|
@@ -140,6 +141,30 @@ npm install -g sharp @imgly/background-removal-node
|
|
|
140
141
|
`--remove-bg`. (Prefer the always-available hosted version? The web app renders
|
|
141
142
|
one from your GitHub avatar at `/api/section/portrait?username=<you>`.)
|
|
142
143
|
|
|
144
|
+
|
|
145
|
+
### `gitskins template`
|
|
146
|
+
|
|
147
|
+
Make a README template for the [GitSkins gallery](https://www.gitskins.com/readme-generator)
|
|
148
|
+
and get credited in every README built from it. A template is a JSON recipe
|
|
149
|
+
(sections, order, headings, layouts, theme), never code.
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
npx gitskins template init # writes gitskins-template.json
|
|
153
|
+
npx gitskins template validate # checks it offline
|
|
154
|
+
npx gitskins template preview --user torvalds # renders README.preview.md
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
| Action | Description |
|
|
158
|
+
| --- | --- |
|
|
159
|
+
| `init [file]` | Write a starter template (`--example <name>` to start from a ready-made one, `--force` to overwrite) |
|
|
160
|
+
| `examples` | List the ready-made examples |
|
|
161
|
+
| `validate [file]` | Check the template against the GitSkins rules, offline |
|
|
162
|
+
| `preview [file] --user <login>` | Render it with a real GitHub profile; `--pro` for the Pro look, `--out <file>` to choose the output, `--author <login>` for the credit line |
|
|
163
|
+
|
|
164
|
+
When it looks right, submit it at
|
|
165
|
+
[gitskins.com/community-templates](https://www.gitskins.com/community-templates)
|
|
166
|
+
with **Import JSON**. A person reviews every template before it goes live.
|
|
167
|
+
|
|
143
168
|
## Configuration
|
|
144
169
|
|
|
145
170
|
`.gitskins.json`:
|
|
@@ -149,11 +174,21 @@ one from your GitHub avatar at `/api/section/portrait?username=<you>`.)
|
|
|
149
174
|
"username": "torvalds",
|
|
150
175
|
"theme": "satan",
|
|
151
176
|
"outputDir": ".gitskins",
|
|
152
|
-
"widgets": ["card", "languages", "streak", "stats"]
|
|
177
|
+
"widgets": ["card", "languages", "streak", "stats", "projects"],
|
|
178
|
+
"projects": ["torvalds/linux", "git/git", "torvalds/subsurface"]
|
|
153
179
|
}
|
|
154
180
|
```
|
|
155
181
|
|
|
156
|
-
Available widgets: `card`, `languages`, `streak`, `stats
|
|
182
|
+
Available widgets: `card`, `languages`, `streak`, `stats`, `portrait`,
|
|
183
|
+
`wordmark`, `projects`.
|
|
184
|
+
|
|
185
|
+
### Curated projects panel
|
|
186
|
+
|
|
187
|
+
Add the `projects` widget and a `projects` array of `owner/repo` slugs to hand-
|
|
188
|
+
pick and order the repos in your projects panel (instead of relying on GitHub
|
|
189
|
+
pins). GitSkins fills each card with live data — stars, languages (the animated
|
|
190
|
+
donut), topics, and last-push freshness. Edit the list any time; the README
|
|
191
|
+
never changes. Up to 6 repos.
|
|
157
192
|
|
|
158
193
|
## How it compares to hot-linking
|
|
159
194
|
|
|
@@ -171,3 +206,24 @@ Node.js 18+. No dependencies.
|
|
|
171
206
|
## License
|
|
172
207
|
|
|
173
208
|
MIT
|
|
209
|
+
|
|
210
|
+
## Character portfolio with an AI agent
|
|
211
|
+
|
|
212
|
+
Work on your GitSkins character portfolio in Claude Code, Codex, Cursor or any
|
|
213
|
+
agent with a terminal. On gitskins.com, open your portfolio builder and choose
|
|
214
|
+
**Continue with AI → Copy prompt for my agent**, or run the steps yourself:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
npx gitskins portfolio pull "<link from Continue with AI>" my-portfolio
|
|
218
|
+
cd my-portfolio
|
|
219
|
+
npx gitskins portfolio dev # preview at http://localhost:4321
|
|
220
|
+
npx gitskins portfolio status # content changed since pull
|
|
221
|
+
npx gitskins portfolio push # send gitskins.json "content" to GitSkins
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
The folder has an `AGENTS.md` (and `CLAUDE.md`) that tells the agent how the page
|
|
225
|
+
and the character work and what not to break. Wording, projects, look and accent
|
|
226
|
+
go in the `content` section of `gitskins.json`; `push` sends them back to your
|
|
227
|
+
GitSkins portfolio, where they are checked like edits in the builder. Code changes
|
|
228
|
+
stay in your folder; deploy it to any static host if you change code. The push key
|
|
229
|
+
is stored in `.gitskins-portfolio/` (git-ignored) and lasts a week.
|
package/bin/gitskins.js
CHANGED
|
@@ -7,11 +7,14 @@
|
|
|
7
7
|
*
|
|
8
8
|
* npx gitskins init scaffold config + GitHub Action, render once
|
|
9
9
|
* npx gitskins render refresh the committed widget files
|
|
10
|
+
* npx gitskins template build and preview a community README template
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
import { initCommand } from '../src/commands/init.js';
|
|
13
14
|
import { renderCommand } from '../src/commands/render.js';
|
|
14
15
|
import { portraitCommand } from '../src/commands/portrait.js';
|
|
16
|
+
import { templateCommand } from '../src/commands/template.js';
|
|
17
|
+
import { portfolioCommand } from '../src/commands/portfolio.js';
|
|
15
18
|
import { log } from '../src/util.js';
|
|
16
19
|
|
|
17
20
|
const HELP = `
|
|
@@ -24,6 +27,8 @@ ${log.bold('Commands')}
|
|
|
24
27
|
init Scaffold .gitskins.json + a GitHub Action, then render once
|
|
25
28
|
render Re-render the widgets defined in .gitskins.json
|
|
26
29
|
portrait Render a local photo to an ASCII-art SVG (subject on dark)
|
|
30
|
+
template Build, validate and preview a community README template
|
|
31
|
+
portfolio Work on your character portfolio with an AI agent (pull, dev, status, push)
|
|
27
32
|
help Show this help
|
|
28
33
|
|
|
29
34
|
${log.bold('init options')}
|
|
@@ -49,10 +54,29 @@ ${log.bold('portrait options')}
|
|
|
49
54
|
--title <text> Terminal title line
|
|
50
55
|
Needs the optional deps: npm i -g sharp @imgly/background-removal-node
|
|
51
56
|
|
|
57
|
+
${log.bold('template actions')}
|
|
58
|
+
init [file] Write a starter template (default: gitskins-template.json)
|
|
59
|
+
--example <name> Start from a ready-made example instead
|
|
60
|
+
examples List the ready-made examples
|
|
61
|
+
validate [file] Check it against the GitSkins rules, offline
|
|
62
|
+
preview [file] Render it with a real profile to README.preview.md
|
|
63
|
+
--user <login> GitHub profile to render with (required)
|
|
64
|
+
--pro Render the Pro look (terminal cards, animated activity)
|
|
65
|
+
--out <file> Output path (default: README.preview.md)
|
|
66
|
+
--author <login> Whose credit the footer shows (default: the --user profile)
|
|
67
|
+
Submit a finished template at https://www.gitskins.com/community-templates
|
|
68
|
+
|
|
69
|
+
${log.bold('portfolio actions')}
|
|
70
|
+
pull <link> [dir] Download your portfolio (link from "Continue with AI")
|
|
71
|
+
dev [--port 4321] Preview it locally
|
|
72
|
+
status Content changes not pushed yet
|
|
73
|
+
push Send gitskins.json "content" back to GitSkins
|
|
74
|
+
|
|
52
75
|
${log.bold('Examples')}
|
|
53
76
|
npx gitskins init --username torvalds --theme satan
|
|
54
77
|
npx gitskins render --snippet
|
|
55
78
|
npx gitskins portrait me.jpg --remove-bg --out .gitskins/portrait.svg
|
|
79
|
+
npx gitskins template init && npx gitskins template preview --user torvalds
|
|
56
80
|
`;
|
|
57
81
|
|
|
58
82
|
async function main() {
|
|
@@ -70,6 +94,12 @@ async function main() {
|
|
|
70
94
|
case 'portrait':
|
|
71
95
|
await portraitCommand(argv);
|
|
72
96
|
break;
|
|
97
|
+
case 'template':
|
|
98
|
+
await templateCommand(argv);
|
|
99
|
+
break;
|
|
100
|
+
case 'portfolio':
|
|
101
|
+
await portfolioCommand(argv);
|
|
102
|
+
break;
|
|
73
103
|
case undefined:
|
|
74
104
|
case 'help':
|
|
75
105
|
case '--help':
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gitskins",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "GitSkins from the terminal: self-updating profile widgets via a GitHub Action, community README templates, and your character portfolio with AI agents (pull, preview, push).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"gitskins": "bin/gitskins.js"
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gitskins portfolio: work on a GitSkins character portfolio with an AI coding
|
|
3
|
+
* agent (Claude Code, Codex, Cursor) and send the content back.
|
|
4
|
+
*
|
|
5
|
+
* gitskins portfolio pull <link> [dir] download the folder (from "Continue with AI")
|
|
6
|
+
* gitskins portfolio dev [--port 4321] preview it locally
|
|
7
|
+
* gitskins portfolio status show content changes not pushed yet
|
|
8
|
+
* gitskins portfolio push send gitskins.json "content" to GitSkins
|
|
9
|
+
*
|
|
10
|
+
* Dependency-free. The push key lives in .gitskins-portfolio/ (git-ignored), never in gitskins.json.
|
|
11
|
+
*/
|
|
12
|
+
import { createServer } from 'node:http';
|
|
13
|
+
import { existsSync } from 'node:fs';
|
|
14
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
15
|
+
import { dirname, extname, join, normalize, resolve, sep } from 'node:path';
|
|
16
|
+
import { log } from '../util.js';
|
|
17
|
+
|
|
18
|
+
export const SESSION_DIR = '.gitskins-portfolio';
|
|
19
|
+
const SESSION_FILE = join(SESSION_DIR, 'session.json');
|
|
20
|
+
const ALLOWED_HOSTS = /^(?:[a-z0-9-]+\.)*gitskins\.com$|^localhost$|^127\.0\.0\.1$/;
|
|
21
|
+
|
|
22
|
+
const HELP = `Usage:
|
|
23
|
+
gitskins portfolio pull <link> [dir] Download your portfolio (link from "Continue with AI" on gitskins.com)
|
|
24
|
+
gitskins portfolio dev [--port 4321] Preview it at http://localhost:4321
|
|
25
|
+
gitskins portfolio status Show content changes not sent yet
|
|
26
|
+
gitskins portfolio push Send the "content" in gitskins.json to your GitSkins portfolio`;
|
|
27
|
+
|
|
28
|
+
/** Only GitSkins links; the folder JSON format; a safe path for every file. */
|
|
29
|
+
export function bundleRequestUrl(link) {
|
|
30
|
+
let url;
|
|
31
|
+
try { url = new URL(link); } catch { throw new Error('That is not a link. Copy it from "Continue with AI" on gitskins.com.'); }
|
|
32
|
+
if (url.protocol !== 'https:' && !/^(localhost|127\.0\.0\.1)$/.test(url.hostname)) throw new Error('Use the https link from gitskins.com.');
|
|
33
|
+
if (!ALLOWED_HOSTS.test(url.hostname)) throw new Error('Only gitskins.com portfolio links can be pulled.');
|
|
34
|
+
if (!url.pathname.endsWith('/api/agent/portfolio-bundle') || !url.searchParams.get('t')) throw new Error('That is not a GitSkins portfolio link.');
|
|
35
|
+
url.searchParams.set('format', 'json');
|
|
36
|
+
return url;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function safeTarget(root, name) {
|
|
40
|
+
const target = normalize(join(root, name));
|
|
41
|
+
if (!target.startsWith(resolve(root) + sep) || name.includes('\0')) throw new Error(`Refusing to write outside the folder: ${name}`);
|
|
42
|
+
return target;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function pull(link, dir = 'gitskins-portfolio', { fetchImpl = fetch } = {}) {
|
|
46
|
+
const url = bundleRequestUrl(link);
|
|
47
|
+
log.step('Downloading your portfolio…');
|
|
48
|
+
const response = await fetchImpl(url, { headers: { Accept: 'application/json' } });
|
|
49
|
+
const body = await response.json().catch(() => ({}));
|
|
50
|
+
if (!response.ok) throw new Error(body.error || `GitSkins answered ${response.status}.`);
|
|
51
|
+
if (!body.files || typeof body.files !== 'object') throw new Error('GitSkins sent an unexpected answer.');
|
|
52
|
+
const root = resolve(dir);
|
|
53
|
+
await mkdir(root, { recursive: true });
|
|
54
|
+
let count = 0;
|
|
55
|
+
for (const [name, base64] of Object.entries(body.files)) {
|
|
56
|
+
const target = safeTarget(root, name);
|
|
57
|
+
await mkdir(dirname(target), { recursive: true });
|
|
58
|
+
await writeFile(target, Buffer.from(base64, 'base64'));
|
|
59
|
+
count += 1;
|
|
60
|
+
}
|
|
61
|
+
const manifest = JSON.parse(await readFile(join(root, 'gitskins.json'), 'utf8'));
|
|
62
|
+
await mkdir(join(root, SESSION_DIR), { recursive: true });
|
|
63
|
+
await writeFile(join(root, SESSION_FILE), JSON.stringify({ buildId: body.buildId, template: body.template, username: body.username, pushUrl: body.pushUrl, pushToken: body.pushToken, pulledContent: manifest.content ?? {}, pulledAt: new Date().toISOString() }, null, 2));
|
|
64
|
+
// Keep the push key out of git, whatever else the folder becomes.
|
|
65
|
+
const gitignore = join(root, '.gitignore');
|
|
66
|
+
const existing = existsSync(gitignore) ? await readFile(gitignore, 'utf8') : '';
|
|
67
|
+
if (!existing.split('\n').includes(`${SESSION_DIR}/`)) await writeFile(gitignore, `${existing}${existing && !existing.endsWith('\n') ? '\n' : ''}${SESSION_DIR}/\n`);
|
|
68
|
+
log.ok(`Saved ${count} files to ${dir}`);
|
|
69
|
+
log.dim(' Next: read AGENTS.md, then run: npx gitskins portfolio dev');
|
|
70
|
+
return { root, count };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function readSession(root) {
|
|
74
|
+
const file = join(root, SESSION_FILE);
|
|
75
|
+
if (!existsSync(file)) throw new Error('No GitSkins session here. Run this inside a folder made by "gitskins portfolio pull".');
|
|
76
|
+
return JSON.parse(await readFile(file, 'utf8'));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function contentChanges(before = {}, after = {}) {
|
|
80
|
+
const keys = new Set([...Object.keys(before), ...Object.keys(after)]);
|
|
81
|
+
return [...keys].filter((key) => JSON.stringify(before[key]) !== JSON.stringify(after[key])).sort();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export async function status(root = process.cwd()) {
|
|
85
|
+
const session = await readSession(root);
|
|
86
|
+
const { content = {} } = JSON.parse(await readFile(join(root, 'gitskins.json'), 'utf8'));
|
|
87
|
+
const changed = contentChanges(session.pulledContent, content);
|
|
88
|
+
if (!changed.length) log.ok('No content changes to push.');
|
|
89
|
+
else log.info(`Changed since pull: ${changed.join(', ')}`);
|
|
90
|
+
return changed;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export async function push(root = process.cwd(), { fetchImpl = fetch } = {}) {
|
|
94
|
+
const session = await readSession(root);
|
|
95
|
+
const { content } = JSON.parse(await readFile(join(root, 'gitskins.json'), 'utf8'));
|
|
96
|
+
if (!content || typeof content !== 'object') throw new Error('gitskins.json has no "content" section.');
|
|
97
|
+
log.step('Sending your content to GitSkins…');
|
|
98
|
+
const response = await fetchImpl(session.pushUrl, { method: 'POST', headers: { Authorization: `Bearer ${session.pushToken}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ content }) });
|
|
99
|
+
const body = await response.json().catch(() => ({}));
|
|
100
|
+
if (!response.ok) throw new Error(body.error || `GitSkins answered ${response.status}.`);
|
|
101
|
+
if (!body.changed?.length) { log.ok('Already up to date.'); return body; }
|
|
102
|
+
// Keep what GitSkins stored (it checks every field), so status starts clean.
|
|
103
|
+
session.pulledContent = { ...content, ...body.content };
|
|
104
|
+
await writeFile(join(root, SESSION_FILE), JSON.stringify(session, null, 2));
|
|
105
|
+
log.ok(`Updated on GitSkins: ${body.changed.join(', ')}`);
|
|
106
|
+
log.dim(' Open your portfolio builder on gitskins.com to see it. Code changes to index.html stay in this folder.');
|
|
107
|
+
return body;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const TYPES = { '.html': 'text/html; charset=utf-8', '.js': 'text/javascript', '.json': 'application/json', '.webp': 'image/webp', '.png': 'image/png', '.woff2': 'font/woff2', '.md': 'text/markdown; charset=utf-8', '.css': 'text/css' };
|
|
111
|
+
|
|
112
|
+
export function dev(root = process.cwd(), port = 4321) {
|
|
113
|
+
const server = createServer(async (req, res) => {
|
|
114
|
+
try {
|
|
115
|
+
const path = decodeURIComponent(new URL(req.url, 'http://x').pathname);
|
|
116
|
+
const file = safeTarget(root, path === '/' ? 'index.html' : path.slice(1));
|
|
117
|
+
if (file.includes(`${sep}${SESSION_DIR}`)) throw new Error('private');
|
|
118
|
+
const data = await readFile(file);
|
|
119
|
+
res.writeHead(200, { 'Content-Type': TYPES[extname(file)] ?? 'application/octet-stream', 'Cache-Control': 'no-store' });
|
|
120
|
+
res.end(data);
|
|
121
|
+
} catch {
|
|
122
|
+
res.writeHead(404); res.end('Not found');
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
server.listen(port, '127.0.0.1', () => log.ok(`Preview: http://localhost:${port} (edit gitskins.json or index.html, then reload)`));
|
|
126
|
+
return server;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export async function portfolioCommand(argv) {
|
|
130
|
+
const [action, ...tail] = argv;
|
|
131
|
+
const portIndex = tail.indexOf('--port');
|
|
132
|
+
const args = { port: portIndex >= 0 ? tail[portIndex + 1] : undefined };
|
|
133
|
+
const rest = tail.filter((_, i) => i !== portIndex && i !== portIndex + 1 || portIndex < 0);
|
|
134
|
+
if (action === 'pull') {
|
|
135
|
+
if (!rest[0]) throw new Error(`Pass the link.\n${HELP}`);
|
|
136
|
+
return pull(rest[0], rest[1]);
|
|
137
|
+
}
|
|
138
|
+
if (action === 'dev') return dev(process.cwd(), Number(args.port) || 4321);
|
|
139
|
+
if (action === 'status') return status();
|
|
140
|
+
if (action === 'push') return push();
|
|
141
|
+
log.info(HELP);
|
|
142
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `gitskins template <init|validate|preview>`: build a community README
|
|
3
|
+
* template locally, check it against the GitSkins rules, and render it with a
|
|
4
|
+
* real GitHub profile before submitting it at gitskins.com/community-templates.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { readFile, readdir, writeFile, mkdir } from 'node:fs/promises';
|
|
8
|
+
import { existsSync } from 'node:fs';
|
|
9
|
+
import { resolve, dirname, relative, basename } from 'node:path';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import { log, parseFlags } from '../util.js';
|
|
12
|
+
import { DEFAULT_BASE_URL } from '../constants.js';
|
|
13
|
+
import { starterTemplate, templateIsFree, validateTemplate } from '../template.js';
|
|
14
|
+
|
|
15
|
+
const DEFAULT_FILE = 'gitskins-template.json';
|
|
16
|
+
/** Ready-made templates to start from: `gitskins template init --example <name>`. */
|
|
17
|
+
const EXAMPLES_DIR = resolve(dirname(fileURLToPath(import.meta.url)), '../../templates/examples');
|
|
18
|
+
const SUBMIT_URL = 'https://www.gitskins.com/community-templates';
|
|
19
|
+
const GITHUB_LOGIN = /^[a-z\d](?:[a-z\d-]{0,37}[a-z\d])?$/i;
|
|
20
|
+
|
|
21
|
+
const USAGE = `Usage:
|
|
22
|
+
gitskins template init [file] [--example <name>] [--force]
|
|
23
|
+
gitskins template examples
|
|
24
|
+
gitskins template validate [file]
|
|
25
|
+
gitskins template preview [file] --user <github-login> [--pro] [--out <file>]`;
|
|
26
|
+
|
|
27
|
+
const positional = (argv) => argv.filter((arg, index) => !arg.startsWith('--') && !(index > 0 && argv[index - 1].startsWith('--') && !argv[index - 1].includes('=')));
|
|
28
|
+
|
|
29
|
+
async function readTemplate(path) {
|
|
30
|
+
if (!existsSync(path)) throw new Error(`Template not found: ${relative(process.cwd(), path) || path}. Create one with \`gitskins template init\`.`);
|
|
31
|
+
try {
|
|
32
|
+
return JSON.parse(await readFile(path, 'utf8'));
|
|
33
|
+
} catch (err) {
|
|
34
|
+
throw new Error(`Could not parse ${relative(process.cwd(), path)}: ${err.message}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Validate, print problems, and return the cleaned template or null. */
|
|
39
|
+
function check(raw, file) {
|
|
40
|
+
const { template, errors, warnings } = validateTemplate(raw);
|
|
41
|
+
for (const warning of warnings) log.warn(warning);
|
|
42
|
+
if (errors.length) {
|
|
43
|
+
log.error(`${file} has ${errors.length} problem${errors.length === 1 ? '' : 's'}:`);
|
|
44
|
+
for (const error of errors) log.info(` - ${error}`);
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return template;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The bundled example templates, by name. */
|
|
51
|
+
export async function listExamples() {
|
|
52
|
+
const files = (await readdir(EXAMPLES_DIR)).filter((file) => file.endsWith('.json')).sort();
|
|
53
|
+
return Promise.all(files.map(async (file) => ({
|
|
54
|
+
id: basename(file, '.json'),
|
|
55
|
+
template: JSON.parse(await readFile(resolve(EXAMPLES_DIR, file), 'utf8')),
|
|
56
|
+
})));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function examples() {
|
|
60
|
+
for (const { id, template } of await listExamples()) {
|
|
61
|
+
log.info(`${log.bold(id.padEnd(18))} ${templateIsFree(template.recipe) ? 'Free' : 'Pro '} ${template.description}`);
|
|
62
|
+
}
|
|
63
|
+
log.dim('\n Start from one: gitskins template init --example <name>');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function init(argv, flags) {
|
|
67
|
+
const file = positional(argv)[0] || DEFAULT_FILE;
|
|
68
|
+
const path = resolve(process.cwd(), file);
|
|
69
|
+
if (existsSync(path) && !flags.force) throw new Error(`${file} already exists. Use --force to overwrite it.`);
|
|
70
|
+
let template = starterTemplate();
|
|
71
|
+
if (flags.example) {
|
|
72
|
+
const found = (await listExamples()).find(({ id }) => id === flags.example);
|
|
73
|
+
if (!found) throw new Error(`No example called "${flags.example}". See \`gitskins template examples\`.`);
|
|
74
|
+
template = found.template;
|
|
75
|
+
}
|
|
76
|
+
await mkdir(dirname(path), { recursive: true });
|
|
77
|
+
await writeFile(path, JSON.stringify(template, null, 2) + '\n');
|
|
78
|
+
log.ok(`Wrote ${file}${flags.example ? ` from the "${flags.example}" example` : ''}`);
|
|
79
|
+
log.dim(' Edit it, then: gitskins template validate && gitskins template preview --user <your-login>');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function validate(argv) {
|
|
83
|
+
const file = positional(argv)[0] || DEFAULT_FILE;
|
|
84
|
+
const template = check(await readTemplate(resolve(process.cwd(), file)), file);
|
|
85
|
+
if (!template) process.exit(1);
|
|
86
|
+
log.ok(`${file} is a valid template: "${template.name}", ${template.recipe.sectionOrder.length} sections, ${templateIsFree(template.recipe) ? 'Free' : 'Pro'}.`);
|
|
87
|
+
log.dim(` Submit it at ${SUBMIT_URL} (Import JSON).`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function preview(argv, flags) {
|
|
91
|
+
const file = positional(argv)[0] || DEFAULT_FILE;
|
|
92
|
+
const user = typeof flags.user === 'string' ? flags.user.replace(/^@/, '') : '';
|
|
93
|
+
if (!GITHUB_LOGIN.test(user)) throw new Error('Pass the GitHub profile to render with --user <login>.');
|
|
94
|
+
const template = check(await readTemplate(resolve(process.cwd(), file)), file);
|
|
95
|
+
if (!template) process.exit(1);
|
|
96
|
+
|
|
97
|
+
const baseUrl = (typeof flags['base-url'] === 'string' ? flags['base-url'] : DEFAULT_BASE_URL).replace(/\/+$/, '');
|
|
98
|
+
log.step(`Rendering "${template.name}" for @${user}${flags.pro ? ' (Pro look)' : ''}…`);
|
|
99
|
+
const response = await fetch(`${baseUrl}/api/community-templates/preview`, {
|
|
100
|
+
method: 'POST',
|
|
101
|
+
headers: { 'Content-Type': 'application/json', 'User-Agent': 'gitskins-cli' },
|
|
102
|
+
body: JSON.stringify({
|
|
103
|
+
username: user,
|
|
104
|
+
name: template.name,
|
|
105
|
+
recipe: template.recipe,
|
|
106
|
+
look: flags.pro ? 'pro' : 'free',
|
|
107
|
+
...(typeof flags.author === 'string' ? { author: flags.author.replace(/^@/, '') } : {}),
|
|
108
|
+
}),
|
|
109
|
+
});
|
|
110
|
+
const data = await response.json().catch(() => ({}));
|
|
111
|
+
if (!response.ok) throw new Error(data.error || `Preview failed (HTTP ${response.status}).`);
|
|
112
|
+
|
|
113
|
+
const out = typeof flags.out === 'string' ? flags.out : 'README.preview.md';
|
|
114
|
+
const outPath = resolve(process.cwd(), out);
|
|
115
|
+
await mkdir(dirname(outPath), { recursive: true });
|
|
116
|
+
await writeFile(outPath, data.markdown.endsWith('\n') ? data.markdown : `${data.markdown}\n`);
|
|
117
|
+
log.ok(`Wrote ${relative(process.cwd(), outPath)} (${data.pricing === 'free' ? 'Free' : 'Pro'} template)`);
|
|
118
|
+
log.dim(' Open it in a Markdown preview, or paste it into a GitHub gist to see it as GitHub does.');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export async function templateCommand(argv) {
|
|
122
|
+
const [action, ...rest] = argv;
|
|
123
|
+
const flags = parseFlags(rest);
|
|
124
|
+
switch (action) {
|
|
125
|
+
case 'init':
|
|
126
|
+
return init(rest, flags);
|
|
127
|
+
case 'examples':
|
|
128
|
+
return examples();
|
|
129
|
+
case 'validate':
|
|
130
|
+
case 'check':
|
|
131
|
+
return validate(rest);
|
|
132
|
+
case 'preview':
|
|
133
|
+
return preview(rest, flags);
|
|
134
|
+
case undefined:
|
|
135
|
+
case 'help':
|
|
136
|
+
case '--help':
|
|
137
|
+
case '-h':
|
|
138
|
+
log.info(USAGE);
|
|
139
|
+
return undefined;
|
|
140
|
+
default:
|
|
141
|
+
log.error(`Unknown template action: ${action}`);
|
|
142
|
+
log.info(USAGE);
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
}
|
package/src/constants.js
CHANGED
|
@@ -56,6 +56,12 @@ export const WIDGETS = {
|
|
|
56
56
|
alt: "%USER% as a rotating 3D ASCII wordmark",
|
|
57
57
|
defaultExt: 'svg',
|
|
58
58
|
},
|
|
59
|
+
projects: {
|
|
60
|
+
endpoint: 'section/projects',
|
|
61
|
+
label: 'Projects Panel',
|
|
62
|
+
alt: "%USER%'s featured projects",
|
|
63
|
+
defaultExt: 'svg',
|
|
64
|
+
},
|
|
59
65
|
};
|
|
60
66
|
|
|
61
67
|
/** Widgets included by default when a config is scaffolded. */
|
package/src/render.js
CHANGED
|
@@ -32,10 +32,27 @@ function retryConfig() {
|
|
|
32
32
|
|
|
33
33
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const MAX_WIDGET_BYTES = 10 * 1024 * 1024;
|
|
36
|
+
|
|
37
|
+
function validateBaseUrl(value) {
|
|
38
|
+
const url = new URL(value);
|
|
39
|
+
if (url.username || url.password || url.search || url.hash) {
|
|
40
|
+
throw new Error('baseUrl must not contain credentials, query parameters, or a fragment');
|
|
41
|
+
}
|
|
42
|
+
const isLocalHttp = url.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
|
|
43
|
+
if (url.protocol !== 'https:' && !isLocalHttp) {
|
|
44
|
+
throw new Error('baseUrl must use HTTPS, except for localhost development');
|
|
45
|
+
}
|
|
46
|
+
return url;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function widgetUrl(baseUrl, endpoint, username, theme, extraParams = {}) {
|
|
50
|
+
const u = new URL(`/api/${endpoint}`, `${validateBaseUrl(baseUrl).origin}/`);
|
|
37
51
|
u.searchParams.set('username', username);
|
|
38
52
|
u.searchParams.set('theme', theme);
|
|
53
|
+
for (const [key, value] of Object.entries(extraParams)) {
|
|
54
|
+
if (value) u.searchParams.set(key, value);
|
|
55
|
+
}
|
|
39
56
|
return u.toString();
|
|
40
57
|
}
|
|
41
58
|
|
|
@@ -45,11 +62,13 @@ async function fetchOnce(url, timeoutMs) {
|
|
|
45
62
|
try {
|
|
46
63
|
const res = await fetch(url, {
|
|
47
64
|
signal: controller.signal,
|
|
65
|
+
redirect: 'error',
|
|
48
66
|
headers: { 'user-agent': 'gitskins-cli', accept: 'image/*' },
|
|
49
67
|
});
|
|
50
68
|
if (!res.ok) {
|
|
51
|
-
|
|
52
|
-
|
|
69
|
+
// Do not echo arbitrary upstream bodies into CLI errors. Widget
|
|
70
|
+
// endpoints can return HTML, stack traces, or reflected request data.
|
|
71
|
+
throw new Error(`HTTP ${res.status}`);
|
|
53
72
|
}
|
|
54
73
|
const contentType = res.headers.get('content-type') || '';
|
|
55
74
|
if (!contentType.startsWith('image/')) {
|
|
@@ -57,6 +76,7 @@ async function fetchOnce(url, timeoutMs) {
|
|
|
57
76
|
}
|
|
58
77
|
const bytes = Buffer.from(await res.arrayBuffer());
|
|
59
78
|
if (bytes.length === 0) throw new Error('empty response body');
|
|
79
|
+
if (bytes.length > MAX_WIDGET_BYTES) throw new Error('response body is too large');
|
|
60
80
|
return { bytes, contentType };
|
|
61
81
|
} finally {
|
|
62
82
|
clearTimeout(timer);
|
|
@@ -64,8 +84,8 @@ async function fetchOnce(url, timeoutMs) {
|
|
|
64
84
|
}
|
|
65
85
|
|
|
66
86
|
/** 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);
|
|
87
|
+
export async function fetchWidget({ baseUrl, endpoint, username, theme, extraParams }) {
|
|
88
|
+
const url = widgetUrl(baseUrl, endpoint, username, theme, extraParams);
|
|
69
89
|
const { maxAttempts, retryDelayMs, timeoutMs } = retryConfig();
|
|
70
90
|
let lastErr;
|
|
71
91
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
@@ -100,12 +120,18 @@ export async function renderAll(config, cwd = process.cwd()) {
|
|
|
100
120
|
continue;
|
|
101
121
|
}
|
|
102
122
|
const alt = widget.alt.replace('%USER%', config.username);
|
|
123
|
+
// Curated projects: a `projects` array in the config picks/orders repos.
|
|
124
|
+
const extraParams =
|
|
125
|
+
id === 'projects' && Array.isArray(config.projects) && config.projects.length
|
|
126
|
+
? { repos: config.projects.join(',') }
|
|
127
|
+
: undefined;
|
|
103
128
|
try {
|
|
104
129
|
const { bytes, ext } = await fetchWidget({
|
|
105
130
|
baseUrl: config.baseUrl,
|
|
106
131
|
endpoint: widget.endpoint,
|
|
107
132
|
username: config.username,
|
|
108
133
|
theme: config.theme,
|
|
134
|
+
extraParams,
|
|
109
135
|
});
|
|
110
136
|
const absPath = resolve(outDir, `${id}.${ext}`);
|
|
111
137
|
await writeFile(absPath, bytes);
|
package/src/template.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Community README templates, for the `gitskins template` commands.
|
|
3
|
+
*
|
|
4
|
+
* A template file is JSON: a name, description and category, plus a `recipe`
|
|
5
|
+
* that tells GitSkins' renderer which sections to draw, in which order, under
|
|
6
|
+
* which headings, with which layouts and theme. It is never code or markup.
|
|
7
|
+
*
|
|
8
|
+
* These rules mirror the server's (src/lib/community-templates.ts) without any
|
|
9
|
+
* dependency, so `validate` works offline. A parity test in the GitSkins repo
|
|
10
|
+
* runs both validators on the same cases, so they cannot drift apart.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const TEMPLATE_SECTIONS = ['header', 'about', 'skills', 'stats', 'projects', 'highlights', 'heatmap', 'connect'];
|
|
14
|
+
export const TEMPLATE_CATEGORIES = ['recruiter', 'open-source', 'creative', 'technical'];
|
|
15
|
+
export const TEMPLATE_THEMES = [
|
|
16
|
+
'matrix', 'github-dark', 'neon', 'dracula',
|
|
17
|
+
'midnight', 'winter', 'aurora', 'ocean', 'forest',
|
|
18
|
+
'satan', 'halloween', 'summer', 'sunset', 'autumn', 'retro', 'christmas',
|
|
19
|
+
'minimal', 'pastel', 'zen', 'spring',
|
|
20
|
+
];
|
|
21
|
+
export const FREE_TEMPLATE_THEMES = ['satan', 'neon', 'zen', 'github-dark'];
|
|
22
|
+
export const TEMPLATE_VARIANTS = {
|
|
23
|
+
hero: ['profile', 'statement', 'terminal', 'portfolio'],
|
|
24
|
+
about: ['brief', 'manifest', 'story', 'learning', 'systems', 'community'],
|
|
25
|
+
skills: ['badges', 'stack', 'language-list', 'toolbox'],
|
|
26
|
+
stats: ['signal', 'metrics', 'activity', 'progress'],
|
|
27
|
+
projects: ['cards', 'impact', 'details', 'case-studies', 'repos'],
|
|
28
|
+
};
|
|
29
|
+
export const TEMPLATE_PRO_LOOK = {
|
|
30
|
+
cardStyle: ['aura', 'terminal'],
|
|
31
|
+
heatmap: ['aura', 'jet', 'erased', 'snake'],
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const SAFE_TEXT = /^[\p{L}\p{N}\p{M}\p{Extended_Pictographic}️ .,:;'’"“”&+/?!()@–—·-]+$/u;
|
|
35
|
+
const RECIPE_KEYS = new Set(['version', 'theme', 'sectionOrder', 'headings', ...Object.keys(TEMPLATE_VARIANTS), ...Object.keys(TEMPLATE_PRO_LOOK)]);
|
|
36
|
+
const FILE_KEYS = new Set(['$schema', 'name', 'description', 'category', 'recipe', 'allowRemix']);
|
|
37
|
+
|
|
38
|
+
const isObject = (value) => Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
39
|
+
const list = (values) => values.map((value) => `"${value}"`).join(', ');
|
|
40
|
+
|
|
41
|
+
/** Collapse whitespace, then check length, characters and links. Returns [value, error]. */
|
|
42
|
+
function safeText(label, value, min, max) {
|
|
43
|
+
if (typeof value !== 'string') return [null, `${label} must be text.`];
|
|
44
|
+
const clean = value.replace(/\s+/g, ' ').trim();
|
|
45
|
+
if (clean.length < min) return [null, `${label} needs at least ${min} characters.`];
|
|
46
|
+
if (clean.length > max) return [null, `${label} can be at most ${max} characters.`];
|
|
47
|
+
if (!SAFE_TEXT.test(clean)) return [null, `${label} can use letters, numbers, emoji and simple punctuation only.`];
|
|
48
|
+
if (/:\/\/|www\./i.test(clean)) return [null, `${label} cannot contain links.`];
|
|
49
|
+
return [clean, null];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Validate a recipe. Returns `{ recipe, errors, warnings }`; `recipe` is the
|
|
54
|
+
* cleaned value the server would store, or null when there are errors.
|
|
55
|
+
*/
|
|
56
|
+
export function validateRecipe(input) {
|
|
57
|
+
const errors = [];
|
|
58
|
+
const warnings = [];
|
|
59
|
+
if (!isObject(input)) return { recipe: null, errors: ['"recipe" must be an object.'], warnings };
|
|
60
|
+
|
|
61
|
+
for (const key of Object.keys(input)) {
|
|
62
|
+
if (!RECIPE_KEYS.has(key)) warnings.push(`recipe.${key} is not a recipe field and will be ignored.`);
|
|
63
|
+
}
|
|
64
|
+
if (input.version !== undefined && input.version !== 1) errors.push('recipe.version must be 1.');
|
|
65
|
+
if (!TEMPLATE_THEMES.includes(input.theme)) errors.push(`recipe.theme must be one of ${list(TEMPLATE_THEMES)}.`);
|
|
66
|
+
|
|
67
|
+
const order = input.sectionOrder;
|
|
68
|
+
if (!Array.isArray(order)) {
|
|
69
|
+
errors.push('recipe.sectionOrder must be a list of sections.');
|
|
70
|
+
} else {
|
|
71
|
+
const unknown = order.filter((section) => !TEMPLATE_SECTIONS.includes(section));
|
|
72
|
+
if (unknown.length) errors.push(`recipe.sectionOrder has unknown sections (${list(unknown)}). Use ${list(TEMPLATE_SECTIONS)}.`);
|
|
73
|
+
if (order.length < 3) errors.push('Pick at least 3 sections.');
|
|
74
|
+
if (order.length > TEMPLATE_SECTIONS.length) errors.push(`Pick at most ${TEMPLATE_SECTIONS.length} sections.`);
|
|
75
|
+
if (new Set(order).size !== order.length) errors.push('Each section can appear once.');
|
|
76
|
+
if (!order.includes('header')) errors.push('Include the header section.');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const headings = {};
|
|
80
|
+
if (input.headings !== undefined) {
|
|
81
|
+
if (!isObject(input.headings)) {
|
|
82
|
+
errors.push('recipe.headings must be an object of section: heading.');
|
|
83
|
+
} else {
|
|
84
|
+
for (const [section, value] of Object.entries(input.headings)) {
|
|
85
|
+
if (!TEMPLATE_SECTIONS.includes(section)) {
|
|
86
|
+
errors.push(`recipe.headings.${section} is not a section.`);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const [clean, error] = safeText('A heading', value, 1, 48);
|
|
90
|
+
if (error) errors.push(`recipe.headings.${section}: ${error}`);
|
|
91
|
+
else headings[section] = clean;
|
|
92
|
+
if (Array.isArray(order) && !order.includes(section)) warnings.push(`recipe.headings.${section} is set but "${section}" is not in sectionOrder.`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
for (const [key, options] of Object.entries(TEMPLATE_VARIANTS)) {
|
|
98
|
+
if (!options.includes(input[key])) errors.push(`recipe.${key} must be one of ${list(options)}.`);
|
|
99
|
+
}
|
|
100
|
+
for (const [key, options] of Object.entries(TEMPLATE_PRO_LOOK)) {
|
|
101
|
+
if (input[key] !== undefined && !options.includes(input[key])) errors.push(`recipe.${key} must be one of ${list(options)}, or left out.`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (errors.length) return { recipe: null, errors, warnings };
|
|
105
|
+
const recipe = {
|
|
106
|
+
version: 1,
|
|
107
|
+
theme: input.theme,
|
|
108
|
+
sectionOrder: [...order],
|
|
109
|
+
headings,
|
|
110
|
+
hero: input.hero,
|
|
111
|
+
about: input.about,
|
|
112
|
+
skills: input.skills,
|
|
113
|
+
stats: input.stats,
|
|
114
|
+
projects: input.projects,
|
|
115
|
+
};
|
|
116
|
+
if (input.cardStyle !== undefined) recipe.cardStyle = input.cardStyle;
|
|
117
|
+
if (input.heatmap !== undefined) recipe.heatmap = input.heatmap;
|
|
118
|
+
return { recipe, errors, warnings };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Validate a whole template file: name, description, category and recipe. */
|
|
122
|
+
export function validateTemplate(input) {
|
|
123
|
+
if (!isObject(input)) return { template: null, errors: ['The template file must be a JSON object.'], warnings: [] };
|
|
124
|
+
const errors = [];
|
|
125
|
+
const warnings = [];
|
|
126
|
+
for (const key of Object.keys(input)) {
|
|
127
|
+
if (!FILE_KEYS.has(key)) warnings.push(`"${key}" is not a template field and will be ignored.`);
|
|
128
|
+
}
|
|
129
|
+
const [name, nameError] = safeText('The name', input.name, 3, 40);
|
|
130
|
+
if (nameError) errors.push(nameError);
|
|
131
|
+
const [description, descriptionError] = safeText('The description', input.description, 10, 160);
|
|
132
|
+
if (descriptionError) errors.push(descriptionError);
|
|
133
|
+
if (!TEMPLATE_CATEGORIES.includes(input.category)) errors.push(`"category" must be one of ${list(TEMPLATE_CATEGORIES)}.`);
|
|
134
|
+
if (input.allowRemix !== undefined && typeof input.allowRemix !== 'boolean') errors.push('"allowRemix" must be true or false.');
|
|
135
|
+
const result = validateRecipe(input.recipe);
|
|
136
|
+
errors.push(...result.errors);
|
|
137
|
+
warnings.push(...result.warnings);
|
|
138
|
+
if (errors.length) return { template: null, errors, warnings };
|
|
139
|
+
// Others may remix it unless the creator says no (credit is always kept).
|
|
140
|
+
return { template: { name, description, category: input.category, recipe: result.recipe, allowRemix: input.allowRemix ?? true }, errors, warnings };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Community templates are free: free accounts get their free look, as the server prices it. */
|
|
144
|
+
export function templateIsFree(_recipe) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** A valid starting point for `gitskins template init`. */
|
|
149
|
+
export function starterTemplate() {
|
|
150
|
+
return {
|
|
151
|
+
name: 'My Template',
|
|
152
|
+
description: 'A short line on who this template is for and what it shows.',
|
|
153
|
+
category: 'creative',
|
|
154
|
+
recipe: {
|
|
155
|
+
version: 1,
|
|
156
|
+
theme: 'neon',
|
|
157
|
+
sectionOrder: ['header', 'about', 'projects', 'skills', 'stats', 'connect'],
|
|
158
|
+
headings: {
|
|
159
|
+
header: 'Hello, I build things',
|
|
160
|
+
projects: 'Selected work',
|
|
161
|
+
connect: 'Say hello',
|
|
162
|
+
},
|
|
163
|
+
hero: 'statement',
|
|
164
|
+
about: 'story',
|
|
165
|
+
skills: 'badges',
|
|
166
|
+
stats: 'metrics',
|
|
167
|
+
projects: 'cards',
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
package/src/util.js
CHANGED
|
@@ -62,6 +62,10 @@ export async function loadConfig(cwd = process.cwd()) {
|
|
|
62
62
|
outputDir: (raw.outputDir || DEFAULT_OUTPUT_DIR).trim(),
|
|
63
63
|
baseUrl: (raw.baseUrl || DEFAULT_BASE_URL).trim().replace(/\/+$/, ''),
|
|
64
64
|
widgets: Array.isArray(raw.widgets) && raw.widgets.length ? raw.widgets : DEFAULT_WIDGETS,
|
|
65
|
+
// Curated `owner/repo` list for the `projects` widget (arifhaxn model).
|
|
66
|
+
projects: Array.isArray(raw.projects)
|
|
67
|
+
? raw.projects.filter((p) => typeof p === 'string' && p.trim()).map((p) => p.trim())
|
|
68
|
+
: [],
|
|
65
69
|
};
|
|
66
70
|
}
|
|
67
71
|
|
|
@@ -76,6 +80,9 @@ export async function writeConfig(config, cwd = process.cwd()) {
|
|
|
76
80
|
if (config.baseUrl && config.baseUrl !== DEFAULT_BASE_URL) {
|
|
77
81
|
body.baseUrl = config.baseUrl;
|
|
78
82
|
}
|
|
83
|
+
if (Array.isArray(config.projects) && config.projects.length) {
|
|
84
|
+
body.projects = config.projects;
|
|
85
|
+
}
|
|
79
86
|
await writeFile(path, JSON.stringify(body, null, 2) + '\n');
|
|
80
87
|
return path;
|
|
81
88
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Founder Log",
|
|
3
|
+
"category": "creative",
|
|
4
|
+
"description": "Build in public: the why, what you are shipping, traction and how to reach you.",
|
|
5
|
+
"recipe": {
|
|
6
|
+
"version": 1,
|
|
7
|
+
"theme": "satan",
|
|
8
|
+
"sectionOrder": [
|
|
9
|
+
"header",
|
|
10
|
+
"about",
|
|
11
|
+
"projects",
|
|
12
|
+
"stats",
|
|
13
|
+
"skills",
|
|
14
|
+
"connect"
|
|
15
|
+
],
|
|
16
|
+
"headings": {
|
|
17
|
+
"header": "Building in the open",
|
|
18
|
+
"about": "The why",
|
|
19
|
+
"projects": "What I'm shipping",
|
|
20
|
+
"stats": "Traction",
|
|
21
|
+
"skills": "The stack",
|
|
22
|
+
"connect": "Talk to me"
|
|
23
|
+
},
|
|
24
|
+
"hero": "statement",
|
|
25
|
+
"about": "story",
|
|
26
|
+
"skills": "toolbox",
|
|
27
|
+
"stats": "metrics",
|
|
28
|
+
"projects": "case-studies",
|
|
29
|
+
"cardStyle": "terminal"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Green Screen",
|
|
3
|
+
"category": "technical",
|
|
4
|
+
"description": "A terminal session for systems and backend engineers, from whoami to ssh.",
|
|
5
|
+
"recipe": {
|
|
6
|
+
"version": 1,
|
|
7
|
+
"theme": "matrix",
|
|
8
|
+
"sectionOrder": [
|
|
9
|
+
"header",
|
|
10
|
+
"about",
|
|
11
|
+
"projects",
|
|
12
|
+
"stats",
|
|
13
|
+
"skills",
|
|
14
|
+
"heatmap",
|
|
15
|
+
"connect"
|
|
16
|
+
],
|
|
17
|
+
"headings": {
|
|
18
|
+
"header": "whoami",
|
|
19
|
+
"about": "cat about.txt",
|
|
20
|
+
"projects": "ls projects",
|
|
21
|
+
"stats": "top",
|
|
22
|
+
"skills": "which tools",
|
|
23
|
+
"heatmap": "git log --graph",
|
|
24
|
+
"connect": "ssh me"
|
|
25
|
+
},
|
|
26
|
+
"hero": "terminal",
|
|
27
|
+
"about": "systems",
|
|
28
|
+
"skills": "stack",
|
|
29
|
+
"stats": "metrics",
|
|
30
|
+
"projects": "details",
|
|
31
|
+
"cardStyle": "terminal",
|
|
32
|
+
"heatmap": "jet"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Hire Me Brief",
|
|
3
|
+
"category": "recruiter",
|
|
4
|
+
"description": "A one-screen profile for job hunting: what you do, the numbers, then proof of work.",
|
|
5
|
+
"recipe": {
|
|
6
|
+
"version": 1,
|
|
7
|
+
"theme": "github-dark",
|
|
8
|
+
"sectionOrder": [
|
|
9
|
+
"header",
|
|
10
|
+
"about",
|
|
11
|
+
"stats",
|
|
12
|
+
"projects",
|
|
13
|
+
"skills",
|
|
14
|
+
"connect"
|
|
15
|
+
],
|
|
16
|
+
"headings": {
|
|
17
|
+
"header": "At a glance",
|
|
18
|
+
"about": "What I do",
|
|
19
|
+
"stats": "By the numbers",
|
|
20
|
+
"projects": "Proof of work",
|
|
21
|
+
"skills": "Toolkit",
|
|
22
|
+
"connect": "Get in touch"
|
|
23
|
+
},
|
|
24
|
+
"hero": "profile",
|
|
25
|
+
"about": "brief",
|
|
26
|
+
"skills": "badges",
|
|
27
|
+
"stats": "metrics",
|
|
28
|
+
"projects": "impact"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Maintainer's Desk",
|
|
3
|
+
"category": "open-source",
|
|
4
|
+
"description": "For open-source maintainers: the repositories you look after, your contribution log and how to help.",
|
|
5
|
+
"recipe": {
|
|
6
|
+
"version": 1,
|
|
7
|
+
"theme": "neon",
|
|
8
|
+
"sectionOrder": [
|
|
9
|
+
"header",
|
|
10
|
+
"about",
|
|
11
|
+
"projects",
|
|
12
|
+
"heatmap",
|
|
13
|
+
"skills",
|
|
14
|
+
"connect"
|
|
15
|
+
],
|
|
16
|
+
"headings": {
|
|
17
|
+
"header": "Maintainer on duty",
|
|
18
|
+
"about": "Why I maintain",
|
|
19
|
+
"projects": "Repositories I look after",
|
|
20
|
+
"heatmap": "Contribution log",
|
|
21
|
+
"skills": "Tools of the trade",
|
|
22
|
+
"connect": "Come contribute"
|
|
23
|
+
},
|
|
24
|
+
"hero": "profile",
|
|
25
|
+
"about": "community",
|
|
26
|
+
"skills": "toolbox",
|
|
27
|
+
"stats": "activity",
|
|
28
|
+
"projects": "repos",
|
|
29
|
+
"heatmap": "erased"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Quiet Pastel",
|
|
3
|
+
"category": "creative",
|
|
4
|
+
"description": "Soft, light and short: a hello, a few things you made and where to find you.",
|
|
5
|
+
"recipe": {
|
|
6
|
+
"version": 1,
|
|
7
|
+
"theme": "pastel",
|
|
8
|
+
"sectionOrder": [
|
|
9
|
+
"header",
|
|
10
|
+
"about",
|
|
11
|
+
"projects",
|
|
12
|
+
"skills",
|
|
13
|
+
"connect"
|
|
14
|
+
],
|
|
15
|
+
"headings": {
|
|
16
|
+
"header": "Hello there",
|
|
17
|
+
"about": "Lately",
|
|
18
|
+
"projects": "Things I've made",
|
|
19
|
+
"skills": "What I use",
|
|
20
|
+
"connect": "Find me"
|
|
21
|
+
},
|
|
22
|
+
"hero": "portfolio",
|
|
23
|
+
"about": "brief",
|
|
24
|
+
"skills": "language-list",
|
|
25
|
+
"stats": "signal",
|
|
26
|
+
"projects": "cards"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Study Hall",
|
|
3
|
+
"category": "technical",
|
|
4
|
+
"description": "For students and career changers: what you are learning, projects in progress and your streak.",
|
|
5
|
+
"recipe": {
|
|
6
|
+
"version": 1,
|
|
7
|
+
"theme": "zen",
|
|
8
|
+
"sectionOrder": [
|
|
9
|
+
"header",
|
|
10
|
+
"about",
|
|
11
|
+
"skills",
|
|
12
|
+
"projects",
|
|
13
|
+
"stats",
|
|
14
|
+
"heatmap",
|
|
15
|
+
"connect"
|
|
16
|
+
],
|
|
17
|
+
"headings": {
|
|
18
|
+
"header": "Learning out loud",
|
|
19
|
+
"about": "Currently studying",
|
|
20
|
+
"skills": "Languages I'm practicing",
|
|
21
|
+
"projects": "Projects in progress",
|
|
22
|
+
"stats": "Progress so far",
|
|
23
|
+
"heatmap": "Study streak",
|
|
24
|
+
"connect": "Say hi"
|
|
25
|
+
},
|
|
26
|
+
"hero": "profile",
|
|
27
|
+
"about": "learning",
|
|
28
|
+
"skills": "language-list",
|
|
29
|
+
"stats": "progress",
|
|
30
|
+
"projects": "details",
|
|
31
|
+
"heatmap": "snake"
|
|
32
|
+
}
|
|
33
|
+
}
|