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

Aberta Para iniciantes
#35 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
90/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
javascript, node.js
Domínio
cli, testing

Direção de pesquisa

Comece pelos testes de CLI em scripts/devices/validate.test.mjs e scripts/devices/table.test.mjs; depois, leia as linhas de uso no comentário de cabeçalho de cada script e sua função main(). Adicione testes para ajuda, flags desconhecidas e valores ausentes, usando um arquivo de documentação temporário para verificar que argumentos inválidos da tabela o deixam inalterado. Execute node --test scripts/devices/*.test.mjs e confirme que validate.mjs ainda aceita os argumentos --event, --github-output e --comment do workflow.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.
Linguagem predominante
TypeScript
Estrelas
11
Forks
0
Merge médio
10min
PRs com merge (30d)
6

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de DojoCodingLabs/hermit

Todas as issues de DojoCodingLabs/hermit

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.