Skip to content

Adds hostProperties option to applicationcustomizer commands. Closes …#7084

Draft
Saurabh7019 wants to merge 1 commit intopnp:mainfrom
Saurabh7019:issue-6825
Draft

Adds hostProperties option to applicationcustomizer commands. Closes …#7084
Saurabh7019 wants to merge 1 commit intopnp:mainfrom
Saurabh7019:issue-6825

Conversation

@Saurabh7019
Copy link
Copy Markdown
Contributor

Closes #6825

@Saurabh7019 Saurabh7019 marked this pull request as ready for review December 29, 2025 20:06
Copilot AI review requested due to automatic review settings December 29, 2025 20:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds the hostProperties option to all four application customizer commands (add and set variants for both site-level and tenant-level), enabling users to configure host properties for Application Customizers. This addresses issue #6825.

Key Changes

  • Added hostProperties optional parameter to all four application customizer commands
  • Implemented JSON validation for hostProperties in applicationcustomizer-add.ts
  • Added test coverage for the new option across all commands
  • Updated documentation to reflect the new parameter and its JSON handling requirements

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/m365/spo/commands/tenant/tenant-applicationcustomizer-add.ts Adds hostProperties option, telemetry tracking, and sets field value when adding tenant-wide customizers
src/m365/spo/commands/tenant/tenant-applicationcustomizer-add.spec.ts Adds test case verifying hostProperties can be set when adding a tenant-wide customizer
src/m365/spo/commands/tenant/tenant-applicationcustomizer-set.ts Adds hostProperties option, telemetry tracking, validation check, and update logic for tenant-wide customizers
src/m365/spo/commands/tenant/tenant-applicationcustomizer-set.spec.ts Adds test case verifying hostProperties can be updated for existing tenant-wide customizers
src/m365/spo/commands/applicationcustomizer/applicationcustomizer-add.ts Adds hostProperties option with JSON validation, telemetry tracking, and sets field value when adding site-level customizers
src/m365/spo/commands/applicationcustomizer/applicationcustomizer-add.spec.ts Adds test cases for both successful hostProperties usage and validation of invalid JSON input
src/m365/spo/commands/applicationcustomizer/applicationcustomizer-set.ts Adds hostProperties option, telemetry tracking, validation check, and update logic for site-level customizers
src/m365/spo/commands/applicationcustomizer/applicationcustomizer-set.spec.ts Adds test case verifying hostProperties can be updated for existing site-level customizers
docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-add.mdx Documents the new hostProperties option and updates JSON escaping guidance to include it
docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-set.mdx Documents the new hostProperties option with clear/empty string capability and updates remarks for JSON handling
docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-add.mdx Documents the new hostProperties option and updates JSON escaping guidance to include it
docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-set.mdx Documents the new hostProperties option with clear/empty string capability and updates remarks for JSON handling

@milanholemans
Copy link
Copy Markdown
Contributor

milanholemans commented Dec 29, 2025

Thanks @Saurabh7019! We'll try to review it soon.

@milanholemans milanholemans self-assigned this Feb 26, 2026
Copy link
Copy Markdown
Contributor

@milanholemans milanholemans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement!

Made a few comments while reviewing.

Comment on lines +137 to +139
if (args.options.hostProperties) {
requestBody.HostProperties = args.options.hostProperties;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's assign this value directly to the request body. Also, by default these host properties are just an empty string. Maybe we should do this as well.

Comment on lines +134 to +137
&& opts.data['Location'] === 'ClientSideExtension.ApplicationCustomizer'
&& opts.data['ClientSideComponentId'] === clientSideComponentId
&& opts.data['HostProperties'] === clientSideComponentProperties
&& opts.data['Name'] === title) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of checking the body like this, let's remove it from here and use assert.deepstrictequal to validate the body.
This way if there is a mismatch, it will be much clearer what the problem is.

Comment on lines +110 to 112
if (!args.options.newTitle && args.options.description === undefined && !args.options.clientSideComponentProperties && args.options.hostProperties === undefined) {
return `Please specify an option to be updated`;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Over here, we're not validating if it's a valid JSON like we do for the add command.

Comment on lines +156 to +158
if (hostProperties !== undefined) {
requestBody.HostProperties = hostProperties;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we assign this directly to the request body object?

Comment on lines +64 to +66
{
option: '--hostProperties [hostProperties]'
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add some JSON validation for hostProperties? Let's do the same for clientSideComponentProperties.

});

await command.action(logger, { options: { clientSideComponentId: clientSideComponentId, title: customizerTitle, hostProperties: '{ "preAllocatedApplicationCustomizerTopHeight": "50", "preAllocatedApplicationCustomizerBottomHeight": "50" }', verbose: true } });
assert.strictEqual(executeCommandCalled, true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we validate that the right host properties were passed?

option: '-p, --clientSideComponentProperties [clientSideComponentProperties]'
},
{
option: '--hostProperties [hostProperties]'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also validate if it's a valid JSON string.


await command.action(logger, {
options: {
id: id, hostProperties: hostProperties
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put the hostProperties on a new line here.

@milanholemans milanholemans marked this pull request as draft April 7, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add hostProperties option to applicationcustomizer commands

3 participants