Migrates root commands to Zod. Closes #7291#7361
Open
waldekmastykarz wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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, andrequestcommands 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. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
MartinM85
approved these changes
Jun 5, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Migrates root commands to Zod. Closes #7291