SharePoint / SharePoint/spfx

Introduce JSON output mode for the `spfx list-templates` command

Open
#235 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: api area: cli type: enhancement
Dominant language
TypeScript
Stars
32
Forks
18
PR merge metrics
No merged PRs in 30d

Description

Description

currently the spfx list-templates command has a ASCII like table output mode which is note that helpful.
First of all, it is not always readable in smaller terminals

Image

Second of all, it is tricky to parse when used in scripts, tests, CI-CD. Since it is not standard, the view may change at any time, which creates an even bigger challenge.

I suggest we introduce JSON output mode to this command, which is standard and easily parse to a TS/C#/PS and other objects and I would make the JSON output mode default.
Additionally, we could introduce other output modes besides json like:

  • text - which could be what is currently shown, so the table
  • csv

In order to allo to the use to specify a different output mode we could add a new option -o, --output so that if user would like a text output, he or she could run:
spfx list-templates --output 'text'

Use case

Introducing JSON output mode will allow to use this command in CI CD automation, scripts and tests.
The current output format is not readable and tricky to parse

Alternatives considered

Alternatively, you could provide and script example how to easily parse the current output format to an TS object

Additional context

IMHO JSON output format is kinda standard which I think this tool could follow.
CLI for Microsoft 365 is a good example of a tool that supports multiple output modes
https://pnp.github.io/cli-microsoft365/user-guide/cli-output-mode

I would follow a similar pattern

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the spfx list-templates command and inspect how its current ASCII table output is produced. Define the scope of the -o, --output option, including JSON as the default and whether text and CSV are supported; done means template listings are reliably parseable for scripts, tests, and CI.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.