From b7ce705b2b7a7ca4499c8bb3a0fb15319a1ed140 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 2 Apr 2026 02:09:00 -0500 Subject: [PATCH] Add versioning system, changelog page, and release skill Replace calver (YYYY.MM.DD+sha) with marketing versioning (X.Y.Z), starting at 9.9.0. Add changelog page at /changelog with Keep a Changelog parsing, pre-release banner, and expandable entries linked to GitLab releases. Add VersionCheck component that shows a "What's new" toast when the app version changes. Add release skill for managing versioned releases with changelog and git tagging. --- .agents/skills/release/SKILL.md | 198 ++++++++++++++++++++ CHANGELOG.md | 7 + package-lock.json | 29 +-- package.json | 2 +- public/CHANGELOG.md | 7 + src/App.tsx | 2 + src/AppRouter.tsx | 2 + src/components/VersionCheck.tsx | 67 +++++++ src/lib/changelog.ts | 81 ++++++++ src/lib/tools/AppTool.ts | 2 +- src/locales/en.json | 1 + src/locales/ha.json | 1 + src/locales/ig.json | 1 + src/locales/pt.json | 1 + src/locales/yo.json | 1 + src/locales/zh.json | 1 + src/pages/AboutSettings.tsx | 25 ++- src/pages/ChangelogPage.tsx | 323 ++++++++++++++++++++++++++++++++ src/vite-env.d.ts | 13 +- vite.config.ts | 33 +++- 20 files changed, 754 insertions(+), 43 deletions(-) create mode 100644 .agents/skills/release/SKILL.md create mode 100644 CHANGELOG.md create mode 100644 public/CHANGELOG.md create mode 100644 src/components/VersionCheck.tsx create mode 100644 src/lib/changelog.ts create mode 100644 src/pages/ChangelogPage.tsx diff --git a/.agents/skills/release/SKILL.md b/.agents/skills/release/SKILL.md new file mode 100644 index 00000000..8eafedff --- /dev/null +++ b/.agents/skills/release/SKILL.md @@ -0,0 +1,198 @@ +--- +name: release +description: Publish a new app release with versioning, changelog, and git tagging. Triggered by "publish a new release" or similar requests. +--- + +# Release Skill + +This skill guides you through publishing a new release of the app. It handles version bumping, changelog generation, and git tagging/pushing. + +## Overview + +- **Version format**: Marketing version (X.Y.Z), starting from 9.9.0. **This is NOT semver.** Version numbers are chosen based on how the release looks to end users, not based on API compatibility or breaking changes. Think of it like an app store version -- the number reflects the perceived significance of the update to a regular user. +- **Version source of truth**: `package.json` `version` field +- **Changelog**: `CHANGELOG.md` in repo root, using [Keep a Changelog](https://keepachangelog.com/) format +- **Version bumping**: + - **Patch (Z)**: Most releases. Bug fixes, tweaks, internal improvements, anything a user wouldn't specifically notice or seek out. + - **Minor (Y)**: Releases with headline features -- things worth announcing. A user should be able to look at the minor bump and think "oh, something new happened." + - **Major (X)**: Only when the user explicitly requests it (milestones, rebrands, major redesigns) +- **CI trigger**: Pushing a version tag (`v9.9.0`) triggers the CI pipeline to build and create a GitLab release + +## Release Procedure + +Follow these steps in order. Do NOT skip any step. + +### Step 1: Required Reading + +Before writing any release notes, you MUST read these pages to understand the product context, voice, and values: + +1. **https://soapbox.pub/** -- Soapbox company overview and product suite +2. **https://shakespeare.diy/** -- Shakespeare product page + +These pages define what Shakespeare is, how it's positioned, and the tone of voice to use. Changelog entries should reflect this identity: creative, empowering, user-focused, emphasizing building and self-expression. Avoid dry technical jargon -- write for people who use the app, not developers. + +### Step 2: Pre-flight Checks + +```bash +# Ensure working directory is clean +git status + +# Ensure we're on main branch +git branch --show-current + +# Run the full test suite +npm run test +``` + +- If the working directory has uncommitted changes, ask the user whether to commit them first or abort. +- If not on `main`, warn the user and ask whether to proceed. +- If tests fail, stop and fix the issues before continuing. + +### Step 3: Determine What Changed + +```bash +# Get the current version from package.json +node -p "require('./package.json').version" + +# Get commits since the last version tag +git log v$(node -p "require('./package.json').version")..HEAD --oneline +``` + +- If there are no commits since the last tag, inform the user there is nothing to release and stop. +- Review the commit list to understand the scope of changes. + +### Step 4: Decide the Version Bump + +Analyze the commits from Step 3 and determine the appropriate bump level: + +| Bump | When to use | Example | +|------|-------------|---------| +| **Patch** | Bug fixes, minor tweaks, dependency updates, small UI polish, internal tooling, developer-facing pages, CI/build changes, settings/admin screens | 9.9.0 -> 9.9.1 | +| **Minor** | Significant new product features that change how users interact with the app -- the kind of thing you'd highlight in an app store update or announce on social media (e.g., new template support, new AI features, new deployment options, major UI overhaul) | 9.9.1 -> 9.10.0 | +| **Major** | ONLY when the user explicitly instructs a major bump | 9.10.0 -> 10.0.0 | + +**Default to patch** when in doubt. The bar for a minor bump is high -- ask yourself: "Would a regular user notice and care about this change?" If the answer is no, it's a patch. Internal pages (changelog, settings, about screens), infrastructure improvements, CI fixes, and developer tooling are always patch-level regardless of whether they technically add a new page or screen. + +When bumping minor, reset patch to 0 (e.g., 9.9.3 -> 9.10.0). +When bumping major, reset minor and patch to 0 (e.g., 9.3.1 -> 10.0.0). + +### Step 5: Write the Changelog Entry + +Prepend a new section to `CHANGELOG.md` directly below the `# Changelog` heading. + +**Format:** + +```markdown +## [X.Y.Z] - YYYY-MM-DD + +### Added +- Description of new features + +### Changed +- Description of changes to existing features + +### Fixed +- Description of bug fixes + +### Removed +- Description of removed features +``` + +**Rules:** +- Only include categories that have entries (omit empty categories) +- Write **user-facing descriptions**, not raw commit messages +- Keep descriptions concise -- one line per change +- Group related commits into single entries where appropriate +- Use present tense ("Add dark mode toggle", not "Added dark mode toggle") +- Focus on what the user sees/experiences, not internal implementation details +- Use the current date in YYYY-MM-DD format +- **Collapse related work into one entry.** If a feature was added and then fixed/tweaked across multiple commits in the same release, present the finished result as a single "Added" entry. Never list something as "Added" and then also list fixes for that same thing -- the user sees the end product, not the development history. +- **Omit purely internal changes.** CI fixes, build pipeline tweaks, developer tooling, and infrastructure changes should be omitted from the changelog entirely unless they have a direct, visible impact on the user experience. The changelog is for users, not developers. +- **Compare the actual code between versions** to understand what really changed, rather than just reading commit messages. Commit messages may over- or under-represent the significance of changes. + +### Step 6: Update Version in All Files + +#### 6a. `package.json` + +Update the `version` field: + +```json +"version": "X.Y.Z" +``` + +### Step 7: Copy Changelog to Public Directory + +The changelog is served at runtime by the app from the `public/` directory. After updating `CHANGELOG.md`, copy it: + +```bash +cp CHANGELOG.md public/CHANGELOG.md +``` + +### Step 8: Pull Latest Changes + +Before committing the release, pull the latest changes from the remote to ensure the release commit sits on top of the latest code. This **must** happen before committing and tagging. + +```bash +git pull origin main +``` + +**CRITICAL**: Always use `git pull` (merge), NEVER `git pull --rebase`. Rebasing rewrites commit hashes, which would orphan any tag pointing to the original commit. Since version tags are often protected on the remote and cannot be deleted or updated, a broken tag cannot be easily fixed. + +If there are merge conflicts with the pulled changes, resolve them before proceeding. + +### Step 9: Commit the Release + +```bash +git add package.json CHANGELOG.md public/CHANGELOG.md +git commit -m "release: vX.Y.Z" +``` + +### Step 10: Tag the Release + +```bash +git tag vX.Y.Z +``` + +The tag format is `v` followed by the version with no suffix. Examples: `v9.9.0`, `v9.10.0`, `v10.0.0`. + +### Step 11: Push + +```bash +git push origin main vX.Y.Z +``` + +**CRITICAL**: Push only the specific tag being released. NEVER use `--tags` -- that pushes ALL local tags, including stale or deleted ones. + +### Step 12: Confirm + +After pushing, inform the user: +- The new version number +- A brief summary of what was released +- That CI will handle building and publishing the artifacts + +## File Reference + +| File | What to update | Notes | +|------|---------------|-------| +| `package.json` | `version` field | Source of truth for the version | +| `CHANGELOG.md` | Prepend new section | User-facing changelog | +| `public/CHANGELOG.md` | Copy from `CHANGELOG.md` | Served at runtime by the app | + +## Troubleshooting + +### "Nothing to release" +If `git log` shows no commits since the last tag, there genuinely is nothing to release. + +### Tests fail +Fix the failing tests before proceeding. The release must not contain broken code. + +### Wrong version bumped +If you tagged the wrong version and haven't pushed yet: +```bash +git tag -d vX.Y.Z # delete the local tag +git reset --soft HEAD~1 # undo the commit but keep changes staged +``` +Then redo steps 4-10 with the correct version. + +### Already pushed a bad release +This requires manual intervention. Inform the user and suggest they delete the tag and release from GitLab manually, then re-run the release process. diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..bfeeca8b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +## [9.9.0] - 2026-04-02 + +### Added +- Changelog page and versioning system with "What's new" toast notifications on updates +- Release skill for managing versioned releases with changelog generation and git tagging diff --git a/package-lock.json b/package-lock.json index b12db75e..6def1106 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "shakespeare.diy", - "version": "0.0.0", + "version": "9.9.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "shakespeare.diy", - "version": "0.0.0", + "version": "9.9.0", "license": "AGPL-3.0-or-later", "dependencies": { "@dnd-kit/core": "^6.3.1", @@ -4677,7 +4677,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4691,7 +4690,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4705,7 +4703,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4719,7 +4716,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4733,7 +4729,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4747,7 +4742,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4761,7 +4755,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4775,7 +4768,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4789,7 +4781,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4803,7 +4794,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4817,7 +4807,6 @@ "cpu": [ "loong64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4831,7 +4820,6 @@ "cpu": [ "loong64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4845,7 +4833,6 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4859,7 +4846,6 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4873,7 +4859,6 @@ "cpu": [ "riscv64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4887,7 +4872,6 @@ "cpu": [ "riscv64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4901,7 +4885,6 @@ "cpu": [ "s390x" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4915,7 +4898,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4929,7 +4911,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4943,7 +4924,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4957,7 +4937,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4971,7 +4950,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4985,7 +4963,6 @@ "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4999,7 +4976,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -5013,7 +4989,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ diff --git a/package.json b/package.json index 19ca11c8..097ce58f 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "Build custom apps with AI assistance using Shakespeare, an open-source development environment", "homepage": "https://shakespeare.diy", "license": "AGPL-3.0-or-later", - "version": "0.0.0", + "version": "9.9.0", "type": "module", "author": { "name": "shakespeare.diy", diff --git a/public/CHANGELOG.md b/public/CHANGELOG.md new file mode 100644 index 00000000..bfeeca8b --- /dev/null +++ b/public/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +## [9.9.0] - 2026-04-02 + +### Added +- Changelog page and versioning system with "What's new" toast notifications on updates +- Release skill for managing versioned releases with changelog generation and git tagging diff --git a/src/App.tsx b/src/App.tsx index c77ecc0c..fab7a7dc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -30,6 +30,7 @@ import { OfflineIndicator } from '@/components/OfflineIndicator'; import { PWAUpdatePrompt } from '@/components/PWAUpdatePrompt'; import { ErrorBoundary } from '@/components/ErrorBoundary'; import { LockdownModeDetector } from '@/components/LockdownModeDetector'; +import { VersionCheck } from '@/components/VersionCheck'; import AppRouter from './AppRouter'; @@ -152,6 +153,7 @@ export function App() { + diff --git a/src/AppRouter.tsx b/src/AppRouter.tsx index db4d0dee..01f1d710 100644 --- a/src/AppRouter.tsx +++ b/src/AppRouter.tsx @@ -23,6 +23,7 @@ import { NIP19Page } from "./pages/NIP19Page"; import NotFound from "./pages/NotFound"; import { ProjectView } from "./pages/ProjectView"; import { SettingsLayout } from "./components/SettingsLayout"; +import { ChangelogPage } from "./pages/ChangelogPage"; export function AppRouter() { return ( @@ -49,6 +50,7 @@ export function AppRouter() { } /> } /> + } /> } /> {/* NIP-19 route for npub1, note1, naddr1, nevent1, nprofile1 */} } /> diff --git a/src/components/VersionCheck.tsx b/src/components/VersionCheck.tsx new file mode 100644 index 00000000..d4a300c9 --- /dev/null +++ b/src/components/VersionCheck.tsx @@ -0,0 +1,67 @@ +import { useEffect } from 'react'; +import { Link } from 'react-router-dom'; + +import { toast } from '@/hooks/useToast'; +import { ToastAction } from '@/components/ui/toast'; +import { parseChangelog } from '@/lib/changelog'; + +const STORAGE_KEY = 'shakespeare:app-version'; + +/** Fetch the first changelog item for the given version (or the latest entry). */ +async function fetchChangelogExcerpt(version: string): Promise { + try { + const res = await fetch('/CHANGELOG.md'); + if (!res.ok) return undefined; + const markdown = await res.text(); + const entries = parseChangelog(markdown); + + // Try to find the entry matching the current version, otherwise use the first entry. + const entry = entries.find((e) => e.version === version) ?? entries[0]; + if (!entry) return undefined; + + // Return the first item from the first section. + return entry.sections[0]?.items[0]; + } catch { + return undefined; + } +} + +/** Compares the running app version against localStorage and shows a toast when the version changes. */ +export function VersionCheck() { + useEffect(() => { + const currentVersion = import.meta.env.VERSION; + if (!currentVersion) return; + + const storedVersion = localStorage.getItem(STORAGE_KEY); + localStorage.setItem(STORAGE_KEY, currentVersion); + + if (storedVersion && storedVersion !== currentVersion) { + // Show the toast immediately, then enrich it with a changelog excerpt. + const { update, id } = toast({ + title: `What's new in v${currentVersion}`, + action: ( + + See all + + ), + }); + + fetchChangelogExcerpt(currentVersion).then((excerpt) => { + if (excerpt) { + update({ + id, + title: `What's new in v${currentVersion}`, + description: excerpt, + action: ( + + See all + + ), + }); + } + }); + } + }, []); + + return null; +} diff --git a/src/lib/changelog.ts b/src/lib/changelog.ts new file mode 100644 index 00000000..1c0d85da --- /dev/null +++ b/src/lib/changelog.ts @@ -0,0 +1,81 @@ +/** Category types from Keep a Changelog format. */ +type ChangelogCategory = 'Added' | 'Changed' | 'Deprecated' | 'Removed' | 'Fixed' | 'Security'; + +/** A single version entry in the changelog. */ +interface ChangelogEntry { + version: string; + date: string; + sections: { + category: ChangelogCategory; + items: string[]; + }[]; +} + +/** Apply basic typographic transformations to a changelog item string. */ +function prettify(text: string): string { + return text + .replace(/ -- /g, ' \u2014 ') // space-dash-dash-space → em dash + .replace(/(\w)--(\w)/g, '$1\u2013$2') // word--word → en dash + .replace(/ (\S+)$/, '\u00A0$1'); // prevent orphaned last word +} + +/** + * Parse a Keep a Changelog formatted markdown string into structured data. + * @see https://keepachangelog.com/ + */ +function parseChangelog(markdown: string): ChangelogEntry[] { + const entries: ChangelogEntry[] = []; + let current: ChangelogEntry | null = null; + let currentCategory: ChangelogCategory | null = null; + + for (const line of markdown.split('\n')) { + // Match version heading: ## [X.Y.Z] - YYYY-MM-DD + const versionMatch = line.match(/^## \[([^\]]+)\]\s*-\s*(.+)$/); + if (versionMatch) { + current = { version: versionMatch[1], date: versionMatch[2].trim(), sections: [] }; + entries.push(current); + currentCategory = null; + continue; + } + + // Match category heading: ### Added, ### Changed, etc. + const categoryMatch = line.match(/^### (.+)$/); + if (categoryMatch && current) { + currentCategory = categoryMatch[1].trim() as ChangelogCategory; + current.sections.push({ category: currentCategory, items: [] }); + continue; + } + + // Match list item: - Description + const itemMatch = line.match(/^- (.+)$/); + if (itemMatch && current) { + const section = current.sections[current.sections.length - 1]; + if (section) { + section.items.push(prettify(itemMatch[1])); + } else { + // Item without a category heading — treat as "Changed" + current.sections.push({ category: 'Changed', items: [prettify(itemMatch[1])] }); + } + continue; + } + + // Lines that don't start with "- " but aren't blank may be a continuation or + // freeform text after the version heading (e.g. "Initial release of Shakespeare"). + const trimmed = line.trim(); + if (trimmed && current && !trimmed.startsWith('#')) { + const section = current.sections[current.sections.length - 1]; + if (section) { + // Append to last item or add new item + section.items.push(prettify(trimmed)); + } else { + // Freeform text under version with no category — store in a generic section + current.sections.push({ category: 'Changed', items: [prettify(trimmed)] }); + } + } + } + + return entries; +} + +export { parseChangelog }; +export type { ChangelogEntry, ChangelogCategory }; diff --git a/src/lib/tools/AppTool.ts b/src/lib/tools/AppTool.ts index aeec3132..19c08a80 100644 --- a/src/lib/tools/AppTool.ts +++ b/src/lib/tools/AppTool.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; import { NPool, NRelay1 } from '@nostrify/nostrify'; -import type { NostrEvent, NostrSigner } from '@nostrify/nostrify'; +import type { NostrSigner } from '@nostrify/nostrify'; import { DotAI } from '../DotAI'; import { buildAppEvent } from '../appEvent'; diff --git a/src/locales/en.json b/src/locales/en.json index c327ebe4..8216d0c8 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -239,6 +239,7 @@ "aboutShakespeareDescription": "Information about Shakespeare", "mirrors": "Mirrors", "mirrorsDescription": "Shakespeare is available at multiple mirror URLs for redundancy and accessibility.", + "changelog": "Changelog", "sourceCode": "Source Code", "description": "Description", "license": "License", diff --git a/src/locales/ha.json b/src/locales/ha.json index 80844246..e0920681 100644 --- a/src/locales/ha.json +++ b/src/locales/ha.json @@ -267,6 +267,7 @@ "aboutShakespeareDescription": "Bayani game da Shakespeare.", "mirrors": "Madubai", "mirrorsDescription": "Shakespeare yana samuwa a URLs masu yawa don inganci da samun dama.", + "changelog": "Tarihin Canje-canje", "sourceCode": "Lambar Tushe", "description": "Bayanin", "license": "Lasisi", diff --git a/src/locales/ig.json b/src/locales/ig.json index c2909e96..62eb36e6 100644 --- a/src/locales/ig.json +++ b/src/locales/ig.json @@ -267,6 +267,7 @@ "aboutShakespeareDescription": "Ozi gbasara Shakespeare.", "mirrors": "Enyo", "mirrorsDescription": "Shakespeare dị na ọtụtụ URL enyo maka nnọchi na nnweta.", + "changelog": "Ndekọ Mgbanwe", "sourceCode": "Koodu Isi", "description": "Nkọwa", "license": "Ikike", diff --git a/src/locales/pt.json b/src/locales/pt.json index a015ac34..6b14087e 100644 --- a/src/locales/pt.json +++ b/src/locales/pt.json @@ -276,6 +276,7 @@ "aboutShakespeareDescription": "Informações sobre o Shakespeare.", "mirrors": "Espelhos", "mirrorsDescription": "Shakespeare está disponível em vários URLs espelhados para redundância e acessibilidade.", + "changelog": "Registro de alterações", "sourceCode": "Código-fonte", "description": "Descrição", "license": "Licença", diff --git a/src/locales/yo.json b/src/locales/yo.json index f784104a..e310342a 100644 --- a/src/locales/yo.json +++ b/src/locales/yo.json @@ -267,6 +267,7 @@ "aboutShakespeareDescription": "Alaye nipa Shakespeare.", "mirrors": "Awọn Digi", "mirrorsDescription": "Shakespeare wa ni awọn URL digi pupọ fun aredundan ati iraye si.", + "changelog": "Akọsilẹ Ayipada", "sourceCode": "Koodu Orisun", "description": "Apejuwe", "license": "Iwe-aṣẹ", diff --git a/src/locales/zh.json b/src/locales/zh.json index aa88ed17..e70b8d48 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -276,6 +276,7 @@ "aboutShakespeareDescription": "关于Shakespeare的信息。", "mirrors": "镜像", "mirrorsDescription": "Shakespeare可通过多个镜像URL访问,以确保冗余和可访问性。", + "changelog": "更新日志", "sourceCode": "源代码", "description": "描述", "license": "许可证", diff --git a/src/pages/AboutSettings.tsx b/src/pages/AboutSettings.tsx index 08f1a3a3..11707f49 100644 --- a/src/pages/AboutSettings.tsx +++ b/src/pages/AboutSettings.tsx @@ -1,6 +1,7 @@ import { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; -import { Info, ExternalLink, Loader2, AlertTriangle, Code, Globe } from 'lucide-react'; +import { Link } from 'react-router-dom'; +import { Info, ExternalLink, Loader2, AlertTriangle, Code, Globe, ScrollText } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { SettingsPageLayout } from '@/components/SettingsPageLayout'; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion'; @@ -97,6 +98,22 @@ export function AboutSettings() { + {/* Changelog */} + + + + + + {/* Project Information */} @@ -148,9 +165,9 @@ export function AboutSettings() { {import.meta.env.VERSION && ( -
- v{import.meta.env.VERSION} -
+ + v{import.meta.env.VERSION}{import.meta.env.COMMIT_TAG ? '' : '+'} ({new Date(import.meta.env.BUILD_DATE).toLocaleDateString()}) + )} ); diff --git a/src/pages/ChangelogPage.tsx b/src/pages/ChangelogPage.tsx new file mode 100644 index 00000000..8209dea8 --- /dev/null +++ b/src/pages/ChangelogPage.tsx @@ -0,0 +1,323 @@ +import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; +import { Link } from 'react-router-dom'; +import { useSeoMeta } from '@unhead/react'; +import { ArrowLeft, Bug, FlaskConical, Minus, Package, Plus, RefreshCw, ShieldAlert } from 'lucide-react'; + +import { Button } from '@/components/ui/button'; +import { Skeleton } from '@/components/ui/skeleton'; +import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'; +import { parseChangelog } from '@/lib/changelog'; +import type { ChangelogCategory, ChangelogEntry } from '@/lib/changelog'; + +const GITLAB_REPO = 'https://gitlab.com/soapbox-pub/shakespeare'; + +/** Per-category icon + color used as inline list bullets. */ +const CATEGORY_STYLES: Record = { + Added: { icon: Plus, colorClass: 'text-emerald-600 dark:text-emerald-400' }, + Changed: { icon: RefreshCw, colorClass: 'text-blue-600 dark:text-blue-400' }, + Deprecated: { icon: Package, colorClass: 'text-orange-600 dark:text-orange-400' }, + Removed: { icon: Minus, colorClass: 'text-red-600 dark:text-red-400' }, + Fixed: { icon: Bug, colorClass: 'text-amber-600 dark:text-amber-400' }, + Security: { icon: ShieldAlert, colorClass: 'text-purple-600 dark:text-purple-400' }, +}; + +/** Format "2026-03-26" as a readable date string. */ +function formatDate(raw: string): string { + const date = new Date(raw + 'T00:00:00'); + if (isNaN(date.getTime())) return raw; + return date.toLocaleDateString(undefined, { year: 'numeric', month: 'long', day: 'numeric' }); +} + +const commitSha = import.meta.env.COMMIT_SHA; +const commitTag = import.meta.env.COMMIT_TAG; +const buildDate = import.meta.env.BUILD_DATE; +const isPreRelease = !commitTag; + +export function ChangelogPage() { + const [content, setContent] = useState(null); + const [error, setError] = useState(false); + + useSeoMeta({ + title: 'Changelog | Shakespeare', + description: "What's new in Shakespeare", + }); + + useEffect(() => { + fetch('/CHANGELOG.md') + .then((res) => { + if (!res.ok) throw new Error(res.statusText); + return res.text(); + }) + .then(setContent) + .catch(() => setError(true)); + }, []); + + const entries = useMemo(() => (content ? parseChangelog(content) : []), [content]); + const latestVersion = entries[0]?.version; + + return ( +
+ {/* Header */} +
+
+ +

Changelog

+
+
+ +
+ {error ? ( +

Failed to load changelog.

+ ) : content === null ? ( + + ) : entries.length === 0 ? ( +

No releases yet.

+ ) : ( + <> + {isPreRelease && latestVersion && } + + + + {entries.length > 1 && ( + <> +
+
+ Past releases +
+
+ + {entries.slice(1).map((entry) => ( + + ))} + + )} + + )} +
+
+ ); +} + +/** Hero treatment for the most recent release — no card, centered version + date. */ +function LatestRelease({ entry }: { entry: ChangelogEntry }) { + const contentRef = useRef(null); + const [overflows, setOverflows] = useState(false); + const [expanded, setExpanded] = useState(false); + + const measure = useCallback(() => { + const el = contentRef.current; + if (el) setOverflows(el.scrollHeight > ENTRY_MAX_HEIGHT); + }, []); + + useEffect(() => { + measure(); + window.addEventListener('resize', measure); + return () => window.removeEventListener('resize', measure); + }, [measure]); + + return ( +
+ {/* Big centered version + date */} + + v{entry.version} + + + {formatDate(entry.date)} + + + {/* Items */} +
+
    + {entry.sections.flatMap((section) => { + const style = CATEGORY_STYLES[section.category] ?? CATEGORY_STYLES.Changed; + const Icon = style.icon; + + return section.items.map((item, i) => ( +
  • + + + + + {section.category} + + {item} +
  • + )); + })} +
+ {!expanded && overflows && ( +
+ )} +
+ + {overflows && ( + + )} +
+ ); +} + +const ENTRY_MAX_HEIGHT = 240; // px — entries taller than this get a "Read more" button + +/** A single changelog release card with truncation for long entries. */ +function ChangelogEntryCard({ entry }: { entry: ChangelogEntry }) { + const contentRef = useRef(null); + const [overflows, setOverflows] = useState(false); + const [expanded, setExpanded] = useState(false); + + const measure = useCallback(() => { + const el = contentRef.current; + if (el) setOverflows(el.scrollHeight > ENTRY_MAX_HEIGHT); + }, []); + + useEffect(() => { + measure(); + window.addEventListener('resize', measure); + return () => window.removeEventListener('resize', measure); + }, [measure]); + + return ( +
+ {/* Version header */} + + + {/* Items */} +
+
    + {entry.sections.flatMap((section) => { + const style = CATEGORY_STYLES[section.category] ?? CATEGORY_STYLES.Changed; + const Icon = style.icon; + + return section.items.map((item, i) => ( +
  • + + + + + {section.category} + + {item} +
  • + )); + })} +
+ {!expanded && overflows && ( +
+ )} +
+ + {overflows && ( + + )} +
+ ); +} + +/** Banner shown at the top of the changelog for untagged (pre-release) builds. */ +function PreReleaseBanner({ latestVersion }: { latestVersion: string }) { + return ( +
+
+ + Pre-release build + {commitSha && buildDate && ( + + {formatDate(buildDate.split('T')[0])} + + )} +
+

+ This build contains changes not yet included in a release.{' '} + + View unreleased changes + +

+
+ ); +} + +function ChangelogSkeleton() { + return ( +
+ {[1, 2].map((i) => ( +
+
+ + +
+ + +
+
+
+ + + + +
+
+ ))} +
+ ); +} + +export default ChangelogPage; diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index 26ed71da..9c3fa068 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -1,2 +1,13 @@ /// -/// \ No newline at end of file +/// + +interface ImportMetaEnv { + /** Marketing version from package.json (e.g., "9.9.0"). */ + readonly VERSION: string; + /** ISO 8601 timestamp of when the app was built (e.g., "2026-04-02T19:42:00.000Z"). */ + readonly BUILD_DATE: string; + /** Short git commit SHA (e.g., "c1266823"). Empty string if unavailable. */ + readonly COMMIT_SHA: string; + /** Git tag for the current commit (e.g., "v9.9.0"). Empty string if untagged (pre-release build). */ + readonly COMMIT_TAG: string; +} diff --git a/vite.config.ts b/vite.config.ts index 6a981e21..be81e68d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,3 +1,4 @@ +import { createRequire } from "node:module"; import { execSync } from "node:child_process"; import path from "node:path"; @@ -5,15 +6,26 @@ import react from "@vitejs/plugin-react-swc"; import { defineConfig } from "vitest/config"; import { VitePWA } from 'vite-plugin-pwa'; -function getVersion(): string { +const require = createRequire(import.meta.url); +const pkg = require("./package.json") as { version: string }; + +/** Short commit SHA — prefer CI env var, fall back to git. */ +function getCommitSha(): string { + if (process.env.CI_COMMIT_SHORT_SHA) return process.env.CI_COMMIT_SHORT_SHA; try { - const gitCommit = execSync('git rev-parse --short HEAD').toString().trim(); - const commitTimestamp = execSync('git log -1 --format=%ct').toString().trim(); - const commitDate = new Date(parseInt(commitTimestamp) * 1000); - const utcDate = commitDate.toISOString().split('T')[0].replace(/-/g, '.'); - return `${utcDate}+${gitCommit}`; + return execSync("git rev-parse --short HEAD", { encoding: "utf-8" }).trim(); } catch { - return new Date().toISOString().split('T')[0].replace(/-/g, '.'); + return ""; + } +} + +/** Git tag for the current commit — prefer CI env var, fall back to git. Empty string if untagged. */ +function getCommitTag(): string { + if (process.env.CI_COMMIT_TAG) return process.env.CI_COMMIT_TAG; + try { + return execSync("git describe --exact-match --tags HEAD 2>/dev/null", { encoding: "utf-8" }).trim(); + } catch { + return ""; } } @@ -24,7 +36,10 @@ export default defineConfig(() => ({ port: 8080, }, define: { - 'import.meta.env.VERSION': JSON.stringify(getVersion()), + 'import.meta.env.VERSION': JSON.stringify(pkg.version), + 'import.meta.env.BUILD_DATE': JSON.stringify(new Date().toISOString()), + 'import.meta.env.COMMIT_SHA': JSON.stringify(getCommitSha()), + 'import.meta.env.COMMIT_TAG': JSON.stringify(getCommitTag()), }, plugins: [ react(), @@ -62,4 +77,4 @@ export default defineConfig(() => ({ "@": path.resolve(__dirname, "./src"), }, }, -})); \ No newline at end of file +}));