Add markpost push --dry-run to preview files before creating records - #140
Open
grimicorn-agent wants to merge 5 commits into
Open
Add markpost push --dry-run to preview files before creating records#140grimicorn-agent wants to merge 5 commits into
markpost push --dry-run to preview files before creating records#140grimicorn-agent wants to merge 5 commits into
Conversation
…n reporter, skipped test
Collaborator
Author
Independent code review trailRan the independent reviewer ( Round 1
Round 2
Round 3
Round 4
Unresolved after the loop: none blocking. The two skipped items are recorded as follow-up suggestions in the PR body. Lint clean; full suite 718 passing. |
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 & why
Adds
markpost push --dry-run, a read-only preview of a bulk import. A push resolves its whole plan up front viaresolveMarkdownInputs(files, missing, skipped) beforepushFilescreates any records, so--dry-runprints that resolved plan and returns before anycreateRecord/POST /api/recordscall. A bulk import across globs/directories otherwise has no way to confirm the glob matched the right notes before it hits the API once per file; the dry run catches a wrong glob cheaply and mirrors thesync --dry-runaffordance.Viewable by running
markpost push <glob> --dry-run(CLI; no hosted page).Closes #136
Behaviour
markpost push --dry-run <path...>resolves inputs, prints the missing/unreadable inputs, then a yellowDry run —header over a dimWould push N file(s):list, and returns without creating records.Decisions
reportDryRunPlan. That previews server records written to local files; push previews local files sent to the server — disjoint inputs. Only the visual style is shared (mirrored), not the code, so there's no shared logic to abstract (rule of three).--dryrunmust fail loud rather than silently run the real push. Unknown--flags are rejected (Unexpected arguments: …), matching the guardsyncgives its one destructive command. A genuine dash-leading filename stays pushable via the POSIX--end-of-options separator (push -- --notes.md).sanitizeForTerminal(as sync'sprintWritePreviewalready does) so a crafted title/name can't inject a live escape sequence.Tests
New cases in
tests/commands/push.test.ts: dry run previews without callingcreateRecord/readMarkdown; lists each resolved file; surfaces missing and skipped inputs and exits 1; empty resolution still exits 1;--dry-runexcluded from resolved paths and doesn't check config; mistyped flag rejected (with and without a valid--dry-runpresent);--separator keeps dash-leading paths pushable; control characters stripped from a previewed path and from a pushed record title. Full suite: 718 passing.Follow-up suggestions
Preview and push should flag unreadable regular files— a mode-000 regular file stats fine so it lands under "would push" / gets attempted, then the real read throws EACCES;resolveMarkdownInputscould pre-check readability (accessSync R_OK) so both the preview and the real push report it as skipped up front (suggested: P3, effort: M, evidence: src/libs/files.ts resolveMarkdownInputs + src/libs/markdown.ts readMarkdown)Share one --dry-run flag literal across commands—DRY_RUN_FLAG = '--dry-run'is declared independently insrc/commands/push.tsandsrc/index.ts; a single exported constant (e.g. insrc/libs/usage.ts) would stop the literal drifting as more commands gain the flag (suggested: P4, effort: S, evidence: src/commands/push.ts + src/index.ts)