gitsona 0.2.0 → 0.2.1
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 +3 -3
- package/dist/cli.js +24 -4
- package/dist/publish.js +17 -7
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ It reads your public activity and draws it as a terminal running `gitsona <you>`
|
|
|
14
14
|
## Two steps to your profile
|
|
15
15
|
|
|
16
16
|
1. **Look.** `npx gitsona --preview`, then open `<you>/gitsona-preview.html`.
|
|
17
|
-
2. **Ship.** `npx gitsona --push --action` commits it to your `<you>/<you>` repo (asks first), with a workflow that redraws it every
|
|
17
|
+
2. **Ship.** `npx gitsona --push --action` commits it to your `<you>/<you>` repo (asks first), with a workflow that redraws it every day. Leave out `--action` to redraw by hand.
|
|
18
18
|
|
|
19
19
|
The token comes from `GITSONA_TOKEN`, `GITHUB_TOKEN`, `GH_TOKEN`, or `gh auth token`, and gitsona draws the account behind it. To draw someone else, name them: `npx gitsona octocat --preview`.
|
|
20
20
|
|
|
@@ -47,7 +47,7 @@ The token comes from `GITSONA_TOKEN`, `GITHUB_TOKEN`, `GH_TOKEN`, or `gh auth to
|
|
|
47
47
|
| --- | --- |
|
|
48
48
|
| `--preview` | Also write `gitsona-preview.html`, framed like a GitHub profile with a light/dark switch |
|
|
49
49
|
| `--push` | Create `<you>/<you>` if needed, commit and push. `-y` skips the questions |
|
|
50
|
-
| `--action` | Add a
|
|
50
|
+
| `--action` | Add a workflow that redraws the profile every day. `--schedule weekly` for Mondays only |
|
|
51
51
|
| `--sections <list>` | `all`, or pick and order panels, such as `hero,rhythm` |
|
|
52
52
|
| `--font <name>` | `pixel`, `geist`, `mono`, `grotesk`, `rounded` or `retro` |
|
|
53
53
|
| `--accent <hex>` | Accent colour. Defaults to your top language's colour |
|
|
@@ -59,7 +59,7 @@ The token comes from `GITSONA_TOKEN`, `GITHUB_TOKEN`, `GH_TOKEN`, or `gh auth to
|
|
|
59
59
|
## Re-running
|
|
60
60
|
|
|
61
61
|
- Only the block between `<!-- gitsona:start -->` and `<!-- gitsona:end -->` is redrawn. Anything you write outside it stays. A README without the markers keeps its old content below the new block; `--replace` overwrites the whole file instead.
|
|
62
|
-
- The
|
|
62
|
+
- The scheduled workflow redraws with the options of the run that wrote it (`--sections`, `--font`, `--accent`, `--bio` and so on), commits only when something changed, and stays on the gitsona version that wrote it. Run `--action` again to upgrade. For private contribution counts, add a token with repo read access as the `GITSONA_TOKEN` secret.
|
|
63
63
|
|
|
64
64
|
## Notes
|
|
65
65
|
|
package/dist/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ import { analyze } from "./analyze.js";
|
|
|
7
7
|
import { collect } from "./collect.js";
|
|
8
8
|
import { GitHub, GitHubError, resolveToken } from "./github.js";
|
|
9
9
|
import { previewHtml } from "./preview.js";
|
|
10
|
-
import { ASSETS, commitAndPush, createProfileRepo, DRAWN, ensureCheckout, hasGh, repoExists, writeWorkflow, } from "./publish.js";
|
|
10
|
+
import { ASSETS, commitAndPush, createProfileRepo, DRAWN, ensureCheckout, hasGh, repoExists, SCHEDULES, writeWorkflow, } from "./publish.js";
|
|
11
11
|
import { mergeReadme, readmeBlock } from "./readme.js";
|
|
12
12
|
import { DEFAULT_TYPESET, fontFileProblem, TYPESET_NAMES, TYPESETS, withDisplayFont, } from "./render/fonts.js";
|
|
13
13
|
import { DEFAULT_SECTIONS, fetchAvatars, render, SECTIONS } from "./render/index.js";
|
|
@@ -41,7 +41,8 @@ Content
|
|
|
41
41
|
(their names are never drawn)
|
|
42
42
|
|
|
43
43
|
Publishing
|
|
44
|
-
--action Add a
|
|
44
|
+
--action Add a GitHub Actions workflow that redraws the profile
|
|
45
|
+
--schedule <when> How often the workflow redraws: daily (default) or weekly
|
|
45
46
|
--push Create <user>/<user> if needed, commit and push (asks first)
|
|
46
47
|
-y, --yes Don't ask before creating the repository or pushing
|
|
47
48
|
|
|
@@ -91,6 +92,7 @@ async function main(argv) {
|
|
|
91
92
|
"no-bio": { type: "boolean" },
|
|
92
93
|
private: { type: "boolean" },
|
|
93
94
|
action: { type: "boolean" },
|
|
95
|
+
schedule: { type: "string" },
|
|
94
96
|
push: { type: "boolean" },
|
|
95
97
|
yes: { type: "boolean", short: "y" },
|
|
96
98
|
token: { type: "string" },
|
|
@@ -116,6 +118,9 @@ async function main(argv) {
|
|
|
116
118
|
process.stderr.write(`${s}\n`);
|
|
117
119
|
};
|
|
118
120
|
const sections = parseSections(v.sections);
|
|
121
|
+
const schedule = (v.schedule ?? "daily");
|
|
122
|
+
if (!SCHEDULES.includes(schedule))
|
|
123
|
+
throw new UsageError(`--schedule takes ${SCHEDULES.join(" or ")}.`);
|
|
119
124
|
if (v.accent && !/^#[0-9a-f]{6}$/i.test(v.accent))
|
|
120
125
|
throw new UsageError("--accent takes a hex colour like #3fb950.");
|
|
121
126
|
const fontName = (v.font ?? DEFAULT_TYPESET);
|
|
@@ -184,8 +189,23 @@ async function main(argv) {
|
|
|
184
189
|
}
|
|
185
190
|
if (v.preview)
|
|
186
191
|
writeFileSync(join(out, "gitsona-preview.html"), previewHtml(profile, block));
|
|
187
|
-
if (v.action)
|
|
188
|
-
|
|
192
|
+
if (v.action) {
|
|
193
|
+
// Carry the look of this run into the scheduled ones. Every value here was validated above.
|
|
194
|
+
const keep = [];
|
|
195
|
+
if (v.sections)
|
|
196
|
+
keep.push("--sections", sections.join(","));
|
|
197
|
+
if (fontName !== DEFAULT_TYPESET)
|
|
198
|
+
keep.push("--font", fontName);
|
|
199
|
+
if (v.accent)
|
|
200
|
+
keep.push("--accent", `"${v.accent}"`);
|
|
201
|
+
for (const flag of ["bio", "private", "no-motion", "no-cursor"])
|
|
202
|
+
if (v[flag])
|
|
203
|
+
keep.push(`--${flag}`);
|
|
204
|
+
if (v["display-font"]) {
|
|
205
|
+
log(` note: the workflow can't reach ${v["display-font"]}; scheduled redraws use --font ${fontName}`);
|
|
206
|
+
}
|
|
207
|
+
writeWorkflow(out, schedule, keep);
|
|
208
|
+
}
|
|
189
209
|
const rel = relative(process.cwd(), out) || ".";
|
|
190
210
|
const bytes = [...rendered.files.values()].reduce((s, f) => s + f.length, 0);
|
|
191
211
|
log("");
|
package/dist/publish.js
CHANGED
|
@@ -121,13 +121,23 @@ export function commitAndPush(dir, paths, message) {
|
|
|
121
121
|
throw new Error(`git push failed: ${p.out}`);
|
|
122
122
|
return "pushed";
|
|
123
123
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
export const SCHEDULES = ["daily", "weekly"];
|
|
125
|
+
/** Off the hour, so the run doesn't queue behind every other scheduled job at :00. */
|
|
126
|
+
const CRON = { daily: "23 3 * * *", weekly: "23 3 * * 1" };
|
|
127
|
+
/**
|
|
128
|
+
* The scheduled workflow. `args` are the drawing options of the run that wrote it, so each redraw looks
|
|
129
|
+
* the same; callers pass only values the CLI has already validated (section names, preset names, hex).
|
|
130
|
+
*/
|
|
131
|
+
export function workflow(schedule = "daily", args = []) {
|
|
132
|
+
return WORKFLOW.replace("__CRON__", CRON[schedule]).replace("__ARGS__", args.map((a) => ` ${a}`).join(""));
|
|
133
|
+
}
|
|
134
|
+
// Pinned to the release that wrote it, so every scheduled redraw runs the same code instead of
|
|
135
|
+
// whatever is on main. Running gitsona --action again moves the pin.
|
|
136
|
+
const WORKFLOW = `name: gitsona
|
|
127
137
|
|
|
128
138
|
on:
|
|
129
139
|
schedule:
|
|
130
|
-
- cron: "
|
|
140
|
+
- cron: "__CRON__"
|
|
131
141
|
workflow_dispatch:
|
|
132
142
|
|
|
133
143
|
permissions:
|
|
@@ -146,7 +156,7 @@ jobs:
|
|
|
146
156
|
with:
|
|
147
157
|
node-version: 22
|
|
148
158
|
- name: Redraw the profile
|
|
149
|
-
run: npx -y gitsona@${VERSION} "\${{ github.repository_owner }}" --out . --
|
|
159
|
+
run: npx -y gitsona@${VERSION} "\${{ github.repository_owner }}" --out . --quiet__ARGS__
|
|
150
160
|
env:
|
|
151
161
|
# The default token sees public activity. For private contribution counts, add a
|
|
152
162
|
# fine-grained token with read access to your repos as the GITSONA_TOKEN secret.
|
|
@@ -163,10 +173,10 @@ jobs:
|
|
|
163
173
|
git push
|
|
164
174
|
fi
|
|
165
175
|
`;
|
|
166
|
-
export function writeWorkflow(dir) {
|
|
176
|
+
export function writeWorkflow(dir, schedule = "daily", args = []) {
|
|
167
177
|
const wf = join(dir, ".github", "workflows");
|
|
168
178
|
mkdirSync(wf, { recursive: true });
|
|
169
179
|
const path = join(wf, "gitsona.yml");
|
|
170
|
-
writeFileSync(path,
|
|
180
|
+
writeFileSync(path, workflow(schedule, args));
|
|
171
181
|
return path;
|
|
172
182
|
}
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Kept equal to package.json by test/version.test.ts; the release workflow runs that test before publishing. */
|
|
2
|
-
export const VERSION = "0.2.
|
|
2
|
+
export const VERSION = "0.2.1";
|
package/package.json
CHANGED