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

Ouverte Adaptée aux débutants
#35 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
90/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
javascript, node.js
Domaine
cli, testing

Piste de recherche

Commencez par les tests CLI dans scripts/devices/validate.test.mjs et scripts/devices/table.test.mjs, puis lisez les lignes d’utilisation dans le commentaire d’en-tête de chaque script et sa fonction main(). Ajoutez des tests pour l’aide, les options inconnues et les valeurs manquantes, en utilisant un fichier de documentation temporaire pour vérifier que des arguments de table invalides le laissent inchangé. Exécutez node --test scripts/devices/*.test.mjs et confirmez que validate.mjs accepte toujours les arguments --event, --github-output et --comment du workflow.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.
Langage dominant
TypeScript
Étoiles
11
Forks
0
Merge moyen
10 min
PR mergées (30 j)
6

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de DojoCodingLabs/hermit

Toutes les issues de DojoCodingLabs/hermit

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.