-
Notifications
You must be signed in to change notification settings - Fork 370
New command: spo brandcenter settings list. Closes #6653 #7058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Saurabh7019
wants to merge
1
commit into
pnp:main
Choose a base branch
from
Saurabh7019:issue-6653
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+403
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
docs/docs/cmd/spo/brandcenter/brandcenter-settings-list.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| import Global from '/docs/cmd/_global.mdx'; | ||
| import Tabs from '@theme/Tabs'; | ||
| import TabItem from '@theme/TabItem'; | ||
|
|
||
| # spo brandcenter settings list | ||
|
|
||
| Lists the brand center configuration | ||
|
|
||
| ## Usage | ||
|
|
||
| ```sh | ||
| m365 spo brandcenter settings list [options] | ||
| ``` | ||
|
|
||
| ## Options | ||
|
|
||
| <Global /> | ||
|
|
||
| ## Permissions | ||
|
|
||
| <Tabs> | ||
| <TabItem value="Delegated"> | ||
|
|
||
| | Resource | Permissions | | ||
| |-----------------|-----------------| | ||
| | Microsoft Graph | Sites.Read.All | | ||
| | SharePoint | AllSites.Read | | ||
|
|
||
| </TabItem> | ||
| <TabItem value="Application"> | ||
|
|
||
| | Resource | Permissions | | ||
| |-----------------|------------------| | ||
| | Microsoft Graph | Sites.Read.All | | ||
| | SharePoint | Sites.Read.All | | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| ## Examples | ||
|
|
||
| List all brand center config | ||
|
|
||
| ```sh | ||
| m365 spo brandcenter settings list | ||
| ``` | ||
|
|
||
| ## Response | ||
|
|
||
| <Tabs> | ||
| <TabItem value="JSON"> | ||
|
|
||
| ```json | ||
| { | ||
| "BrandColorsListId": "00000000-0000-0000-0000-000000000000", | ||
| "BrandColorsListUrl": null, | ||
| "BrandFontLibraryId": "23af51de-856c-4d00-aa11-0d03af0e46e3", | ||
| "BrandFontLibraryUrl": { | ||
| "DecodedUrl": "https://contoso.sharepoint.com/sites/BrandGuide/Fonts" | ||
| }, | ||
| "IsBrandCenterSiteFeatureEnabled": true, | ||
| "IsPublicCdnEnabled": true, | ||
| "OrgAssets": { | ||
| "CentralAssetRepositoryLibraries": null, | ||
| "Domain": { | ||
| "DecodedUrl": "https://contoso.sharepoint.com" | ||
| }, | ||
| "OrgAssetsLibraries": { | ||
| "OrgAssetsLibraries": [ | ||
| { | ||
| "DisplayName": "Fonts", | ||
| "FileType": "", | ||
| "LibraryUrl": { | ||
| "DecodedUrl": "sites/BrandGuide/Fonts" | ||
| }, | ||
| "ListId": "23af51de-856c-4d00-aa11-0d03af0e46e3", | ||
| "OrgAssetFlags": 0, | ||
| "OrgAssetType": 8, | ||
| "ThumbnailUrl": null, | ||
| "UniqueId": "00000000-0000-0000-0000-000000000000" | ||
| } | ||
| ], | ||
| "Items": [ | ||
| { | ||
| "DisplayName": "Fonts", | ||
| "FileType": "", | ||
| "LibraryUrl": { | ||
| "DecodedUrl": "sites/BrandGuide/Fonts" | ||
| }, | ||
| "ListId": "23af51de-856c-4d00-aa11-0d03af0e46e3", | ||
| "OrgAssetFlags": 0, | ||
| "OrgAssetType": 8, | ||
| "ThumbnailUrl": null, | ||
| "UniqueId": "00000000-0000-0000-0000-000000000000" | ||
| } | ||
| ] | ||
| }, | ||
| "SiteId": "52b46e48-9c0c-40cb-a955-13eb6c717ff3", | ||
| "Url": { | ||
| "DecodedUrl": "/sites/BrandGuide" | ||
| }, | ||
| "WebId": "206988d5-e133-4a24-819d-24101f3407ce" | ||
| }, | ||
| "SiteId": "52b46e48-9c0c-40cb-a955-13eb6c717ff3", | ||
| "SiteUrl": "https://contoso.sharepoint.com/sites/BrandGuide" | ||
| } | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem value="Text"> | ||
|
|
||
| ```txt | ||
| BrandColorsListId : 00000000-0000-0000-0000-000000000000 | ||
| BrandColorsListUrl : null | ||
| BrandFontLibraryId : 23af51de-856c-4d00-aa11-0d03af0e46e3 | ||
| BrandFontLibraryUrl : {"DecodedUrl":"https://contoso.sharepoint.com/sites/BrandGuide/Fonts"} | ||
| IsBrandCenterSiteFeatureEnabled: true | ||
| IsPublicCdnEnabled : true | ||
| OrgAssets : {"CentralAssetRepositoryLibraries":null,"Domain":{"DecodedUrl":"https://contoso.sharepoint.com"},"OrgAssetsLibraries":{"OrgAssetsLibraries":[{"DisplayName":"Fonts","FileType":"","LibraryUrl":{"DecodedUrl":"sites/BrandGuide/Fonts"},"ListId":"23af51de-856c-4d00-aa11-0d03af0e46e3","OrgAssetFlags":0,"OrgAssetType":8,"ThumbnailUrl":null,"UniqueId":"00000000-0000-0000-0000-000000000000"}],"Items":[{"DisplayName":"Fonts","FileType":"","LibraryUrl":{"DecodedUrl":"sites/BrandGuide/Fonts"},"ListId":"23af51de-856c-4d00-aa11-0d03af0e46e3","OrgAssetFlags":0,"OrgAssetType":8,"ThumbnailUrl":null,"UniqueId":"00000000-0000-0000-0000-000000000000"}]},"SiteId":"52b46e48-9c0c-40cb-a955-13eb6c717ff3","Url":{"DecodedUrl":"/sites/BrandGuide"},"WebId":"206988d5-e133-4a24-819d-24101f3407ce"} | ||
| SiteId : 52b46e48-9c0c-40cb-a955-13eb6c717ff3 | ||
| SiteUrl : https://contoso.sharepoint.com/sites/BrandGuide | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem value="CSV"> | ||
|
|
||
| ```csv | ||
| BrandColorsListId,BrandColorsListUrl,BrandFontLibraryId,IsBrandCenterSiteFeatureEnabled,IsPublicCdnEnabled,SiteId,SiteUrl | ||
| 00000000-0000-0000-0000-000000000000,,23af51de-856c-4d00-aa11-0d03af0e46e3,1,1,52b46e48-9c0c-40cb-a955-13eb6c717ff3,https://contoso.sharepoint.com/sites/BrandGuide | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem value="Markdown"> | ||
|
|
||
| ```md | ||
| # spo brandcenter settings list --debug "false" --verbose "false" | ||
|
|
||
| Date: 12/1/2025 | ||
|
|
||
| Property | Value | ||
| ---------|------- | ||
| BrandColorsListId | 00000000-0000-0000-0000-000000000000 | ||
| BrandFontLibraryId | 23af51de-856c-4d00-aa11-0d03af0e46e3 | ||
| IsBrandCenterSiteFeatureEnabled | true | ||
| IsPublicCdnEnabled | true | ||
| SiteId | 52b46e48-9c0c-40cb-a955-13eb6c717ff3 | ||
| SiteUrl | https://contoso.sharepoint.com/sites/BrandGuide | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 176 additions & 0 deletions
176
src/m365/spo/commands/brandcenter/brandcenter-settings-list.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| import assert from 'assert'; | ||
| import sinon from 'sinon'; | ||
| import auth from '../../../../Auth.js'; | ||
| import { cli } from '../../../../cli/cli.js'; | ||
| import { CommandInfo } from '../../../../cli/CommandInfo.js'; | ||
| import { Logger } from '../../../../cli/Logger.js'; | ||
| import { CommandError } from '../../../../Command.js'; | ||
| import request from '../../../../request.js'; | ||
| import { telemetry } from '../../../../telemetry.js'; | ||
| import { pid } from '../../../../utils/pid.js'; | ||
| import { session } from '../../../../utils/session.js'; | ||
| import { sinonUtil } from '../../../../utils/sinonUtil.js'; | ||
| import { z } from 'zod'; | ||
| import commands from '../../commands.js'; | ||
| import command from './brandcenter-settings-list.js'; | ||
|
|
||
| describe(commands.BRANDCENTER_SETTINGS_LIST, () => { | ||
| let log: any[]; | ||
| let logger: Logger; | ||
| let loggerLogSpy: sinon.SinonSpy; | ||
| let commandInfo: CommandInfo; | ||
| let commandOptionsSchema: z.ZodTypeAny; | ||
|
|
||
| const successResponse = { | ||
| "BrandColorsListId": "00000000-0000-0000-0000-000000000000", | ||
| "BrandColorsListUrl": null, | ||
| "BrandFontLibraryId": "23af51de-856c-4d00-aa11-0d03af0e46e3", | ||
| "BrandFontLibraryUrl": { | ||
| "DecodedUrl": "https://contoso.sharepoint.com/sites/BrandGuide/Fonts" | ||
| }, | ||
| "IsBrandCenterSiteFeatureEnabled": true, | ||
| "IsPublicCdnEnabled": true, | ||
| "OrgAssets": { | ||
| "CentralAssetRepositoryLibraries": null, | ||
| "Domain": { | ||
| "DecodedUrl": "https://contoso.sharepoint.com" | ||
| }, | ||
| "OrgAssetsLibraries": { | ||
| "OrgAssetsLibraries": [ | ||
| { | ||
| "DisplayName": "Fonts", | ||
| "FileType": "", | ||
| "LibraryUrl": { | ||
| "DecodedUrl": "sites/BrandGuide/Fonts" | ||
| }, | ||
| "ListId": "23af51de-856c-4d00-aa11-0d03af0e46e3", | ||
| "OrgAssetFlags": 0, | ||
| "OrgAssetType": 8, | ||
| "ThumbnailUrl": null, | ||
| "UniqueId": "00000000-0000-0000-0000-000000000000" | ||
| } | ||
| ], | ||
| "Items": [ | ||
| { | ||
| "DisplayName": "Fonts", | ||
| "FileType": "", | ||
| "LibraryUrl": { | ||
| "DecodedUrl": "sites/BrandGuide/Fonts" | ||
| }, | ||
| "ListId": "23af51de-856c-4d00-aa11-0d03af0e46e3", | ||
| "OrgAssetFlags": 0, | ||
| "OrgAssetType": 8, | ||
| "ThumbnailUrl": null, | ||
| "UniqueId": "00000000-0000-0000-0000-000000000000" | ||
| } | ||
| ] | ||
| }, | ||
| "SiteId": "52b46e48-9c0c-40cb-a955-13eb6c717ff3", | ||
| "Url": { | ||
| "DecodedUrl": "/sites/BrandGuide" | ||
| }, | ||
| "WebId": "206988d5-e133-4a24-819d-24101f3407ce" | ||
| }, | ||
| "SiteId": "52b46e48-9c0c-40cb-a955-13eb6c717ff3", | ||
| "SiteUrl": "https://contoso.sharepoint.com/sites/BrandGuide" | ||
| }; | ||
|
|
||
| before(() => { | ||
| sinon.stub(auth, 'restoreAuth').resolves(); | ||
| sinon.stub(telemetry, 'trackEvent').resolves(); | ||
| sinon.stub(pid, 'getProcessName').returns(''); | ||
| sinon.stub(session, 'getId').returns(''); | ||
|
|
||
| auth.connection.active = true; | ||
| auth.connection.spoUrl = 'https://contoso.sharepoint.com'; | ||
| commandInfo = cli.getCommandInfo(command); | ||
| commandOptionsSchema = commandInfo.command.getSchemaToParse()!; | ||
| }); | ||
|
|
||
| beforeEach(() => { | ||
| log = []; | ||
| logger = { | ||
| log: async (msg: string) => { | ||
| log.push(msg); | ||
| }, | ||
| logRaw: async (msg: string) => { | ||
| log.push(msg); | ||
| }, | ||
| logToStderr: async (msg: string) => { | ||
| log.push(msg); | ||
| } | ||
| }; | ||
| loggerLogSpy = sinon.spy(logger, 'log'); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| sinonUtil.restore([ | ||
| request.get | ||
| ]); | ||
| }); | ||
|
|
||
| after(() => { | ||
| sinon.restore(); | ||
| auth.connection.active = false; | ||
| auth.connection.spoUrl = undefined; | ||
| }); | ||
|
|
||
| it('has correct name', () => { | ||
| assert.strictEqual(command.name, commands.BRANDCENTER_SETTINGS_LIST); | ||
| }); | ||
|
|
||
| it('has a description', () => { | ||
| assert.notStrictEqual(command.description, null); | ||
| }); | ||
|
|
||
| it('passes validation with no options', () => { | ||
| const actual = commandOptionsSchema.safeParse({}); | ||
| assert.strictEqual(actual.success, true); | ||
| }); | ||
|
|
||
| it('fails validation with unknown options', () => { | ||
| const actual = commandOptionsSchema.safeParse({ option: "value" }); | ||
| assert.strictEqual(actual.success, false); | ||
| }); | ||
|
|
||
| it('successfully lists brand center settings', async () => { | ||
| const getStub = sinon.stub(request, 'get').callsFake(async (opts: any) => { | ||
| if (opts.url === `https://contoso.sharepoint.com/_api/Brandcenter/Configuration`) { | ||
| return successResponse; | ||
| } | ||
|
|
||
| throw 'Invalid request'; | ||
| }); | ||
|
|
||
| await command.action(logger, { options: {} }); | ||
| assert(getStub.calledOnce); | ||
| assert(loggerLogSpy.calledWith(successResponse)); | ||
| }); | ||
|
|
||
| it('successfully lists brand center settings with verbose output', async () => { | ||
| const getStub = sinon.stub(request, 'get').callsFake(async (opts: any) => { | ||
| if (opts.url === `https://contoso.sharepoint.com/_api/Brandcenter/Configuration`) { | ||
| return successResponse; | ||
| } | ||
|
|
||
| throw 'Invalid request'; | ||
| }); | ||
|
|
||
| await command.action(logger, { options: { verbose: true } }); | ||
| assert(getStub.calledOnce); | ||
| assert(loggerLogSpy.calledWith(successResponse)); | ||
| }); | ||
|
|
||
| it('correctly handles error when retrieving settings', async () => { | ||
| sinon.stub(request, 'get').callsFake(async (opts) => { | ||
| if (opts.url === 'https://contoso.sharepoint.com/_api/Brandcenter/Configuration') { | ||
| throw 'An unknown error has occurred'; | ||
| } | ||
|
|
||
| throw 'Invalid request'; | ||
| }); | ||
|
|
||
| await assert.rejects(command.action(logger, { options: {} }), | ||
| new CommandError(`An unknown error has occurred`)); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The example description uses the abbreviation "config" instead of the full word "configuration" used in the command description. For consistency, consider using "Lists the brand center configuration" or "Retrieve the brand center configuration".