Skip to content

Modularize the policy generation script#272332

Merged
pwang347 merged 22 commits into
mainfrom
pawang/policiesClean
Oct 22, 2025
Merged

Modularize the policy generation script#272332
pwang347 merged 22 commits into
mainfrom
pawang/policiesClean

Conversation

@pwang347
Copy link
Copy Markdown
Member

@pwang347 pwang347 commented Oct 20, 2025

Follow-up for #272018

Base automatically changed from pawang/policies to main October 20, 2025 21:38
Comment thread build/lib/test/render.test.ts Dismissed
Comment thread build/lib/test/render.test.ts Dismissed
Comment thread build/lib/test/render.test.ts Dismissed
@pwang347 pwang347 requested a review from joshspicer October 20, 2025 22:01
@pwang347 pwang347 marked this pull request as ready for review October 20, 2025 22:01
Copilot AI review requested due to automatic review settings October 20, 2025 22:01
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 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.ts module for rendering functions
  • Added comprehensive unit tests for the extracted modules
  • Updated policyGenerator.ts to 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

Comment thread build/lib/policies/numberPolicy.ts
Comment thread build/lib/policies/render.ts Outdated
Comment thread build/lib/policies/render.ts Outdated
@vs-code-engineering vs-code-engineering Bot added this to the October 2025 milestone Oct 20, 2025
joshspicer
joshspicer previously approved these changes Oct 20, 2025
Copy link
Copy Markdown
Member

@joshspicer joshspicer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome 🚀 Suggestion to add some tests that encode verbatim config generated with the old script

@pwang347
Copy link
Copy Markdown
Member Author

pwang347 commented Oct 21, 2025

@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!
CodeOSS.adml.fr-fr.diff.txt
CodeOSS.admx.diff.txt
com.visualstudio.code.oss.mobileconfig.diff.txt
com.visualstudio.code.oss.plist.fr-fr.diff.txt

Also see "behaviour changes" section in #272018

@pwang347
Copy link
Copy Markdown
Member Author

note that tests are not currently run in CI, that will be enabled as part of this PR: #272564

joshspicer
joshspicer previously approved these changes Oct 21, 2025
@pwang347
Copy link
Copy Markdown
Member Author

@microsoft-github-policy-service rerun

@pwang347 pwang347 merged commit 0ea6a23 into main Oct 22, 2025
28 checks passed
@pwang347 pwang347 deleted the pawang/policiesClean branch October 22, 2025 00:08
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Dec 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants