Modularize the policy generation script#272332
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request modularizes the policy generation script by extracting classes, interfaces, and rendering functions from a monolithic policyGenerator.ts file into separate, focused modules. The refactoring improves code organization, testability, and maintainability without changing functionality.
Key changes:
- Extracted policy classes (
BooleanPolicy,NumberPolicy,StringPolicy,StringEnumPolicy,ObjectPolicy,BasePolicy) into individual files - Moved type definitions and interfaces to
types.ts - Created a separate
render.tsmodule for rendering functions - Added comprehensive unit tests for the extracted modules
- Updated
policyGenerator.tsto import from the new modules
Reviewed Changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/vs/base/common/policyDto.ts |
Added new DTO interfaces for policy data structures used across modules |
build/package.json |
Added test script to run mocha tests |
build/lib/policies/types.ts |
Extracted common types, interfaces, and enums from policyGenerator |
build/lib/policies/basePolicy.ts |
Extracted abstract base class for policy implementations |
build/lib/policies/booleanPolicy.ts |
Extracted BooleanPolicy class into separate module |
build/lib/policies/numberPolicy.ts |
Extracted NumberPolicy class into separate module |
build/lib/policies/stringPolicy.ts |
Extracted StringPolicy class into separate module |
build/lib/policies/stringEnumPolicy.ts |
Extracted StringEnumPolicy class into separate module |
build/lib/policies/objectPolicy.ts |
Extracted ObjectPolicy class into separate module |
build/lib/policies/render.ts |
Extracted rendering utility functions into separate module |
build/lib/policies/policyGenerator.ts |
Updated to import from modularized files and pass product parameter to render functions |
build/lib/test/*.test.ts |
Added comprehensive unit tests for all policy classes and rendering functions |
joshspicer
left a comment
There was a problem hiding this comment.
This is awesome 🚀 Suggestion to add some tests that encode verbatim config generated with the old script
|
@joshspicer I added tests based on the new changes - there are some slight differences such as sort order etc and some updates due to the wrong type being used previously. I've attached the diffs here in case they are interesting! Also see "behaviour changes" section in #272018 |
|
note that tests are not currently run in CI, that will be enabled as part of this PR: #272564 |
|
@microsoft-github-policy-service rerun |
Follow-up for #272018