pnp / cli-microsoft365

Manage Microsoft 365 and SharePoint Framework projects on any platform
https://aka.ms/cli-m365
MIT License
882 stars 311 forks source link

Format client side component properties for SPFx commands in SharePoint #5975

Open milanholemans opened 2 months ago

milanholemans commented 2 months ago

We currently have a few commands in spo that do stuff with SPFx solutions (spo applicationcustomizer, spo commandset, ...). These are great commands to do stuff with your deployed SPFx solutions. For example: it's really easy to see which properties are set on the SPFx custom action. One annoying thing here is that the properties are string escaped, so the result looks like this:

{
   "ClientSideComponentProperties": "{\"sampleTextOne\":\"One item is selected in the list.\", \"sampleTextTwo\":\"This command is always visible.\"}",
}

It would improve the readability a lot if you could specify a flag so that only the client-side properties are printed as JSON:

{
  "sampleTextOne": "One item is selected in the list.",
  "sampleTextTwo": "This command is always visible."
}

So, I suggest that we add a new flag to a few SPO SPFx commands:

Option Description
-p, --clientSideComponentProperties Only output the client-side component properties.

Commands to update:

waldekmastykarz commented 2 months ago

--properties as a flag seems too vague. It doesn't convey what its purpose is without looking at the docs and at the first glance could be confused for specifying which properties you want to retrieve. Something along the lines of --parseProperties or --onlyProperties would be clearer.

The question is, if we should replace the output with just the properties, or should we add a new property named ClientSideComponentPropertiesParsed and attached the parsed object to it, so that user can use --query to select what they want without us forcing only a part of the output.

milanholemans commented 2 months ago

We have a few commands that do something similar. They have a flag that replaces the entire output. Example: spo sitescript get for example. So for the sake of consistency, my vote would go to replacing the entire output.

waldekmastykarz commented 2 months ago

We have a few commands that do something similar. They have a flag that replaces the entire output. Example: spo sitescript get for example. So for the sake of consistency, my vote would go to replacing the entire output.

Hmmm, good point. For consistency, shall we then use the full property name, ie. --clientSideComponentProperties?

milanholemans commented 2 months ago

Ok, updated the spec.

Jwaegebaert commented 2 months ago

Great enhancement, specs look clear to me so let's open it up.