Skip to content

Commit

Permalink
Changes to upgrade guidance
Browse files Browse the repository at this point in the history
  • Loading branch information
MathijsVerbeeck authored and milanholemans committed Aug 12, 2023
1 parent b7c2a8d commit 151f0d4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 26 deletions.
8 changes: 8 additions & 0 deletions docs/docs/v7-upgrade-guidance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ In version 7 of the CLI for Microsoft 365, we changed the `id` property of `spo

Update your scripts to use the list item id for `id` property instead of UniqueId product id.

## Updated `spo theme list` command output

In version 7 of the CLI For Microsoft 365, we have made an adjustment for the data returned by the `spo theme list` command. Previously, when no items were found the command had no output. This made this command very unpredictable to use in scripts. The command has now been updated so an empty array will be logged when no items are found.

### What action do I need to take?

Make sure that your script expects an empty array when there are no themes found.

## Aligned options with naming convention

In version 7 of the CLI for Microsoft 365, we have made updates to the options for certain commands, aligning with our naming convention. This includes renaming options to ensure consistency and improve the CLI experience. For example, the option `--environment` for the command `m365 pa app consent set` has been changed to `--environmentName`. These changes aim to make it easier for you to use the CLI.
Expand Down
15 changes: 0 additions & 15 deletions src/m365/spo/commands/theme/theme-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,6 @@ describe(commands.THEME_LIST, () => {
assert(loggerLogSpy.calledWith(expected.themePreviews), 'Invalid request');
});

it('retrieves available themes - no custom themes available', async () => {
const expected: any = {
"themePreviews": []
};
sinon.stub(request, 'post').callsFake(async (opts) => {
if ((opts.url as string).indexOf('/_api/thememanager/GetTenantThemingOptions') > -1) {
return expected;
}
throw 'Invalid request';
});

await command.action(logger, { options: { debug: true, verbose: true } });
assert(loggerLogToStderrSpy.calledWith('No themes found'), 'Invalid request');
});

it('retrieves available themes - handle error', async () => {
sinon.stub(request, 'post').callsFake(async (opts) => {
if ((opts.url as string).indexOf('/_api/thememanager/GetTenantThemingOptions') > -1) {
Expand Down
14 changes: 3 additions & 11 deletions src/m365/spo/commands/theme/theme-list.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Logger } from '../../../../cli/Logger.js';
import request from '../../../../request.js';
import request, { CliRequestOptions } from '../../../../request.js';
import { spo } from '../../../../utils/spo.js';
import SpoCommand from '../../../base/SpoCommand.js';
import commands from '../../commands.js';
Expand All @@ -24,7 +24,7 @@ class SpoThemeListCommand extends SpoCommand {
await logger.logToStderr(`Retrieving themes from tenant store...`);
}

const requestOptions: any = {
const requestOptions: CliRequestOptions = {
url: `${spoAdminUrl}/_api/thememanager/GetTenantThemingOptions`,
headers: {
'accept': 'application/json;odata=nometadata'
Expand All @@ -33,15 +33,7 @@ class SpoThemeListCommand extends SpoCommand {
};

const rawRes: any = await request.post(requestOptions);
const themePreviews: any[] = rawRes.themePreviews;
if (themePreviews && themePreviews.length > 0) {
await logger.log(themePreviews);
}
else {
if (this.verbose) {
await logger.logToStderr('No themes found');
}
}
await logger.log(rawRes.themePreviews);
}
catch (err: any) {
this.handleRejectedODataJsonPromise(err);
Expand Down

0 comments on commit 151f0d4

Please sign in to comment.