Skip to content

Migrate 'entra administrativeunit add' to Zod #6848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 15, 2025

Migrates the entra administrativeunit add command from traditional validation to Zod schema validation following the established pattern in .github/prompts/migrate-command-to-zod.prompt.md.

Changes made:

  • Replaced GlobalOptions interface with Zod schema using globalOptionsZod.extend()
  • Used zod.alias() for options with short aliases (displayName: 'n', description: 'd')
  • Applied .passthrough() to maintain allowUnknownOptions() functionality for directory extensions
  • Removed constructor and #init methods, replaced with schema getter
  • Updated Options type to use z.infer<typeof options>
  • Added Zod validation tests using commandOptionsSchema.safeParse()
  • Updated all test command.action() calls to use commandOptionsSchema.parse()

The command functionality remains unchanged - it still creates administrative units with the same options (displayName, description, hiddenMembership) and supports unknown options for directory extensions.

Fixes #6814.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@martinlingstuyl
Copy link
Contributor

The PR contains a lot of issues.
You should've used the prompt file .github/prompts/migrate-command-to-zod.prompt.md. Could you retry based on that @copilot?

Co-authored-by: martinlingstuyl <5267487+martinlingstuyl@users.noreply.github.com>
Copy link
Author

Copilot AI commented Aug 15, 2025

The PR contains a lot of issues.
You should've used the prompt file .github/prompts/migrate-command-to-zod.prompt.md. Could you retry based on that @copilot?

I've retried the migration following the pattern from .github/prompts/migrate-command-to-zod.prompt.md. The implementation now correctly:

  • Uses globalOptionsZod.extend() with zod.alias() for command options
  • Applies .passthrough() to maintain allowUnknownOptions() for directory extensions
  • Removes constructor/init methods in favor of schema getter
  • Updates tests with Zod validation pattern using commandOptionsSchema.safeParse()
  • Replaces all test action calls with commandOptionsSchema.parse()

Commit: 09dce69

@Copilot Copilot AI changed the title [WIP] Migrate 'entra administrativeunit add' to Zod. Migrate 'entra administrativeunit add' to Zod Aug 15, 2025
Copilot finished work on behalf of martinlingstuyl August 15, 2025 13:23
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 'entra administrativeunit add' to Zod.
2 participants