Skip to content

feat(cli): add the check command and fail builds on errors - #344

Merged
alexgrozav merged 6 commits into
styleframe-agent-ergonomics-uxf-406from
add-check-command-uxf-411
Oct 21, 2026
Merged

alexgrozav merged 6 commits into
styleframe-agent-ergonomics-uxf-406from
add-check-command-uxf-411

Conversation

@alexgrozav

@alexgrozav alexgrozav commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

styleframe build logged a failed build and exited with 0, so neither CI nor an agent could trust its exit code. This PR makes the CLI and the bundler plugin report what validate() finds, and adds a command that checks a configuration without building it.

  • styleframe build prints one warning line per diagnostic (code, path, message with the did-you-mean), exits with 1 under strict: true without writing any files, and exits with 1 when the build fails.
  • styleframe check [entry] [--json] runs validate() on the configuration, writes nothing, and exits with 1 on any diagnostic or when the entry file doesn't exist. With --json, it prints one { "ok", "diagnostics" } document on stdout and nothing else.
  • @styleframe/plugin logs each diagnostic once per build, although it transpiles up to three times, and fails the build under strict. In the dev server, the debounced type generation sends a strict failure to the error overlay instead of only logging it.
  • inspect(instance) in @styleframe/core returns a JSON-serialisable snapshot of the root variables (with the custom property and value they emit), themes, utilities (values, class names, modifiers), modifiers and recipes (variant options and defaults).

The CLI inlines @styleframe/core into its dist, as it already does, so its package.json doesn't change.

Related issue

Builds on #343.

Type of change

  • 🐞 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior)
  • 📖 Documentation
  • ♻️ Refactor / internal (no functional change)
  • 🔧 Build / tooling / CI

Checklist

  • My commits follow Conventional Commits with a package scope (e.g. feat(theme): …)
  • I ran pnpm build:nodocs && pnpm lint && pnpm typecheck && pnpm test and everything passes
  • I added a changeset (pnpm changeset) for changes to publishable packages, or this change only touches docs/storybook/app/playground/tests
  • I added or updated tests where relevant
  • I updated documentation where relevant
  • I did not edit generated files (dist/, .styleframe/)
  • My PR targets main and stays focused in scope

Notes / screenshots

This PR targets the integration branch, which collects the remaining layers of this work before one PR to main. Builds through the plugin, Inkline's included, will start showing the warnings, which the changeset says.

A reference to a missing token in a recipe or a utility value built
silently and emitted a var() that is never declared, and a misspelled
theme override or a duplicate variable lost a value without a word.

validate(instance) walks the finished instance and returns every
problem in one pass: unresolved-reference, undefined-theme-override and
duplicate-variable, each with the path that made it and the closest
token name within two edits. transpile() runs it once and returns the
diagnostics beside files, or throws one error listing them all under
the new strict option. variable() and the utility namespace fallback
keep a record on the root of what the finished tree no longer holds.

Nested at-rules keep hyphenated names, so @starting-style and
@font-feature-values emit as written. The theme gains z-index.tooltip,
which the tooltip recipe already used, and the xs chip indicator stops
referencing the undefined font-size.4xs. The transpiler and barrel peer
on the core release that ships validate(). The theme typecheck builds
again without the duplicate wcagContrast declaration.
A plain @token string in a selector or theme still throws when it's
defined, so the docs and changeset now say which references validate()
reports. The default z-index output blocks list the tooltip level, and a
namespace fallback whose variable was defined later says so instead of
claiming no variable exists.
`styleframe build` logged a failed build and exited 0, so neither CI nor an
agent could trust it. It now prints one warning line per diagnostic that
`validate()` finds, exits 1 under `strict: true` without writing files, and
exits 1 when the build fails. The new `styleframe check [--json]` reports
the same diagnostics without writing anything, and exits 1 on any.

The plugin logs each diagnostic once per build, although it transpiles up
to three times, and under `strict` the debounced type generation in the
dev server sends its failure to the error overlay instead of only logging.

Core gains `inspect(instance)`, a JSON-serialisable snapshot of the
variables, themes, utilities, modifiers and recipes an instance defines.
@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
styleframe-dev Ready Ready Preview Oct 21, 2026 7:52am UTC
styleframe-dev-storybook Ready Ready Preview Oct 21, 2026 7:52am UTC

Request Review

`styleframe check` on an entry that doesn't exist reported a clean config,
because the loader falls back to an empty instance. It now prints
"Config file not found" on stderr and exits 1.

The plugin keyed logged diagnostics on code and path, so a second
unresolved reference in the same value was never logged. It now keys on
the message too.

The check tests now run in a temporary working directory with every
consola level on, so a written file or a stray stdout line fails them.
`check` resolved the entry with `path.resolve`, which drops a trailing slash and collapses `..` by text, so an entry the loader can't find, like `styleframe.config.ts/`, still loaded an empty instance and passed. It now builds the path with `path.join`, as the loader does.
@alexgrozav
alexgrozav merged commit 3b0fa98 into styleframe-agent-ergonomics-uxf-406 Oct 21, 2026
2 of 3 checks passed
@alexgrozav
alexgrozav deleted the add-check-command-uxf-411 branch October 21, 2026 07:51

This branch was successfully deployed

2 active deployments
Preview – styleframe-dev — bc1447c2 Deployed Oct 21, 2026 by vercel[bot]
Preview – styleframe-dev-storybook — bc1447c2 Deployed Oct 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant