Extend: `spo site add` command with Brand center option
Usage
m365 spo site add [options]
Description
Creates a brand center site
Options
| Option | Description |
|---|---|
--type [type] |
Type of sites to add. Allowed values TeamSite, CommunicationSite, ClassicSite, BrandCenter, default TeamSite |
Examples
Create a brand center site.
m365 spo site add --type BrandCenter --url https://contoso.sharepoint.com/sites/brandcenter --title Branding
Default properties
No response
Additional Info
POST https://admin.microsoft.com/_api/SPSiteManager/Create
{"request":{"__metadata":{"type":"Microsoft.SharePoint.Portal.SPSiteCreationRequest"},"Title":"Brand Guide","Url":"https://contoso.sharepoint.com/sites/BrandGuide","WebTemplate":"SITEPAGEPUBLISHING#0","Classification":"","Description":"","SensitivityLabel":"00000000-0000-0000-0000-000000000000","Owner":"","SiteDesignId":"00000000-0000-0000-0000-000000000000","ShareByEmailEnabled":false,"Lcid":1033,"TimeZoneId":13,"AdditionalSiteFeatureIds":{"results":["99cd6e8b-189b-4611-ae89-f89105876e43"]}}}
Before executing this command, we need to check if the Brand Center already exists. (As only one brand center can exist).
As suggested by @milanholemans we should also prompt the user for confirmation and notify that the site cannot be deleted.
In the layout there was a checkbox that needed to be accepted (related to the public CDN) before creating the Brand Center, but I can no longer see it. However, it might be a good idea to ask the same question before executing the command.
@milanholemans can you add it to the #6652 parent?
@mkm17 I suggest that we add a -f, --force flag like we do for removing commands. However this is not a destructive command, it is something that is irreversible. In this prompt we can warn the user that the site cannot be removed.
@milanholemans ok, I have added the option
@mkm17 thinking about it some more, shouldn't we also have an option called url where the user can specify the URL of the site?
Maybe also a title and an optional description?
@milanholemans have added url, title and description, but maybe we can use more parameters used already in spo site add command. like --timeZone, --lcid --owners and --classification.
Maybe we should just enhance spo site add with the possibility of adding a brand center. When the type brandCenter is picked, we can still show a prompt. This means we won't have to duplicate almost an entire command. Any second opinion @pnp/cli-for-microsoft-365-maintainers?
Maybe we should just enhance
spo site addwith the possibility of adding a brand center. When the type brandCenter is picked, we can still show a prompt. This means we won't have to duplicate almost an entire command. Any second opinion @pnp/cli-for-microsoft-365-maintainers?
Interesting suggestion. I don't have any strong opinion which approach is better as I think both have pros and cons. The only thing is that this command is kinda similar to tenant app catalog for which we also have separate command š¤. I think it is kind of a command that will not be used that frequent, most probably once per tenant š. And if we have a separate command for it then it will increase viability of this. Most probable folks will notice a separate command rather then an additional example in the spo site add command. When it comes for duplicated logic I guess we should extract as much as possible to utils. We could check how the appcatalog add or site appcatalog add do it as I guess they also use same logic
I'm not a huge fan of duplicating code either, but as @Adam-it mentioned, separating the command makes it easier to find. That being said, you could argue the same for many other options in commands, they could be more discoverable if separated. Since this won't be a frequently used command per tenant, Iād lean towards implementing it within spo site add. That way, we reduce the amount of code to manage š
@Jwaegebaert @Adam-it @milanholemans, why can't we include both options? We can extract the site creation code and reuse it for different scenarios: a regular site, a Brand Center site (which appears to be a Community site with an additional site feature), and potentially even a SharePoint Premium Content Center site.
I need to explore this further, but there might be a way to simply set a site as a Brand Center by enabling a site feature, and 'remove' the Brand Center by disabling that same feature. However, I need to check if there are any consequences, as this option doesn't seem to be available in the admin center.
@Jwaegebaert @Adam-it @milanholemans, why can't we include both options? We can extract the site creation code and reuse it for different scenarios: a regular site, a Brand Center site (which appears to be a Community site with an additional site feature), and potentially even a SharePoint Premium Content Center site.
@mkm17 exactly š This is what I had in mind when I wrote
When it comes for duplicated logic I guess we should extract as much as possible to utils. We could check how the appcatalog add or site appcatalog add do it as I guess they also use same logic
We already do this in several places were common logic is extracted and reshared between multiple commands. I think this approach makes most sense IMO š
I need to explore this further, but there might be a way to simply set a site as a Brand Center by enabling a site feature, and 'remove' the Brand Center by disabling that same feature. However, I need to check if there are any consequences, as this option doesn't seem to be available in the admin center.
good find. It would be interested if it would work this way as in this case it would be quite flexible and we could have commands allowing it to activate and deactivate
I need to explore this further, but there might be a way to simply set a site as a Brand Center by enabling a site feature, and 'remove' the Brand Center by disabling that same feature. However, I need to check if there are any consequences, as this option doesn't seem to be available in the admin center.
good find. It would be interested if it would work this way as in this case it would be quite flexible and we could have commands allowing it to activate and deactivate
In this case, we'll have to check if it's actually supported to do so.
How different is the code for adding a brandcenter site vs a regular site? If it's just a matter of specifying the site template, then I suggest we merge it with spo site add. If it's using a different API, then I suggest that we build a separate command to avoid the code getting too complex.
@waldekmastykarz the only difference I can see is the additional feature that needs to be enabled on the site. If that's the case, and we decide not to create a separate command, then maybe we can follow the same approach as with the removal of the SharePoint page header. Instead of creating a new command, we could just provide an example script to create/configure the Brand Center. This would be a very simple solution, just using the existing spo site add and spo feature enable commands.
That sounds like a fair approach. Providing an example script using spo site add and spo feature enable makes sense if the only difference is toggling that feature flag.
@pnp/cli-for-microsoft-365-maintainers I think this issue has become a bit stale and we only need to decide for the approach. I think we all agreed that we rather not add a separate command for it as most probably it would not be used that often, although its worth pointing out that for tenant app catalog we have a separate command so I am only afraid it may seem inconsistent.
Now we should rather decide if:
- we want to add a separate script sample for it which would be a combination of site add and feature enable.
- or we want to expose this as an additional option in the site add command.
I vote for 2nd option
Thanks for reviving this issue @Adam-it. My vote would go to option 2 as well.
+1 on option 2
Ok, so I think I can change the description of the command to an update of site add :)
Ok, so I think I can change the description of the command to an update of
site add:)
Perfect. Let's open it up @mkm17 did you maybe want to take action on that and implement it?
It's gonna be hard to review it in my case as I already have brand center on my dev tenant š
@Adam-it I can take it :) Some time ago, it was possible to remove the Brand Center by disabling the feature mentioned in the task.
@mkm17 all yours ššššš