facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
56.71k stars 8.53k forks source link

Extended CLI commands no longer appear in `-h` or `--help` output #10681

Open sserrata opened 4 hours ago

sserrata commented 4 hours ago

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

Using extendCli to extend the docusaurus CLI with new commands no longer includes those commands, i.e. usage, description, arguments, options, when executing docusaurus --help or docusaurus -h.

However, the extended commands do appear in the console output after attempting to call an unknown command.

I verified that extended command usage does appear in prior docusaurus release, e.g. v2.4.3 but have not tested releases in between that and the current release.

Reproducible demo

https://codesandbox.io/p/devbox/elegant-water-docusaurus?privacy=public

Steps to reproduce

  1. Bootstrap a fresh docusaurus site
  2. Create the example plugin referenced in the extendCli docs.
  3. Update docusaurus.config.js to include the new plugin.
  4. Execute yarn docusaurus -h and observe the extended command is not present in help output.
  5. Execute yarn docusaurus foo and observe the extended command in the output.

Expected behavior

When executing yarn docusaurus -h I expect to see my extended command usage, description, options, etc., in the output.

Actual behavior

Running yarn docusaurus -h not not include the usage for my extended command. However, my extended command does appear when I attempt to pass an invalid command argument.

Your environment

Self-service

sserrata commented 4 hours ago

CLI output from my repro:

$ docusaurus -h

    ------------------------------------------------------------------------------------------------------------------------------------------------ 

                                                             Update available 3.6.0 → 3.6.1                                                          

                                    To upgrade Docusaurus packages with the latest version, run the following command:                               
         `yarn upgrade @docusaurus/core@latest @docusaurus/preset-classic@latest @docusaurus/module-type-aliases@latest @docusaurus/types@latest`    

    ------------------------------------------------------------------------------------------------------------------------------------------------ 

Usage: docusaurus <command> [options]

Options:
  -V, --version                                            output the version number
  -h, --help                                               display help for command

Commands:
  build [options] [siteDir]                                Build website.
  swizzle [options] [themeName] [componentName] [siteDir]  Wraps or ejects the original theme files into website folder for customization.
  deploy [options] [siteDir]                               Deploy website to GitHub pages.
  start [options] [siteDir]                                Start the development server.
  serve [options] [siteDir]                                Serve website locally.
  clear [siteDir]                                          Remove build artifacts.
  write-translations [options] [siteDir]                   Extract required translations of your site.
  write-heading-ids [options] [siteDir] [files...]         Generate heading ids in Markdown content.
Done in 1.56s.

➜  workspace git:(master) ✗ yarn docusaurus foo
yarn run v1.22.19
$ docusaurus foo

    ------------------------------------------------------------------------------------------------------------------------------------------------ 

                                                             Update available 3.6.0 → 3.6.1                                                          

                                    To upgrade Docusaurus packages with the latest version, run the following command:                               
         `yarn upgrade @docusaurus/core@latest @docusaurus/preset-classic@latest @docusaurus/module-type-aliases@latest @docusaurus/types@latest`    

    ------------------------------------------------------------------------------------------------------------------------------------------------ 

Usage: docusaurus <command> [options]

Options:
  -V, --version                                            output the version number
  -h, --help                                               display help for command

Commands:
  build [options] [siteDir]                                Build website.
  swizzle [options] [themeName] [componentName] [siteDir]  Wraps or ejects the original theme files into website folder for customization.
  deploy [options] [siteDir]                               Deploy website to GitHub pages.
  start [options] [siteDir]                                Start the development server.
  serve [options] [siteDir]                                Serve website locally.
  clear [siteDir]                                          Remove build artifacts.
  write-translations [options] [siteDir]                   Extract required translations of your site.
  write-heading-ids [options] [siteDir] [files...]         Generate heading ids in Markdown content.
  docs:version <version>                                   Tag a new docs version
  roll                                                     Roll a random number between 1 and 1000
[ERROR] Unknown Docusaurus CLI command foo.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
➜  workspace git:(master) ✗