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
104 changes: 54 additions & 50 deletions bun.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Purview Development

Shared engineering documentation and architecture decisions for Purview Development.

## Architecture decisions

- [ADR 0001: Architecture](decisions/0001-architecture.md)
21 changes: 21 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
site_name: Purview Development
site_description: Documentation for Purview Development
repo_url: https://github.com/purview-dev/purview-dev.github.io
edit_uri: edit/main/docs/
docs_dir: docs

theme:
name: material
palette:
- media: "(prefers-color-scheme: light)"
scheme: default
primary: indigo
accent: cyan
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: indigo
accent: cyan
features: [navigation.instant, navigation.sections, navigation.top, search.highlight, search.suggest, content.code.copy]

plugins: [search, techdocs-core]
markdown_extensions: [admonition, attr_list, md_in_html, pymdownx.details, pymdownx.superfences]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "purview-dev",
"version": "0.3.0",
"version": "0.3.1",
"private": true,
"description": "Purview-Dev public website and unified documentation portal (workspace root).",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
"@astrojs/check": "0.9.10",
"@astrojs/preact": "6.0.5",
"@astrojs/sitemap": "3.7.4",
"@astrojs/starlight": "0.42.1",
"@astrojs/starlight": "0.42.3",
"@astrojs/starlight-tailwind": "5.0.0",
"@tailwindcss/vite": "4.3.3",
"@types/bun": "1.4.2",
"@types/semver": "^7.8.0",
"astro": "7.3.3",
"astro": "7.3.4",
"fast-glob": "3.3.3",
"lefthook": "2.1.14",
"oxfmt": "0.68.0",
Expand Down
45 changes: 34 additions & 11 deletions src/src/components/SiteFooter.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import SiteBrand from '~/components/SiteBrand.astro';
import { NAV_ITEMS } from '~/components/SiteNav.astro';
import { loadProjects } from '~/lib/manifest/load';
import { siteVersion } from '~/lib/site-version';
import { getReleaseInfo } from '~/lib/site-version';
import { OWNER, SITE } from '~/lib/site';
import { withBase } from '~/lib/urls';

Expand All @@ -12,13 +12,11 @@ const footerProjects = loadProjects()
.filter((project) => project.status !== 'archived')
.toSorted(
(a, b) =>
Number(b.featured) - Number(a.featured) ||
a.order - b.order ||
a.name.localeCompare(b.name),
Number(b.featured) - Number(a.featured) || a.order - b.order || a.name.localeCompare(b.name),
)
.slice(0, 3);

const version = siteVersion();
const releaseInfo = getReleaseInfo();
const releasesUrl = `${SITE.githubUrl}/${OWNER}.github.io/releases`;
---

Expand Down Expand Up @@ -93,13 +91,38 @@ const releasesUrl = `${SITE.githubUrl}/${OWNER}.github.io/releases`;
<span class="beta-badge">Beta</span>
This site is under active development.
</p>
<div class="flex flex-col gap-1">
<p class="flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-sm">
<a href={releasesUrl} class="pv-link" title={`Purview website v${releaseInfo.version}`}>
v{releaseInfo.version}
</a>

<span class="text-muted" aria-hidden="true">·</span>

<code class="text-muted text-xs" title={`Commit ${releaseInfo.commitSha}`}>
{releaseInfo.commitSha.slice(0, 7)}
</code>

<span class="text-muted" aria-hidden="true">·</span>

<time
class="text-muted"
datetime={releaseInfo.buildDate.toISOString()}
title={`Built ${releaseInfo.buildDate.toISOString()}`}
>
{
releaseInfo.buildDate.toLocaleDateString('en-GB', {
day: '2-digit',
month: 'short',
year: 'numeric',
})
}
</time>
</p>
</div>
<p class="flex items-center gap-2">
<a href={releasesUrl} class="pv-link" title={`Purview website v${version}`}
>v{version}</a
>
</p>
<p class="flex items-center gap-2">
Built with <a href="https://astro.build" class="pv-link">Astro</a> and <a
Built with <span aria-label="love" role="img">💕</span> using
<a href="https://astro.build" class="pv-link">Astro</a> and <a
href="https://starlight.astro.build"
class="pv-link">Starlight</a
>.
Expand Down
45 changes: 42 additions & 3 deletions src/src/lib/site-version.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { execFileSync } from 'node:child_process';
import { existsSync, readFileSync } from 'node:fs';
import { dirname, join, resolve } from 'node:path';

/**
* Locate the workspace root: the nearest ancestor package.json that declares a
* `workspaces` array. This is the repository root, which owns the site's
Expand Down Expand Up @@ -41,6 +41,45 @@ export function readVersion(root: string): string {
return version;
}

export function siteVersion(): string {
return readVersion(findWorkspaceRoot());
/**
* Gets the full Git commit SHA for the revision being built.
*
* CI-provided values are preferred because some build environments use shallow
* clones or do not make the .git directory available. Local builds fall back
* to querying Git directly.
*/
export function readCommitSha(root: string): string {
const environmentSha =
process.env.GITHUB_SHA ??
process.env.CF_PAGES_COMMIT_SHA ??
process.env.VERCEL_GIT_COMMIT_SHA ??
process.env.COMMIT_SHA;

if (environmentSha) {
return environmentSha;
}

try {
return execFileSync('git', ['rev-parse', 'HEAD'], {
cwd: root,
encoding: 'utf8',
}).trim();
} catch {
return 'unknown';
}
}

export function getReleaseInfo(): ReleaseInfo {
const root = findWorkspaceRoot();
return {
version: readVersion(root),
commitSha: readCommitSha(root),
buildDate: new Date(),
};
}

export interface ReleaseInfo {
version: string;
commitSha: string;
buildDate: Date;
}
2 changes: 1 addition & 1 deletion src/tests/dist/built-output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('built footer version', () => {
expect(version).toBeTruthy();

const content = requireBuilt('index.html');
expect(content).toContain(`>v${version}<`);
expect(content).toContain(`>\nv${version} <`);
expect(content).toContain('https://github.com/purview-dev/purview-dev.github.io/releases');
});
});
Loading