Skip to content

Migrates context commands to Zod. Closes #7293#7363

Open
waldekmastykarz wants to merge 1 commit into
pnp:mainfrom
waldekmastykarz:waldekmastykarz/migrate-context-to-zod
Open

Migrates context commands to Zod. Closes #7293#7363
waldekmastykarz wants to merge 1 commit into
pnp:mainfrom
waldekmastykarz:waldekmastykarz/migrate-context-to-zod

Conversation

@waldekmastykarz
Copy link
Copy Markdown
Member

Closes #7293

Completes the Zod migration for the two remaining context commands that still used the old #initOptions() pattern:

  • context-init: Added a Zod schema with global options and the get schema() getter. This command has no custom options, so the schema only spreads globalOptionsZod.
  • option-set: Replaced the constructor-based #initOptions() and GlobalOptions interface with a Zod strictObject schema defining name (alias n) and value (alias v) as required strings.

Updated both test files to import the exported options schema, set up commandOptionsSchema via getSchemaToParse(), use commandOptionsSchema.parse() in all command.action() calls, and added schema validation tests (required fields, unknown options).

The other three context commands (context-remove, option-list, option-remove) were already migrated.

Migrates context-init and option-set commands from the old
#initOptions() pattern to Zod schemas, completing the migration
of all context commands.

Changes:
- context-init: Add Zod schema with global options
- option-set: Replace #initOptions() constructor with Zod schema
  defining name and value as required string options with aliases
- Update test files to import and use commandOptionsSchema.parse()
- Add schema validation tests for both commands

Closes pnp#7293

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 context commands to Zod

1 participant