Skip to content

Commit f9c4b09

Browse files
committed
cleanup
1 parent 6a3b6c0 commit f9c4b09

4 files changed

Lines changed: 49 additions & 49 deletions

File tree

site/src/components/TerminalWindow/index.tsx

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -60,35 +60,30 @@ function ShellOutput({code}: {code: string}) {
6060
);
6161
}
6262

63+
type PrefixRule = {
64+
prefix: string;
65+
symbolClass: string;
66+
bodyClass?: string;
67+
};
68+
69+
const PREFIX_RULES: PrefixRule[] = [
70+
{ prefix: '$ ', symbolClass: styles.prompt },
71+
{ prefix: '→ ', symbolClass: styles.arrow, bodyClass: styles.arrowText },
72+
{ prefix: '✓ ', symbolClass: styles.check },
73+
{ prefix: '✗ ', symbolClass: styles.xmark },
74+
];
75+
6376
function renderShellLine(line: string): ReactNode {
64-
if (line.startsWith('$ ')) {
65-
return (
66-
<>
67-
<span className={styles.prompt}>$</span> {line.slice(2)}
68-
</>
69-
);
70-
}
71-
if (line.startsWith('→ ')) {
72-
return (
73-
<>
74-
<span className={styles.arrow}></span>{' '}
75-
<span className={styles.arrowText}>{line.slice(2)}</span>
76-
</>
77-
);
78-
}
79-
if (line.startsWith('✓ ')) {
80-
return (
81-
<>
82-
<span className={styles.check}></span> {line.slice(2)}
83-
</>
84-
);
85-
}
86-
if (line.startsWith('✗ ')) {
87-
return (
88-
<>
89-
<span className={styles.xmark}></span> {line.slice(2)}
90-
</>
91-
);
77+
for (const {prefix, symbolClass, bodyClass} of PREFIX_RULES) {
78+
if (line.startsWith(prefix)) {
79+
const body = line.slice(prefix.length);
80+
return (
81+
<>
82+
<span className={symbolClass}>{prefix.trimEnd()}</span>{' '}
83+
{bodyClass ? <span className={bodyClass}>{body}</span> : body}
84+
</>
85+
);
86+
}
9287
}
9388
if (/^Done\b/.test(line)) {
9489
return <span className={styles.done}>{line}</span>;

site/src/lib/__tests__/comparison.test.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
comparisonFeatures,
33
supportScore,
44
toolScore,
5-
type Tool,
5+
tools,
66
} from '../comparison';
77

88
describe('supportScore', () => {
@@ -26,15 +26,14 @@ describe('toolScore', () => {
2626

2727
test('raid scores strictly higher than every other tool', () => {
2828
const raid = toolScore(comparisonFeatures, 'raid');
29-
for (const tool of ['make', 'just', 'mise'] as const) {
30-
expect(raid).toBeGreaterThan(toolScore(comparisonFeatures, tool));
29+
for (const {id} of tools.filter((t) => t.id !== 'raid')) {
30+
expect(raid).toBeGreaterThan(toolScore(comparisonFeatures, id));
3131
}
3232
});
3333

3434
test('score is bounded by the number of features', () => {
35-
const tools: Tool[] = ['raid', 'make', 'just', 'mise'];
36-
for (const tool of tools) {
37-
const score = toolScore(comparisonFeatures, tool);
35+
for (const {id} of tools) {
36+
const score = toolScore(comparisonFeatures, id);
3837
expect(score).toBeGreaterThanOrEqual(0);
3938
expect(score).toBeLessThanOrEqual(comparisonFeatures.length);
4039
}
@@ -51,11 +50,10 @@ describe('comparisonFeatures', () => {
5150
});
5251

5352
test('every feature has a non-empty label and a support value for every tool', () => {
54-
const tools: Tool[] = ['raid', 'make', 'just', 'mise'];
5553
for (const feature of comparisonFeatures) {
5654
expect(feature.label).toBeTruthy();
57-
for (const tool of tools) {
58-
expect(['yes', 'no', 'partial']).toContain(feature[tool]);
55+
for (const {id} of tools) {
56+
expect(['yes', 'no', 'partial']).toContain(feature[id]);
5957
}
6058
}
6159
});

site/src/lib/comparison.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ export type Tool = 'raid' | 'make' | 'just' | 'mise' | 'turbo';
44

55
export type ComparisonFeature = { label: string } & Record<Tool, Support>;
66

7+
/** Tools in display order, with the label rendered in the comparison table header. */
8+
export const tools: { id: Tool; label: string }[] = [
9+
{ id: 'raid', label: 'Raid' },
10+
{ id: 'make', label: 'make' },
11+
{ id: 'just', label: 'just' },
12+
{ id: 'mise', label: 'mise' },
13+
{ id: 'turbo', label: 'turbo' },
14+
];
15+
716
export const comparisonFeatures: ComparisonFeature[] = [
817
{ label: 'Multi-repo orchestration', raid: 'yes', make: 'no', just: 'no', mise: 'partial', turbo: 'partial' },
918
{ label: 'Team profile sharing', raid: 'yes', make: 'no', just: 'no', mise: 'no', turbo: 'no' },

site/src/pages/index.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Link from '@docusaurus/Link';
22
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
33
import HomepageFeatures from '@site/src/components/HomepageFeatures';
44
import SectionsNav from '@site/src/components/SectionsNav';
5-
import { comparisonFeatures, type Support } from '@site/src/lib/comparison';
5+
import { comparisonFeatures, tools, type Support } from '@site/src/lib/comparison';
66
import Heading from '@theme/Heading';
77
import Layout from '@theme/Layout';
88
import ThemedImage from '@theme/ThemedImage';
@@ -173,7 +173,7 @@ function InstallSection() {
173173
<InstallOption label="Script" cmd="curl -fsSL https://raidcli.dev/install.sh | bash" />
174174
</div>
175175
<a
176-
href="https://github.com/8bitAlex/raid/releases/latest"
176+
href="https://github.com/8bitalex/raid/releases/latest"
177177
target="_blank"
178178
rel="noopener noreferrer"
179179
className={styles.manualDownload}>
@@ -203,22 +203,20 @@ function ComparisonSection() {
203203
<thead>
204204
<tr>
205205
<th className={styles.thFeature}></th>
206-
<th className={styles.thRaid}>Raid</th>
207-
<th className={styles.thOther}>make</th>
208-
<th className={styles.thOther}>just</th>
209-
<th className={styles.thOther}>mise</th>
210-
<th className={styles.thOther}>turbo</th>
206+
{tools.map(({id, label}) => (
207+
<th key={id} className={id === 'raid' ? styles.thRaid : styles.thOther}>{label}</th>
208+
))}
211209
</tr>
212210
</thead>
213211
<tbody>
214212
{comparisonFeatures.map((row) => (
215213
<tr key={row.label} className={styles.tableRow}>
216214
<td className={styles.featureLabel}>{row.label}</td>
217-
<td className={clsx(styles.cell, styles.colRaid)}><SupportIcon value={row.raid} /></td>
218-
<td className={styles.cell}><SupportIcon value={row.make} /></td>
219-
<td className={styles.cell}><SupportIcon value={row.just} /></td>
220-
<td className={styles.cell}><SupportIcon value={row.mise} /></td>
221-
<td className={styles.cell}><SupportIcon value={row.turbo} /></td>
215+
{tools.map(({id}) => (
216+
<td key={id} className={clsx(styles.cell, id === 'raid' && styles.colRaid)}>
217+
<SupportIcon value={row[id]} />
218+
</td>
219+
))}
222220
</tr>
223221
))}
224222
</tbody>

0 commit comments

Comments
 (0)