Make the device scripts answer --help and refuse bad flags

未关闭 适合新手
#35 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
90/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
cli, testing

调研方向

先查看 scripts/devices/validate.test.mjs 和 scripts/devices/table.test.mjs 中的 CLI 测试,然后阅读每个脚本头部注释中的用法说明行及其 main() 函数。添加对帮助、未知 flag 和缺少值的测试,并使用临时文档文件检查无效的表格参数不会更改该文件。运行 node --test scripts/devices/*.test.mjs,并确认 validate.mjs 仍接受工作流的 --event、--github-output 和 --comment 参数。

由索引模型根据 Issue 内容生成。

描述

agent-friendly good first issue

Why

docs/devices.md tells people to check a report with node scripts/devices/validate.mjs report.json, but --help makes that script try to open a file named --help, and table.mjs rewrites docs/devices.md when given a flag it doesn't know. ROADMAP.md, Now: the Device lab.

What to do

Today:

  • node scripts/devices/validate.mjs --help prints ENOENT: no such file or directory, open '--help'.
  • node scripts/devices/table.mjs ignores flags it doesn't know, so --help or a typo like --chek rewrites docs/devices.md instead of checking it, and --data with no folder after it writes a table with no reports.
  1. Test first, in scripts/devices/validate.test.mjs and scripts/devices/table.test.mjs, which already run the scripts with execFileSync:
    • --help and -h print the usage and exit 0, for both scripts;
    • table.mjs with an unknown flag, or with --data or --doc and no value after it, prints the usage, exits 1 and leaves the doc unchanged. Use a temporary doc file, as the existing CLI test does.
  2. In each script's main(), handle --help and -h first, then refuse unknown arguments and flags with no value. Reuse the usage lines from each file's header comment.

Done when

  • The new tests pass, and every existing test in scripts/devices/ still passes.
  • validate.mjs behaves exactly as before when called the way .github/workflows/device-report.yml calls it: --event, --github-output and --comment.

How to check

node --test scripts/devices/*.test.mjs
node scripts/devices/validate.mjs --help
node scripts/devices/table.mjs --check

Keep in mind

  • validate.mjs runs on public issues. It reads the issue as data and runs nothing from it. Keep it that way, and never print a report's values in an error.
  • Don't run node scripts/devices/table.mjs without --check on your branch unless you mean to rewrite the table.
  • Node built-ins only. No new dependency.
主要语言
TypeScript
星标
11
派生
0
平均合并
10 分钟
30 天内合并 PR
6

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DojoCodingLabs/hermit 的其他 Issue

查看 DojoCodingLabs/hermit 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。