Skip to content

Implement list-templates CLI command #89

@nick-pape

Description

@nick-pape

Summary

The dev design specifies a spfx-cli list-templates command that lists all available templates from registered sources. This command does not exist today — only create is implemented.

Requirements

Command signature

spfx list-templates [options]

Flags

Flag Type Required Description
--local-source PATH string (repeatable) No Path(s) to local template folder(s) to include
--remote-source URL string (repeatable) No Public GitHub repo URL(s) to include as template sources

Behavior

  • Fetches templates from all registered sources (default GitHub source + any additional local/remote sources)
  • Displays a formatted list of templates with: name, description, version, spfxVersion, component category (once Add unit tests for scaffolding API #9 lands)
  • Groups or labels by source origin (local vs. remote)

Existing infrastructure

  • SPFxTemplateRepositoryManager already supports multiple sources and concurrent fetching
  • SPFxTemplateCollection has a toString() method with formatted output
  • LocalFileSystemRepositorySource and PublicGitHubRepositorySource are both implemented in @microsoft/spfx-template-api

Implementation notes

  • Add a new ListTemplatesAction class in apps/spfx-cli/src/actions/ extending CommandLineAction from @rushstack/ts-command-line
  • Register it in SPFxCommandLineParser alongside the existing CreateAction
  • Wire up the repository manager with default + user-specified sources

Acceptance criteria

  • spfx list-templates lists all templates from default source
  • --local-source adds local templates to output
  • --remote-source adds remote GitHub templates to output
  • Multiple --local-source and --remote-source flags can be combined
  • Output is human-readable with template metadata

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions