Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Rendering in your own Actions run spends your own token budget, fails loudly in

| Input | Required | Default | Description |
| --------- | -------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `card` | yes | — | `stats`, `top-langs`, `pin`, `wakatime` or `gist`. |
| `card` | yes | — | `stats`, `top-langs`, `pin`, `wakatime`, `gist` or `contributed-to`. |
| `options` | no | `""` | Card options as a query string (`key=value&...`) or JSON. Repeated keys are joined with commas. If `username` is omitted, the repository owner is used. |
| `path` | no | `profile/<card>.svg` | Output path, including the filename. |
| `token` | no | `github.token` | GitHub token (PAT or `GITHUB_TOKEN`). For private repo stats use a PAT with `repo` and `read:user`; for any gist, a PAT with `gist`. |
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ branding:

inputs:
card:
description: Card type to generate (stats, top-langs, pin, wakatime, gist).
description: Card type to generate (stats, top-langs, pin, wakatime, gist, contributed-to).
required: true
options:
description: Options for the card (query string or JSON).
Expand Down
1,076 changes: 579 additions & 497 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"dependencies": {
"@actions/core": "3.0.1",
"@stats-forge/github-stats-forge-core": "0.1.0"
"@stats-forge/github-stats-forge-core": "0.2.0"
},
"devDependencies": {
"@marcalexiei/oxfmt-config": "1.3.0",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getInput, info, setOutput, warning } from '@actions/core';
// action tag pins the version.
import {
CardConfig,
contributedTo,
gist,
pin,
stats,
Expand All @@ -30,6 +31,7 @@ const CARDS = {
pin: { handler: pin, requires: 'repo' },
wakatime: { handler: wakatime, requires: 'username' },
gist: { handler: gist, requires: 'id' },
'contributed-to': { handler: contributedTo, requires: 'username' },
} satisfies Record<string, CardDefinition>;

type CardName = keyof typeof CARDS;
Expand Down
17 changes: 10 additions & 7 deletions tests/resolve-card.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ import { describe, expect, it } from 'vitest';
import { resolveCard } from '../src/action.js';

describe(resolveCard, () => {
it('resolves every card the action documents', () => {
expect(resolveCard('stats', { username: 'octocat' })).toBeDefined();
expect(resolveCard('top-langs', { username: 'octocat' })).toBeDefined();
expect(resolveCard('pin', { repo: 'github-stats-forge' })).toBeDefined();
expect(resolveCard('wakatime', { username: 'octocat' })).toBeDefined();
expect(resolveCard('gist', { id: 'bbfce31e0217a3689c8d' })).toBeDefined();
it.each([
['stats', { username: 'octocat' }],
['top-langs', { username: 'octocat' }],
['pin', { repo: 'github-stats-forge' }],
['wakatime', { username: 'octocat' }],
['gist', { id: 'bbfce31e0217a3689c8d' }],
['contributed-to', { username: 'octocat' }],
])('resolves the %s card the action documents', (card, options) => {
expect(resolveCard(card, options)).toBeDefined();
});

it('names the supported cards when given one it does not know', () => {
expect(() => resolveCard('stat', { username: 'octocat' })).toThrow(
'Unsupported card type: stat. Expected one of stats, top-langs, pin, wakatime, gist.',
'Unsupported card type: stat. Expected one of stats, top-langs, pin, wakatime, gist, contributed-to.',
);
});

Expand Down
2 changes: 2 additions & 0 deletions tests/run.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const mocks = vi.hoisted(() => {
pin: card(),
wakatime: card(),
gist: card(),
contributedTo: card(),
},
};
});
Expand Down Expand Up @@ -56,6 +57,7 @@ vi.mock(import('@stats-forge/github-stats-forge-core/api'), async (importOrigina
pin: Object.assign(mocks.handlers.pin, actual.pin),
wakatime: Object.assign(mocks.handlers.wakatime, actual.wakatime),
gist: Object.assign(mocks.handlers.gist, actual.gist),
contributedTo: Object.assign(mocks.handlers.contributedTo, actual.contributedTo),
};
});

Expand Down