Repository navigation
feat(render): code hosts and shared text snippets #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c7269bd
020778b
75b61be
21d3148
16b1aec
29bafff
1117a8b
9cb7a04
c098863
6def597
751868c
cc40395
0fe5354
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| // render. | ||
| import { mkdirSync, readFileSync, rmSync, writeFileSync, existsSync } from "node:fs"; | ||
| import { dirname, join } from "node:path"; | ||
| import { distDir, hosts, listFiles, renderHost, root, vars } from "./lib.mjs"; | ||
| import { distDir, hosts, isCodeHost, listFiles, renderHost, root, vars } from "./lib.mjs"; | ||
|
|
||
| const check = process.argv.includes("--check"); | ||
| const only = process.argv.slice(2).filter((a) => !a.startsWith("--")); | ||
|
|
@@ -26,7 +26,10 @@ function hostsList() { | |
| const rows = hosts() | ||
| .map((host) => [vars(host).host_full ?? host, host]) | ||
| .sort(([a], [b]) => a.localeCompare(b)) | ||
| .map(([name, host]) => `| ${name} | [dist/${host}/README.md](dist/${host}/README.md) |`); | ||
| .map(([name, host]) => { | ||
| const guide = isCodeHost(vars(host)) ? `platforms/${host}/README.md` : `dist/${host}/README.md`; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There’s no check that It seems easy to run into, since CONTRIBUTING now describes a code host’s README as something that stays here rather than being shipped, so it’s a separate file to remember. Would it make sense for validate to require one when
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| return `| ${name} | [${guide}](${guide}) |`; | ||
| }); | ||
| const table = ["| Host | Setup guide |", "|---|---|", ...rows].join("\n"); | ||
| const head = readme.slice(0, readme.indexOf("\n", start) + 1); | ||
| return Buffer.from(`${head}${table}\n${readme.slice(end)}`); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allowlist fails quietly, which was fine when the output was manifests and markdown but is riskier now that a code host’s whole output is code. Anything with an extension that isn’t on the list gets copied byte for byte, placeholders and all, with no warning.
I set up a
kind: codehost to see the effect:Both render and validate were clean.
.tsx, .jsx, .vue, .py and .goall land here.One option instead of extending the regex each time a host brings a new file type is to check the rendered output. Something like this at the end of renderHost, once out is built:
It matches what CONTRIBUTING already describes (“Unknown variables … fail the render”), and it covers the
{{ < name}}case above and any future variation of the same thing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took the idea of checking the output:
renderHostnow fails on any of this tool's tokens left in a rendered file ({{name}},{{< x}},{{text:x}}, …), whatever its extension, and the error names the leftover. I first made it fail on any{{, but that blocked JSXstyle={{…}}and Make/n8n expressions, which code hosts will need, so it only matches our own token shapes (9cb7a04). The allow-list still decides which files get filled. In #5 I'll reword the one doc comment that mentions{{text:…}}when it merges main.