Repository navigation
fix(cli): CLI flag, run-folder and inspect edges, and two GitHub Action edges - #264
Merged
Merged
Conversation
…on edges - `--max-warnings=-1` is no limit, as in ESLint; an empty or non-integer value exits 2 instead of being read as 0. - An option `--help` gives to other commands exits 2 instead of being ignored (`check . --out report.json` wrote no file). The drift test runs every such pair against `--help`. - From a folder with no config, components.json, package.json or project.json (`app/settings`), check, inspect, export and init work on the nearest folder above with one, as the Claude Code hook does. - `inspect` says when color tokens or components are missing, and the root `--require-design-system` error names what each project lacks. - Ctrl+D or Ctrl+C at an `init` question says it cancelled (exit 130) instead of printing an AbortError stack. - `--format github` titles annotations `onsystem: <rule>`, as the Action does. - The Action counts each hunk's lines, so an added `++ ` line is not read as a file header, and passes the workspace folders as git safe.directory, so a container job's checkout is read. Roadmap item OS2-59.
…res other commands' options
- The changeset is minor, with an Upgrading note: an option of another
command, an empty --max-warnings= and a run from a subfolder can each
fail a CI run that passed before.
- check names the project it walked up to once ("Checking the project
in ../.."), on stderr with --format json, sarif or github. The
single-project notice names it too, and at a monorepo root the
notices name projects relative to the working directory, not "in .".
- The walk-up compares with the home folder as findProjectRoot does
(case-insensitive on Windows), does not start above it when run from
it, and keeps a folder with components/ui or src/components/ui.
- serve says on stderr that it ignores an option of another command and
starts, so a stale flag in an MCP client's args does not break it.
- The cancel message is init's only, on a line of its own.
- The Action passes its safe.directory entries to the CLI it runs as
GIT_CONFIG_* variables, after any already set, so the CLI's
git check-ignore reads a container job's checkout.
- --help and docs/cli.md write --max-warnings=-1; docs/cli.md covers the
walk-up, the new exit-2 cases and serve. init names the baseline
relative to the working directory, as it names the config.
…s why check could not run A run from src in a src layout, or from app in a React Router one, kept that folder as the root because it holds components/ui, and lost findings: 4 errors and 3 warnings from src, and 1 error with no color tokens from app, against 8 errors and 3 warnings from the root. The folder's own components/ui now keeps it as the root only when the project above would not read them: it is not the project's src or app folder, and the project has no components.json or config. A design system with no package.json below a stray one is still its own root. The Action's error annotation took "Checking the project in ../.." for the reason the CLI exited 2, when working-directory has no project marker. It now takes the first other line.
Merged
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.
Part of the OS2-59 polish bundle: the CLI and GitHub Action area. The message and ESLint area is #265, the package and contributor area #266. None of them share a file.
What was wrong
check --max-warnings=-1(ESLint's "no limit") failed a clean file withToo many warnings (0, max -1)., and--max-warnings=from an unset variable was read as 0:Number('')is 0 and passesNumber.isInteger.check . --out report.jsonwrote no file and exited as if it had, andcheck . --explainandinspect --max-warnings 0were ignored.check danger-zone.tsxrun fromexamples/shadcn-demo/app/settings(no config,components.jsonorpackage.jsonthere) took that folder as the root, found no design system and printedNo problems in 1 file.with exit 0. From the demo's root the same file has errors. The Claude Code hook and the MCP server already walk up to the project.inspectdid not say that color tokens were missing (onlycheckdid, after its findings), and the rootcheck --require-design-systemerror did not say which project lacked what.init's questions printed anAbortError: Aborted with Ctrl+Dstack trace.check --format githubtitled annotationsno-hardcoded-color, the Actiononsystem: no-hardcoded-color.parseDiffread any line starting with+++as a file header, so an added line++ counter;(shown as+++ counter;) reset the file and its later hunks were dropped: findings there were filed as "not reported".container:job, git refuses the workspace as another user's ("dubious ownership"), and the Action failed every pull request with advice to check out withfetch-depth: 0.What changed
.changeset/cli-and-action-edges.mdis a minor bump and opens with an Upgrading note: an option of another command, an empty--max-warnings=and a run from a folder without a project marker can each fail a CI run that passed before, and it says what to do for each.src/cli.ts--max-warningstakes a whole number; a negative one is no limit. Anything else (empty,1.5,0x10,many) exits 2 with one line.--helpwrites it--max-warnings=-1, as--max-warnings -1is refused by Node's parser as ambiguous.--helpgives to some commands only (check:,inspect:,export:,init:,serve:in its text) exit 2 on any other command:check: --out is an option of export only. Run onsystem --help for usage.serveinstead saysserve: -y is an option of init only, so it is ignored.on stderr and starts, so a stale flag in an MCP client's args does not leave the client with a broken server. The table is next to the parser, andtest/cli-docs.test.tsruns every option against every command--helpdoes not give it to, so the table and--helpcannot drift apart.check,inspect,exportandinit, run from a folder with none of the project markers, use the nearest folder above with one as--root(relative, so the commands the hints print still work from there). Not when--root,--config,--components,--tokensor--docsis given, not when the folder has a baseline, not when it has acomponents/uiorsrc/components/uifolder the project above would not read (it is not the project'ssrcorappfolder, and the project has nocomponents.jsonor config: a design system with nopackage.jsonbelow a stray one), not from the home folder, never the home folder or the filesystem root (compared asfindProjectRootcompares them, without case on Windows), and never forserve. I chose the nearest marker rather thanfindProjectRoot's workspace root, so a run fromapps/web/appusesapps/web, the same root and baseline as a run fromapps/web.checksays so once:Checking the project in ../.., first in pretty output and on stderr with--format json,sariforgithub, so machine output still parses (not with--quiet-without-design-system, the hook's flag). The single-project notice names it (No design system found in ../.. (…)), and at a monorepo root the notices and the--require-design-systemerror name projects relative to the working directory, as the files are named: fromtools/scriptsthe root's own files were said to bein ..inspectprintsNo color tokens found: check will not run no-hardcoded-color. See …/configuration(or the same for missing components) after the tokens. At a monorepo root, each project gets amissingline. The root--require-design-systemerror adds; no color tokens in apps/admin, apps/web and packages/ui. The new lines are not underWarnings, so the corpus's inspect counts do not move.AbortErrorfrom one ofinit's questions (Ctrl+D or Ctrl+C) printsinit: cancelled; nothing after that question was done.on a line of its own, and exits 130. Other commands keep the generic handling.src/init.ts: run from a folder below the project, the baseline line names../../onsystem.baseline.json, as the config line already named../../onsystem.config.json.src/workspace.ts:samePathis exported for the walk-up.src/lint/format.ts:--format githubtitles annotationsonsystem: <rule>, asaction/check.mjsdoes.action/check.mjsparseDiffcounts each hunk's removed and added lines from its header and reads a+++line as a header only when the hunk is done.-c safe.directory=<dir>for each folder from the working directory up toGITHUB_WORKSPACE, one of which is the repository top. Nothing is added outside Actions, or for a folder outside the workspace. When git still refuses, the error suggests addingsafe.directoryinstead offetch-depth: 0.GIT_CONFIG_COUNT/GIT_CONFIG_KEY_<n>/GIT_CONFIG_VALUE_<n>, after any the job already set, so the CLI'sgit check-ignorereads a container job's checkout and git-ignored files are left out there too.Checking the project in …, so from aworking-directorywith no project marker it still says why check could not run.docs/cli.md: the--rootrow and a paragraph on the walk-up, the exit-2 list (an option of another command, an empty--max-warnings),--max-warnings=-1, and whatservedoes with another command's option.How it was tested
New tests fail on main and pass here:
test/cli-edges.test.ts:--max-warnings=-1on a clean file and on 11 warnings;'',' ',many,1.5and0x10; options of other commands (check --outwrites no file);servegiven-yand--formattwice warns once for each and answerslistToolsover an in-memory transport; Ctrl+D through a realreadlineterminal interface atinit's first question (exit 130, message on its own line, no config written);check danger-zone.tsxfromapp/settingsreports the same 11 findings as from the demo's root, withChecking the project in ../..on stderr for JSON and first on stdout for pretty, and not from the root or with--quiet-without-design-system;--root ., a baseline or acomponents/ui/src/components/uifolder keeps the folder despite a straypackage.jsonabove; the demo laid out as a Next.jssrcproject and as a React Routerappproject (components.jsonand tsconfig paths) reports the same findings fromsrcorapp, and from the settings folder, as from the root (with the folder kept as the root, the built CLI gave 4 errors and 3 warnings fromsrc, and 1 error with "No color tokens found" fromapp, against 8 errors and 3 warnings); run from inside the home folder or from it, the walk never reaches it or goes above it (with the home folder spelled in capitals on Windows); the notices sayin ../..from a subfolder of one project and fromtools/scriptsof a monorepo;init -yfromapp/settingsprintsWrote ../../onsystem.config.json.andBaseline: 1 finding in 1 file → ../../onsystem.baseline.json;inspectnaming missing color tokens.test/cli-docs.test.ts: every option against every command--helpdoes not give it to: exit 2 with the error, or forserveexit 0 with the warning.test/action.test.ts: a diff with+++ counter;,--- removedand\ No newline at end of fileinside hunks;configEnvnumbering after an existingGIT_CONFIG_COUNT; and an end-to-end Action run on a repository git takes for another user's (GIT_TEST_ASSUME_DIFFERENT_OWNER=1, with no system or global git config), inside and outsideGITHUB_WORKSPACE. The stand-in CLI now leaves out whatgit check-ignorereports, as the CLI does, and in that run a file in.gitignoreand one in acore.excludesFileset throughGIT_CONFIG_COUNT=1are both left out: without the variables, or with them numbered from 0, they are checked. From aworking-directorywith no project marker, the stand-in, like the CLI, saysChecking the project in ../..before the reason it exits 2, and the annotation gives the reason.test/cli.test.ts(annotation title),test/workspace.test.ts(themissingline and the root error).Gate on this branch, up to date with main:
pnpm install --frozen-lockfile --prefer-offline,pnpm format:check,pnpm lint,pnpm typecheck,pnpm test(112 files passed and 1 skipped; 1,459 tests passed, 3 skipped),pnpm buildandpnpm smokeall pass.I also ran the built CLI from
examples/shadcn-demo/app/settings:check danger-zone.tsxprintsChecking the project in ../..then the findings (exit 1),check danger-zone.tsx --max-warnings -1gives Node's "argument is ambiguous" message (exit 2), andonsystem -y --format json --no-watchprints the twoserve:lines andready on stdio. The Action'srun()with the built CLI, from aworking-directorywith no marker under a repositorypackage.json, annotatesonsystem check exited with 2: check --require-design-system: No design system found in ../.. (…); before this fix it annotatedChecking the project in ../...Left for later (outside this bundle's files)
docs/troubleshooting.md:inspectnow prints "No color tokens found", and the root--require-design-systemcase.src/lint/sarif.ts:helpUristill points to/rules#id, not/rules/<id>.docs/ci.md: say that--format githubshows at most 10 annotations of each kind per step, and point to the Action's job summary.init: a warning when the token files it found hold no colors.Roadmap item: OS2-59 (os-bugs-edges/os-cli-flag-polish, os-arch/os-error-message-polish (h), os-adopt-monorepo/polish-cli-ci-nits (a, f), os-adopt-monorepo/tokens-missing-not-surfaced, os-bugs-edges/os-parsediff-plusplus-line, os-bugs-edges/os-action-git-refuses-checkout).