Skip to content

Migrates root commands to Zod. Closes #7291#7361

Open
waldekmastykarz wants to merge 2 commits into
pnp:mainfrom
waldekmastykarz:zod-root-commands
Open

Migrates root commands to Zod. Closes #7291#7361
waldekmastykarz wants to merge 2 commits into
pnp:mainfrom
waldekmastykarz:zod-root-commands

Conversation

@waldekmastykarz
Copy link
Copy Markdown
Member

Migrates root commands to Zod. Closes #7291

Copy link
Copy Markdown
Contributor

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 PR migrates several root-level CLI commands to the new Zod-based option schema/validation flow, aligning them with the project’s ongoing move away from custom validators and manual option definitions (closes #7291).

Changes:

  • Migrated version, setup, search, and request commands to define options via Zod schemas (including refined schema rules where needed).
  • Updated existing Mocha specs to validate/execute commands using the parsed Zod schema output rather than legacy command.validate(...).
  • Ensured commands that need unknown options (eg. request) use a loose Zod object schema so custom headers/options can pass through.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/m365/commands/version.ts Adds Zod schema for global options to support schema-based parsing/telemetry.
src/m365/commands/setup.ts Replaces legacy option/validator setup with Zod schema + refinement (mutual exclusivity).
src/m365/commands/setup.spec.ts Updates tests to use getSchemaToParse() and parsed options for execution/validation.
src/m365/commands/search.ts Introduces Zod schema + refined rules for scopes/top results/sorting constraints.
src/m365/commands/search.spec.ts Updates validation and execution tests to use Zod parsing/safeParse.
src/m365/commands/request.ts Introduces loose Zod schema (passthrough) + refined constraints for method/body/content-type/filePath.
src/m365/commands/request.spec.ts Updates tests to use schema parsing; adjusts scenarios to satisfy refined schema rules.

Comment thread src/m365/commands/search.ts Outdated
@MartinM85 MartinM85 marked this pull request as draft June 2, 2026 13:43
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@waldekmastykarz waldekmastykarz marked this pull request as ready for review June 5, 2026 07:06
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.

Migrate root commands to Zod

3 participants