~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/knotless

git that lives in your Atmosphere account

knotless.dev
1 collaborator

knotless 0.13.0 Latest 2 packages, 1 image

1
10

web: Badge cards describe what an account did, in plain words

Merged chadtmiller.com asked to merge into main from chadtmiller.com/knotless:badge-copy
web/src/lib/badges.ts+15−18
@@ -9,18 +9,18 @@ type Earned = 'tiers' | 'once' | 'limited';
/** Each badge knotless knows: its name, what its count is of, said of `n`, and how it is earned. */
const KNOWN: Record<string, { name: string; counted: (n: number) => string; earned?: Earned }> = {
upstream: { name: 'Upstream', counted: (n) => `${pulls(n)} merged into repositories of other accounts.` },
'second-pair': { name: 'Second pair of eyes', counted: (n) => `${pulls(n)} of other accounts commented on before ${n === 1 ? 'it' : 'they'} merged.` },
peacemaker: { name: 'Peacemaker', counted: (n) => `${pulls(n)} landed after the queue turned ${n === 1 ? 'it' : 'them'} away for a conflict.` },
'forked-and-fixed': { name: 'Forked and fixed', counted: (n) => `${pulls(n)} merged from forks of its repositories.`, earned: 'once' },
'good-company': { name: 'In good company', counted: (n) => `${pulls(n)} landed in a batch of five or more.` },
'smooth-landing': { name: 'Smooth landing', counted: (n) => `${pulls(n)} landed by the merge queue without being turned away.` },
bisected: { name: 'Bisected', counted: (n) => `${pulls(n)} found by halving a batch that failed. It happens to everyone.`, earned: 'once' },
shipped: { name: 'Shipped', counted: (n) => `${number(n)} ${n === 1 ? 'release' : 'releases'} published.` },
stargazer: { name: 'Stargazer', counted: (n) => `${number(n)} ${n === 1 ? 'star' : 'stars'} on one repository.` },
'carry-your-own': { name: 'Carry your own', counted: () => 'Its account lives on a PDS of its own, one holding five accounts or fewer.', earned: 'once' },
'moved-house': { name: 'Moved house', counted: () => 'It moved its account from one PDS to another.', earned: 'once' },
'first-light': { name: 'First light', counted: () => 'Here with a repository before knotless 1.0.', earned: 'limited' }
upstream: { name: 'Upstream', counted: (n) => `Got ${pulls(n)} merged into other accounts' repositories.` },
'second-pair': { name: 'Second pair of eyes', counted: (n) => `Weighed in on ${pulls(n)} from others before ${n === 1 ? 'it' : 'they'} merged.` },
peacemaker: { name: 'Peacemaker', counted: (n) => `Landed ${pulls(n)} after fixing a conflict the merge queue flagged.` },
'forked-and-fixed': { name: 'Forked and fixed', counted: (n) => `Merged ${pulls(n)} sent from forks of their repositories.`, earned: 'once' },
'good-company': { name: 'In good company', counted: (n) => `Landed ${pulls(n)} in a merge queue batch of five or more.` },
'smooth-landing': { name: 'Smooth landing', counted: (n) => `Landed ${pulls(n)} through the merge queue on the first try.` },
bisected: { name: 'Bisected', counted: (n) => `Had ${pulls(n)} caught breaking a merge queue batch. It happens to everyone.`, earned: 'once' },
shipped: { name: 'Shipped', counted: (n) => `Published ${number(n)} ${n === 1 ? 'release' : 'releases'}.` },
stargazer: { name: 'Stargazer', counted: (n) => `${number(n)} ${n === 1 ? 'star' : 'stars'} on their most-starred repository.` },
'carry-your-own': { name: 'Carry your own', counted: () => 'Hosts their account on a small PDS, five accounts or fewer.', earned: 'once' },
'moved-house': { name: 'Moved house', counted: () => 'Moved their account to a new PDS.', earned: 'once' },
'first-light': { name: 'First light', counted: () => 'Had a repository here before knotless 1.0.', earned: 'limited' }
};
/** `n` pulls, in words. */
@@ -39,9 +39,6 @@ export const metal = (kind: string, tier: number) => {
/** Whether knotless knows how to show a badge of its kind: one newer than these pages is left out. */
export const known = (b: getProfile.BadgeView) => b.kind in KNOWN;
/** Which of the four a tier is, in words. */
const ORDINALS = ['first', 'second', 'third', 'fourth'];
/** A badge's name. */
export const name = (b: getProfile.BadgeView) => KNOWN[b.kind].name;
@@ -51,10 +48,10 @@ export const named = (b: getProfile.BadgeView) => (earned(b.kind) === 'tiers' ?
/** Its tier, what it counted, and how far its next tier is, if it has one. */
export const said = (b: getProfile.BadgeView) => {
const counted = KNOWN[b.kind].counted(b.count);
if (earned(b.kind) === 'once') return { tier: 'Earned once.', counted, next: undefined };
if (earned(b.kind) === 'limited') return { tier: 'Limited. Only before 1.0.', counted, next: undefined };
if (earned(b.kind) === 'once') return { tier: 'One-time badge.', counted, next: undefined };
if (earned(b.kind) === 'limited') return { tier: 'Limited. Earned only before 1.0.', counted, next: undefined };
const at = metal(b.kind, b.tier);
const tier = `${capitalized(at)} tier, the ${ORDINALS[METALS.indexOf(at as (typeof METALS)[number])]} of four.`;
const tier = `${capitalized(at)}, tier ${METALS.indexOf(at as (typeof METALS)[number]) + 1} of ${METALS.length}.`;
const next = b.next === undefined ? undefined : `${number(b.next - b.count)} more for ${metal(b.kind, b.tier + 1)}.`;
return { tier, counted, next };
};