Skip to content

Migrates 'spo cdn' commands to Zod. Closes #7321 - #7428

Merged
milanholemans merged 2 commits into
pnp:mainfrom
MartinM85:feature/7321-migrate-spo-cdn-to-zod
Sep 5, 2026
Merged

milanholemans merged 2 commits into
pnp:mainfrom
MartinM85:feature/7321-migrate-spo-cdn-to-zod

Conversation

@MartinM85

Copy link
Copy Markdown
Contributor

Closes #7321

Copilot AI left a comment

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.

Pull request overview

Migrates the SharePoint Online spo cdn command group from the legacy initOptions/types/validators model to schema-driven option parsing and validation using Zod, aligning these commands with the newer CLI validation/telemetry pipeline.

Changes:

  • Introduces Zod schema definitions for all spo cdn* commands and removes legacy option/validator initialization.
  • Updates unit tests to use the command schema (getSchemaToParse()) for parsing/validating options.
  • Adds negative validation tests for unknown options via z.strictObject(...).

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/m365/spo/commands/cdn/cdn-get.ts Adds Zod schema for spo cdn get options (type).
src/m365/spo/commands/cdn/cdn-get.spec.ts Updates tests to parse via command schema and validate unknown options.
src/m365/spo/commands/cdn/cdn-origin-add.ts Adds Zod schema for spo cdn origin add options (type, origin).
src/m365/spo/commands/cdn/cdn-origin-add.spec.ts Updates tests to parse via schema; validation tests updated (missing required-option assertion noted).
src/m365/spo/commands/cdn/cdn-origin-list.ts Adds Zod schema for spo cdn origin list options (type).
src/m365/spo/commands/cdn/cdn-origin-list.spec.ts Updates tests to parse via schema and validate unknown options.
src/m365/spo/commands/cdn/cdn-origin-remove.ts Adds Zod schema for spo cdn origin remove options (type, origin, force).
src/m365/spo/commands/cdn/cdn-origin-remove.spec.ts Updates tests to parse via schema; validation tests updated (missing required-option assertion noted).
src/m365/spo/commands/cdn/cdn-policy-list.ts Adds Zod schema for spo cdn policy list options (cdnType).
src/m365/spo/commands/cdn/cdn-policy-list.spec.ts Updates tests to parse via schema and validate unknown options.
src/m365/spo/commands/cdn/cdn-policy-set.ts Adds Zod schema for spo cdn policy set options (cdnType, policy, value).
src/m365/spo/commands/cdn/cdn-policy-set.spec.ts Updates tests to parse via schema; validation tests updated (missing required-option assertions noted).
src/m365/spo/commands/cdn/cdn-set.ts Adds Zod schema for spo cdn set options (type, enabled, noDefaultOrigins).
src/m365/spo/commands/cdn/cdn-set.spec.ts Updates tests to parse via schema; validation tests updated (missing required-option assertion noted).

Comment thread src/m365/spo/commands/cdn/cdn-set.spec.ts
Comment thread src/m365/spo/commands/cdn/cdn-policy-set.spec.ts
Comment thread src/m365/spo/commands/cdn/cdn-origin-add.spec.ts
Comment thread src/m365/spo/commands/cdn/cdn-origin-remove.spec.ts

Copilot AI left a comment

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.

🟡 Changes recommended

Required-origin validation coverage is missing in two suites, and one validation test is incorrectly named.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 14/14 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment thread src/m365/spo/commands/cdn/cdn-origin-add.ts
Comment thread src/m365/spo/commands/cdn/cdn-origin-remove.ts
it('accepts Public SharePoint Online CDN type', async () => {
const actual = await command.validate({ options: { cdnType: 'Public', policy: 'IncludeFileExtensions', value: 'CSS,EOT,GIF,ICO,JPEG,JPG,JS,MAP,PNG,SVG,TTF,WOFF,JSON' } }, commandInfo);
assert.strictEqual(actual, true);
it('fails validation when required origin option not specified', () => {
@milanholemans
milanholemans merged commit aee07d9 into pnp:main Sep 5, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate spo cdn commands to Zod

3 participants