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
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
site/node_modules
site/dist
site/dist-ssr
site/public/maze-solver.jar
9 changes: 0 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
# syntax=docker/dockerfile:1
FROM maven:3.9-eclipse-temurin-21-alpine AS maze-solver
ARG MAZE_SOLVER_REPO=https://github.com/FRC2713/maze-solver-java.git
ARG MAZE_SOLVER_REF=main
RUN apk add --no-cache git \
&& git clone --depth 1 --branch "${MAZE_SOLVER_REF}" "${MAZE_SOLVER_REPO}" /maze-solver \
&& cd /maze-solver \
&& mvn -B -q -DskipTests package

FROM node:24-bookworm-slim AS builder
WORKDIR /app/site
COPY site/package.json site/package-lock.json ./
RUN npm ci
WORKDIR /app
COPY lessons ./lessons
COPY site ./site
COPY --from=maze-solver /maze-solver/target/maze-solver.jar ./site/public/maze-solver.jar
WORKDIR /app/site
RUN npm run build

Expand Down
2 changes: 1 addition & 1 deletion scripts/smoke-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ for _attempt in $(seq 1 60); do
const health = await fetch("http://127.0.0.1:3000/health").then(r => r.json());
if (health.status !== "ok") process.exit(1);
if (process.env.EXPECTED_REV && health.revision !== process.env.EXPECTED_REV) process.exit(1);
for (const p of ["/", "/tools.jar", "/maze-solver.jar"]) {
for (const p of ["/"]) {
const r = await fetch("http://127.0.0.1:3000" + p, { method: "HEAD" });
if (!r.ok) { console.error("Missing asset:", p, r.status); process.exit(1); }
}
Expand Down
22 changes: 0 additions & 22 deletions site/package-lock.json

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

4 changes: 1 addition & 3 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "oxlint",
"preview": "vite preview",
"vendor:maze-solver": "bash scripts/vendor-maze-solver.sh"
"preview": "vite preview"
},
"dependencies": {
"@codemirror/lang-java": "^6.0.2",
"@codemirror/lang-python": "^6.2.1",
"@codemirror/theme-one-dark": "^6.1.3",
"@radix-ui/react-dialog": "^1.1.18",
Expand Down
Binary file removed site/public/tools.jar
Binary file not shown.
23 changes: 0 additions & 23 deletions site/scripts/vendor-maze-solver.sh

This file was deleted.

12 changes: 4 additions & 8 deletions site/src/components/CodeBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import { useMemo } from 'react'
import CodeMirror, { EditorView } from '@uiw/react-codemirror'
import { java } from '@codemirror/lang-java'
import { python } from '@codemirror/lang-python'
import { oneDark } from '@codemirror/theme-one-dark'
import { editorTheme, usePrefersDark } from '@/lib/editorTheme'

// A read-only, syntax-highlighted rendering of a fenced code block in the prose.
// Python and Java blocks get language highlighting + line numbers; other fences
// (e.g. ```text``` output samples) get the same themed surface without either.
// Python blocks get language highlighting + line numbers; other fences (e.g.
// ```text``` output samples) get the same themed surface without either.
export function CodeBlock({ code, language }: { code: string; language?: string }) {
const dark = usePrefersDark()
const isJava = language === 'java'
const isPython = language === 'python'
const isCode = isJava || isPython

const extensions = useMemo(() => {
const ext = [editorTheme, EditorView.lineWrapping]
if (isPython) ext.unshift(python())
else if (isJava) ext.unshift(java())
return ext
}, [isJava, isPython])
}, [isPython])

return (
<div className="my-4 overflow-hidden rounded-lg border bg-muted">
Expand All @@ -29,7 +25,7 @@ export function CodeBlock({ code, language }: { code: string; language?: string
extensions={extensions}
theme={dark ? oneDark : 'light'}
basicSetup={{
lineNumbers: isCode,
lineNumbers: isPython,
foldGutter: false,
highlightActiveLine: false,
highlightActiveLineGutter: false,
Expand Down
16 changes: 3 additions & 13 deletions site/src/components/JavaRunner.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import { useMemo, useState } from 'react'
import CodeMirror, { EditorView } from '@uiw/react-codemirror'
import { java } from '@codemirror/lang-java'
import { python } from '@codemirror/lang-python'
import { oneDark } from '@codemirror/theme-one-dark'
import { getJavaRuntimeStatus, runJava } from '@/lib/javaRuntime'
import { runPython } from '@/lib/pythonRuntime'
import type { RunnableLanguage } from '@/lib/lessons'
import { editorTheme, usePrefersDark } from '@/lib/editorTheme'
import { Button } from '@/components/ui/button'
import { cn } from '@/lib/utils'

export function JavaRunner({
initialCode,
storageKey,
language = 'java',
}: {
initialCode: string
storageKey: string
language?: RunnableLanguage
}) {
const originalCode = initialCode.trimEnd()
const [code, setCode] = useState(() => localStorage.getItem(storageKey) ?? originalCode)
Expand All @@ -26,17 +21,12 @@ export function JavaRunner({
const [running, setRunning] = useState(false)
const dark = usePrefersDark()

const extensions = useMemo(
() => [language === 'python' ? python() : java(), editorTheme, EditorView.lineWrapping],
[language],
)
const extensions = useMemo(() => [python(), editorTheme, EditorView.lineWrapping], [])

const handleRun = async () => {
const label =
language === 'python' || getJavaRuntimeStatus() === 'ready' ? 'Running…' : 'Loading Java…'
setRunning(true)
setOutput(label)
const result = language === 'python' ? await runPython(code) : await runJava(code)
setOutput('Running…')
const result = await runPython(code)
setOk(result.ok)
setOutput(result.output || '(no output)')
setRunning(false)
Expand Down
Loading
Loading