Repository navigation
feat: extract --check and the check-sync GitHub Action (#28, 1/2) - #57
Open
adrianbrowning wants to merge 4 commits into
Open
adrianbrowning wants to merge 4 commits into
adrianbrowning wants to merge 4 commits into
Conversation
|
The changes in this PR will be included in the next version bump.
|
|
|
|
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 #28 (PR 1 of 2: check-sync). The update-readme action follows in a stacked PR, which closes #28.
Summary
A read-only CI gate that verifies both directions of sync, plus the CLI support it needs.
Decisions (agreed before starting):
extract --check, not a temp copy of the checkout. It builds each target exactly asextractwould: whole file, region splice or appended region. The action passes--forceso existing whole files are compared rather than reported skipped.npx --yes mdcode-ts@<version>, where the version comes frompackages/mdcode/package.jsonat the action's own ref. Pinning the action SHA pins the CLI.mdcode-commandoverrides it, and this repo's dogfood step sets it to the branch build.v1tag. The docs show how to find the commit behind amdcode-ts@x.y.zrelease tag, which bumpy's publish step creates.Bugs found by dogfooding, all fixed here, because a passing check has to mean
extractwould change nothing:extractontests/examples/fibonaccirewrotefibonacci.jswith every region body pushed right by the marker's indent.updatecopies a region verbatim, indentation included, and the splice then added the indent again. Per your call, the splice now leaves a body as it stands when its first non-empty line already starts with the marker's indent. A dedented body is still indented to the marker.extract --forcedropped the final newline of an overwritten file. It now keeps the file's LF or CRLF; new files are written as before.extract --forceon a symlinked target replaced the link with a regular file (writeAtomicrenames over it), and on a target that isn't valid UTF-8 it re-encoded the bytes. It now refuses both, as splices already did, so a passingextract --check --forcealways meansextract --forcewould change nothing.The action:
documentstakes one path or glob per line, so paths may contain spaces.basesets the root for both directions. Withprojectorconfig, the configuration's roots apply.both. Annotations name the direction, document, line, block, file and region.contents: readand runs no code from the Markdown. The docs say to usepull_request, neverpull_request_target.Evidence
mdcode extracton a copy oftests/examples/fibonaccichangedfibonacci.js(diff:if (n < 1) {→if (n < 1) {).After: byte-identical, and the dogfood run passes:
✓ 6 document(s) in sync: files → Markdown (update) and Markdown → files (extract).extract.test.ts"extract: check":unchanged, nothing written;--force, an existing file is skipped;region.test.ts: read-then-splice round trip for indented markers, including a body whose last line closes a scope left of the marker.check-sync-action.test.ts(8 tests), run the wayaction.ymlruns the script:my docs/withfile="hello world.ts", passes and every file is unchanged;both, with document, line, block and file;missing_regionfor update and "would append" for extract;directionsselection andbase;mdcode-command, it runsnpx --yes mdcode-ts@<package.json version>(checked with a stubnpx).pnpm checkpasses (pre-push).intent maintainer check: 0 pending.Merge Danger
Door: two-way
Blast Radius: extract output
extract --forcenow keeps final newlines and refuses symlinked targets.extract --check. The script reports that clearly, and the docs say to pin a release commit.