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

オープン 初心者向け
#35 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
90/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, node.js
領域
cli, testing

調査の方向性

まず scripts/devices/validate.test.mjs と scripts/devices/table.test.mjs の CLI テストを確認し、次に各スクリプトのヘッダーコメントにある使用方法の行と main() 関数を読みます。ヘルプ、不明なフラグ、値の不足をカバーするテストを追加し、一時的なドキュメントファイルを使って、無効なテーブル引数を渡してもファイルが変更されないことを確認します。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分
マージ済み PR(30日)
6

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

DojoCodingLabs/hermit のほかの issue

DojoCodingLabs/hermit の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。