From b17a273e472cf340af4ded4d84a40ebaeace40c5 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 21 Jan 2025 18:08:31 +0100 Subject: [PATCH] feat: add patch to use policies (#2209) --- build.sh | 3 + dev/patch.sh | 4 +- patches/windows/policies.patch | 137 +++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 patches/windows/policies.patch diff --git a/build.sh b/build.sh index 07d77528d92..6ed4d4bf736 100755 --- a/build.sh +++ b/build.sh @@ -29,6 +29,9 @@ if [[ "${SHOULD_BUILD}" == "yes" ]]; then VSCODE_PLATFORM="darwin" elif [[ "${OS_NAME}" == "windows" ]]; then + # generate Group Policy definitions + node build/lib/policies + # in CI, packaging will be done by a different job if [[ "${CI_BUILD}" == "no" ]]; then . ../build/windows/rtf/make.sh diff --git a/dev/patch.sh b/dev/patch.sh index fadc0148548..c6a755cd6f0 100755 --- a/dev/patch.sh +++ b/dev/patch.sh @@ -29,7 +29,7 @@ while [ $# -gt 1 ]; do done git add . -git commit -q -m "VSCODIUM HELPER" --no-verify +git commit --no-verify -q -m "VSCODIUM HELPER" if [[ "${1}" == *patch ]]; then FILE="../patches/${1}" @@ -47,6 +47,4 @@ git add . git diff --staged -U1 > "${FILE}" git reset -q --hard HEAD~ -cd .. - echo "The patch has been generated." diff --git a/patches/windows/policies.patch b/patches/windows/policies.patch new file mode 100644 index 00000000000..130a3ef3eb1 --- /dev/null +++ b/patches/windows/policies.patch @@ -0,0 +1,137 @@ +diff --git a/build/.moduleignore b/build/.moduleignore +index 01541e8..5b67f2b 100644 +--- a/build/.moduleignore ++++ b/build/.moduleignore +@@ -120,9 +120,11 @@ vsda/** + +-@vscode/policy-watcher/build/** +-@vscode/policy-watcher/.husky/** +-@vscode/policy-watcher/src/** +-@vscode/policy-watcher/binding.gyp +-@vscode/policy-watcher/README.md +-@vscode/policy-watcher/index.d.ts +-!@vscode/policy-watcher/build/Release/vscode-policy-watcher.node ++@vscodium/policy-watcher/.github/** ++@vscodium/policy-watcher/.husky/** ++@vscodium/policy-watcher/build/** ++@vscodium/policy-watcher/src/** ++@vscodium/policy-watcher/.release-it.yml ++@vscodium/policy-watcher/binding.gyp ++@vscodium/policy-watcher/README.md ++@vscodium/policy-watcher/index.d.ts ++!@vscodium/policy-watcher/build/Release/vscode-policy-watcher.node + +diff --git a/build/lib/policies.js b/build/lib/policies.js +index 1560dc7..07c7348 100644 +--- a/build/lib/policies.js ++++ b/build/lib/policies.js +@@ -61,3 +61,3 @@ class BasePolicy { + return [ +- ``, ++ ``, + ` `, +@@ -373,3 +373,3 @@ function renderADMX(regKey, versions, categories, policies) { + +- ++ + +diff --git a/build/lib/policies.ts b/build/lib/policies.ts +index f602c8a..11919c9 100644 +--- a/build/lib/policies.ts ++++ b/build/lib/policies.ts +@@ -80,3 +80,3 @@ abstract class BasePolicy implements Policy { + return [ +- ``, ++ ``, + ` `, +@@ -553,3 +553,3 @@ function renderADMX(regKey: string, versions: string[], categories: Category[], + +- ++ + +diff --git a/package-lock.json b/package-lock.json +index 99a6c49..0997218 100644 +--- a/package-lock.json ++++ b/package-lock.json +@@ -18,3 +18,2 @@ + "@vscode/iconv-lite-umd": "0.7.0", +- "@vscode/policy-watcher": "^1.1.8", + "@vscode/proxy-agent": "^0.30.0", +@@ -29,2 +28,3 @@ + "@vscode/windows-registry": "^1.1.0", ++ "@vscodium/policy-watcher": "^1.1.8-2501211616", + "@xterm/addon-clipboard": "^0.2.0-beta.79", +@@ -2830,22 +2830,2 @@ + }, +- "node_modules/@vscode/policy-watcher": { +- "version": "1.1.8", +- "resolved": "https://registry.npmjs.org/@vscode/policy-watcher/-/policy-watcher-1.1.8.tgz", +- "integrity": "sha512-IFT3eIPLIcjjgyOUBvbxfKlqTjSDJU+ZJrTlrgdjZrwS3HRLexAMTCfmBqIgZ+vS5N9QWtQW0yp8vX8UJv8JFg==", +- "hasInstallScript": true, +- "license": "MIT", +- "dependencies": { +- "bindings": "^1.5.0", +- "node-addon-api": "^8.2.0" +- } +- }, +- "node_modules/@vscode/policy-watcher/node_modules/node-addon-api": { +- "version": "8.2.0", +- "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.2.0.tgz", +- "integrity": "sha512-qnyuI2ROiCkye42n9Tj5aX1ns7rzj6n7zW1XReSnLSL9v/vbLeR6fJq6PU27YU/ICfYw6W7Ouk/N7cysWu/hlw==", +- "license": "MIT", +- "engines": { +- "node": "^18 || ^20 || >= 21" +- } +- }, + "node_modules/@vscode/proxy-agent": { +@@ -3264,2 +3244,22 @@ + }, ++ "node_modules/@vscodium/policy-watcher": { ++ "version": "1.1.8-2501211616", ++ "resolved": "https://registry.npmjs.org/@vscodium/policy-watcher/-/policy-watcher-1.1.8-2501211616.tgz", ++ "integrity": "sha512-zrMcMkvh4D7Kicwz/Z/6Nm4FsCLrDIhjLZswzBMlZhTH1vP4XhEBYsic7j/RSgeCPCUxkBQx7c9io3yVovy2HA==", ++ "hasInstallScript": true, ++ "license": "MIT", ++ "dependencies": { ++ "bindings": "^1.5.0", ++ "node-addon-api": "^8.2.0" ++ } ++ }, ++ "node_modules/@vscodium/policy-watcher/node_modules/node-addon-api": { ++ "version": "8.3.0", ++ "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.3.0.tgz", ++ "integrity": "sha512-8VOpLHFrOQlAH+qA0ZzuGRlALRA6/LVh8QJldbrC4DY0hXoMP0l4Acq8TzFC018HztWiRqyCEj2aTWY2UvnJUg==", ++ "license": "MIT", ++ "engines": { ++ "node": "^18 || ^20 || >= 21" ++ } ++ }, + "node_modules/@webassemblyjs/ast": { +diff --git a/package.json b/package.json +index 2a79290..a924360 100644 +--- a/package.json ++++ b/package.json +@@ -76,3 +76,3 @@ + "@vscode/iconv-lite-umd": "0.7.0", +- "@vscode/policy-watcher": "^1.1.8", ++ "@vscodium/policy-watcher": "^1.1.8-2501211616", + "@vscode/proxy-agent": "^0.30.0", +diff --git a/src/vs/platform/policy/node/nativePolicyService.ts b/src/vs/platform/policy/node/nativePolicyService.ts +index 67f7892..5b8859c 100644 +--- a/src/vs/platform/policy/node/nativePolicyService.ts ++++ b/src/vs/platform/policy/node/nativePolicyService.ts +@@ -8,3 +8,3 @@ import { IStringDictionary } from '../../../base/common/collections.js'; + import { Throttler } from '../../../base/common/async.js'; +-import type { PolicyUpdate, Watcher } from '@vscode/policy-watcher'; ++import type { PolicyUpdate, Watcher } from '@vscodium/policy-watcher'; + import { MutableDisposable } from '../../../base/common/lifecycle.js'; +@@ -27,3 +27,3 @@ export class NativePolicyService extends AbstractPolicyService implements IPolic + +- const { createWatcher } = await import('@vscode/policy-watcher'); ++ const { createWatcher } = await import('@vscodium/policy-watcher'); + +@@ -31,3 +31,3 @@ export class NativePolicyService extends AbstractPolicyService implements IPolic + try { +- this.watcher.value = createWatcher(this.productName, policyDefinitions, update => { ++ this.watcher.value = createWatcher('VSCodium', this.productName, policyDefinitions, update => { + this._onDidPolicyChange(update);