Repository navigation
refactor(validate): extract a side-effect-free repository validation function - #106
Merged
Merged
Conversation
…function
validate-content ran at import time and called process.exit, so nothing
could test it. validateRepository(repoRoot) now returns per-file schema
and cross-reference errors plus client asset errors and warnings, and
never prints or exits. The CLI is a thin wrapper with the same output
and exit codes.
Cross-reference errors now share the { path, message } shape of schema
errors, so later rules return data instead of preformatted strings.
Refs #93
Contributor
|
🔍 Preview: https://website-7jkx0o9jj-ocobo-22231b32.vercel.app Built from website |
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.
Closes #93
What
scripts/validate-repository.jsexportsvalidateRepository(repoRoot). It returns{ failures, assetErrors, assetWarnings }; each failure carriesfile,schemaErrorsandcrossRefErrors. It reads files but never prints and never exits.scripts/validate-content.jsis now a thin CLI: it calls the function, prints and sets the exit code.{ path, message }shape as schema errors. The CLI formats both with the same function, so the printed lines do not change.scripts/__tests__/validate-repository.test.jsbuilds a fixture repository on disk and covers: all valid, one schema error, one danglingauthor, one client asset error.Behaviour check
pnpm validateoutput compared byte for byte, stdout and stderr, before and after:author,featuredToolandhiringContact, a.jpegclient asset, a missing story avatar): identical, exit 1.Why
Test seam 2 of the spec #91. #94 (enjeu schema and validation) and #95 (Team member expert fields) add their rules and tests through this function.
pnpm test: 193 passed.