diff --git a/website/src/lib/changelog.ts b/website/src/lib/changelog.ts index 312a7c5..c4225be 100644 --- a/website/src/lib/changelog.ts +++ b/website/src/lib/changelog.ts @@ -87,3 +87,13 @@ export function loadChangelog(): ChangelogRelease[] { const md = readFileSync(file, 'utf8'); return parseChangelog(md); } + +let cachedVersion: string | null = null; + +export function latestVersion(): string { + if (cachedVersion) return cachedVersion; + const latest = loadChangelog().find((r) => r.isLatest); + if (!latest?.version) throw new Error('CHANGELOG.md has no stable release entry'); + cachedVersion = latest.version; + return cachedVersion; +} diff --git a/website/src/lib/highlight.ts b/website/src/lib/highlight.ts index 6df94e6..77622c4 100644 --- a/website/src/lib/highlight.ts +++ b/website/src/lib/highlight.ts @@ -25,9 +25,15 @@ export const synapseTheme: ThemeRegistration = { const highlighter = await createHighlighter({ themes: [synapseTheme], - langs: ['java'], + langs: ['java', 'groovy', 'kotlin', 'properties'], }) export function highlightJava(code: string): string { return highlighter.codeToHtml(code, { lang: 'java', theme: synapseTheme }) } + +export type SnippetLang = 'java' | 'groovy' | 'kotlin' | 'properties'; + +export function highlightCode(code: string, lang: SnippetLang): string { + return highlighter.codeToHtml(code, { lang, theme: synapseTheme }) +} diff --git a/website/src/pages/index.astro b/website/src/pages/index.astro index af8444c..6b0c84e 100644 --- a/website/src/pages/index.astro +++ b/website/src/pages/index.astro @@ -3,6 +3,7 @@ import BaseLayout from '~/components/layout/BaseLayout.astro'; import { highlightJava } from '@/lib/highlight'; import { QUICKSTART_CODE, PUBSUB_CODE, HARDWARE_CODE } from '@/lib/code-samples'; +import { latestVersion } from '@/lib/changelog'; import { Badge } from '@/components/ui/badge'; import { @@ -103,7 +104,7 @@ const pools = [ const REPO = 'https://github.com/IamCoder18/synapse'; -const VERSION = '0.4.0'; +const VERSION = latestVersion(); const DESCRIPTION = 'A tiny, annotation-driven pub/sub bus for FTC robot code. 40 KB. Zero dependencies. One hardware thread.'; diff --git a/website/src/pages/install.astro b/website/src/pages/install.astro index 26432ad..bac9d4a 100644 --- a/website/src/pages/install.astro +++ b/website/src/pages/install.astro @@ -2,22 +2,49 @@ import BaseLayout from '~/components/layout/BaseLayout.astro'; import Nav from '~/components/layout/Nav.astro'; import Footer from '~/components/layout/Footer.astro'; +import { highlightCode, type SnippetLang } from '@/lib/highlight'; +import { latestVersion } from '@/lib/changelog'; +import { Badge } from '@/components/ui/badge'; +import { buttonVariants } from '@/components/ui/button'; +import { ArrowRight, BookOpen, Check } from 'lucide-react'; -const groovy = `dependencies { - implementation 'com.aaravlabs:synapse:0.4.0' +const VERSION = latestVersion(); + +const snippets: Array<{ + id: SnippetLang; + label: string; + file: string; + code: string; +}> = [ + { + id: 'groovy', + label: 'Gradle — Groovy', + file: 'build.dependencies.gradle', + code: `dependencies { + implementation 'com.aaravlabs:synapse:${VERSION}' // ... your other FTC deps -}`; +}`, + }, + { + id: 'kotlin', + label: 'Gradle — Kotlin DSL', + file: 'build.dependencies.gradle.kts', + code: `dependencies { + implementation("com.aaravlabs:synapse:${VERSION}") + // ... your other FTC deps +}`, + }, +]; -const kotlinDsl = `dependencies { - implementation("com.aaravlabs:synapse:0.4.0") -}`; +const reassurances = [ + 'No token or credentials', + 'No repository changes', + 'R8-safe out of the box', +]; -const maven = ` - - com.aaravlabs - synapse - 0.4.0 -`; +const gprProps = `# ~/.gradle/gradle.properties (never commit) +githubUser= +githubToken=`; const gprGroovy = `repositories { mavenCentral() @@ -32,183 +59,325 @@ const gprGroovy = `repositories { } dependencies { - implementation 'com.aaravlabs:synapse:0.4.0' -}`; - -const gprKotlinDsl = `repositories { - mavenCentral() - google() - maven { - url = uri("https://maven.pkg.github.com/IamCoder18/synapse") - credentials { - username = (findProperty("githubUser") as String?) - ?: System.getenv("GITHUB_USER") - ?: System.getenv("GITHUB_ACTOR") - password = (findProperty("githubToken") as String?) - ?: System.getenv("GITHUB_TOKEN") - } - } -} - -dependencies { - implementation("com.aaravlabs:synapse:0.4.0") -}`; - -const gradleProps = `# ~/.gradle/gradle.properties (never commit) -githubUser= -githubToken=`; -const proguard = `# Already in the JAR. R8 keeps everything you need. --keep class com.aaravlabs.synapse.** { *; } --keep @com.aaravlabs.synapse.annotation.* class *`; - -const verify = `import com.qualcomm.robotcore.eventloop.opmode.TeleOp; -import com.aaravlabs.synapse.ftc.GamepadAdaptor; -import com.aaravlabs.synapse.ftc.SafeOpMode; - -@TeleOp(name = "MyFirstOpMode", group = "Synapse") -public class MyFirstOpMode extends SafeOpMode { - @Override protected void onSafeInit() { - // You now have: orchestrator, hardware, safeMap ready. - GamepadAdaptor.attach(orchestrator, gamepad1, "g1"); - } - @Override protected void onSafeLoop() { - telemetry.update(); - } + implementation 'com.aaravlabs:synapse:${VERSION}' }`; ---