瀏覽代碼

feat: add patch to use policies (#2209)

Baptiste Augrain 4 月之前
父節點
當前提交
b17a273e47
共有 3 個文件被更改,包括 141 次插入3 次删除
  1. 3 0
      build.sh
  2. 1 3
      dev/patch.sh
  3. 137 0
      patches/windows/policies.patch

+ 3 - 0
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

+ 1 - 3
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."

+ 137 - 0
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 [
+-            `<policy name="${this.name}" class="Both" displayName="$(string.${this.name})" explainText="$(string.${this.name}_${this.description.nlsKey.replace(/\./g, '_')})" key="Software\\Policies\\Microsoft\\${regKey}" presentation="$(presentation.${this.name})">`,
++            `<policy name="${this.name}" class="Both" displayName="$(string.${this.name})" explainText="$(string.${this.name}_${this.description.nlsKey.replace(/\./g, '_')})" key="Software\\Policies\\VSCodium\\${regKey}" presentation="$(presentation.${this.name})">`,
+             `	<parentCategory ref="${this.category.name.nlsKey}" />`,
+@@ -373,3 +373,3 @@ function renderADMX(regKey, versions, categories, policies) {
+ 	<policyNamespaces>
+-		<target prefix="${regKey}" namespace="Microsoft.Policies.${regKey}" />
++		<target prefix="${regKey}" namespace="VSCodium.Policies.${regKey}" />
+ 	</policyNamespaces>
+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 [
+-			`<policy name="${this.name}" class="Both" displayName="$(string.${this.name})" explainText="$(string.${this.name}_${this.description.nlsKey.replace(/\./g, '_')})" key="Software\\Policies\\Microsoft\\${regKey}" presentation="$(presentation.${this.name})">`,
++			`<policy name="${this.name}" class="Both" displayName="$(string.${this.name})" explainText="$(string.${this.name}_${this.description.nlsKey.replace(/\./g, '_')})" key="Software\\Policies\\VSCodium\\${regKey}" presentation="$(presentation.${this.name})">`,
+ 			`	<parentCategory ref="${this.category.name.nlsKey}" />`,
+@@ -553,3 +553,3 @@ function renderADMX(regKey: string, versions: string[], categories: Category[],
+ 	<policyNamespaces>
+-		<target prefix="${regKey}" namespace="Microsoft.Policies.${regKey}" />
++		<target prefix="${regKey}" namespace="VSCodium.Policies.${regKey}" />
+ 	</policyNamespaces>
+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);