Check & fix
micropage check reports the parser's diagnostics for your local .page files. micropage fix applies the suggested fixes. Neither saves a build, uploads assets or changes the live site.
Both take an optional project folder. Without one, they use the current directory, which must contain .micropage/project.json.
check
cd my-site
micropage check
Each problem is one line, in the same file:line:column: severity: message [code] format as push, followed by a summary:
landing.page:56:1: warning: This image has no alt text. Write a short description before <- (img: Team photo <- team.jpg), or use alt: "" if the image is decorative. [missing-alt]
about.page:12:1: hint: buton: is not a tag, so this line is plain text. Did you mean button:? [unknown-tag]
suggested: button: Contact us -> /contact
Check reported 1 warning, 1 hint.
With no problems it prints No problems found.
| Option | Description |
|---|---|
--strict | Also exit with status 1 on warnings. Hints never fail. |
--json | Print the result as JSON on stdout. |
--diff | Print the suggested fixes as a patch on stdout. Diagnostics and notes go to stderr. Can't be combined with --json. |
Exit codes
| Code | Meaning |
|---|---|
0 | No errors. With --strict: no errors and no warnings. |
1 | Errors found. With --strict: errors or warnings found. |
2 | The check could not run: not a project folder, no .page content, not logged in, network or server failure. |
Use it in CI before publishing:
cd my-site
micropage check --strict && micropage publish
JSON output
--json prints one object:
diagnostics: each entry hasfile,line,column,severity,code,messageand, when there is one,fix: {file, line, replace}. Lines are 1-based within the named file. Apply a fix tofix.line, not to the entry'sline.counts:{error, warning, hint}.truncated:truewhen more than 50 problems were found and only the 50 most severe are listed. Fix those and check again to see the rest.
Patch output
--diff writes a unified diff of every suggested fix, with paths relative to the project folder. Run it from the project folder, review the patch, then apply it with git:
cd my-site
micropage check --diff > fixes.patch
git apply fixes.patch
After git apply, git add -p lets you stage the fixes one at a time. Files with Windows (CRLF) line endings keep them; git may print whitespace warnings for those files, but the patch still applies.
What check doesn't verify
Check never fetches remote images, so a broken image URL or an Unsplash keyword that isn't already stored in the project is only reported on push. Files in assets/ are treated as present, because push uploads them. See What check doesn't verify.
fix
cd my-site
micropage fix
fix runs a check, prints the diagnostics, then asks about each suggested fix in turn, one line at a time:
Fix 1 of 2: about.page:12:1: hint: buton: is not a tag, so this line is plain text. Did you mean button:? [unknown-tag]
old: buton: Contact us -> /contact
new: button: Contact us -> /contact
Apply this fix? [y,n,a,q,?]
Type one letter and press Enter:
y: apply this fix.n: skip this fix.a: apply this fix and every remaining fix.q: stop asking; apply only the fixes already accepted.?: list these choices.
End of input or Ctrl-C stops without writing anything.
| Option | Description |
|---|---|
-y, --yes | Apply every suggested fix without asking. Each fix is still printed. |
fix needs a terminal to ask. Without one, and without --yes, it writes nothing and exits with status 2. In a script, use micropage fix --yes, or micropage check --diff > fixes.patch to review the changes first.
After you answer, fix writes the accepted fixes file by file. It leaves a file untouched, with a note, when the file changed since the check, is read-only, or isn't UTF-8. Written files keep their line endings, byte order mark and permissions.
It then checks once more and prints what is left. The exit code comes from that second check: 0 with no errors left, 1 with errors left, 2 when the second check couldn't run or a file couldn't be written. When nothing is written, the exit code comes from the first check.