Repository navigation
feat: plain Astro support, and the smoke suite run against the packed package - #17
Merged
Merged
Conversation
`@purview-dev/astroc4/integration` is now a published entry point: the same LikeC4
Vite plugin, fence transform, Windows preload and dependency fix the Starlight
plugin installs, because both call the new `src/integration.ts`. The default export
keeps working for `starlight({ plugins: [astroc4()] })` and also carries the Astro
`astro:config:setup` hook, so the `integrations: [astroc4()]` that `astro add`
writes produces a working site — and warns when it lands on a Starlight site,
where the translations and the highlighting cannot run.
Three Starlight assumptions had to go: `Astro.locals.t` is read as `unknown`
because `App.Locals` is an empty interface without Starlight's augmentation,
colours moved to a `--likec4-*` layer that falls back to scheme-neutral values so
a plain Astro page is still legible, and the fence warning goes through
`logger.fork('likec4-fences')` instead of `console`. The integration also adds
`@astrojs/react` when the site has not, since the islands are
`client:only="react"` and a site without a renderer builds and then draws nothing.
`@astrojs/mdx` and `astro-expressive-code` stay the site's decision.
`examples/astro` is a runnable plain-Astro site (`bun run dev:astro`, port 4322):
one page, one model, an inline fence and `ec.config.mjs` highlighting.
Bumps to 1.0.0-prerelease.5.
`test:site` installs the tarball into copies of both host sites instead of into a hand-written page: `playground/` (Starlight) and `examples/astro/` (plain Astro). The Starlight copy gets `astro check`, `astro build` and then the full `scripts/smoke.ts` suite on its preview server — hydration, drawn nodes, icons, highlighting colours, the loading placeholder and both locales — so those are proven on the artifact a user installs, not on `dist/` beside the repository. It then rebuilds the plain-Astro copy with the exact config `astro add` writes. `scripts/hydration.ts` is the shared browser check: it waits for a rendered LikeC4 node, fails while the `.likec4-loading` placeholder is still visible, fails on any console error, and can assert the frame is styled. The CI site job installs Chromium for it.
The README and a new `guide/Plain-Astro.md` cover the two registrations and say what `astro add` writes; `guide/Components.md` documents the `--likec4-*` tokens, `guide/Configuration-Reference.md` marks `highlighting` as Starlight-only, and the contributing pages record the two entry points, the logger convention, the integrations-library keywords and the new `test:site`. Also corrects the claim that `astroc4()` must precede `astroExpressiveCode()`: tested, they work in either order (Astro applies a processor's mdast plugins and the site's `markdown.rehypePlugins`), and `examples/astro` now lists Expressive Code first so that stays true. The changelog records the release as 1.0.0-prerelease.5.
The job installs the tarball into copies of both host sites, builds them, runs the full smoke suite, a dev-server hydration check and the astro add rebuild, and finishes in about 85 seconds on ubuntu-latest. The 35-minute ceiling was sized from a Windows run, where two bun installs alone take half a minute each.
The smoke suite itself takes about nine seconds on ubuntu-latest; the browser download in front of it is the slowest and only variable step (twenty seconds usually, minutes when the CDN stalls, which is what held the first run of this PR open). Both jobs now restore ~/.cache/ms-playwright keyed on the lockfile, so whichever runs second downloads nothing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Three things in one PR, because they share one test story: the package can now be
used from plain Astro, the dev-only hydration bug is fixed, and
test:siteproves both from the packed tarball instead of from
dist/sitting beside therepository.
1.
@purview-dev/astroc4/integration— plain Astro, first classsrc/integration.tsholds everything that was always Astro-only: LikeC4's Viteplugin, the fence transform, the Windows preload, the
react/compiler-runtimefix.src/index.tsis now the Starlight layer that calls it (i18n injection,expressiveCode, Starlight's plugin context). Both entry points therefore cannotdrift.
Three Starlight assumptions had to go:
Astro.locals.tis read asunknown—App.Localsis an empty interfacewithout Starlight's augmentation, so a site that type-checks the components
without Starlight now passes instead of failing with
TS2339.--likec4-*layer that defaults to--sl-color-*and toscheme-neutral fallbacks, so a plain page is legible rather than transparent.
(
logger.fork('likec4-fences')), notconsole.The integration also adds
@astrojs/reactwhen the site has not, because theislands are
client:only="react". It deliberately does not add@astrojs/mdxorastro-expressive-code: those change the host's content typesand every code block, so they stay the site's decision (and a fence in a
.mdpage now says "add MDX" instead of "rename the page", which could not work).
examples/astrois a runnable plain-Astro site —bun run dev:astro, port 4322 —with a project view, an inline fence and
ec.config.mjshighlighting.2. The dev-only hydration bug
likec4/reactis React-Compiler-built and importscfrom React 19's CommonJSreact/compiler-runtime; dev served it raw and every island died withdoes not provide an export named 'c'whileastro buildstayed green. Theintegration now adds the dependency to
vite.optimizeDeps.include(only entriesthe site lacks — Astro concatenates Vite arrays).
3.
test:siteruns the real smoke suite on the packed packageIt installs the tarball into copies of both host sites —
playground/andexamples/astro/— and then runsastro check,astro build, the fullscripts/smoke.tssuite against the Starlight copy on its preview server, adev-server hydration check against the plain-Astro copy, and a rebuild of that copy
with the exact config
astro addwrites.scripts/hydration.tsis the sharedbrowser check (rendered node, no visible placeholder, no console errors, frame is
styled).
Verified locally
bun run testbun run checkexamples/astro19 files 0 errors ·tscscripts cleanbun run build+bun scripts/smoke.tsbun run test:siteastro addshapeoptimizeDepsentry removed and.vitecleared, the check reports the threedoes not provide an export named 'c'errors, 0 nodes and a visible placeholderAstro.localscast reverted,examples/astro'sastro checkfails withTS2339: Property 't' does not exist on type 'Locals'Notes for reviewers
package.jsonis bumped to1.0.0-prerelease.5, so merging this publishesthe prerelease and tags it (
release.yml).astro addworks now. The default export carries the Astroastro:config:setuphook as well as the Starlight plugin hooks; the two sets aredisjoint, so
integrations: [astroc4()](what the CLI writes) renders diagrams,and a Starlight site that ends up with that shape gets a warning naming
starlight({ plugins: [astroc4()] }).astroc4()andastroExpressiveCode()work in either order (tested), andexamples/astronowlists Expressive Code first so it stays true.
@astrojs/starlightis an optional peer now; a plain Astro site never loads it.Checklist
bun run testbun run checkbun run buildandbun scripts/smoke.tsbun run test:site(needs Chromium)guide/Plain-Astro.md, Components, ConfigurationReference, Getting Started, Architecture, Local Development, Repository
CI/CD, AGENTS.md, CHANGELOG