Skip to content

Commit d2089e6

Browse files
committed
Merge remote-tracking branch 'upstream/source' into landing--interactive-editor-on-landing
2 parents f38060f + a367f08 commit d2089e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2579
-1677
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"editor.defaultFormatter": "esbenp.prettier-vscode"
1111
},
1212
"tailwindCSS.classFunctions": ["clsx"],
13+
"files.associations": {
14+
"*.css": "tailwindcss"
15+
},
1316
"editor.quickSuggestions": {
1417
"strings": "on"
1518
},

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"validate:snippets": "node scripts/validate-snippets.js"
2525
},
2626
"dependencies": {
27+
"@base-ui-components/react": "1.0.0-beta.4",
2728
"@codemirror/autocomplete": "^6.18.6",
2829
"@codemirror/commands": "^6.3.3",
2930
"@codemirror/language": "^6.10.0",
@@ -37,7 +38,6 @@
3738
"@lezer/highlight": "^1.2.1",
3839
"@next/bundle-analyzer": "^15.4.5",
3940
"@plaiceholder/next": "^3.0.0",
40-
"@radix-ui/react-radio-group": "^1.2.2",
4141
"@sparticuz/chromium": "^138.0.2",
4242
"@tailwindcss/container-queries": "^0.1.1",
4343
"@tailwindcss/nesting": "0.0.0-insiders.565cd3e",
@@ -55,7 +55,6 @@
5555
"iframe-resizer-react": "^1.1.1",
5656
"leaflet": "^1.9.4",
5757
"lucide-react": "^0.469.0",
58-
"markdown-to-jsx": "^7.7.2",
5958
"motion": "^12.11.0",
6059
"next": "^14.2.32",
6160
"next-query-params": "^5.0.1",
@@ -96,7 +95,7 @@
9695
"@playwright/test": "^1.54.2",
9796
"@svgr/webpack": "^8.1.0",
9897
"@testing-library/react": "^16.3.0",
99-
"@types/codemirror": "5.60.16",
98+
"@types/codemirror": "5.60.17",
10099
"@types/hast": "3.0.4",
101100
"@types/jsdom": "^21.1.7",
102101
"@types/node": "^22.10.5",

pnpm-lock.yaml

Lines changed: 244 additions & 506 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prettier.config.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ export default {
2626
},
2727
},
2828
],
29-
plugins: ["prettier-plugin-pkg", "prettier-plugin-tailwindcss"],
30-
// We need this to ensure classes format the same across CI and editors.
29+
// We need the absolute paths here to ensure classes format the same across CI and editors.
30+
plugins: [
31+
import.meta.resolve("prettier-plugin-pkg").replace("file://", ""),
32+
import.meta.resolve("prettier-plugin-tailwindcss").replace("file://", ""),
33+
],
3134
tailwindConfig: resolve(__dirname, "./tailwind.config.ts"),
3235
}

scripts/get-github-info/get-github-info.ts

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,101 @@ const LAST_RUN_PATH = new URL("./last-success.isodate", import.meta.url)
1111
.pathname
1212
const CODE_DIR = new URL("../../src/code", import.meta.url).pathname
1313

14+
type ConflictSide = "ours" | "theirs"
15+
16+
function resolveLastRunConflict(
17+
content: string,
18+
): { value: string; side: ConflictSide } | null {
19+
if (!content.includes("<<<<<<<")) {
20+
return null
21+
}
22+
23+
const ours: string[] = []
24+
const theirs: string[] = []
25+
let mode: "normal" | ConflictSide = "normal"
26+
27+
for (const line of content.split("\n")) {
28+
if (line.startsWith("<<<<<<<")) {
29+
mode = "ours"
30+
continue
31+
}
32+
33+
if (line.startsWith("=======")) {
34+
mode = "theirs"
35+
continue
36+
}
37+
38+
if (line.startsWith(">>>>>>>")) {
39+
mode = "normal"
40+
continue
41+
}
42+
43+
if (mode === "ours") {
44+
ours.push(line)
45+
} else if (mode === "theirs") {
46+
theirs.push(line)
47+
}
48+
}
49+
50+
const candidates = [
51+
{ side: "ours" as const, value: ours.join("\n").trim() },
52+
{ side: "theirs" as const, value: theirs.join("\n").trim() },
53+
].map(candidate => {
54+
const time = Date.parse(candidate.value)
55+
return { ...candidate, time }
56+
})
57+
58+
const validCandidates = candidates.filter(candidate =>
59+
Number.isFinite(candidate.time),
60+
)
61+
62+
if (validCandidates.length === 0) {
63+
return null
64+
}
65+
66+
validCandidates.sort((a, b) => b.time - a.time)
67+
const [latest] = validCandidates
68+
69+
return { value: latest.value, side: latest.side }
70+
}
71+
72+
function resolveStatsConflict(
73+
content: string,
74+
preferred: ConflictSide,
75+
): string {
76+
if (!content.includes("<<<<<<<")) {
77+
return content
78+
}
79+
80+
const resolved: string[] = []
81+
let mode: "normal" | ConflictSide = "normal"
82+
83+
for (const line of content.split("\n")) {
84+
if (line.startsWith("<<<<<<<")) {
85+
mode = "ours"
86+
continue
87+
}
88+
89+
if (line.startsWith("=======")) {
90+
mode = "theirs"
91+
continue
92+
}
93+
94+
if (line.startsWith(">>>>>>>")) {
95+
mode = "normal"
96+
continue
97+
}
98+
99+
if (mode === "normal" || mode === preferred) {
100+
resolved.push(line)
101+
}
102+
}
103+
104+
const needsTrailingNewline = content.endsWith("\n")
105+
const joined = resolved.join("\n")
106+
return needsTrailingNewline ? `${joined}\n` : joined
107+
}
108+
14109
async function main() {
15110
const filePaths = await fg("./**/*.md", { cwd: CODE_DIR, absolute: true })
16111

@@ -19,7 +114,30 @@ async function main() {
19114
{
20115
// we only sync once every two hours
21116
const TWO_HOURS = 2 * 60 * 60 * 1000
22-
const lastRun = await fs.readFile(LAST_RUN_PATH, "utf8").catch(() => "")
117+
const lastRunRaw = await fs.readFile(LAST_RUN_PATH, "utf8").catch(() => "")
118+
119+
const conflictResolution = resolveLastRunConflict(lastRunRaw)
120+
const lastRun = conflictResolution
121+
? conflictResolution.value
122+
: lastRunRaw.trim()
123+
124+
if (conflictResolution) {
125+
await fs.writeFile(LAST_RUN_PATH, lastRun)
126+
const statsContent = await fs.readFile(DATA_PATH, "utf8")
127+
if (statsContent.includes("<<<<<<<")) {
128+
console.log(
129+
"Resolved conflict. Picked",
130+
conflictResolution.side,
131+
"from",
132+
lastRun,
133+
)
134+
await fs.writeFile(
135+
DATA_PATH,
136+
resolveStatsConflict(statsContent, conflictResolution.side),
137+
)
138+
}
139+
}
140+
23141
const twoHoursAgo = new Date(Date.now() - TWO_HOURS)
24142
if (lastRun && new Date(lastRun).getTime() > twoHoursAgo.getTime()) {
25143
console.info(
@@ -40,6 +158,7 @@ async function main() {
40158
const content = await fs.readFile(filePath, "utf8")
41159
const { data } = grayMatter(content)
42160
if (data.github) {
161+
// TODO: This needs to be pooled to make the builds faster.
43162
const stats = await getGitHubStats(data.github)
44163
if (stats) {
45164
newState.set(data.github, stats)

0 commit comments

Comments
 (0)