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

Abierto Apto para principiantes
#35 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
90/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
javascript, node.js
Área
cli, testing

Línea de trabajo

Empieza con las pruebas de CLI en scripts/devices/validate.test.mjs y scripts/devices/table.test.mjs; después, lee las líneas de uso en el comentario de encabezado de cada script y su función main(). Añade cobertura para la ayuda, las flags desconocidas y los valores que faltan, usando un archivo de documentación temporal para comprobar que los argumentos no válidos de la tabla lo dejan sin cambios. Ejecuta node --test scripts/devices/*.test.mjs y confirma que validate.mjs sigue aceptando los argumentos --event, --github-output y --comment del workflow.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
TypeScript
Estrellas
11
Forks
0
Merge medio
10 min
PR fusionados (30 d)
6

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de DojoCodingLabs/hermit

Todos los issues de DojoCodingLabs/hermit

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.