From 0fe07c1f2ba42ebc3c567e787dfe9e1d1afdd24b Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 27 Apr 2022 21:43:46 +0200 Subject: [PATCH 01/32] wip: generate policies --- build/lib/policies.js | 72 ++++ build/lib/policies.ts | 79 +++++ build/package.json | 2 + build/yarn.lock | 332 +++++++++++++++++- .../common/configurationRegistry.ts | 7 + .../common/update.config.contribution.ts | 6 +- 6 files changed, 491 insertions(+), 7 deletions(-) create mode 100644 build/lib/policies.js create mode 100644 build/lib/policies.ts diff --git a/build/lib/policies.js b/build/lib/policies.js new file mode 100644 index 0000000000000..c385506a23701 --- /dev/null +++ b/build/lib/policies.js @@ -0,0 +1,72 @@ +"use strict"; +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +const child_process_1 = require("child_process"); +const fs_1 = require("fs"); +const byline = require("byline"); +const ripgrep_1 = require("@vscode/ripgrep"); +const Parser = require("tree-sitter"); +const { Query } = Parser; +const { typescript } = require('tree-sitter-typescript'); +async function getFiles(root) { + return new Promise((c, e) => { + const result = []; + const rg = (0, child_process_1.spawn)(ripgrep_1.rgPath, ['-l', 'registerConfiguration\\(', '-g', 'src/**/*.ts', '-g', '!src/**/test/**', root]); + const stream = byline(rg.stdout.setEncoding('utf8')); + stream.on('data', path => result.push(path)); + stream.on('error', err => e(err)); + stream.on('end', () => c(result)); + }); +} +async function main() { + const parser = new Parser(); + parser.setLanguage(typescript); + const query = new Query(typescript, ` + ( + (call_expression + function: (member_expression object: (identifier) property: (property_identifier) @registerConfiguration) + arguments: (arguments (object (pair + key: [(property_identifier)(string)] @properties + value: (object (pair + key: [(property_identifier)(string)] + value: (object (pair + key: [(property_identifier)(string)] @policy + value: (object + (pair key: [(property_identifier)(string)] @name value: (string) @policyName) + (pair key: [(property_identifier)(string)] @category value: (call_expression function: (identifier) @localize arguments: (arguments (string) @policyCategoryNlsKey (string) @policyCategoryEnglish))) + ) + )) + )) + ))) + ) + + (#eq? @registerConfiguration registerConfiguration) + (#eq? @properties properties) + (#eq? @policy policy) + (#eq? @name name) + (#eq? @category category) + (#eq? @localize localize) + ) + `); + const files = await getFiles(process.cwd()); + for (const file of files) { + const contents = await fs_1.promises.readFile(file, { encoding: 'utf8' }); + const tree = parser.parse(contents); + const matches = query.matches(tree.rootNode); + for (const match of matches) { + for (const capture of match.captures) { + console.log(capture.name, capture.node.text); + } + console.log('---'); + } + } +} +if (require.main === module) { + main().catch(err => { + console.error(err); + process.exit(1); + }); +} diff --git a/build/lib/policies.ts b/build/lib/policies.ts new file mode 100644 index 0000000000000..129384c89719e --- /dev/null +++ b/build/lib/policies.ts @@ -0,0 +1,79 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { spawn } from 'child_process'; +import { promises as fs } from 'fs'; +import * as byline from 'byline'; +import { rgPath } from '@vscode/ripgrep'; +import * as Parser from 'tree-sitter'; + +const { Query } = Parser; +const { typescript } = require('tree-sitter-typescript'); + +async function getFiles(root: string): Promise { + return new Promise((c, e) => { + const result: string[] = []; + const rg = spawn(rgPath, ['-l', 'registerConfiguration\\(', '-g', 'src/**/*.ts', '-g', '!src/**/test/**', root]); + const stream = byline(rg.stdout.setEncoding('utf8')); + stream.on('data', path => result.push(path)); + stream.on('error', err => e(err)); + stream.on('end', () => c(result)); + }); +} + +async function main() { + const parser = new Parser(); + parser.setLanguage(typescript); + + const query = new Query(typescript, ` + ( + (call_expression + function: (member_expression object: (identifier) property: (property_identifier) @registerConfiguration) + arguments: (arguments (object (pair + key: [(property_identifier)(string)] @properties + value: (object (pair + key: [(property_identifier)(string)] + value: (object (pair + key: [(property_identifier)(string)] @policy + value: (object + (pair key: [(property_identifier)(string)] @name value: (string) @policyName) + (pair key: [(property_identifier)(string)] @category value: (call_expression function: (identifier) @localize arguments: (arguments (string) @policyCategoryNlsKey (string) @policyCategoryEnglish))) + ) + )) + )) + ))) + ) + + (#eq? @registerConfiguration registerConfiguration) + (#eq? @properties properties) + (#eq? @policy policy) + (#eq? @name name) + (#eq? @category category) + (#eq? @localize localize) + ) + `); + + const files = await getFiles(process.cwd()); + + for (const file of files) { + const contents = await fs.readFile(file, { encoding: 'utf8' }); + const tree = parser.parse(contents); + const matches = query.matches(tree.rootNode); + + for (const match of matches) { + for (const capture of match.captures) { + console.log(capture.name, capture.node.text); + } + console.log('---'); + } + } +} + +if (require.main === module) { + main().catch(err => { + console.error(err); + process.exit(1); + }); +} diff --git a/build/package.json b/build/package.json index ab6b24d496d9f..91400ffe1408e 100644 --- a/build/package.json +++ b/build/package.json @@ -62,6 +62,8 @@ "source-map": "0.6.1", "through2": "^4.0.2", "tmp": "^0.2.1", + "tree-sitter": "^0.20.0", + "tree-sitter-typescript": "^0.20.1", "vsce": "^1.100.0", "vscode-universal-bundler": "^0.0.2" }, diff --git a/build/yarn.lock b/build/yarn.lock index db78aeacc16b1..837c32940885d 100644 --- a/build/yarn.lock +++ b/build/yarn.lock @@ -805,6 +805,16 @@ ansi-gray@^0.1.1: dependencies: ansi-wrap "0.1.0" +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" @@ -842,6 +852,19 @@ applicationinsights@1.4.2: diagnostic-channel "0.2.0" diagnostic-channel-publishers "^0.3.3" +aproba@^1.0.3: + version "1.2.0" + resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" + integrity sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw== + +are-we-there-yet@~1.1.2: + version "1.1.7" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.7.tgz#b15474a932adab4ff8a50d9adfa7e4e926f21146" + integrity sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g== + dependencies: + delegates "^1.0.0" + readable-stream "^2.0.6" + argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" @@ -926,11 +949,20 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== -base64-js@^1.5.1: +base64-js@^1.3.1, base64-js@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== +bl@^4.0.3: + version "4.1.0" + resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a" + integrity sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w== + dependencies: + buffer "^5.5.0" + inherits "^2.0.4" + readable-stream "^3.4.0" + bluebird@^3.5.0: version "3.7.2" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" @@ -994,6 +1026,14 @@ buffer-fill@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c" integrity sha1-+PeLdniYiO858gXNY39o5wISKyw= +buffer@^5.5.0: + version "5.7.1" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" + integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.1.13" + byline@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/byline/-/byline-5.0.0.tgz#741c5216468eadc457b03410118ad77de8c1ddb1" @@ -1079,6 +1119,11 @@ cheerio@^1.0.0-rc.9: parse5-htmlparser2-tree-adapter "^6.0.1" tslib "^2.2.0" +chownr@^1.1.1: + version "1.1.4" + resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" + integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== + chromium-pickle-js@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz#04a106672c18b085ab774d983dfa3ea138f22205" @@ -1124,6 +1169,11 @@ cls-hooked@^4.2.2: emitter-listener "^1.0.1" semver "^5.4.1" +code-point-at@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= + color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" @@ -1210,6 +1260,11 @@ config-chain@^1.1.11: ini "^1.3.4" proto-list "~1.2.1" +console-control-strings@^1.0.0, console-control-strings@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" + integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4= + continuation-local-storage@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/continuation-local-storage/-/continuation-local-storage-3.2.1.tgz#11f613f74e914fe9b34c92ad2d28fe6ae1db7ffb" @@ -1281,6 +1336,13 @@ decompress-response@^3.3.0: dependencies: mimic-response "^1.0.0" +decompress-response@^4.2.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-4.2.1.tgz#414023cc7a302da25ce2ec82d0d5238ccafd8986" + integrity sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw== + dependencies: + mimic-response "^2.0.0" + decompress-response@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-6.0.0.tgz#ca387612ddb7e104bd16d85aab00d5ecf09c66fc" @@ -1288,6 +1350,11 @@ decompress-response@^6.0.0: dependencies: mimic-response "^3.1.0" +deep-extend@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + defer-to-connect@^1.0.1: version "1.1.3" resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-1.1.3.tgz#331ae050c08dcf789f8c83a7b81f0ed94f4ac591" @@ -1315,11 +1382,21 @@ delayed-stream@~1.0.0: resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= +delegates@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" + integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o= + denodeify@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/denodeify/-/denodeify-1.2.1.tgz#3a36287f5034e699e7577901052c2e6c94251631" integrity sha1-OjYof1A05pnnV3kBBSwubJQlFjE= +detect-libc@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" + integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= + detect-node@^2.0.4: version "2.1.0" resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.1.0.tgz#c9c70775a49c3d03bc2c06d9a73be550f978f8b1" @@ -1415,12 +1492,17 @@ emitter-listener@^1.0.1, emitter-listener@^1.1.1: dependencies: shimmer "^1.2.0" +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + encodeurl@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= -end-of-stream@^1.1.0: +end-of-stream@^1.1.0, end-of-stream@^1.4.1: version "1.4.4" resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== @@ -1612,6 +1694,11 @@ events@^3.0.0: resolved "https://registry.yarnpkg.com/events/-/events-3.2.0.tgz#93b87c18f8efcd4202a461aec4dfc0556b639379" integrity sha512-/46HWwbfCX2xTawVfkKLGxMifJYQBWMwY1mjywRtb4c9x8l5NP3KoJtnIOiL1hfdRkIuYhETxQlo62IF8tcnlg== +expand-template@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/expand-template/-/expand-template-2.0.3.tgz#6e14b3fcee0f3a6340ecb57d2e8918692052a47c" + integrity sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg== + extend-shallow@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8" @@ -1701,6 +1788,11 @@ form-data@^4.0.0: combined-stream "^1.0.8" mime-types "^2.1.12" +fs-constants@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" + integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== + fs-extra@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" @@ -1730,6 +1822,20 @@ function-bind@^1.1.1: resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== +gauge@~2.7.3: + version "2.7.4" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" + integrity sha1-LANAXHU4w51+s3sxcCLjJfsBi/c= + dependencies: + aproba "^1.0.3" + console-control-strings "^1.0.0" + has-unicode "^2.0.0" + object-assign "^4.1.0" + signal-exit "^3.0.0" + string-width "^1.0.1" + strip-ansi "^3.0.1" + wide-align "^1.1.0" + get-intrinsic@^1.0.2: version "1.1.1" resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" @@ -1753,6 +1859,11 @@ get-stream@^5.1.0: dependencies: pump "^3.0.0" +github-from-package@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce" + integrity sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4= + glob-parent@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" @@ -1908,6 +2019,11 @@ has-symbols@^1.0.1: resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.2.tgz#165d3070c00309752a1236a479331e3ac56f1423" integrity sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw== +has-unicode@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" + integrity sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk= + has@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" @@ -1962,6 +2078,11 @@ https-proxy-agent@^5.0.0: agent-base "6" debug "4" +ieee754@^1.1.13: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + ignore@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" @@ -1980,7 +2101,7 @@ inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.3: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== -ini@^1.3.4: +ini@^1.3.4, ini@~1.3.0: version "1.3.8" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== @@ -2002,6 +2123,18 @@ is-extglob@^2.1.1: resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + integrity sha1-754xOG8DGn8NZDr4L95QxFfvAMs= + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + is-glob@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" @@ -2326,6 +2459,11 @@ mimic-response@^1.0.0, mimic-response@^1.0.1: resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== +mimic-response@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-2.1.0.tgz#d13763d35f613d09ec37ebb30bac0469c0ee8f43" + integrity sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA== + mimic-response@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9" @@ -2338,11 +2476,16 @@ minimatch@3.0.4, minimatch@^3.0.3, minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" -minimist@^1.2.0, minimist@^1.2.5: +minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.5: version "1.2.6" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== +mkdirp-classic@^0.5.2, mkdirp-classic@^0.5.3: + version "0.5.3" + resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113" + integrity sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A== + mkdirp@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" @@ -2368,6 +2511,23 @@ mute-stream@~0.0.4: resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" integrity sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s= +nan@^2.14.0: + version "2.15.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee" + integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ== + +napi-build-utils@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/napi-build-utils/-/napi-build-utils-1.0.2.tgz#b1fddc0b2c46e380a0b7a76f984dd47c41a13806" + integrity sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg== + +node-abi@^2.21.0: + version "2.30.1" + resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-2.30.1.tgz#c437d4b1fe0e285aaf290d45b45d4d7afedac4cf" + integrity sha512-/2D0wOQPgaUWzVSVgRMx+trKJRC2UG4SUc4oCJoXx9Uxjtp0Vy3/kt7zcbxHF8+Z/pK3UloLWzBISg72brfy1w== + dependencies: + semver "^5.4.1" + node-abort-controller@^1.2.0: version "1.2.1" resolved "https://registry.yarnpkg.com/node-abort-controller/-/node-abort-controller-1.2.1.tgz#1eddb57eb8fea734198b11b28857596dc6165708" @@ -2398,6 +2558,16 @@ npm-conf@^1.1.3: config-chain "^1.1.11" pify "^3.0.0" +npmlog@^4.0.1: + version "4.1.2" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" + integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== + dependencies: + are-we-there-yet "~1.1.2" + console-control-strings "~1.1.0" + gauge "~2.7.3" + set-blocking "~2.0.0" + nth-check@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-2.0.1.tgz#2efe162f5c3da06a28959fbd3db75dbeea9f0fc2" @@ -2405,6 +2575,16 @@ nth-check@^2.0.0: dependencies: boolbase "^1.0.0" +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= + +object-assign@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= + object-inspect@^1.9.0: version "1.11.0" resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.11.0.tgz#9dceb146cedd4148a0d9e51ab88d34cf509922b1" @@ -2552,6 +2732,25 @@ plugin-error@^1.0.1: source-map "^0.6.1" supports-color "^6.1.0" +prebuild-install@^6.0.1: + version "6.1.4" + resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-6.1.4.tgz#ae3c0142ad611d58570b89af4986088a4937e00f" + integrity sha512-Z4vpywnK1lBg+zdPCVCsKq0xO66eEV9rWo2zrROGGiRS4JtueBOdlB1FnY8lcy7JsUud/Q3ijUxyWN26Ika0vQ== + dependencies: + detect-libc "^1.0.3" + expand-template "^2.0.3" + github-from-package "0.0.0" + minimist "^1.2.3" + mkdirp-classic "^0.5.3" + napi-build-utils "^1.0.1" + node-abi "^2.21.0" + npmlog "^4.0.1" + pump "^3.0.0" + rc "^1.2.7" + simple-get "^3.0.3" + tar-fs "^2.0.0" + tunnel-agent "^0.6.0" + prepend-http@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" @@ -2617,6 +2816,16 @@ quick-lru@^5.1.1: resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== +rc@^1.2.7: + version "1.2.8" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" + integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== + dependencies: + deep-extend "^0.6.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + read@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/read/-/read-1.0.7.tgz#b3da19bd052431a97671d44a42634adf710b40c4" @@ -2624,7 +2833,7 @@ read@^1.0.7: dependencies: mute-stream "~0.0.4" -"readable-stream@2 || 3", readable-stream@3: +"readable-stream@2 || 3", readable-stream@3, readable-stream@^3.1.1, readable-stream@^3.4.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== @@ -2633,7 +2842,7 @@ read@^1.0.7: string_decoder "^1.1.1" util-deprecate "^1.0.1" -readable-stream@^2.3.5: +readable-stream@^2.0.6, readable-stream@^2.3.5: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -2767,6 +2976,11 @@ serialize-error@^7.0.1: dependencies: type-fest "^0.13.1" +set-blocking@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= + shebang-command@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" @@ -2793,6 +3007,25 @@ side-channel@^1.0.4: get-intrinsic "^1.0.2" object-inspect "^1.9.0" +signal-exit@^3.0.0: + version "3.0.7" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" + integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== + +simple-concat@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.1.tgz#f46976082ba35c2263f1c8ab5edfe26c41c9552f" + integrity sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q== + +simple-get@^3.0.3: + version "3.1.1" + resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-3.1.1.tgz#cc7ba77cfbe761036fbfce3d021af25fc5584d55" + integrity sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA== + dependencies: + decompress-response "^4.2.0" + once "^1.3.1" + simple-concat "^1.0.0" + slash@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" @@ -2828,6 +3061,24 @@ stoppable@^1.1.0: resolved "https://registry.yarnpkg.com/stoppable/-/stoppable-1.1.0.tgz#32da568e83ea488b08e4d7ea2c3bcc9d75015d5b" integrity sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw== +string-width@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + integrity sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M= + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +"string-width@^1.0.2 || 2 || 3 || 4": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + string_decoder@^1.1.1: version "1.3.0" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" @@ -2842,6 +3093,25 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" +strip-ansi@^3.0.0, strip-ansi@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8= + dependencies: + ansi-regex "^2.0.0" + +strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + sumchecker@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/sumchecker/-/sumchecker-3.0.1.tgz#6377e996795abb0b6d348e9b3e1dfb24345a8e42" @@ -2870,6 +3140,27 @@ supports-color@^7.1.0: dependencies: has-flag "^4.0.0" +tar-fs@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-2.1.1.tgz#489a15ab85f1f0befabb370b7de4f9eb5cbe8784" + integrity sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng== + dependencies: + chownr "^1.1.1" + mkdirp-classic "^0.5.2" + pump "^3.0.0" + tar-stream "^2.1.4" + +tar-stream@^2.1.4: + version "2.2.0" + resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-2.2.0.tgz#acad84c284136b060dc3faa64474aa9aebd77287" + integrity sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ== + dependencies: + bl "^4.0.3" + end-of-stream "^1.4.1" + fs-constants "^1.0.0" + inherits "^2.0.3" + readable-stream "^3.1.1" + through2@^3.0.1: version "3.0.2" resolved "https://registry.yarnpkg.com/through2/-/through2-3.0.2.tgz#99f88931cfc761ec7678b41d5d7336b5b6a07bf4" @@ -2928,6 +3219,21 @@ tr46@~0.0.3: resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= +tree-sitter-typescript@^0.20.1: + version "0.20.1" + resolved "https://registry.yarnpkg.com/tree-sitter-typescript/-/tree-sitter-typescript-0.20.1.tgz#6b338a1414f5ed13cc39e60275ddeaa0f25870a9" + integrity sha512-wqpnhdVYX26ATNXeZtprib4+mF2GlYQB1cjRPibYGxDRiugx5OfjWwLE4qPPxEGdp2ZLSmZVesGUjLWzfKo6rA== + dependencies: + nan "^2.14.0" + +tree-sitter@^0.20.0: + version "0.20.0" + resolved "https://registry.yarnpkg.com/tree-sitter/-/tree-sitter-0.20.0.tgz#b24f4d0ce6b9fdd9e99101907c954c5d938cb82d" + integrity sha512-tqTdtD1T2cN4aEES0sZCjKTQrc9Ls8H/iYlzpskhGy8yCwNPKBIbK9YuuCg/AxACr8RAY4wMoeCigM1X/A79yg== + dependencies: + nan "^2.14.0" + prebuild-install "^6.0.1" + tslib@^1.10.0: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" @@ -2955,6 +3261,13 @@ tsutils@^3.21.0: dependencies: tslib "^1.8.1" +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + integrity sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0= + dependencies: + safe-buffer "^5.0.1" + tunnel@0.0.6, tunnel@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c" @@ -3092,6 +3405,13 @@ which@^2.0.1: dependencies: isexe "^2.0.0" +wide-align@^1.1.0: + version "1.1.5" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.5.tgz#df1d4c206854369ecf3c9a4898f1b23fbd9d15d3" + integrity sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg== + dependencies: + string-width "^1.0.2 || 2 || 3 || 4" + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" diff --git a/src/vs/platform/configuration/common/configurationRegistry.ts b/src/vs/platform/configuration/common/configurationRegistry.ts index d6fecacc967cb..f45052cc9a939 100644 --- a/src/vs/platform/configuration/common/configurationRegistry.ts +++ b/src/vs/platform/configuration/common/configurationRegistry.ts @@ -127,6 +127,11 @@ export const enum ConfigurationScope { MACHINE_OVERRIDABLE, } +export interface PolicyConfiguration { + readonly name: string; + readonly category?: string; +} + export interface IConfigurationPropertySchema extends IJSONSchema { scope?: ConfigurationScope; @@ -175,6 +180,8 @@ export interface IConfigurationPropertySchema extends IJSONSchema { * within the settings editor. Otherwise, the setting is placed at the end. */ order?: number; + + policy?: PolicyConfiguration; } export interface IExtensionInfo { diff --git a/src/vs/platform/update/common/update.config.contribution.ts b/src/vs/platform/update/common/update.config.contribution.ts index 5ceb95727b510..1a10f0402e3a7 100644 --- a/src/vs/platform/update/common/update.config.contribution.ts +++ b/src/vs/platform/update/common/update.config.contribution.ts @@ -27,7 +27,11 @@ configurationRegistry.registerConfiguration({ localize('manual', "Disable automatic background update checks. Updates will be available if you manually check for updates."), localize('start', "Check for updates only on startup. Disable automatic background update checks."), localize('default', "Enable automatic update checks. Code will check for updates automatically and periodically.") - ] + ], + policy: { + name: 'UpdateMode', + category: localize('update', "Update") + } }, 'update.channel': { type: 'string', From 2f54cb9e3203693a8e5aebd2401f4b89d4ef9cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Thu, 28 Apr 2022 17:15:51 +0200 Subject: [PATCH 02/32] fix native modules in /build --- build/.gitignore | 1 + build/lib/watch/.gitignore | 1 - build/lib/watch/package.json | 12 -- build/lib/watch/yarn.lock | 400 ----------------------------------- build/npm/dirs.js | 1 - build/npm/postinstall.js | 13 +- build/package.json | 1 + build/yarn.lock | 138 +++++++++++- 8 files changed, 135 insertions(+), 432 deletions(-) create mode 100644 build/.gitignore delete mode 100644 build/lib/watch/.gitignore delete mode 100644 build/lib/watch/package.json delete mode 100644 build/lib/watch/yarn.lock diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 0000000000000..5a8136bb88412 --- /dev/null +++ b/build/.gitignore @@ -0,0 +1 @@ +.yarnrc diff --git a/build/lib/watch/.gitignore b/build/lib/watch/.gitignore deleted file mode 100644 index d777dcaa9d6e1..0000000000000 --- a/build/lib/watch/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.yarnrc \ No newline at end of file diff --git a/build/lib/watch/package.json b/build/lib/watch/package.json deleted file mode 100644 index e2e4f55202550..0000000000000 --- a/build/lib/watch/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "watch", - "version": "1.0.0", - "description": "", - "author": "Microsoft ", - "private": true, - "license": "MIT", - "devDependencies": {}, - "dependencies": { - "vscode-gulp-watch": "^5.0.3" - } -} diff --git a/build/lib/watch/yarn.lock b/build/lib/watch/yarn.lock deleted file mode 100644 index 258c0edadadd4..0000000000000 --- a/build/lib/watch/yarn.lock +++ /dev/null @@ -1,400 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -ansi-colors@4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" - integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== - -ansi-colors@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-1.1.0.tgz#6374b4dd5d4718ff3ce27a671a3b1cad077132a9" - integrity sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA== - dependencies: - ansi-wrap "^0.1.0" - -ansi-gray@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/ansi-gray/-/ansi-gray-0.1.1.tgz#2962cf54ec9792c48510a3deb524436861ef7251" - integrity sha1-KWLPVOyXksSFEKPetSRDaGHvclE= - dependencies: - ansi-wrap "0.1.0" - -ansi-wrap@0.1.0, ansi-wrap@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/ansi-wrap/-/ansi-wrap-0.1.0.tgz#a82250ddb0015e9a27ca82e82ea603bbfa45efaf" - integrity sha1-qCJQ3bABXponyoLoLqYDu/pF768= - -anymatch@^3.1.1, anymatch@~3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.1.tgz#c55ecf02185e2469259399310c173ce31233b142" - integrity sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg== - dependencies: - normalize-path "^3.0.0" - picomatch "^2.0.4" - -arr-diff@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" - integrity sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA= - -arr-union@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" - integrity sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ= - -assign-symbols@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" - integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c= - -binary-extensions@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.0.0.tgz#23c0df14f6a88077f5f986c0d167ec03c3d5537c" - integrity sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow== - -braces@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - -chokidar@3.5.1: - version "3.5.1" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.1.tgz#ee9ce7bbebd2b79f49f304799d5468e31e14e68a" - integrity sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw== - dependencies: - anymatch "~3.1.1" - braces "~3.0.2" - glob-parent "~5.1.0" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.5.0" - optionalDependencies: - fsevents "~2.3.1" - -clone-buffer@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/clone-buffer/-/clone-buffer-1.0.0.tgz#e3e25b207ac4e701af721e2cb5a16792cac3dc58" - integrity sha1-4+JbIHrE5wGvch4staFnksrD3Fg= - -clone-stats@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-1.0.0.tgz#b3782dff8bb5474e18b9b6bf0fdfe782f8777680" - integrity sha1-s3gt/4u1R04Yuba/D9/ngvh3doA= - -clone@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" - integrity sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18= - -cloneable-readable@^1.0.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/cloneable-readable/-/cloneable-readable-1.1.3.tgz#120a00cb053bfb63a222e709f9683ea2e11d8cec" - integrity sha512-2EF8zTQOxYq70Y4XKtorQupqF0m49MBz2/yf5Bj+MHjvpG3Hy7sImifnqD6UA+TKYxeSV+u6qqQPawN5UvnpKQ== - dependencies: - inherits "^2.0.1" - process-nextick-args "^2.0.0" - readable-stream "^2.3.5" - -color-support@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2" - integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg== - -core-util-is@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" - integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= - -extend-shallow@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8" - integrity sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg= - dependencies: - assign-symbols "^1.0.0" - is-extendable "^1.0.1" - -fancy-log@^1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/fancy-log/-/fancy-log-1.3.3.tgz#dbc19154f558690150a23953a0adbd035be45fc7" - integrity sha512-k9oEhlyc0FrVh25qYuSELjr8oxsCoc4/LEZfg2iJJrfEk/tZL9bCoJE47gqAvI2m/AUjluCS4+3I0eTx8n3AEw== - dependencies: - ansi-gray "^0.1.1" - color-support "^1.1.3" - parse-node-version "^1.0.0" - time-stamp "^1.0.0" - -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - -first-chunk-stream@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/first-chunk-stream/-/first-chunk-stream-2.0.0.tgz#1bdecdb8e083c0664b91945581577a43a9f31d70" - integrity sha1-G97NuOCDwGZLkZRVgVd6Q6nzHXA= - dependencies: - readable-stream "^2.0.2" - -fsevents@~2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.1.tgz#b209ab14c61012636c8863507edf7fb68cc54e9f" - integrity sha512-YR47Eg4hChJGAB1O3yEAOkGO+rlzutoICGqGo9EZ4lKWokzZRSyIW1QmTzqjtw8MJdj9srP869CuWw/hyzSiBw== - -glob-parent@^5.1.1, glob-parent@~5.1.0: - version "5.1.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== - dependencies: - is-glob "^4.0.1" - -graceful-fs@^4.1.2: - version "4.2.3" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423" - integrity sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ== - -inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.3: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -is-binary-path@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" - integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== - dependencies: - binary-extensions "^2.0.0" - -is-extendable@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" - integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA== - dependencies: - is-plain-object "^2.0.4" - -is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= - -is-glob@^4.0.1, is-glob@~4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" - integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== - dependencies: - is-extglob "^2.1.1" - -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -is-plain-object@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" - integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== - dependencies: - isobject "^3.0.1" - -is-utf8@^0.2.0, is-utf8@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" - integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= - -isarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= - -isobject@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" - integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= - -normalize-path@^3.0.0, normalize-path@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" - integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== - -object-assign@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= - -parse-node-version@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/parse-node-version/-/parse-node-version-1.0.1.tgz#e2b5dbede00e7fa9bc363607f53327e8b073189b" - integrity sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA== - -picomatch@^2.0.4, picomatch@^2.2.1: - version "2.2.2" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" - integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== - -pify@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" - integrity sha1-7RQaasBDqEnqWISY59yosVMw6Qw= - -plugin-error@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/plugin-error/-/plugin-error-1.0.1.tgz#77016bd8919d0ac377fdcdd0322328953ca5781c" - integrity sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA== - dependencies: - ansi-colors "^1.0.1" - arr-diff "^4.0.0" - arr-union "^3.1.0" - extend-shallow "^3.0.2" - -process-nextick-args@^2.0.0, process-nextick-args@~2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" - integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== - -readable-stream@^2.0.2, readable-stream@^2.3.5: - version "2.3.7" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" - integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.3" - isarray "~1.0.0" - process-nextick-args "~2.0.0" - safe-buffer "~5.1.1" - string_decoder "~1.1.1" - util-deprecate "~1.0.1" - -readable-stream@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - -readdirp@~3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.5.0.tgz#9ba74c019b15d365278d2e91bb8c48d7b4d42c9e" - integrity sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ== - dependencies: - picomatch "^2.2.1" - -remove-trailing-separator@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" - integrity sha1-wkvOKig62tW8P1jg1IJJuSN52O8= - -replace-ext@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-1.0.0.tgz#de63128373fcbf7c3ccfa4de5a480c45a67958eb" - integrity sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs= - -safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - -safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -string_decoder@^1.1.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -string_decoder@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" - integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== - dependencies: - safe-buffer "~5.1.0" - -strip-bom-buf@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-bom-buf/-/strip-bom-buf-1.0.0.tgz#1cb45aaf57530f4caf86c7f75179d2c9a51dd572" - integrity sha1-HLRar1dTD0yvhsf3UXnSyaUd1XI= - dependencies: - is-utf8 "^0.2.1" - -strip-bom-stream@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-bom-stream/-/strip-bom-stream-2.0.0.tgz#f87db5ef2613f6968aa545abfe1ec728b6a829ca" - integrity sha1-+H217yYT9paKpUWr/h7HKLaoKco= - dependencies: - first-chunk-stream "^2.0.0" - strip-bom "^2.0.0" - -strip-bom@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" - integrity sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4= - dependencies: - is-utf8 "^0.2.0" - -time-stamp@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/time-stamp/-/time-stamp-1.1.0.tgz#764a5a11af50561921b133f3b44e618687e0f5c3" - integrity sha1-dkpaEa9QVhkhsTPztE5hhofg9cM= - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -util-deprecate@^1.0.1, util-deprecate@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= - -vinyl-file@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/vinyl-file/-/vinyl-file-3.0.0.tgz#b104d9e4409ffa325faadd520642d0a3b488b365" - integrity sha1-sQTZ5ECf+jJfqt1SBkLQo7SIs2U= - dependencies: - graceful-fs "^4.1.2" - pify "^2.3.0" - strip-bom-buf "^1.0.0" - strip-bom-stream "^2.0.0" - vinyl "^2.0.1" - -vinyl@^2.0.1, vinyl@^2.2.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.2.1.tgz#23cfb8bbab5ece3803aa2c0a1eb28af7cbba1974" - integrity sha512-LII3bXRFBZLlezoG5FfZVcXflZgWP/4dCwKtxd5ky9+LOtM4CS3bIRQsmR1KMnMW07jpE8fqR2lcxPZ+8sJIcw== - dependencies: - clone "^2.1.1" - clone-buffer "^1.0.0" - clone-stats "^1.0.0" - cloneable-readable "^1.0.0" - remove-trailing-separator "^1.0.1" - replace-ext "^1.0.0" - -vscode-gulp-watch@^5.0.3: - version "5.0.3" - resolved "https://registry.yarnpkg.com/vscode-gulp-watch/-/vscode-gulp-watch-5.0.3.tgz#1ca1c03581d43692ecb1fe0b9afd4256faeb701b" - integrity sha512-MTUp2yLE9CshhkNSNV58EQNxQSeF8lIj3mkXZX9a1vAk+EQNM2PAYdPUDSd/P/08W3PMHGznEiZyfK7JAjLosg== - dependencies: - ansi-colors "4.1.1" - anymatch "^3.1.1" - chokidar "3.5.1" - fancy-log "^1.3.3" - glob-parent "^5.1.1" - normalize-path "^3.0.0" - object-assign "^4.1.1" - plugin-error "1.0.1" - readable-stream "^3.6.0" - vinyl "^2.2.0" - vinyl-file "^3.0.0" diff --git a/build/npm/dirs.js b/build/npm/dirs.js index 4011050e4667b..bbf75d07ac20f 100644 --- a/build/npm/dirs.js +++ b/build/npm/dirs.js @@ -7,7 +7,6 @@ exports.dirs = [ '', 'build', - 'build/lib/watch', 'extensions', 'extensions/configuration-editing', 'extensions/css-language-features', diff --git a/build/npm/postinstall.js b/build/npm/postinstall.js index 4fad92fd60b3d..2718ff9fad987 100644 --- a/build/npm/postinstall.js +++ b/build/npm/postinstall.js @@ -47,9 +47,9 @@ for (let dir of dirs) { continue; } - if (dir === 'build/lib/watch') { + if (dir === 'build') { // node modules for watching, specific to host node version, not electron - yarnInstallBuildDependencies(); + yarnInstallBuildDependencies(dir); continue; } @@ -73,11 +73,10 @@ for (let dir of dirs) { yarnInstall(dir, opts); } -function yarnInstallBuildDependencies() { - // make sure we install the deps of build/lib/watch for the system installed +function yarnInstallBuildDependencies(dir) { + // make sure we install the deps of build for the system installed // node, since that is the driver of gulp - const watchPath = path.join(path.dirname(__dirname), 'lib', 'watch'); - const yarnrcPath = path.join(watchPath, '.yarnrc'); + const yarnrcPath = path.join(dir, '.yarnrc'); const disturl = 'https://nodejs.org/download/release'; const target = process.versions.node; @@ -88,7 +87,7 @@ target "${target}" runtime "${runtime}"`; fs.writeFileSync(yarnrcPath, yarnrc, 'utf8'); - yarnInstall(watchPath); + yarnInstall(dir); } cp.execSync('git config pull.rebase merges'); diff --git a/build/package.json b/build/package.json index 91400ffe1408e..85aaafb182c50 100644 --- a/build/package.json +++ b/build/package.json @@ -65,6 +65,7 @@ "tree-sitter": "^0.20.0", "tree-sitter-typescript": "^0.20.1", "vsce": "^1.100.0", + "vscode-gulp-watch": "^5.0.3", "vscode-universal-bundler": "^0.0.2" }, "scripts": { diff --git a/build/yarn.lock b/build/yarn.lock index 837c32940885d..573d9474c2c42 100644 --- a/build/yarn.lock +++ b/build/yarn.lock @@ -791,6 +791,11 @@ agent-base@6: dependencies: debug "4" +ansi-colors@4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" + integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== + ansi-colors@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-1.1.0.tgz#6374b4dd5d4718ff3ce27a671a3b1cad077132a9" @@ -834,7 +839,7 @@ ansi-wrap@0.1.0, ansi-wrap@^0.1.0: resolved "https://registry.yarnpkg.com/ansi-wrap/-/ansi-wrap-0.1.0.tgz#a82250ddb0015e9a27ca82e82ea603bbfa45efaf" integrity sha1-qCJQ3bABXponyoLoLqYDu/pF768= -anymatch@^3.0.0: +anymatch@^3.0.0, anymatch@^3.1.1, anymatch@~3.1.1: version "3.1.2" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== @@ -954,6 +959,11 @@ base64-js@^1.3.1, base64-js@^1.5.1: resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== +binary-extensions@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" + integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== + bl@^4.0.3: version "4.1.0" resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a" @@ -986,7 +996,7 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" -braces@^3.0.1: +braces@^3.0.1, braces@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== @@ -1119,6 +1129,21 @@ cheerio@^1.0.0-rc.9: parse5-htmlparser2-tree-adapter "^6.0.1" tslib "^2.2.0" +chokidar@3.5.1: + version "3.5.1" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.1.tgz#ee9ce7bbebd2b79f49f304799d5468e31e14e68a" + integrity sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw== + dependencies: + anymatch "~3.1.1" + braces "~3.0.2" + glob-parent "~5.1.0" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.5.0" + optionalDependencies: + fsevents "~2.3.1" + chownr@^1.1.1: version "1.1.4" resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" @@ -1765,6 +1790,13 @@ fill-range@^7.0.1: dependencies: to-regex-range "^5.0.1" +first-chunk-stream@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/first-chunk-stream/-/first-chunk-stream-2.0.0.tgz#1bdecdb8e083c0664b91945581577a43a9f31d70" + integrity sha1-G97NuOCDwGZLkZRVgVd6Q6nzHXA= + dependencies: + readable-stream "^2.0.2" + follow-redirects@^1.14.0: version "1.14.8" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc" @@ -1817,6 +1849,11 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= +fsevents@~2.3.1: + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + function-bind@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" @@ -1864,7 +1901,7 @@ github-from-package@0.0.0: resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce" integrity sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4= -glob-parent@^5.1.2: +glob-parent@^5.1.1, glob-parent@^5.1.2, glob-parent@~5.1.0: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== @@ -1971,6 +2008,11 @@ got@^9.6.0: to-readable-stream "^1.0.0" url-parse-lax "^3.0.0" +graceful-fs@^4.1.2: + version "4.2.10" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" + integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== + graceful-fs@^4.1.6, graceful-fs@^4.2.0: version "4.2.8" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.8.tgz#e412b8d33f5e006593cbd3cee6df9f2cebbe802a" @@ -2106,6 +2148,13 @@ ini@^1.3.4, ini@~1.3.0: resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + is-docker@^2.0.0, is-docker@^2.1.1: version "2.2.1" resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" @@ -2142,7 +2191,7 @@ is-glob@^4.0.1: dependencies: is-extglob "^2.1.1" -is-glob@^4.0.3: +is-glob@^4.0.3, is-glob@~4.0.1: version "4.0.3" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== @@ -2161,6 +2210,11 @@ is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" +is-utf8@^0.2.0, is-utf8@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= + is-wsl@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" @@ -2540,7 +2594,7 @@ node-fetch@^2.6.0: dependencies: whatwg-url "^5.0.0" -normalize-path@^3.0.0: +normalize-path@^3.0.0, normalize-path@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== @@ -2580,7 +2634,7 @@ number-is-nan@^1.0.0: resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= -object-assign@^4.1.0: +object-assign@^4.1.0, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= @@ -2695,11 +2749,16 @@ picomatch@^2.0.4: resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.0.tgz#f1f061de8f6a4bf022892e2d128234fb98302972" integrity sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw== -picomatch@^2.2.3: +picomatch@^2.2.1, picomatch@^2.2.3: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== +pify@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" + integrity sha1-7RQaasBDqEnqWISY59yosVMw6Qw= + pify@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" @@ -2713,7 +2772,7 @@ plist@^3.0.1: base64-js "^1.5.1" xmlbuilder "^9.0.7" -plugin-error@^1.0.1: +plugin-error@1.0.1, plugin-error@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/plugin-error/-/plugin-error-1.0.1.tgz#77016bd8919d0ac377fdcdd0322328953ca5781c" integrity sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA== @@ -2833,7 +2892,7 @@ read@^1.0.7: dependencies: mute-stream "~0.0.4" -"readable-stream@2 || 3", readable-stream@3, readable-stream@^3.1.1, readable-stream@^3.4.0: +"readable-stream@2 || 3", readable-stream@3, readable-stream@^3.1.1, readable-stream@^3.4.0, readable-stream@^3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== @@ -2842,7 +2901,7 @@ read@^1.0.7: string_decoder "^1.1.1" util-deprecate "^1.0.1" -readable-stream@^2.0.6, readable-stream@^2.3.5: +readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.3.5: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -2855,6 +2914,13 @@ readable-stream@^2.0.6, readable-stream@^2.3.5: string_decoder "~1.1.1" util-deprecate "~1.0.1" +readdirp@~3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.5.0.tgz#9ba74c019b15d365278d2e91bb8c48d7b4d42c9e" + integrity sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ== + dependencies: + picomatch "^2.2.1" + remove-trailing-separator@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" @@ -3107,6 +3173,28 @@ strip-ansi@^6.0.1: dependencies: ansi-regex "^5.0.1" +strip-bom-buf@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-bom-buf/-/strip-bom-buf-1.0.0.tgz#1cb45aaf57530f4caf86c7f75179d2c9a51dd572" + integrity sha1-HLRar1dTD0yvhsf3UXnSyaUd1XI= + dependencies: + is-utf8 "^0.2.1" + +strip-bom-stream@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-bom-stream/-/strip-bom-stream-2.0.0.tgz#f87db5ef2613f6968aa545abfe1ec728b6a829ca" + integrity sha1-+H217yYT9paKpUWr/h7HKLaoKco= + dependencies: + first-chunk-stream "^2.0.0" + strip-bom "^2.0.0" + +strip-bom@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" + integrity sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4= + dependencies: + is-utf8 "^0.2.0" + strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" @@ -3334,7 +3422,18 @@ uuid@^8.3.0: resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.1.tgz#2ba2e6ca000da60fce5a196954ab241131e05a31" integrity sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg== -vinyl@^2.1.0: +vinyl-file@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/vinyl-file/-/vinyl-file-3.0.0.tgz#b104d9e4409ffa325faadd520642d0a3b488b365" + integrity sha1-sQTZ5ECf+jJfqt1SBkLQo7SIs2U= + dependencies: + graceful-fs "^4.1.2" + pify "^2.3.0" + strip-bom-buf "^1.0.0" + strip-bom-stream "^2.0.0" + vinyl "^2.0.1" + +vinyl@^2.0.1, vinyl@^2.1.0, vinyl@^2.2.0: version "2.2.1" resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.2.1.tgz#23cfb8bbab5ece3803aa2c0a1eb28af7cbba1974" integrity sha512-LII3bXRFBZLlezoG5FfZVcXflZgWP/4dCwKtxd5ky9+LOtM4CS3bIRQsmR1KMnMW07jpE8fqR2lcxPZ+8sJIcw== @@ -3374,6 +3473,23 @@ vsce@^1.100.0: yauzl "^2.3.1" yazl "^2.2.2" +vscode-gulp-watch@^5.0.3: + version "5.0.3" + resolved "https://registry.yarnpkg.com/vscode-gulp-watch/-/vscode-gulp-watch-5.0.3.tgz#1ca1c03581d43692ecb1fe0b9afd4256faeb701b" + integrity sha512-MTUp2yLE9CshhkNSNV58EQNxQSeF8lIj3mkXZX9a1vAk+EQNM2PAYdPUDSd/P/08W3PMHGznEiZyfK7JAjLosg== + dependencies: + ansi-colors "4.1.1" + anymatch "^3.1.1" + chokidar "3.5.1" + fancy-log "^1.3.3" + glob-parent "^5.1.1" + normalize-path "^3.0.0" + object-assign "^4.1.1" + plugin-error "1.0.1" + readable-stream "^3.6.0" + vinyl "^2.2.0" + vinyl-file "^3.0.0" + vscode-universal-bundler@^0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/vscode-universal-bundler/-/vscode-universal-bundler-0.0.2.tgz#2c988dac681d3ffe6baec6defac0995cb833c55a" From 5c1be8d56887d2679a6f257b7ee3b3479fecc0a2 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 29 Apr 2022 15:22:16 +0200 Subject: [PATCH 03/32] nice --- build/lib/policies.js | 59 +++++++++++++++++++++-------------- build/lib/policies.ts | 71 ++++++++++++++++++++++++++++--------------- build/package.json | 2 +- build/yarn.lock | 5 ++- 4 files changed, 86 insertions(+), 51 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index c385506a23701..0b652c37a65e5 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -9,7 +9,6 @@ const fs_1 = require("fs"); const byline = require("byline"); const ripgrep_1 = require("@vscode/ripgrep"); const Parser = require("tree-sitter"); -const { Query } = Parser; const { typescript } = require('tree-sitter-typescript'); async function getFiles(root) { return new Promise((c, e) => { @@ -21,46 +20,62 @@ async function getFiles(root) { stream.on('end', () => c(result)); }); } +async function* getPolicies(parser, query, path) { + const contents = await fs_1.promises.readFile(path, { encoding: 'utf8' }); + const tree = parser.parse(contents); + const matches = query.matches(tree.rootNode); + for (const match of matches) { + const name = match.captures.filter(c => c.name === 'name')[0]?.node.text; + const category = match.captures.filter(c => c.name === 'category')[0]?.node.text; + const categoryNlsKey = match.captures.filter(c => c.name === 'categoryNlsKey')[0]?.node.text; + if (category) { + if (categoryNlsKey) { + yield { name, category: { name: category, nlsKey: categoryNlsKey } }; + } + else { + yield { name, category: { name: category } }; + } + } + else { + yield { name }; + } + } +} async function main() { const parser = new Parser(); parser.setLanguage(typescript); - const query = new Query(typescript, ` + const query = new Parser.Query(typescript, ` ( (call_expression - function: (member_expression object: (identifier) property: (property_identifier) @registerConfiguration) + function: (member_expression object: (identifier) property: (property_identifier) @registerConfigurationFn) (#eq? @registerConfigurationFn registerConfiguration) arguments: (arguments (object (pair - key: [(property_identifier)(string)] @properties + key: [(property_identifier)(string)] @propertiesKey (#eq? @propertiesKey properties) value: (object (pair key: [(property_identifier)(string)] value: (object (pair - key: [(property_identifier)(string)] @policy + key: [(property_identifier)(string)] @policyKey (#eq? @policyKey policy) value: (object - (pair key: [(property_identifier)(string)] @name value: (string) @policyName) - (pair key: [(property_identifier)(string)] @category value: (call_expression function: (identifier) @localize arguments: (arguments (string) @policyCategoryNlsKey (string) @policyCategoryEnglish))) + (pair key: [(property_identifier)(string)] @nameKey value: (string (string_fragment) @name)) (#eq? @nameKey name) + (pair + key: [(property_identifier)(string)] @categoryKey + value: [ + (string (string_fragment) @category) + (call_expression function: (identifier) @localizeFn arguments: (arguments (string (string_fragment) @categoryNlsKey) (string (string_fragment) @category))) + ] + )? + (#eq? @categoryKey category) + (#eq? @localizeFn localize) ) )) )) ))) ) - - (#eq? @registerConfiguration registerConfiguration) - (#eq? @properties properties) - (#eq? @policy policy) - (#eq? @name name) - (#eq? @category category) - (#eq? @localize localize) ) `); const files = await getFiles(process.cwd()); for (const file of files) { - const contents = await fs_1.promises.readFile(file, { encoding: 'utf8' }); - const tree = parser.parse(contents); - const matches = query.matches(tree.rootNode); - for (const match of matches) { - for (const capture of match.captures) { - console.log(capture.name, capture.node.text); - } - console.log('---'); + for await (const policy of getPolicies(parser, query, file)) { + console.log(policy); } } } diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 129384c89719e..04c32f2eb24f3 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -8,8 +8,6 @@ import { promises as fs } from 'fs'; import * as byline from 'byline'; import { rgPath } from '@vscode/ripgrep'; import * as Parser from 'tree-sitter'; - -const { Query } = Parser; const { typescript } = require('tree-sitter-typescript'); async function getFiles(root: string): Promise { @@ -23,50 +21,73 @@ async function getFiles(root: string): Promise { }); } +interface Policy { + readonly name: string; + readonly category?: { + readonly name: string; + readonly nlsKey?: string; + }; +} + +async function* getPolicies(parser: Parser, query: Parser.Query, path: string): AsyncGenerator { + const contents = await fs.readFile(path, { encoding: 'utf8' }); + const tree = parser.parse(contents); + const matches = query.matches(tree.rootNode); + + for (const match of matches) { + const name = match.captures.filter(c => c.name === 'name')[0]?.node.text; + const category = match.captures.filter(c => c.name === 'category')[0]?.node.text; + const categoryNlsKey = match.captures.filter(c => c.name === 'categoryNlsKey')[0]?.node.text; + + if (category) { + if (categoryNlsKey) { + yield { name, category: { name: category, nlsKey: categoryNlsKey } }; + } else { + yield { name, category: { name: category } }; + } + } else { + yield { name }; + } + } +} + async function main() { const parser = new Parser(); parser.setLanguage(typescript); - - const query = new Query(typescript, ` + const query = new Parser.Query(typescript, ` ( (call_expression - function: (member_expression object: (identifier) property: (property_identifier) @registerConfiguration) + function: (member_expression object: (identifier) property: (property_identifier) @registerConfigurationFn) (#eq? @registerConfigurationFn registerConfiguration) arguments: (arguments (object (pair - key: [(property_identifier)(string)] @properties + key: [(property_identifier)(string)] @propertiesKey (#eq? @propertiesKey properties) value: (object (pair key: [(property_identifier)(string)] value: (object (pair - key: [(property_identifier)(string)] @policy + key: [(property_identifier)(string)] @policyKey (#eq? @policyKey policy) value: (object - (pair key: [(property_identifier)(string)] @name value: (string) @policyName) - (pair key: [(property_identifier)(string)] @category value: (call_expression function: (identifier) @localize arguments: (arguments (string) @policyCategoryNlsKey (string) @policyCategoryEnglish))) + (pair key: [(property_identifier)(string)] @nameKey value: (string (string_fragment) @name)) (#eq? @nameKey name) + (pair + key: [(property_identifier)(string)] @categoryKey + value: [ + (string (string_fragment) @category) + (call_expression function: (identifier) @localizeFn arguments: (arguments (string (string_fragment) @categoryNlsKey) (string (string_fragment) @category))) + ] + )? + (#eq? @categoryKey category) + (#eq? @localizeFn localize) ) )) )) ))) ) - - (#eq? @registerConfiguration registerConfiguration) - (#eq? @properties properties) - (#eq? @policy policy) - (#eq? @name name) - (#eq? @category category) - (#eq? @localize localize) ) `); const files = await getFiles(process.cwd()); for (const file of files) { - const contents = await fs.readFile(file, { encoding: 'utf8' }); - const tree = parser.parse(contents); - const matches = query.matches(tree.rootNode); - - for (const match of matches) { - for (const capture of match.captures) { - console.log(capture.name, capture.node.text); - } - console.log('---'); + for await (const policy of getPolicies(parser, query, file)) { + console.log(policy); } } } diff --git a/build/package.json b/build/package.json index 85aaafb182c50..78903df507722 100644 --- a/build/package.json +++ b/build/package.json @@ -62,7 +62,7 @@ "source-map": "0.6.1", "through2": "^4.0.2", "tmp": "^0.2.1", - "tree-sitter": "^0.20.0", + "tree-sitter": "https://github.com/joaomoreno/node-tree-sitter/releases/download/v0.20.0/tree-sitter-0.20.0.tgz", "tree-sitter-typescript": "^0.20.1", "vsce": "^1.100.0", "vscode-gulp-watch": "^5.0.3", diff --git a/build/yarn.lock b/build/yarn.lock index 573d9474c2c42..deec6e2dff53c 100644 --- a/build/yarn.lock +++ b/build/yarn.lock @@ -3314,10 +3314,9 @@ tree-sitter-typescript@^0.20.1: dependencies: nan "^2.14.0" -tree-sitter@^0.20.0: +"tree-sitter@https://github.com/joaomoreno/node-tree-sitter/releases/download/v0.20.0/tree-sitter-0.20.0.tgz": version "0.20.0" - resolved "https://registry.yarnpkg.com/tree-sitter/-/tree-sitter-0.20.0.tgz#b24f4d0ce6b9fdd9e99101907c954c5d938cb82d" - integrity sha512-tqTdtD1T2cN4aEES0sZCjKTQrc9Ls8H/iYlzpskhGy8yCwNPKBIbK9YuuCg/AxACr8RAY4wMoeCigM1X/A79yg== + resolved "https://github.com/joaomoreno/node-tree-sitter/releases/download/v0.20.0/tree-sitter-0.20.0.tgz#5679001aaa698c7cddc38ea23b49b9361b69215f" dependencies: nan "^2.14.0" prebuild-install "^6.0.1" From bf40655caadaa89c5d25d82fa039109119ac646c Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 29 Apr 2022 16:15:58 +0200 Subject: [PATCH 04/32] cleaner --- build/lib/policies.js | 124 +++++++++++++++++++++------------- build/lib/policies.ts | 151 ++++++++++++++++++++++++++++-------------- 2 files changed, 181 insertions(+), 94 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index 0b652c37a65e5..c35af5885dba0 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -6,44 +6,57 @@ Object.defineProperty(exports, "__esModule", { value: true }); const child_process_1 = require("child_process"); const fs_1 = require("fs"); +const path_1 = require("path"); const byline = require("byline"); const ripgrep_1 = require("@vscode/ripgrep"); const Parser = require("tree-sitter"); const { typescript } = require('tree-sitter-typescript'); -async function getFiles(root) { - return new Promise((c, e) => { - const result = []; - const rg = (0, child_process_1.spawn)(ripgrep_1.rgPath, ['-l', 'registerConfiguration\\(', '-g', 'src/**/*.ts', '-g', '!src/**/test/**', root]); - const stream = byline(rg.stdout.setEncoding('utf8')); - stream.on('data', path => result.push(path)); - stream.on('error', err => e(err)); - stream.on('end', () => c(result)); - }); +function getName(node) { + const query = new Parser.Query(typescript, `((pair key: [(property_identifier)(string)] @key value: (string (string_fragment) @name)) (#eq? @key name))`); + const matches = query.matches(node); + return matches[0]?.captures.filter(c => c.name === 'name')[0]?.node.text; } -async function* getPolicies(parser, query, path) { - const contents = await fs_1.promises.readFile(path, { encoding: 'utf8' }); - const tree = parser.parse(contents); - const matches = query.matches(tree.rootNode); - for (const match of matches) { - const name = match.captures.filter(c => c.name === 'name')[0]?.node.text; - const category = match.captures.filter(c => c.name === 'category')[0]?.node.text; - const categoryNlsKey = match.captures.filter(c => c.name === 'categoryNlsKey')[0]?.node.text; - if (category) { - if (categoryNlsKey) { - yield { name, category: { name: category, nlsKey: categoryNlsKey } }; - } - else { - yield { name, category: { name: category } }; - } - } - else { - yield { name }; - } +function getCategory(node) { + const query = new Parser.Query(typescript, ` + (pair + key: [(property_identifier)(string)] @categoryKey (#eq? @categoryKey category) + value: [ + (string (string_fragment) @name) + (call_expression function: (identifier) @localizeFn arguments: (arguments (string (string_fragment) @nlsKey) (string (string_fragment) @name))) + ] + ) + `); + const matches = query.matches(node); + const match = matches[0]; + if (!match) { + return undefined; + } + const name = match.captures.filter(c => c.name === 'name')[0]?.node.text; + if (!name) { + throw new Error(`Category missing required 'name' property.`); + } + const nlsKey = match.captures.filter(c => c.name === 'nlsKey')[0]?.node.text; + if (nlsKey) { + return { name, nlsKey }; + } + else { + return { name }; } } -async function main() { - const parser = new Parser(); - parser.setLanguage(typescript); +function getPolicy(node) { + const name = getName(node); + if (!name) { + throw new Error(`Missing required 'name' property.`); + } + const category = getCategory(node); + if (category) { + return { name, category }; + } + else { + return { name }; + } +} +function getPolicies(node) { const query = new Parser.Query(typescript, ` ( (call_expression @@ -54,29 +67,50 @@ async function main() { key: [(property_identifier)(string)] value: (object (pair key: [(property_identifier)(string)] @policyKey (#eq? @policyKey policy) - value: (object - (pair key: [(property_identifier)(string)] @nameKey value: (string (string_fragment) @name)) (#eq? @nameKey name) - (pair - key: [(property_identifier)(string)] @categoryKey - value: [ - (string (string_fragment) @category) - (call_expression function: (identifier) @localizeFn arguments: (arguments (string (string_fragment) @categoryNlsKey) (string (string_fragment) @category))) - ] - )? - (#eq? @categoryKey category) - (#eq? @localizeFn localize) - ) + value: (object) @result )) )) ))) ) ) `); + return query.matches(node) + .map(m => m.captures.filter(c => c.name === 'result')[0].node) + .map(getPolicy); +} +function nodeAsString(node) { + return `${node.startPosition.row + 1}:${node.startPosition.column + 1}`; +} +async function getFiles(root) { + return new Promise((c, e) => { + const result = []; + const rg = (0, child_process_1.spawn)(ripgrep_1.rgPath, ['-l', 'registerConfiguration\\(', '-g', 'src/**/*.ts', '-g', '!src/**/test/**', root]); + const stream = byline(rg.stdout.setEncoding('utf8')); + stream.on('data', path => result.push(path)); + stream.on('error', err => e(err)); + stream.on('end', () => c(result)); + }); +} +async function main() { + const parser = new Parser(); + parser.setLanguage(typescript); const files = await getFiles(process.cwd()); + let fail = false; for (const file of files) { - for await (const policy of getPolicies(parser, query, file)) { - console.log(policy); + const contents = await fs_1.promises.readFile(file, { encoding: 'utf8' }); + const tree = parser.parse(contents); + try { + for (const policy of getPolicies(tree.rootNode)) { + console.log(policy); + } } + catch (err) { + fail = true; + console.error(`[${(0, path_1.relative)(process.cwd(), file)}:${nodeAsString(node)}] ${err.message}`); + } + } + if (fail) { + throw new Error('Failed parsing policies'); } } if (require.main === module) { diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 04c32f2eb24f3..0e65e346071a4 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -5,55 +5,82 @@ import { spawn } from 'child_process'; import { promises as fs } from 'fs'; +import { relative } from 'path'; import * as byline from 'byline'; import { rgPath } from '@vscode/ripgrep'; import * as Parser from 'tree-sitter'; const { typescript } = require('tree-sitter-typescript'); -async function getFiles(root: string): Promise { - return new Promise((c, e) => { - const result: string[] = []; - const rg = spawn(rgPath, ['-l', 'registerConfiguration\\(', '-g', 'src/**/*.ts', '-g', '!src/**/test/**', root]); - const stream = byline(rg.stdout.setEncoding('utf8')); - stream.on('data', path => result.push(path)); - stream.on('error', err => e(err)); - stream.on('end', () => c(result)); - }); +interface Category { + readonly name: string; + readonly nlsKey?: string; } interface Policy { readonly name: string; - readonly category?: { - readonly name: string; - readonly nlsKey?: string; - }; + readonly category?: Category; } -async function* getPolicies(parser: Parser, query: Parser.Query, path: string): AsyncGenerator { - const contents = await fs.readFile(path, { encoding: 'utf8' }); - const tree = parser.parse(contents); - const matches = query.matches(tree.rootNode); - - for (const match of matches) { - const name = match.captures.filter(c => c.name === 'name')[0]?.node.text; - const category = match.captures.filter(c => c.name === 'category')[0]?.node.text; - const categoryNlsKey = match.captures.filter(c => c.name === 'categoryNlsKey')[0]?.node.text; - - if (category) { - if (categoryNlsKey) { - yield { name, category: { name: category, nlsKey: categoryNlsKey } }; - } else { - yield { name, category: { name: category } }; - } - } else { - yield { name }; - } +function getName(node: Parser.SyntaxNode): string | undefined { + const query = new Parser.Query( + typescript, + `((pair key: [(property_identifier)(string)] @key value: (string (string_fragment) @name)) (#eq? @key name))` + ); + + const matches = query.matches(node); + return matches[0]?.captures.filter(c => c.name === 'name')[0]?.node.text; +} + +function getCategory(node: Parser.SyntaxNode): Category | undefined { + const query = new Parser.Query(typescript, ` + (pair + key: [(property_identifier)(string)] @categoryKey (#eq? @categoryKey category) + value: [ + (string (string_fragment) @name) + (call_expression function: (identifier) @localizeFn arguments: (arguments (string (string_fragment) @nlsKey) (string (string_fragment) @name))) + ] + ) + `); + + const matches = query.matches(node); + const match = matches[0]; + + if (!match) { + return undefined; + } + + const name = match.captures.filter(c => c.name === 'name')[0]?.node.text; + + if (!name) { + throw new Error(`Category missing required 'name' property.`); + } + + const nlsKey = match.captures.filter(c => c.name === 'nlsKey')[0]?.node.text; + + if (nlsKey) { + return { name, nlsKey }; + } else { + return { name }; } } -async function main() { - const parser = new Parser(); - parser.setLanguage(typescript); +function getPolicy(node: Parser.SyntaxNode): Policy { + const name = getName(node); + + if (!name) { + throw new Error(`Missing required 'name' property.`); + } + + const category = getCategory(node); + + if (category) { + return { name, category }; + } else { + return { name }; + } +} + +function getPolicies(node: Parser.SyntaxNode): Policy[] { const query = new Parser.Query(typescript, ` ( (call_expression @@ -64,18 +91,7 @@ async function main() { key: [(property_identifier)(string)] value: (object (pair key: [(property_identifier)(string)] @policyKey (#eq? @policyKey policy) - value: (object - (pair key: [(property_identifier)(string)] @nameKey value: (string (string_fragment) @name)) (#eq? @nameKey name) - (pair - key: [(property_identifier)(string)] @categoryKey - value: [ - (string (string_fragment) @category) - (call_expression function: (identifier) @localizeFn arguments: (arguments (string (string_fragment) @categoryNlsKey) (string (string_fragment) @category))) - ] - )? - (#eq? @categoryKey category) - (#eq? @localizeFn localize) - ) + value: (object) @result )) )) ))) @@ -83,13 +99,50 @@ async function main() { ) `); + return query.matches(node) + .map(m => m.captures.filter(c => c.name === 'result')[0].node) + .map(getPolicy); +} + +function nodeAsString(node: Parser.SyntaxNode): string { + return `${node.startPosition.row + 1}:${node.startPosition.column + 1}`; +} + +async function getFiles(root: string): Promise { + return new Promise((c, e) => { + const result: string[] = []; + const rg = spawn(rgPath, ['-l', 'registerConfiguration\\(', '-g', 'src/**/*.ts', '-g', '!src/**/test/**', root]); + const stream = byline(rg.stdout.setEncoding('utf8')); + stream.on('data', path => result.push(path)); + stream.on('error', err => e(err)); + stream.on('end', () => c(result)); + }); +} + +async function main() { + const parser = new Parser(); + parser.setLanguage(typescript); + const files = await getFiles(process.cwd()); + let fail = false; for (const file of files) { - for await (const policy of getPolicies(parser, query, file)) { - console.log(policy); + const contents = await fs.readFile(file, { encoding: 'utf8' }); + const tree = parser.parse(contents); + + try { + for (const policy of getPolicies(tree.rootNode)) { + console.log(policy); + } + } catch (err) { + fail = true; + console.error(`[${relative(process.cwd(), file)}:${nodeAsString(node)}] ${err.message}`); } } + + if (fail) { + throw new Error('Failed parsing policies'); + } } if (require.main === module) { From 1b910db04a42e1b962276b89aac90be5907bc0f2 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 29 Apr 2022 21:04:46 +0200 Subject: [PATCH 05/32] extract description --- build/lib/policies.js | 82 +++++++++++++++------------------ build/lib/policies.ts | 105 +++++++++++++++++++++--------------------- 2 files changed, 90 insertions(+), 97 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index c35af5885dba0..9e9b0000bc1e2 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -6,54 +6,56 @@ Object.defineProperty(exports, "__esModule", { value: true }); const child_process_1 = require("child_process"); const fs_1 = require("fs"); -const path_1 = require("path"); const byline = require("byline"); const ripgrep_1 = require("@vscode/ripgrep"); const Parser = require("tree-sitter"); const { typescript } = require('tree-sitter-typescript'); -function getName(node) { - const query = new Parser.Query(typescript, `((pair key: [(property_identifier)(string)] @key value: (string (string_fragment) @name)) (#eq? @key name))`); - const matches = query.matches(node); - return matches[0]?.captures.filter(c => c.name === 'name')[0]?.node.text; -} -function getCategory(node) { - const query = new Parser.Query(typescript, ` - (pair - key: [(property_identifier)(string)] @categoryKey (#eq? @categoryKey category) - value: [ - (string (string_fragment) @name) - (call_expression function: (identifier) @localizeFn arguments: (arguments (string (string_fragment) @nlsKey) (string (string_fragment) @name))) - ] - ) - `); +function getStringProperty(node, key) { + const query = new Parser.Query(typescript, `( + (pair + key: [(property_identifier)(string)] @key + value: [ + (string (string_fragment) @value) + (call_expression function: (identifier) @localizeFn arguments: (arguments (string (string_fragment) @nlsKey) (string (string_fragment) @value)) (#eq? @localizeFn localize)) + ] + ) + (#eq? @key ${key}) + )`); const matches = query.matches(node); const match = matches[0]; if (!match) { return undefined; } - const name = match.captures.filter(c => c.name === 'name')[0]?.node.text; - if (!name) { - throw new Error(`Category missing required 'name' property.`); + const value = match.captures.filter(c => c.name === 'value')[0]?.node.text; + if (!value) { + throw new Error(`Missing required 'value' property.`); } const nlsKey = match.captures.filter(c => c.name === 'nlsKey')[0]?.node.text; if (nlsKey) { - return { name, nlsKey }; + return { value, nlsKey }; } else { - return { name }; + return value; } } -function getPolicy(node) { - const name = getName(node); +function getPolicy(settingNode, policyNode) { + const name = getStringProperty(policyNode, 'name'); if (!name) { throw new Error(`Missing required 'name' property.`); } - const category = getCategory(node); + if (typeof name !== 'string') { + throw new Error(`Property 'name' should be a literal string.`); + } + const description = getStringProperty(settingNode, 'description'); + if (!description) { + throw new Error(`Missing required 'description' property.`); + } + const category = getStringProperty(policyNode, 'category'); if (category) { - return { name, category }; + return { name, description, category }; } else { - return { name }; + return { name, description }; } } function getPolicies(node) { @@ -67,19 +69,19 @@ function getPolicies(node) { key: [(property_identifier)(string)] value: (object (pair key: [(property_identifier)(string)] @policyKey (#eq? @policyKey policy) - value: (object) @result + value: (object) @policy )) - )) + )) @setting ))) ) ) `); return query.matches(node) - .map(m => m.captures.filter(c => c.name === 'result')[0].node) - .map(getPolicy); -} -function nodeAsString(node) { - return `${node.startPosition.row + 1}:${node.startPosition.column + 1}`; + .map(m => { + const settingNode = m.captures.filter(c => c.name === 'setting')[0].node; + const policyNode = m.captures.filter(c => c.name === 'policy')[0].node; + return getPolicy(settingNode, policyNode); + }); } async function getFiles(root) { return new Promise((c, e) => { @@ -95,23 +97,13 @@ async function main() { const parser = new Parser(); parser.setLanguage(typescript); const files = await getFiles(process.cwd()); - let fail = false; for (const file of files) { const contents = await fs_1.promises.readFile(file, { encoding: 'utf8' }); const tree = parser.parse(contents); - try { - for (const policy of getPolicies(tree.rootNode)) { - console.log(policy); - } - } - catch (err) { - fail = true; - console.error(`[${(0, path_1.relative)(process.cwd(), file)}:${nodeAsString(node)}] ${err.message}`); + for (const policy of getPolicies(tree.rootNode)) { + console.log(policy); } } - if (fail) { - throw new Error('Failed parsing policies'); - } } if (require.main === module) { main().catch(err => { diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 0e65e346071a4..34a79d5cb3aa6 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -5,43 +5,44 @@ import { spawn } from 'child_process'; import { promises as fs } from 'fs'; -import { relative } from 'path'; import * as byline from 'byline'; import { rgPath } from '@vscode/ripgrep'; import * as Parser from 'tree-sitter'; const { typescript } = require('tree-sitter-typescript'); -interface Category { - readonly name: string; - readonly nlsKey?: string; +interface NlsString { + readonly value: string; + readonly nlsKey: string; } -interface Policy { +interface BasePolicy { readonly name: string; - readonly category?: Category; + readonly description: string | NlsString; + readonly category?: string | NlsString; } -function getName(node: Parser.SyntaxNode): string | undefined { +// interface StringEnumPolicy extends BasePolicy { +// readonly type: 'string'; +// readonly enum: string[]; +// } + +type Policy = BasePolicy; + +function getStringProperty(node: Parser.SyntaxNode, key: string): string | NlsString | undefined { const query = new Parser.Query( typescript, - `((pair key: [(property_identifier)(string)] @key value: (string (string_fragment) @name)) (#eq? @key name))` + `( + (pair + key: [(property_identifier)(string)] @key + value: [ + (string (string_fragment) @value) + (call_expression function: (identifier) @localizeFn arguments: (arguments (string (string_fragment) @nlsKey) (string (string_fragment) @value)) (#eq? @localizeFn localize)) + ] + ) + (#eq? @key ${key}) + )` ); - const matches = query.matches(node); - return matches[0]?.captures.filter(c => c.name === 'name')[0]?.node.text; -} - -function getCategory(node: Parser.SyntaxNode): Category | undefined { - const query = new Parser.Query(typescript, ` - (pair - key: [(property_identifier)(string)] @categoryKey (#eq? @categoryKey category) - value: [ - (string (string_fragment) @name) - (call_expression function: (identifier) @localizeFn arguments: (arguments (string (string_fragment) @nlsKey) (string (string_fragment) @name))) - ] - ) - `); - const matches = query.matches(node); const match = matches[0]; @@ -49,34 +50,44 @@ function getCategory(node: Parser.SyntaxNode): Category | undefined { return undefined; } - const name = match.captures.filter(c => c.name === 'name')[0]?.node.text; + const value = match.captures.filter(c => c.name === 'value')[0]?.node.text; - if (!name) { - throw new Error(`Category missing required 'name' property.`); + if (!value) { + throw new Error(`Missing required 'value' property.`); } const nlsKey = match.captures.filter(c => c.name === 'nlsKey')[0]?.node.text; if (nlsKey) { - return { name, nlsKey }; + return { value, nlsKey }; } else { - return { name }; + return value; } } -function getPolicy(node: Parser.SyntaxNode): Policy { - const name = getName(node); +function getPolicy(settingNode: Parser.SyntaxNode, policyNode: Parser.SyntaxNode): Policy { + const name = getStringProperty(policyNode, 'name'); if (!name) { throw new Error(`Missing required 'name' property.`); } - const category = getCategory(node); + if (typeof name !== 'string') { + throw new Error(`Property 'name' should be a literal string.`); + } + + const description = getStringProperty(settingNode, 'description'); + + if (!description) { + throw new Error(`Missing required 'description' property.`); + } + + const category = getStringProperty(policyNode, 'category'); if (category) { - return { name, category }; + return { name, description, category }; } else { - return { name }; + return { name, description }; } } @@ -91,21 +102,21 @@ function getPolicies(node: Parser.SyntaxNode): Policy[] { key: [(property_identifier)(string)] value: (object (pair key: [(property_identifier)(string)] @policyKey (#eq? @policyKey policy) - value: (object) @result + value: (object) @policy )) - )) + )) @setting ))) ) ) `); return query.matches(node) - .map(m => m.captures.filter(c => c.name === 'result')[0].node) - .map(getPolicy); -} + .map(m => { + const settingNode = m.captures.filter(c => c.name === 'setting')[0].node; + const policyNode = m.captures.filter(c => c.name === 'policy')[0].node; -function nodeAsString(node: Parser.SyntaxNode): string { - return `${node.startPosition.row + 1}:${node.startPosition.column + 1}`; + return getPolicy(settingNode, policyNode); + }); } async function getFiles(root: string): Promise { @@ -124,25 +135,15 @@ async function main() { parser.setLanguage(typescript); const files = await getFiles(process.cwd()); - let fail = false; for (const file of files) { const contents = await fs.readFile(file, { encoding: 'utf8' }); const tree = parser.parse(contents); - try { - for (const policy of getPolicies(tree.rootNode)) { - console.log(policy); - } - } catch (err) { - fail = true; - console.error(`[${relative(process.cwd(), file)}:${nodeAsString(node)}] ${err.message}`); + for (const policy of getPolicies(tree.rootNode)) { + console.log(policy); } } - - if (fail) { - throw new Error('Failed parsing policies'); - } } if (require.main === module) { From c017a6634e31b50d384bd59489c6b24627456e14 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 29 Apr 2022 21:32:03 +0200 Subject: [PATCH 06/32] refactor for reuse --- build/lib/policies.js | 83 +++++++++++++++++++++-------- build/lib/policies.ts | 121 +++++++++++++++++++++++++++++++----------- 2 files changed, 151 insertions(+), 53 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index 9e9b0000bc1e2..0034d4f6d1321 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -10,34 +10,54 @@ const byline = require("byline"); const ripgrep_1 = require("@vscode/ripgrep"); const Parser = require("tree-sitter"); const { typescript } = require('tree-sitter-typescript'); -function getStringProperty(node, key) { +const StringQ = { + Q: `[ + (string (string_fragment) @value) + (call_expression function: (identifier) @localizeFn arguments: (arguments (string (string_fragment) @nlsKey) (string (string_fragment) @value)) (#eq? @localizeFn localize)) + ]`, + value(matches) { + const match = matches[0]; + if (!match) { + return undefined; + } + const value = match.captures.filter(c => c.name === 'value')[0]?.node.text; + if (!value) { + throw new Error(`Missing required 'value' property.`); + } + const nlsKey = match.captures.filter(c => c.name === 'nlsKey')[0]?.node.text; + if (nlsKey) { + return { value, nlsKey }; + } + else { + return value; + } + } +}; +const StringArrayQ = { + Q: `(array ${StringQ.Q})`, + value(matches) { + return matches.map(match => { + return StringQ.value([match]); + }); + } +}; +function getProperty(qtype, node, key) { const query = new Parser.Query(typescript, `( (pair key: [(property_identifier)(string)] @key - value: [ - (string (string_fragment) @value) - (call_expression function: (identifier) @localizeFn arguments: (arguments (string (string_fragment) @nlsKey) (string (string_fragment) @value)) (#eq? @localizeFn localize)) - ] + value: ${qtype.Q} ) (#eq? @key ${key}) )`); - const matches = query.matches(node); - const match = matches[0]; - if (!match) { - return undefined; - } - const value = match.captures.filter(c => c.name === 'value')[0]?.node.text; - if (!value) { - throw new Error(`Missing required 'value' property.`); - } - const nlsKey = match.captures.filter(c => c.name === 'nlsKey')[0]?.node.text; - if (nlsKey) { - return { value, nlsKey }; - } - else { - return value; - } + return qtype.value(query.matches(node)); +} +function getStringProperty(node, key) { + return getProperty(StringQ, node, key); +} +function getStringArrayProperty(node, key) { + return getProperty(StringArrayQ, node, key); } +// --- function getPolicy(settingNode, policyNode) { const name = getStringProperty(policyNode, 'name'); if (!name) { @@ -50,12 +70,27 @@ function getPolicy(settingNode, policyNode) { if (!description) { throw new Error(`Missing required 'description' property.`); } + const type = getStringProperty(settingNode, 'type'); + if (!type) { + throw new Error(`Missing required 'type' property.`); + } + if (type !== 'string') { + throw new Error(`TODO`); + } + const _enum = getStringArrayProperty(settingNode, 'enum'); + if (!_enum) { + throw new Error(`TODO`); + } + const enumDescriptions = getStringArrayProperty(settingNode, 'enumDescriptions'); + if (!enumDescriptions) { + throw new Error(`TODO`); + } const category = getStringProperty(policyNode, 'category'); if (category) { - return { name, description, category }; + return { name, description, type, enum: _enum, enumDescriptions, category }; } else { - return { name, description }; + return { name, description, type, enum: _enum, enumDescriptions }; } } function getPolicies(node) { @@ -83,6 +118,7 @@ function getPolicies(node) { return getPolicy(settingNode, policyNode); }); } +// --- async function getFiles(root) { return new Promise((c, e) => { const result = []; @@ -93,6 +129,7 @@ async function getFiles(root) { stream.on('end', () => c(result)); }); } +// --- async function main() { const parser = new Parser(); parser.setLanguage(typescript); diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 34a79d5cb3aa6..3fa1ec2dffa8b 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -21,50 +21,85 @@ interface BasePolicy { readonly category?: string | NlsString; } -// interface StringEnumPolicy extends BasePolicy { -// readonly type: 'string'; -// readonly enum: string[]; -// } +interface StringEnumPolicy extends BasePolicy { + readonly type: 'string'; + readonly enum: (string | NlsString)[]; + readonly enumDescriptions: (string | NlsString)[]; +} -type Policy = BasePolicy; +type Policy = StringEnumPolicy; -function getStringProperty(node: Parser.SyntaxNode, key: string): string | NlsString | undefined { +// --- + +interface QType { + Q: string; + value(matches: Parser.QueryMatch[]): T | undefined; +} + +const StringQ: QType = { + Q: `[ + (string (string_fragment) @value) + (call_expression function: (identifier) @localizeFn arguments: (arguments (string (string_fragment) @nlsKey) (string (string_fragment) @value)) (#eq? @localizeFn localize)) + ]`, + + value(matches: Parser.QueryMatch[]): string | NlsString | undefined { + const match = matches[0]; + + if (!match) { + return undefined; + } + + const value = match.captures.filter(c => c.name === 'value')[0]?.node.text; + + if (!value) { + throw new Error(`Missing required 'value' property.`); + } + + const nlsKey = match.captures.filter(c => c.name === 'nlsKey')[0]?.node.text; + + if (nlsKey) { + return { value, nlsKey }; + } else { + return value; + } + } +}; + +const StringArrayQ: QType<(string | NlsString)[]> = { + Q: `(array ${StringQ.Q})`, + + value(matches: Parser.QueryMatch[]): (string | NlsString)[] | undefined { + return matches.map(match => { + return StringQ.value([match]) as string | NlsString; + }); + } +}; + +function getProperty(qtype: QType, node: Parser.SyntaxNode, key: string): T | undefined { const query = new Parser.Query( typescript, `( (pair key: [(property_identifier)(string)] @key - value: [ - (string (string_fragment) @value) - (call_expression function: (identifier) @localizeFn arguments: (arguments (string (string_fragment) @nlsKey) (string (string_fragment) @value)) (#eq? @localizeFn localize)) - ] + value: ${qtype.Q} ) (#eq? @key ${key}) )` ); - const matches = query.matches(node); - const match = matches[0]; - - if (!match) { - return undefined; - } - - const value = match.captures.filter(c => c.name === 'value')[0]?.node.text; - - if (!value) { - throw new Error(`Missing required 'value' property.`); - } + return qtype.value(query.matches(node)); +} - const nlsKey = match.captures.filter(c => c.name === 'nlsKey')[0]?.node.text; +function getStringProperty(node: Parser.SyntaxNode, key: string): string | NlsString | undefined { + return getProperty(StringQ, node, key); +} - if (nlsKey) { - return { value, nlsKey }; - } else { - return value; - } +function getStringArrayProperty(node: Parser.SyntaxNode, key: string): (string | NlsString)[] | undefined { + return getProperty(StringArrayQ, node, key); } +// --- + function getPolicy(settingNode: Parser.SyntaxNode, policyNode: Parser.SyntaxNode): Policy { const name = getStringProperty(policyNode, 'name'); @@ -82,12 +117,34 @@ function getPolicy(settingNode: Parser.SyntaxNode, policyNode: Parser.SyntaxNode throw new Error(`Missing required 'description' property.`); } + const type = getStringProperty(settingNode, 'type'); + + if (!type) { + throw new Error(`Missing required 'type' property.`); + } + + if (type !== 'string') { + throw new Error(`TODO`); + } + + const _enum = getStringArrayProperty(settingNode, 'enum'); + + if (!_enum) { + throw new Error(`TODO`); + } + + const enumDescriptions = getStringArrayProperty(settingNode, 'enumDescriptions'); + + if (!enumDescriptions) { + throw new Error(`TODO`); + } + const category = getStringProperty(policyNode, 'category'); if (category) { - return { name, description, category }; + return { name, description, type, enum: _enum, enumDescriptions, category }; } else { - return { name, description }; + return { name, description, type, enum: _enum, enumDescriptions }; } } @@ -119,6 +176,8 @@ function getPolicies(node: Parser.SyntaxNode): Policy[] { }); } +// --- + async function getFiles(root: string): Promise { return new Promise((c, e) => { const result: string[] = []; @@ -130,6 +189,8 @@ async function getFiles(root: string): Promise { }); } +// --- + async function main() { const parser = new Parser(); parser.setLanguage(typescript); From 33965672b6a99935b6c033458fe9822c6e6ba823 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 29 Apr 2022 21:34:22 +0200 Subject: [PATCH 07/32] :lipstick: --- build/lib/policies.js | 3 +-- build/lib/policies.ts | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index 0034d4f6d1321..2178ada617c42 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -111,8 +111,7 @@ function getPolicies(node) { ) ) `); - return query.matches(node) - .map(m => { + return query.matches(node).map(m => { const settingNode = m.captures.filter(c => c.name === 'setting')[0].node; const policyNode = m.captures.filter(c => c.name === 'policy')[0].node; return getPolicy(settingNode, policyNode); diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 3fa1ec2dffa8b..2bc059635168b 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -167,13 +167,11 @@ function getPolicies(node: Parser.SyntaxNode): Policy[] { ) `); - return query.matches(node) - .map(m => { - const settingNode = m.captures.filter(c => c.name === 'setting')[0].node; - const policyNode = m.captures.filter(c => c.name === 'policy')[0].node; - - return getPolicy(settingNode, policyNode); - }); + return query.matches(node).map(m => { + const settingNode = m.captures.filter(c => c.name === 'setting')[0].node; + const policyNode = m.captures.filter(c => c.name === 'policy')[0].node; + return getPolicy(settingNode, policyNode); + }); } // --- From 24c637cde12da61d641fec03b5264cd025ef5565 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 3 May 2022 08:52:18 +0200 Subject: [PATCH 08/32] wip: render ADML --- build/lib/policies.js | 142 ++++++++++++++- build/lib/policies.ts | 168 +++++++++++++++++- .../common/configurationRegistry.ts | 1 + .../common/update.config.contribution.ts | 1 + 4 files changed, 299 insertions(+), 13 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index 2178ada617c42..bdad673614669 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -6,10 +6,21 @@ Object.defineProperty(exports, "__esModule", { value: true }); const child_process_1 = require("child_process"); const fs_1 = require("fs"); +const os_1 = require("os"); const byline = require("byline"); const ripgrep_1 = require("@vscode/ripgrep"); const Parser = require("tree-sitter"); const { typescript } = require('tree-sitter-typescript'); +function isNlsString(value) { + return value ? typeof value !== 'string' : false; +} +function isStringArray(value) { + return !value.some(s => isNlsString(s)); +} +var PolicyType; +(function (PolicyType) { + PolicyType[PolicyType["StringEnum"] = 0] = "StringEnum"; +})(PolicyType || (PolicyType = {})); const StringQ = { Q: `[ (string (string_fragment) @value) @@ -63,9 +74,16 @@ function getPolicy(settingNode, policyNode) { if (!name) { throw new Error(`Missing required 'name' property.`); } - if (typeof name !== 'string') { + if (isNlsString(name)) { throw new Error(`Property 'name' should be a literal string.`); } + const minimumVersion = getStringProperty(policyNode, 'minimumVersion'); + if (!minimumVersion) { + throw new Error(`Missing required 'minimumVersion' property.`); + } + if (isNlsString(minimumVersion)) { + throw new Error(`Property 'minimumVersion' should be a literal string.`); + } const description = getStringProperty(settingNode, 'description'); if (!description) { throw new Error(`Missing required 'description' property.`); @@ -81,16 +99,19 @@ function getPolicy(settingNode, policyNode) { if (!_enum) { throw new Error(`TODO`); } + if (!isStringArray(_enum)) { + throw new Error(`TODO`); + } const enumDescriptions = getStringArrayProperty(settingNode, 'enumDescriptions'); if (!enumDescriptions) { throw new Error(`TODO`); } const category = getStringProperty(policyNode, 'category'); if (category) { - return { name, description, type, enum: _enum, enumDescriptions, category }; + return { policyType: PolicyType.StringEnum, name, minimumVersion, description, type, enum: _enum, enumDescriptions, category }; } else { - return { name, description, type, enum: _enum, enumDescriptions }; + return { policyType: PolicyType.StringEnum, name, minimumVersion, description, type, enum: _enum, enumDescriptions }; } } function getPolicies(node) { @@ -129,17 +150,126 @@ async function getFiles(root) { }); } // --- +// const admxTemplate = ` +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// none +// +// +// +// +// manual +// +// +// +// +// start +// +// +// +// +// default +// +// +// +// +// +// +// +// `; +function renderADMLString(policy, nlsString) { + return `${nlsString.value}`; +} +function pushADMLString(arr, policy, value) { + if (isNlsString(value)) { + arr.push(renderADMLString(policy, value)); + } +} +function pushADMLStrings(arr, policy, values) { + for (const value of values) { + pushADMLString(arr, policy, value); + } +} +function renderADMLStrings(policy) { + const result = []; + pushADMLString(result, policy, policy.category); + pushADMLString(result, policy, policy.description); + switch (policy.policyType) { + case PolicyType.StringEnum: + pushADMLStrings(result, policy, policy.enumDescriptions); + break; + default: + throw new Error(`Unexpected policy type: ${policy.type}`); + } + return result; +} +function renderADMLPresentation(policy) { + switch (policy.policyType) { + case PolicyType.StringEnum: + return ``; + default: + throw new Error(`Unexpected policy type: ${policy.type}`); + } +} +async function renderADML(policies) { + const versions = [...new Set(policies.map(p => p.minimumVersion)).values()].sort(); + const app = JSON.parse(await fs_1.promises.readFile('product.json', 'utf-8')).nameLong; + return ` + + + + + + ${app} + ${versions.map(v => `${app} ${v} or later`)} + ${policies.map(p => renderADMLStrings(p)).flat().join(`${os_1.EOL} `)} + + + ${policies.map(p => renderADMLPresentation(p)).join(`${os_1.EOL} `)} + + + +`; +} +// function renderGP(policies: Policy[]): { admx: string; adml: string } { +// } +// --- async function main() { const parser = new Parser(); parser.setLanguage(typescript); const files = await getFiles(process.cwd()); + const policies = []; for (const file of files) { const contents = await fs_1.promises.readFile(file, { encoding: 'utf8' }); const tree = parser.parse(contents); - for (const policy of getPolicies(tree.rootNode)) { - console.log(policy); - } + // for (const policy of getPolicies(tree.rootNode)) { + // console.log(policy); + // } + policies.push(...getPolicies(tree.rootNode)); } + console.log(await renderADML(policies)); } if (require.main === module) { main().catch(err => { diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 2bc059635168b..1bb249c546ac7 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -5,6 +5,7 @@ import { spawn } from 'child_process'; import { promises as fs } from 'fs'; +import { EOL } from 'os'; import * as byline from 'byline'; import { rgPath } from '@vscode/ripgrep'; import * as Parser from 'tree-sitter'; @@ -15,15 +16,30 @@ interface NlsString { readonly nlsKey: string; } +function isNlsString(value: string | NlsString | undefined): value is NlsString { + return value ? typeof value !== 'string' : false; +} + +function isStringArray(value: (string | NlsString)[]): value is string[] { + return !value.some(s => isNlsString(s)); +} + +enum PolicyType { + StringEnum +} + interface BasePolicy { + readonly policyType: PolicyType; readonly name: string; + readonly minimumVersion: string; readonly description: string | NlsString; readonly category?: string | NlsString; } interface StringEnumPolicy extends BasePolicy { + readonly policyType: PolicyType.StringEnum; readonly type: 'string'; - readonly enum: (string | NlsString)[]; + readonly enum: string[]; readonly enumDescriptions: (string | NlsString)[]; } @@ -107,10 +123,20 @@ function getPolicy(settingNode: Parser.SyntaxNode, policyNode: Parser.SyntaxNode throw new Error(`Missing required 'name' property.`); } - if (typeof name !== 'string') { + if (isNlsString(name)) { throw new Error(`Property 'name' should be a literal string.`); } + const minimumVersion = getStringProperty(policyNode, 'minimumVersion'); + + if (!minimumVersion) { + throw new Error(`Missing required 'minimumVersion' property.`); + } + + if (isNlsString(minimumVersion)) { + throw new Error(`Property 'minimumVersion' should be a literal string.`); + } + const description = getStringProperty(settingNode, 'description'); if (!description) { @@ -133,6 +159,10 @@ function getPolicy(settingNode: Parser.SyntaxNode, policyNode: Parser.SyntaxNode throw new Error(`TODO`); } + if (!isStringArray(_enum)) { + throw new Error(`TODO`); + } + const enumDescriptions = getStringArrayProperty(settingNode, 'enumDescriptions'); if (!enumDescriptions) { @@ -142,9 +172,9 @@ function getPolicy(settingNode: Parser.SyntaxNode, policyNode: Parser.SyntaxNode const category = getStringProperty(policyNode, 'category'); if (category) { - return { name, description, type, enum: _enum, enumDescriptions, category }; + return { policyType: PolicyType.StringEnum, name, minimumVersion, description, type, enum: _enum, enumDescriptions, category }; } else { - return { name, description, type, enum: _enum, enumDescriptions }; + return { policyType: PolicyType.StringEnum, name, minimumVersion, description, type, enum: _enum, enumDescriptions }; } } @@ -189,20 +219,144 @@ async function getFiles(root: string): Promise { // --- +// const admxTemplate = ` +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// none +// +// +// +// +// manual +// +// +// +// +// start +// +// +// +// +// default +// +// +// +// +// +// +// +// `; + +function renderADMLString(policy: Policy, nlsString: NlsString): string { + return `${nlsString.value}`; +} + +function pushADMLString(arr: string[], policy: Policy, value: string | NlsString | undefined): void { + if (isNlsString(value)) { + arr.push(renderADMLString(policy, value)); + } +} + +function pushADMLStrings(arr: string[], policy: Policy, values: (string | NlsString)[]): void { + for (const value of values) { + pushADMLString(arr, policy, value); + } +} + +function renderADMLStrings(policy: Policy): string[] { + const result: string[] = []; + + pushADMLString(result, policy, policy.category); + pushADMLString(result, policy, policy.description); + + switch (policy.policyType) { + case PolicyType.StringEnum: + pushADMLStrings(result, policy, policy.enumDescriptions); + break; + default: + throw new Error(`Unexpected policy type: ${policy.type}`); + } + + return result; +} + +function renderADMLPresentation(policy: Policy): string { + switch (policy.policyType) { + case PolicyType.StringEnum: + return ``; + default: + throw new Error(`Unexpected policy type: ${policy.type}`); + } +} + +async function renderADML(policies: Policy[]) { + const versions = [...new Set(policies.map(p => p.minimumVersion)).values()].sort(); + const app = JSON.parse(await fs.readFile('product.json', 'utf-8')).nameLong; + + return ` + + + + + + ${app} + ${versions.map(v => `${app} ${v} or later`)} + ${policies.map(p => renderADMLStrings(p)).flat().join(`${EOL} `)} + + + ${policies.map(p => renderADMLPresentation(p)).join(`${EOL} `)} + + + +`; +} + +// function renderGP(policies: Policy[]): { admx: string; adml: string } { + +// } + +// --- + async function main() { const parser = new Parser(); parser.setLanguage(typescript); const files = await getFiles(process.cwd()); + const policies = []; for (const file of files) { const contents = await fs.readFile(file, { encoding: 'utf8' }); const tree = parser.parse(contents); - for (const policy of getPolicies(tree.rootNode)) { - console.log(policy); - } + // for (const policy of getPolicies(tree.rootNode)) { + // console.log(policy); + // } + policies.push(...getPolicies(tree.rootNode)); } + + console.log(await renderADML(policies)); } if (require.main === module) { diff --git a/src/vs/platform/configuration/common/configurationRegistry.ts b/src/vs/platform/configuration/common/configurationRegistry.ts index f45052cc9a939..969b4262b0a5a 100644 --- a/src/vs/platform/configuration/common/configurationRegistry.ts +++ b/src/vs/platform/configuration/common/configurationRegistry.ts @@ -129,6 +129,7 @@ export const enum ConfigurationScope { export interface PolicyConfiguration { readonly name: string; + readonly minimumVersion: `1.${number}`; readonly category?: string; } diff --git a/src/vs/platform/update/common/update.config.contribution.ts b/src/vs/platform/update/common/update.config.contribution.ts index 1a10f0402e3a7..ff5dec1cc42c5 100644 --- a/src/vs/platform/update/common/update.config.contribution.ts +++ b/src/vs/platform/update/common/update.config.contribution.ts @@ -30,6 +30,7 @@ configurationRegistry.registerConfiguration({ ], policy: { name: 'UpdateMode', + minimumVersion: '1.67', category: localize('update', "Update") } }, From 1d62fb288a64cd4c9253202dee777a428c73fe6e Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 3 May 2022 11:51:34 +0200 Subject: [PATCH 09/32] end to end render of policies --- build/lib/policies.js | 161 ++++++++------- build/lib/policies.ts | 187 ++++++++++-------- .../common/configurationRegistry.ts | 2 +- 3 files changed, 197 insertions(+), 153 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index bdad673614669..703d757da9245 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const child_process_1 = require("child_process"); const fs_1 = require("fs"); -const os_1 = require("os"); +const path = require("path"); const byline = require("byline"); const ripgrep_1 = require("@vscode/ripgrep"); const Parser = require("tree-sitter"); @@ -17,6 +17,9 @@ function isNlsString(value) { function isStringArray(value) { return !value.some(s => isNlsString(s)); } +function isNlsStringArray(value) { + return value.every(s => isNlsString(s)); +} var PolicyType; (function (PolicyType) { PolicyType[PolicyType["StringEnum"] = 0] = "StringEnum"; @@ -69,7 +72,7 @@ function getStringArrayProperty(node, key) { return getProperty(StringArrayQ, node, key); } // --- -function getPolicy(settingNode, policyNode) { +function getPolicy(settingNode, policyNode, categories) { const name = getStringProperty(policyNode, 'name'); if (!name) { throw new Error(`Missing required 'name' property.`); @@ -88,6 +91,9 @@ function getPolicy(settingNode, policyNode) { if (!description) { throw new Error(`Missing required 'description' property.`); } + if (!isNlsString(description)) { + throw new Error(`Property 'description' should be localized.`); + } const type = getStringProperty(settingNode, 'type'); if (!type) { throw new Error(`Missing required 'type' property.`); @@ -106,13 +112,23 @@ function getPolicy(settingNode, policyNode) { if (!enumDescriptions) { throw new Error(`TODO`); } - const category = getStringProperty(policyNode, 'category'); - if (category) { - return { policyType: PolicyType.StringEnum, name, minimumVersion, description, type, enum: _enum, enumDescriptions, category }; + if (!isNlsStringArray(enumDescriptions)) { + throw new Error(`Property 'enumDescriptions' should be localized.`); + } + const categoryName = getStringProperty(policyNode, 'category'); + if (!categoryName) { + throw new Error(`Missing required 'category' property.`); + } + else if (!isNlsString(categoryName)) { + throw new Error(`Property 'category' should be localized.`); } - else { - return { policyType: PolicyType.StringEnum, name, minimumVersion, description, type, enum: _enum, enumDescriptions }; + const categoryKey = `${categoryName.nlsKey}:${categoryName.value}`; + let category = categories.get(categoryKey); + if (!category) { + category = { name: categoryName }; + categories.set(categoryKey, category); } + return { policyType: PolicyType.StringEnum, name, minimumVersion, description, type, enum: _enum, enumDescriptions, category }; } function getPolicies(node) { const query = new Parser.Query(typescript, ` @@ -132,10 +148,11 @@ function getPolicies(node) { ) ) `); + const categories = new Map(); return query.matches(node).map(m => { const settingNode = m.captures.filter(c => c.name === 'setting')[0].node; const policyNode = m.captures.filter(c => c.name === 'policy')[0].node; - return getPolicy(settingNode, policyNode); + return getPolicy(settingNode, policyNode, categories); }); } // --- @@ -150,55 +167,45 @@ async function getFiles(root) { }); } // --- -// const admxTemplate = ` -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// none -// -// -// -// -// manual -// -// -// -// -// start -// -// -// -// -// default -// -// -// -// -// -// -// -// `; +function renderADMXPolicy(regKey, policy) { + switch (policy.policyType) { + case PolicyType.StringEnum: + return ` + + + + + ${policy.enum.map((value, index) => `${value}`).join(`\n `)} + + + `; + default: + throw new Error(`Unexpected policy type: ${policy.type}`); + } +} +function renderADMX(regKey, versions, categories, policies) { + versions = versions.map(v => v.replace('.', '_')); + return ` + + + + + + + + ${versions.map(v => ``).join(`\n `)} + + + + + ${categories.map(c => ``).join(`\n `)} + + + ${policies.map(p => renderADMXPolicy(regKey, p)).join(`\n `)} + + +`; +} function renderADMLString(policy, nlsString) { return `${nlsString.value}`; } @@ -214,7 +221,6 @@ function pushADMLStrings(arr, policy, values) { } function renderADMLStrings(policy) { const result = []; - pushADMLString(result, policy, policy.category); pushADMLString(result, policy, policy.description); switch (policy.policyType) { case PolicyType.StringEnum: @@ -233,28 +239,36 @@ function renderADMLPresentation(policy) { throw new Error(`Unexpected policy type: ${policy.type}`); } } -async function renderADML(policies) { - const versions = [...new Set(policies.map(p => p.minimumVersion)).values()].sort(); - const app = JSON.parse(await fs_1.promises.readFile('product.json', 'utf-8')).nameLong; +function renderADML(appName, versions, categories, policies) { return ` - ${app} - ${versions.map(v => `${app} ${v} or later`)} - ${policies.map(p => renderADMLStrings(p)).flat().join(`${os_1.EOL} `)} - - - ${policies.map(p => renderADMLPresentation(p)).join(`${os_1.EOL} `)} + ${appName} + ${versions.map(v => `${appName} ${v} or later`)} + ${categories.map(c => `${c.name.value}`)} + ${policies.map(p => renderADMLStrings(p)).flat().join(`\n `)} + + + ${policies.map(p => renderADMLPresentation(p)).join(`\n `)} `; } -// function renderGP(policies: Policy[]): { admx: string; adml: string } { -// } +async function renderGP(policies) { + const product = JSON.parse(await fs_1.promises.readFile('product.json', 'utf-8')); + const appName = product.nameLong; + const regKey = product.win32RegValueName; + const versions = [...new Set(policies.map(p => p.minimumVersion)).values()].sort(); + const categories = [...new Set(policies.map(p => p.category))]; + return { + admx: renderADMX(regKey, versions, categories, policies), + adml: renderADML(appName, versions, categories, policies), + }; +} // --- async function main() { const parser = new Parser(); @@ -264,12 +278,13 @@ async function main() { for (const file of files) { const contents = await fs_1.promises.readFile(file, { encoding: 'utf8' }); const tree = parser.parse(contents); - // for (const policy of getPolicies(tree.rootNode)) { - // console.log(policy); - // } policies.push(...getPolicies(tree.rootNode)); } - console.log(await renderADML(policies)); + const { admx, adml } = await renderGP(policies); + const root = '.build/policies/win32'; + await fs_1.promises.mkdir(root, { recursive: true }); + await fs_1.promises.writeFile(path.join(root, 'Code.admx'), admx.replace(/\r?\n/g, '\n')); + await fs_1.promises.writeFile(path.join(root, 'Code.adml'), adml.replace(/\r?\n/g, '\n')); } if (require.main === module) { main().catch(err => { diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 1bb249c546ac7..493159deaca1b 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -5,7 +5,7 @@ import { spawn } from 'child_process'; import { promises as fs } from 'fs'; -import { EOL } from 'os'; +import * as path from 'path'; import * as byline from 'byline'; import { rgPath } from '@vscode/ripgrep'; import * as Parser from 'tree-sitter'; @@ -24,23 +24,31 @@ function isStringArray(value: (string | NlsString)[]): value is string[] { return !value.some(s => isNlsString(s)); } +function isNlsStringArray(value: (string | NlsString)[]): value is NlsString[] { + return value.every(s => isNlsString(s)); +} + +interface Category { + readonly name: NlsString; +} + enum PolicyType { StringEnum } interface BasePolicy { - readonly policyType: PolicyType; readonly name: string; + readonly policyType: PolicyType; + readonly category: Category; readonly minimumVersion: string; - readonly description: string | NlsString; - readonly category?: string | NlsString; + readonly description: NlsString; } interface StringEnumPolicy extends BasePolicy { readonly policyType: PolicyType.StringEnum; readonly type: 'string'; readonly enum: string[]; - readonly enumDescriptions: (string | NlsString)[]; + readonly enumDescriptions: NlsString[]; } type Policy = StringEnumPolicy; @@ -116,7 +124,7 @@ function getStringArrayProperty(node: Parser.SyntaxNode, key: string): (string | // --- -function getPolicy(settingNode: Parser.SyntaxNode, policyNode: Parser.SyntaxNode): Policy { +function getPolicy(settingNode: Parser.SyntaxNode, policyNode: Parser.SyntaxNode, categories: Map): Policy { const name = getStringProperty(policyNode, 'name'); if (!name) { @@ -143,6 +151,10 @@ function getPolicy(settingNode: Parser.SyntaxNode, policyNode: Parser.SyntaxNode throw new Error(`Missing required 'description' property.`); } + if (!isNlsString(description)) { + throw new Error(`Property 'description' should be localized.`); + } + const type = getStringProperty(settingNode, 'type'); if (!type) { @@ -169,13 +181,27 @@ function getPolicy(settingNode: Parser.SyntaxNode, policyNode: Parser.SyntaxNode throw new Error(`TODO`); } - const category = getStringProperty(policyNode, 'category'); + if (!isNlsStringArray(enumDescriptions)) { + throw new Error(`Property 'enumDescriptions' should be localized.`); + } - if (category) { - return { policyType: PolicyType.StringEnum, name, minimumVersion, description, type, enum: _enum, enumDescriptions, category }; - } else { - return { policyType: PolicyType.StringEnum, name, minimumVersion, description, type, enum: _enum, enumDescriptions }; + const categoryName = getStringProperty(policyNode, 'category'); + + if (!categoryName) { + throw new Error(`Missing required 'category' property.`); + } else if (!isNlsString(categoryName)) { + throw new Error(`Property 'category' should be localized.`); + } + + const categoryKey = `${categoryName.nlsKey}:${categoryName.value}`; + let category = categories.get(categoryKey); + + if (!category) { + category = { name: categoryName }; + categories.set(categoryKey, category); } + + return { policyType: PolicyType.StringEnum, name, minimumVersion, description, type, enum: _enum, enumDescriptions, category }; } function getPolicies(node: Parser.SyntaxNode): Policy[] { @@ -197,10 +223,12 @@ function getPolicies(node: Parser.SyntaxNode): Policy[] { ) `); + const categories = new Map(); + return query.matches(node).map(m => { const settingNode = m.captures.filter(c => c.name === 'setting')[0].node; const policyNode = m.captures.filter(c => c.name === 'policy')[0].node; - return getPolicy(settingNode, policyNode); + return getPolicy(settingNode, policyNode, categories); }); } @@ -219,55 +247,47 @@ async function getFiles(root: string): Promise { // --- -// const admxTemplate = ` -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// none -// -// -// -// -// manual -// -// -// -// -// start -// -// -// -// -// default -// -// -// -// -// -// -// -// `; +function renderADMXPolicy(regKey: string, policy: Policy) { + switch (policy.policyType) { + case PolicyType.StringEnum: + return ` + + + + + ${policy.enum.map((value, index) => `${value}`).join(`\n `)} + + + `; + default: + throw new Error(`Unexpected policy type: ${policy.type}`); + } +} + +function renderADMX(regKey: string, versions: string[], categories: Category[], policies: Policy[]) { + versions = versions.map(v => v.replace('.', '_')); + + return ` + + + + + + + + ${versions.map(v => ``).join(`\n `)} + + + + + ${categories.map(c => ``).join(`\n `)} + + + ${policies.map(p => renderADMXPolicy(regKey, p)).join(`\n `)} + + +`; +} function renderADMLString(policy: Policy, nlsString: NlsString): string { return `${nlsString.value}`; @@ -288,7 +308,6 @@ function pushADMLStrings(arr: string[], policy: Policy, values: (string | NlsStr function renderADMLStrings(policy: Policy): string[] { const result: string[] = []; - pushADMLString(result, policy, policy.category); pushADMLString(result, policy, policy.description); switch (policy.policyType) { @@ -311,31 +330,39 @@ function renderADMLPresentation(policy: Policy): string { } } -async function renderADML(policies: Policy[]) { - const versions = [...new Set(policies.map(p => p.minimumVersion)).values()].sort(); - const app = JSON.parse(await fs.readFile('product.json', 'utf-8')).nameLong; - +function renderADML(appName: string, versions: string[], categories: Category[], policies: Policy[]) { return ` - ${app} - ${versions.map(v => `${app} ${v} or later`)} - ${policies.map(p => renderADMLStrings(p)).flat().join(`${EOL} `)} - - - ${policies.map(p => renderADMLPresentation(p)).join(`${EOL} `)} + ${appName} + ${versions.map(v => `${appName} ${v} or later`)} + ${categories.map(c => `${c.name.value}`)} + ${policies.map(p => renderADMLStrings(p)).flat().join(`\n `)} + + + ${policies.map(p => renderADMLPresentation(p)).join(`\n `)} `; } -// function renderGP(policies: Policy[]): { admx: string; adml: string } { +async function renderGP(policies: Policy[]) { + const product = JSON.parse(await fs.readFile('product.json', 'utf-8')); + const appName = product.nameLong; + const regKey = product.win32RegValueName; + + const versions = [...new Set(policies.map(p => p.minimumVersion)).values()].sort(); + const categories = [...new Set(policies.map(p => p.category))]; -// } + return { + admx: renderADMX(regKey, versions, categories, policies), + adml: renderADML(appName, versions, categories, policies), + }; +} // --- @@ -349,14 +376,16 @@ async function main() { for (const file of files) { const contents = await fs.readFile(file, { encoding: 'utf8' }); const tree = parser.parse(contents); - - // for (const policy of getPolicies(tree.rootNode)) { - // console.log(policy); - // } policies.push(...getPolicies(tree.rootNode)); } - console.log(await renderADML(policies)); + const { admx, adml } = await renderGP(policies); + + const root = '.build/policies/win32'; + await fs.mkdir(root, { recursive: true }); + + await fs.writeFile(path.join(root, 'Code.admx'), admx.replace(/\r?\n/g, '\n')); + await fs.writeFile(path.join(root, 'Code.adml'), adml.replace(/\r?\n/g, '\n')); } if (require.main === module) { diff --git a/src/vs/platform/configuration/common/configurationRegistry.ts b/src/vs/platform/configuration/common/configurationRegistry.ts index 969b4262b0a5a..a1940fa22a7cd 100644 --- a/src/vs/platform/configuration/common/configurationRegistry.ts +++ b/src/vs/platform/configuration/common/configurationRegistry.ts @@ -130,7 +130,7 @@ export const enum ConfigurationScope { export interface PolicyConfiguration { readonly name: string; readonly minimumVersion: `1.${number}`; - readonly category?: string; + readonly category: string; } export interface IConfigurationPropertySchema extends IJSONSchema { From 2541c9569d40c8a1990971d682c262a12df8ee77 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 3 May 2022 14:27:58 +0200 Subject: [PATCH 10/32] working policy xml --- build/lib/policies.js | 4 +++- build/lib/policies.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index 703d757da9245..c386e185b9545 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -220,7 +220,9 @@ function pushADMLStrings(arr, policy, values) { } } function renderADMLStrings(policy) { - const result = []; + const result = [ + `${policy.name}` + ]; pushADMLString(result, policy, policy.description); switch (policy.policyType) { case PolicyType.StringEnum: diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 493159deaca1b..adcd03dd2060e 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -306,7 +306,9 @@ function pushADMLStrings(arr: string[], policy: Policy, values: (string | NlsStr } function renderADMLStrings(policy: Policy): string[] { - const result: string[] = []; + const result: string[] = [ + `${policy.name}` + ]; pushADMLString(result, policy, policy.description); From 0b0b0dee382fda4baad54361872969cc9f5bf8cb Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 3 May 2022 14:34:12 +0200 Subject: [PATCH 11/32] nls --- build/lib/policies.js | 5 ++++- build/lib/policies.ts | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index c386e185b9545..3ffd5d9db5aa3 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -284,9 +284,12 @@ async function main() { } const { admx, adml } = await renderGP(policies); const root = '.build/policies/win32'; + await fs_1.promises.rm(root, { recursive: true, force: true }); await fs_1.promises.mkdir(root, { recursive: true }); await fs_1.promises.writeFile(path.join(root, 'Code.admx'), admx.replace(/\r?\n/g, '\n')); - await fs_1.promises.writeFile(path.join(root, 'Code.adml'), adml.replace(/\r?\n/g, '\n')); + const enUS = path.join(root, 'en-US'); + await fs_1.promises.mkdir(enUS, { recursive: true }); + await fs_1.promises.writeFile(path.join(enUS, 'Code.adml'), adml.replace(/\r?\n/g, '\n')); } if (require.main === module) { main().catch(err => { diff --git a/build/lib/policies.ts b/build/lib/policies.ts index adcd03dd2060e..32b3654ed1b2c 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -384,10 +384,14 @@ async function main() { const { admx, adml } = await renderGP(policies); const root = '.build/policies/win32'; + await fs.rm(root, { recursive: true, force: true }); await fs.mkdir(root, { recursive: true }); await fs.writeFile(path.join(root, 'Code.admx'), admx.replace(/\r?\n/g, '\n')); - await fs.writeFile(path.join(root, 'Code.adml'), adml.replace(/\r?\n/g, '\n')); + + const enUS = path.join(root, 'en-US'); + await fs.mkdir(enUS, { recursive: true }); + await fs.writeFile(path.join(enUS, 'Code.adml'), adml.replace(/\r?\n/g, '\n')); } if (require.main === module) { From 060c757f3db465a147c3075b8477219f3d9d2174 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 3 May 2022 15:32:57 +0200 Subject: [PATCH 12/32] localized policies --- build/lib/policies.js | 101 ++++++++++++++++++++++++---------- build/lib/policies.ts | 123 +++++++++++++++++++++++++++++++----------- build/package.json | 1 + build/yarn.lock | 2 +- en-us/Code.adml | 21 ++++++++ 5 files changed, 189 insertions(+), 59 deletions(-) create mode 100644 en-us/Code.adml diff --git a/build/lib/policies.js b/build/lib/policies.js index 3ffd5d9db5aa3..f1217769cc2b2 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -10,6 +10,7 @@ const path = require("path"); const byline = require("byline"); const ripgrep_1 = require("@vscode/ripgrep"); const Parser = require("tree-sitter"); +const node_fetch_1 = require("node-fetch"); const { typescript } = require('tree-sitter-typescript'); function isNlsString(value) { return value ? typeof value !== 'string' : false; @@ -72,7 +73,7 @@ function getStringArrayProperty(node, key) { return getProperty(StringArrayQ, node, key); } // --- -function getPolicy(settingNode, policyNode, categories) { +function getPolicy(moduleName, settingNode, policyNode, categories) { const name = getStringProperty(policyNode, 'name'); if (!name) { throw new Error(`Missing required 'name' property.`); @@ -128,9 +129,9 @@ function getPolicy(settingNode, policyNode, categories) { category = { name: categoryName }; categories.set(categoryKey, category); } - return { policyType: PolicyType.StringEnum, name, minimumVersion, description, type, enum: _enum, enumDescriptions, category }; + return { policyType: PolicyType.StringEnum, name, minimumVersion, description, type, moduleName, enum: _enum, enumDescriptions, category }; } -function getPolicies(node) { +function getPolicies(moduleName, node) { const query = new Parser.Query(typescript, ` ( (call_expression @@ -152,7 +153,7 @@ function getPolicies(node) { return query.matches(node).map(m => { const settingNode = m.captures.filter(c => c.name === 'setting')[0].node; const policyNode = m.captures.filter(c => c.name === 'policy')[0].node; - return getPolicy(settingNode, policyNode, categories); + return getPolicy(moduleName, settingNode, policyNode, categories); }); } // --- @@ -172,7 +173,7 @@ function renderADMXPolicy(regKey, policy) { case PolicyType.StringEnum: return ` - + ${policy.enum.map((value, index) => `${value}`).join(`\n `)} @@ -184,7 +185,7 @@ function renderADMXPolicy(regKey, policy) { } } function renderADMX(regKey, versions, categories, policies) { - versions = versions.map(v => v.replace('.', '_')); + versions = versions.map(v => v.replace(/\./g, '_')); return ` @@ -206,34 +207,44 @@ function renderADMX(regKey, versions, categories, policies) { `; } -function renderADMLString(policy, nlsString) { - return `${nlsString.value}`; +function renderADMLString(policy, nlsString, translations) { + let value; + if (translations) { + const moduleTranslations = translations[policy.moduleName]; + if (moduleTranslations) { + value = moduleTranslations[nlsString.nlsKey]; + } + } + if (!value) { + value = nlsString.value; + } + return `${value}`; } -function pushADMLString(arr, policy, value) { +function pushADMLString(arr, policy, value, translations) { if (isNlsString(value)) { - arr.push(renderADMLString(policy, value)); + arr.push(renderADMLString(policy, value, translations)); } } -function pushADMLStrings(arr, policy, values) { +function pushADMLStrings(arr, policy, values, translations) { for (const value of values) { - pushADMLString(arr, policy, value); + pushADMLString(arr, policy, value, translations); } } -function renderADMLStrings(policy) { +function renderADMLStrings(policy, translations) { const result = [ `${policy.name}` ]; - pushADMLString(result, policy, policy.description); + pushADMLString(result, policy, policy.description, translations); switch (policy.policyType) { case PolicyType.StringEnum: - pushADMLStrings(result, policy, policy.enumDescriptions); + pushADMLStrings(result, policy, policy.enumDescriptions, translations); break; default: throw new Error(`Unexpected policy type: ${policy.type}`); } return result; } -function renderADMLPresentation(policy) { +function renderADMLPresentation(policy, _translations) { switch (policy.policyType) { case PolicyType.StringEnum: return ``; @@ -241,7 +252,7 @@ function renderADMLPresentation(policy) { throw new Error(`Unexpected policy type: ${policy.type}`); } } -function renderADML(appName, versions, categories, policies) { +function renderADML(appName, versions, categories, policies, translations) { return ` @@ -249,18 +260,18 @@ function renderADML(appName, versions, categories, policies) { ${appName} - ${versions.map(v => `${appName} ${v} or later`)} + ${versions.map(v => `${appName} ${v} or later`)} ${categories.map(c => `${c.name.value}`)} - ${policies.map(p => renderADMLStrings(p)).flat().join(`\n `)} + ${policies.map(p => renderADMLStrings(p, translations)).flat().join(`\n `)} - ${policies.map(p => renderADMLPresentation(p)).join(`\n `)} + ${policies.map(p => renderADMLPresentation(p, translations)).join(`\n `)} `; } -async function renderGP(policies) { +async function renderGP(policies, translations) { const product = JSON.parse(await fs_1.promises.readFile('product.json', 'utf-8')); const appName = product.nameLong; const regKey = product.win32RegValueName; @@ -268,28 +279,64 @@ async function renderGP(policies) { const categories = [...new Set(policies.map(p => p.category))]; return { admx: renderADMX(regKey, versions, categories, policies), - adml: renderADML(appName, versions, categories, policies), + adml: [ + { languageId: 'en-us', contents: renderADML(appName, versions, categories, policies) }, + ...translations.map(({ languageId, languageTranslations }) => ({ languageId, contents: renderADML(appName, versions, categories, policies, languageTranslations) })) + ] }; } // --- +const Languages = { + 'fr': 'fr-fr', + 'it': 'it-it', + 'de': 'de-de', + 'es': 'es-es', + 'ru': 'ru-ru', + 'zh-hans': 'zh-cn', + 'zh-hant': 'zh-tw', + 'ja': 'ja-jp', + 'ko': 'ko-kr', + 'cs': 'cs-cz', + 'pt-br': 'pt-br', + 'tr': 'tr-tr', + 'pl': 'pl-pl', +}; +async function getLatestStableVersion() { + const res = await (0, node_fetch_1.default)(`https://update.code.visualstudio.com/api/update/darwin/stable/latest`); + const { name: version } = await res.json(); + return version; +} +async function getNLS(languageId, version) { + const res = await (0, node_fetch_1.default)(`https://ms-ceintl.vscode-unpkg.net/ms-ceintl/vscode-language-pack-${languageId}/${version}/extension/translations/main.i18n.json`); + const { contents: result } = await res.json(); + return result; +} +// --- async function main() { const parser = new Parser(); parser.setLanguage(typescript); const files = await getFiles(process.cwd()); + const base = path.join(process.cwd(), 'src'); const policies = []; for (const file of files) { + const moduleName = path.relative(base, file).replace(/\.ts$/i, '').replace(/\\/g, '/'); const contents = await fs_1.promises.readFile(file, { encoding: 'utf8' }); const tree = parser.parse(contents); - policies.push(...getPolicies(tree.rootNode)); + policies.push(...getPolicies(moduleName, tree.rootNode)); } - const { admx, adml } = await renderGP(policies); + const version = await getLatestStableVersion(); + const languageIds = Object.keys(Languages); + const translations = await Promise.all(languageIds.map(languageId => getNLS(languageId, version).then(languageTranslations => ({ languageId, languageTranslations })))); + const { admx, adml } = await renderGP(policies, translations); const root = '.build/policies/win32'; await fs_1.promises.rm(root, { recursive: true, force: true }); await fs_1.promises.mkdir(root, { recursive: true }); await fs_1.promises.writeFile(path.join(root, 'Code.admx'), admx.replace(/\r?\n/g, '\n')); - const enUS = path.join(root, 'en-US'); - await fs_1.promises.mkdir(enUS, { recursive: true }); - await fs_1.promises.writeFile(path.join(enUS, 'Code.adml'), adml.replace(/\r?\n/g, '\n')); + for (const { languageId, contents } of adml) { + const languagePath = languageId === 'en-us' ? 'en-us' : path.join(root, Languages[languageId]); + await fs_1.promises.mkdir(languagePath, { recursive: true }); + await fs_1.promises.writeFile(path.join(languagePath, 'Code.adml'), contents.replace(/\r?\n/g, '\n')); + } } if (require.main === module) { main().catch(err => { diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 32b3654ed1b2c..4280f82b15fe0 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -9,12 +9,10 @@ import * as path from 'path'; import * as byline from 'byline'; import { rgPath } from '@vscode/ripgrep'; import * as Parser from 'tree-sitter'; +import fetch from 'node-fetch'; const { typescript } = require('tree-sitter-typescript'); -interface NlsString { - readonly value: string; - readonly nlsKey: string; -} +type NlsString = { value: string; nlsKey: string }; function isNlsString(value: string | NlsString | undefined): value is NlsString { return value ? typeof value !== 'string' : false; @@ -42,6 +40,7 @@ interface BasePolicy { readonly category: Category; readonly minimumVersion: string; readonly description: NlsString; + readonly moduleName: string; } interface StringEnumPolicy extends BasePolicy { @@ -124,7 +123,7 @@ function getStringArrayProperty(node: Parser.SyntaxNode, key: string): (string | // --- -function getPolicy(settingNode: Parser.SyntaxNode, policyNode: Parser.SyntaxNode, categories: Map): Policy { +function getPolicy(moduleName: string, settingNode: Parser.SyntaxNode, policyNode: Parser.SyntaxNode, categories: Map): Policy { const name = getStringProperty(policyNode, 'name'); if (!name) { @@ -201,10 +200,10 @@ function getPolicy(settingNode: Parser.SyntaxNode, policyNode: Parser.SyntaxNode categories.set(categoryKey, category); } - return { policyType: PolicyType.StringEnum, name, minimumVersion, description, type, enum: _enum, enumDescriptions, category }; + return { policyType: PolicyType.StringEnum, name, minimumVersion, description, type, moduleName, enum: _enum, enumDescriptions, category }; } -function getPolicies(node: Parser.SyntaxNode): Policy[] { +function getPolicies(moduleName: string, node: Parser.SyntaxNode): Policy[] { const query = new Parser.Query(typescript, ` ( (call_expression @@ -228,7 +227,7 @@ function getPolicies(node: Parser.SyntaxNode): Policy[] { return query.matches(node).map(m => { const settingNode = m.captures.filter(c => c.name === 'setting')[0].node; const policyNode = m.captures.filter(c => c.name === 'policy')[0].node; - return getPolicy(settingNode, policyNode, categories); + return getPolicy(moduleName, settingNode, policyNode, categories); }); } @@ -252,7 +251,7 @@ function renderADMXPolicy(regKey: string, policy: Policy) { case PolicyType.StringEnum: return ` - + ${policy.enum.map((value, index) => `${value}`).join(`\n `)} @@ -265,7 +264,7 @@ function renderADMXPolicy(regKey: string, policy: Policy) { } function renderADMX(regKey: string, versions: string[], categories: Category[], policies: Policy[]) { - versions = versions.map(v => v.replace('.', '_')); + versions = versions.map(v => v.replace(/\./g, '_')); return ` @@ -289,32 +288,46 @@ function renderADMX(regKey: string, versions: string[], categories: Category[], `; } -function renderADMLString(policy: Policy, nlsString: NlsString): string { - return `${nlsString.value}`; +function renderADMLString(policy: Policy, nlsString: NlsString, translations?: LanguageTranslations): string { + let value: string | undefined; + + if (translations) { + const moduleTranslations = translations[policy.moduleName]; + + if (moduleTranslations) { + value = moduleTranslations[nlsString.nlsKey]; + } + } + + if (!value) { + value = nlsString.value; + } + + return `${value}`; } -function pushADMLString(arr: string[], policy: Policy, value: string | NlsString | undefined): void { +function pushADMLString(arr: string[], policy: Policy, value: string | NlsString | undefined, translations?: LanguageTranslations): void { if (isNlsString(value)) { - arr.push(renderADMLString(policy, value)); + arr.push(renderADMLString(policy, value, translations)); } } -function pushADMLStrings(arr: string[], policy: Policy, values: (string | NlsString)[]): void { +function pushADMLStrings(arr: string[], policy: Policy, values: (string | NlsString)[], translations?: LanguageTranslations): void { for (const value of values) { - pushADMLString(arr, policy, value); + pushADMLString(arr, policy, value, translations); } } -function renderADMLStrings(policy: Policy): string[] { +function renderADMLStrings(policy: Policy, translations?: LanguageTranslations): string[] { const result: string[] = [ `${policy.name}` ]; - pushADMLString(result, policy, policy.description); + pushADMLString(result, policy, policy.description, translations); switch (policy.policyType) { case PolicyType.StringEnum: - pushADMLStrings(result, policy, policy.enumDescriptions); + pushADMLStrings(result, policy, policy.enumDescriptions, translations); break; default: throw new Error(`Unexpected policy type: ${policy.type}`); @@ -323,7 +336,7 @@ function renderADMLStrings(policy: Policy): string[] { return result; } -function renderADMLPresentation(policy: Policy): string { +function renderADMLPresentation(policy: Policy, _translations?: LanguageTranslations): string { switch (policy.policyType) { case PolicyType.StringEnum: return ``; @@ -332,7 +345,7 @@ function renderADMLPresentation(policy: Policy): string { } } -function renderADML(appName: string, versions: string[], categories: Category[], policies: Policy[]) { +function renderADML(appName: string, versions: string[], categories: Category[], policies: Policy[], translations?: LanguageTranslations) { return ` @@ -340,19 +353,23 @@ function renderADML(appName: string, versions: string[], categories: Category[], ${appName} - ${versions.map(v => `${appName} ${v} or later`)} + ${versions.map(v => `${appName} ${v} or later`)} ${categories.map(c => `${c.name.value}`)} - ${policies.map(p => renderADMLStrings(p)).flat().join(`\n `)} + ${policies.map(p => renderADMLStrings(p, translations)).flat().join(`\n `)} - ${policies.map(p => renderADMLPresentation(p)).join(`\n `)} + ${policies.map(p => renderADMLPresentation(p, translations)).join(`\n `)} `; } -async function renderGP(policies: Policy[]) { +type GP = { + admx: string; adml: { languageId: string; contents: string }[]; +}; + +async function renderGP(policies: Policy[], translations: Translations): Promise { const product = JSON.parse(await fs.readFile('product.json', 'utf-8')); const appName = product.nameLong; const regKey = product.win32RegValueName; @@ -362,26 +379,68 @@ async function renderGP(policies: Policy[]) { return { admx: renderADMX(regKey, versions, categories, policies), - adml: renderADML(appName, versions, categories, policies), + adml: [ + { languageId: 'en-us', contents: renderADML(appName, versions, categories, policies) }, + ...translations.map(({ languageId, languageTranslations }) => + ({ languageId, contents: renderADML(appName, versions, categories, policies, languageTranslations) })) + ] }; } // --- +const Languages = { + 'fr': 'fr-fr', + 'it': 'it-it', + 'de': 'de-de', + 'es': 'es-es', + 'ru': 'ru-ru', + 'zh-hans': 'zh-cn', + 'zh-hant': 'zh-tw', + 'ja': 'ja-jp', + 'ko': 'ko-kr', + 'cs': 'cs-cz', + 'pt-br': 'pt-br', + 'tr': 'tr-tr', + 'pl': 'pl-pl', +}; + +type LanguageTranslations = { [moduleName: string]: { [nlsKey: string]: string } }; +type Translations = { languageId: string; languageTranslations: LanguageTranslations }[]; + +async function getLatestStableVersion() { + const res = await fetch(`https://update.code.visualstudio.com/api/update/darwin/stable/latest`); + const { name: version } = await res.json() as { name: string }; + return version; +} + +async function getNLS(languageId: string, version: string) { + const res = await fetch(`https://ms-ceintl.vscode-unpkg.net/ms-ceintl/vscode-language-pack-${languageId}/${version}/extension/translations/main.i18n.json`); + const { contents: result } = await res.json() as { contents: LanguageTranslations }; + return result; +} + +// --- + async function main() { const parser = new Parser(); parser.setLanguage(typescript); const files = await getFiles(process.cwd()); + const base = path.join(process.cwd(), 'src'); const policies = []; for (const file of files) { + const moduleName = path.relative(base, file).replace(/\.ts$/i, '').replace(/\\/g, '/'); const contents = await fs.readFile(file, { encoding: 'utf8' }); const tree = parser.parse(contents); - policies.push(...getPolicies(tree.rootNode)); + policies.push(...getPolicies(moduleName, tree.rootNode)); } - const { admx, adml } = await renderGP(policies); + const version = await getLatestStableVersion(); + const languageIds = Object.keys(Languages); + const translations = await Promise.all(languageIds.map(languageId => getNLS(languageId, version).then(languageTranslations => ({ languageId, languageTranslations })))); + const { admx, adml } = await renderGP(policies, translations); const root = '.build/policies/win32'; await fs.rm(root, { recursive: true, force: true }); @@ -389,9 +448,11 @@ async function main() { await fs.writeFile(path.join(root, 'Code.admx'), admx.replace(/\r?\n/g, '\n')); - const enUS = path.join(root, 'en-US'); - await fs.mkdir(enUS, { recursive: true }); - await fs.writeFile(path.join(enUS, 'Code.adml'), adml.replace(/\r?\n/g, '\n')); + for (const { languageId, contents } of adml) { + const languagePath = languageId === 'en-us' ? 'en-us' : path.join(root, Languages[languageId as keyof typeof Languages]); + await fs.mkdir(languagePath, { recursive: true }); + await fs.writeFile(path.join(languagePath, 'Code.adml'), contents.replace(/\r?\n/g, '\n')); + } } if (require.main === module) { diff --git a/build/package.json b/build/package.json index 78903df507722..be3b82386adba 100644 --- a/build/package.json +++ b/build/package.json @@ -58,6 +58,7 @@ "jsonc-parser": "^2.3.0", "mime": "^1.4.1", "mkdirp": "^1.0.4", + "node-fetch": "2", "p-limit": "^3.1.0", "source-map": "0.6.1", "through2": "^4.0.2", diff --git a/build/yarn.lock b/build/yarn.lock index deec6e2dff53c..46a19fd98577a 100644 --- a/build/yarn.lock +++ b/build/yarn.lock @@ -2587,7 +2587,7 @@ node-abort-controller@^1.2.0: resolved "https://registry.yarnpkg.com/node-abort-controller/-/node-abort-controller-1.2.1.tgz#1eddb57eb8fea734198b11b28857596dc6165708" integrity sha512-79PYeJuj6S9+yOHirR0JBLFOgjB6sQCir10uN6xRx25iD+ZD4ULqgRn3MwWBRaQGB0vEgReJzWwJo42T1R6YbQ== -node-fetch@^2.6.0: +node-fetch@2, node-fetch@^2.6.0: version "2.6.7" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== diff --git a/en-us/Code.adml b/en-us/Code.adml new file mode 100644 index 0000000000000..43837a85dba00 --- /dev/null +++ b/en-us/Code.adml @@ -0,0 +1,21 @@ + + + + + + + Code - OSS + Code - OSS 1.67 or later + Update + UpdateMode + Configure whether you receive automatic updates. Requires a restart after change. The updates are fetched from a Microsoft online service. + Disable updates. + Disable automatic background update checks. Updates will be available if you manually check for updates. + Check for updates only on startup. Disable automatic background update checks. + Enable automatic update checks. Code will check for updates automatically and periodically. + + + + + + From 5057992bd751d1fd7e6c93629df29a3a0975c886 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 3 May 2022 15:34:16 +0200 Subject: [PATCH 13/32] oops --- build/lib/policies.js | 2 +- build/lib/policies.ts | 2 +- en-us/Code.adml | 21 --------------------- 3 files changed, 2 insertions(+), 23 deletions(-) delete mode 100644 en-us/Code.adml diff --git a/build/lib/policies.js b/build/lib/policies.js index f1217769cc2b2..ba89b661cb672 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -333,7 +333,7 @@ async function main() { await fs_1.promises.mkdir(root, { recursive: true }); await fs_1.promises.writeFile(path.join(root, 'Code.admx'), admx.replace(/\r?\n/g, '\n')); for (const { languageId, contents } of adml) { - const languagePath = languageId === 'en-us' ? 'en-us' : path.join(root, Languages[languageId]); + const languagePath = path.join(root, languageId === 'en-us' ? 'en-us' : Languages[languageId]); await fs_1.promises.mkdir(languagePath, { recursive: true }); await fs_1.promises.writeFile(path.join(languagePath, 'Code.adml'), contents.replace(/\r?\n/g, '\n')); } diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 4280f82b15fe0..0403bb68891f7 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -449,7 +449,7 @@ async function main() { await fs.writeFile(path.join(root, 'Code.admx'), admx.replace(/\r?\n/g, '\n')); for (const { languageId, contents } of adml) { - const languagePath = languageId === 'en-us' ? 'en-us' : path.join(root, Languages[languageId as keyof typeof Languages]); + const languagePath = path.join(root, languageId === 'en-us' ? 'en-us' : Languages[languageId as keyof typeof Languages]); await fs.mkdir(languagePath, { recursive: true }); await fs.writeFile(path.join(languagePath, 'Code.adml'), contents.replace(/\r?\n/g, '\n')); } diff --git a/en-us/Code.adml b/en-us/Code.adml deleted file mode 100644 index 43837a85dba00..0000000000000 --- a/en-us/Code.adml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - Code - OSS - Code - OSS 1.67 or later - Update - UpdateMode - Configure whether you receive automatic updates. Requires a restart after change. The updates are fetched from a Microsoft online service. - Disable updates. - Disable automatic background update checks. Updates will be available if you manually check for updates. - Check for updates only on startup. Disable automatic background update checks. - Enable automatic update checks. Code will check for updates automatically and periodically. - - - - - - From 48a64d10769acb0b70c784173e98320a64950ca3 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 3 May 2022 15:38:19 +0200 Subject: [PATCH 14/32] better policy file names --- build/lib/policies.js | 6 +++--- build/lib/policies.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index ba89b661cb672..61a53df0dd18f 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -12,6 +12,7 @@ const ripgrep_1 = require("@vscode/ripgrep"); const Parser = require("tree-sitter"); const node_fetch_1 = require("node-fetch"); const { typescript } = require('tree-sitter-typescript'); +const product = require('../../product.json'); function isNlsString(value) { return value ? typeof value !== 'string' : false; } @@ -272,7 +273,6 @@ function renderADML(appName, versions, categories, policies, translations) { `; } async function renderGP(policies, translations) { - const product = JSON.parse(await fs_1.promises.readFile('product.json', 'utf-8')); const appName = product.nameLong; const regKey = product.win32RegValueName; const versions = [...new Set(policies.map(p => p.minimumVersion)).values()].sort(); @@ -331,11 +331,11 @@ async function main() { const root = '.build/policies/win32'; await fs_1.promises.rm(root, { recursive: true, force: true }); await fs_1.promises.mkdir(root, { recursive: true }); - await fs_1.promises.writeFile(path.join(root, 'Code.admx'), admx.replace(/\r?\n/g, '\n')); + await fs_1.promises.writeFile(path.join(root, `${product.win32RegValueName}.admx`), admx.replace(/\r?\n/g, '\n')); for (const { languageId, contents } of adml) { const languagePath = path.join(root, languageId === 'en-us' ? 'en-us' : Languages[languageId]); await fs_1.promises.mkdir(languagePath, { recursive: true }); - await fs_1.promises.writeFile(path.join(languagePath, 'Code.adml'), contents.replace(/\r?\n/g, '\n')); + await fs_1.promises.writeFile(path.join(languagePath, `${product.win32RegValueName}.adml`), contents.replace(/\r?\n/g, '\n')); } } if (require.main === module) { diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 0403bb68891f7..dc0c916e9c749 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -11,6 +11,7 @@ import { rgPath } from '@vscode/ripgrep'; import * as Parser from 'tree-sitter'; import fetch from 'node-fetch'; const { typescript } = require('tree-sitter-typescript'); +const product = require('../../product.json'); type NlsString = { value: string; nlsKey: string }; @@ -370,7 +371,6 @@ type GP = { }; async function renderGP(policies: Policy[], translations: Translations): Promise { - const product = JSON.parse(await fs.readFile('product.json', 'utf-8')); const appName = product.nameLong; const regKey = product.win32RegValueName; @@ -446,12 +446,12 @@ async function main() { await fs.rm(root, { recursive: true, force: true }); await fs.mkdir(root, { recursive: true }); - await fs.writeFile(path.join(root, 'Code.admx'), admx.replace(/\r?\n/g, '\n')); + await fs.writeFile(path.join(root, `${product.win32RegValueName}.admx`), admx.replace(/\r?\n/g, '\n')); for (const { languageId, contents } of adml) { const languagePath = path.join(root, languageId === 'en-us' ? 'en-us' : Languages[languageId as keyof typeof Languages]); await fs.mkdir(languagePath, { recursive: true }); - await fs.writeFile(path.join(languagePath, 'Code.adml'), contents.replace(/\r?\n/g, '\n')); + await fs.writeFile(path.join(languagePath, `${product.win32RegValueName}.adml`), contents.replace(/\r?\n/g, '\n')); } } From ad7828be1a4aba9055ccc7e4d8f4e416dce44e49 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 3 May 2022 15:42:48 +0200 Subject: [PATCH 15/32] clean todos --- build/lib/policies.js | 8 ++++---- build/lib/policies.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index 61a53df0dd18f..edca03fa3001b 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -101,18 +101,18 @@ function getPolicy(moduleName, settingNode, policyNode, categories) { throw new Error(`Missing required 'type' property.`); } if (type !== 'string') { - throw new Error(`TODO`); + throw new Error(`Can't create policy from setting type '${type}' (needs implementing)`); } const _enum = getStringArrayProperty(settingNode, 'enum'); if (!_enum) { - throw new Error(`TODO`); + throw new Error(`Missing required 'enum' property.`); } if (!isStringArray(_enum)) { - throw new Error(`TODO`); + throw new Error(`Property 'enum' should not be localized.`); } const enumDescriptions = getStringArrayProperty(settingNode, 'enumDescriptions'); if (!enumDescriptions) { - throw new Error(`TODO`); + throw new Error(`Missing required 'enumDescriptions' property.`); } if (!isNlsStringArray(enumDescriptions)) { throw new Error(`Property 'enumDescriptions' should be localized.`); diff --git a/build/lib/policies.ts b/build/lib/policies.ts index dc0c916e9c749..b8c095fa3c79c 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -162,23 +162,23 @@ function getPolicy(moduleName: string, settingNode: Parser.SyntaxNode, policyNod } if (type !== 'string') { - throw new Error(`TODO`); + throw new Error(`Can't create policy from setting type '${type}' (needs implementing)`); } const _enum = getStringArrayProperty(settingNode, 'enum'); if (!_enum) { - throw new Error(`TODO`); + throw new Error(`Missing required 'enum' property.`); } if (!isStringArray(_enum)) { - throw new Error(`TODO`); + throw new Error(`Property 'enum' should not be localized.`); } const enumDescriptions = getStringArrayProperty(settingNode, 'enumDescriptions'); if (!enumDescriptions) { - throw new Error(`TODO`); + throw new Error(`Missing required 'enumDescriptions' property.`); } if (!isNlsStringArray(enumDescriptions)) { From af5c8e545452bbe921b62333c159345ef4297f66 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 3 May 2022 15:53:53 +0200 Subject: [PATCH 16/32] generate policies at build --- .../win32/product-build-win32.yml | 7 +++ build/gulpfile.vscode.js | 4 +- resources/win32/policies/Code.admx | 48 ------------------- resources/win32/policies/en-US/Code.adml | 23 --------- 4 files changed, 10 insertions(+), 72 deletions(-) delete mode 100644 resources/win32/policies/Code.admx delete mode 100644 resources/win32/policies/en-US/Code.adml diff --git a/build/azure-pipelines/win32/product-build-win32.yml b/build/azure-pipelines/win32/product-build-win32.yml index 99b39ee2b2542..6d99d80f558ef 100644 --- a/build/azure-pipelines/win32/product-build-win32.yml +++ b/build/azure-pipelines/win32/product-build-win32.yml @@ -291,6 +291,13 @@ steps: searchFolder: "$(Build.ArtifactStagingDirectory)/test-results" condition: and(succeededOrFailed(), eq(variables['VSCODE_STEP_ON_IT'], 'false'), ne(variables['VSCODE_ARCH'], 'arm64')) + - powershell: | + . build/azure-pipelines/win32/exec.ps1 + $ErrorActionPreference = "Stop" + exec { node build\lib\policies } + displayName: Generate Group Policy + condition: and(succeeded(), ne(variables['VSCODE_PUBLISH'], 'false')) + - task: UseDotNet@2 inputs: version: 3.x diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index e6c30fec11146..14a534fa83862 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -331,7 +331,9 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op result = es.merge(result, gulp.src('resources/win32/VisualElementsManifest.xml', { base: 'resources/win32' }) .pipe(rename(product.nameShort + '.VisualElementsManifest.xml'))); - result = es.merge(result, gulp.src('resources/win32/policies/**', { base: 'resources/win32' })); + result = es.merge(result, gulp.src('.build/policies/win32/**', { base: '.build/policies/win32' })) + .pipe(rename(f => f.dirname += `policies/${f.dirname}`)); + } else if (platform === 'linux') { result = es.merge(result, gulp.src('resources/linux/bin/code.sh', { base: '.' }) .pipe(replace('@@PRODNAME@@', product.nameLong)) diff --git a/resources/win32/policies/Code.admx b/resources/win32/policies/Code.admx deleted file mode 100644 index 916f503b7829b..0000000000000 --- a/resources/win32/policies/Code.admx +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - none - - - - - manual - - - - - start - - - - - default - - - - - - - diff --git a/resources/win32/policies/en-US/Code.adml b/resources/win32/policies/en-US/Code.adml deleted file mode 100644 index f79b1778ec487..0000000000000 --- a/resources/win32/policies/en-US/Code.adml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - Code - OSS 1.67 or later - Code - OSS - Update - Update Mode - Configure whether you receive automatic updates. Requires a restart after change. The updates are fetched from a Microsoft online service. - Disable updates. - Disable automatic background update checks. Updates will be available if you manually check for updates. - Check for updates only on startup. Disable automatic background update checks. - Enable automatic update checks. Code will check for updates automatically and periodically. - - - - - - - - From a0b4595a85da6f9f8a7215c56e5741573cb1f971 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 3 May 2022 16:18:44 +0200 Subject: [PATCH 17/32] parallel --- build/lib/policies.js | 13 ++++++++++--- build/lib/policies.ts | 22 +++++++++++++++------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index edca03fa3001b..bbad4fe1d0ff0 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -272,7 +272,7 @@ function renderADML(appName, versions, categories, policies, translations) { `; } -async function renderGP(policies, translations) { +function renderGP(policies, translations) { const appName = product.nameLong; const regKey = product.win32RegValueName; const versions = [...new Set(policies.map(p => p.minimumVersion)).values()].sort(); @@ -312,7 +312,7 @@ async function getNLS(languageId, version) { return result; } // --- -async function main() { +async function parsePolicies() { const parser = new Parser(); parser.setLanguage(typescript); const files = await getFiles(process.cwd()); @@ -324,9 +324,16 @@ async function main() { const tree = parser.parse(contents); policies.push(...getPolicies(moduleName, tree.rootNode)); } + return policies; +} +async function getTranslations() { const version = await getLatestStableVersion(); const languageIds = Object.keys(Languages); - const translations = await Promise.all(languageIds.map(languageId => getNLS(languageId, version).then(languageTranslations => ({ languageId, languageTranslations })))); + return await Promise.all(languageIds.map(languageId => getNLS(languageId, version) + .then(languageTranslations => ({ languageId, languageTranslations })))); +} +async function main() { + const [policies, translations] = await Promise.all([parsePolicies(), getTranslations()]); const { admx, adml } = await renderGP(policies, translations); const root = '.build/policies/win32'; await fs_1.promises.rm(root, { recursive: true, force: true }); diff --git a/build/lib/policies.ts b/build/lib/policies.ts index b8c095fa3c79c..237cda9091309 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -366,11 +366,7 @@ function renderADML(appName: string, versions: string[], categories: Category[], `; } -type GP = { - admx: string; adml: { languageId: string; contents: string }[]; -}; - -async function renderGP(policies: Policy[], translations: Translations): Promise { +function renderGP(policies: Policy[], translations: Translations) { const appName = product.nameLong; const regKey = product.win32RegValueName; @@ -422,7 +418,7 @@ async function getNLS(languageId: string, version: string) { // --- -async function main() { +async function parsePolicies(): Promise { const parser = new Parser(); parser.setLanguage(typescript); @@ -437,9 +433,21 @@ async function main() { policies.push(...getPolicies(moduleName, tree.rootNode)); } + return policies; +} + +async function getTranslations(): Promise { const version = await getLatestStableVersion(); const languageIds = Object.keys(Languages); - const translations = await Promise.all(languageIds.map(languageId => getNLS(languageId, version).then(languageTranslations => ({ languageId, languageTranslations })))); + + return await Promise.all(languageIds.map( + languageId => getNLS(languageId, version) + .then(languageTranslations => ({ languageId, languageTranslations })) + )); +} + +async function main() { + const [policies, translations] = await Promise.all([parsePolicies(), getTranslations()]); const { admx, adml } = await renderGP(policies, translations); const root = '.build/policies/win32'; From 87e60634405bb0612449caaae11a05a3409e9d28 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 3 May 2022 20:37:29 +0200 Subject: [PATCH 18/32] restructure --- build/lib/policies.js | 141 ++++++++++++++++--------------- build/lib/policies.ts | 189 ++++++++++++++++++++++-------------------- 2 files changed, 170 insertions(+), 160 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index bbad4fe1d0ff0..2b3cae09d82c5 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -26,6 +26,72 @@ var PolicyType; (function (PolicyType) { PolicyType[PolicyType["StringEnum"] = 0] = "StringEnum"; })(PolicyType || (PolicyType = {})); +class BasePolicy { + constructor(policyType, name, category, minimumVersion, description, moduleName) { + this.policyType = policyType; + this.name = name; + this.category = category; + this.minimumVersion = minimumVersion; + this.description = description; + this.moduleName = moduleName; + } + renderADMLString(nlsString, translations) { + let value; + if (translations) { + const moduleTranslations = translations[this.moduleName]; + if (moduleTranslations) { + value = moduleTranslations[nlsString.nlsKey]; + } + } + if (!value) { + value = nlsString.value; + } + return `${value}`; + } + renderADMX(regKey) { + return [ + ``, + ` `, + ` `, + ` `, + ...this.renderADMXElements(), + ` `, + `` + ]; + } + renderADMLStrings(translations) { + return [ + `${this.name}`, + this.renderADMLString(this.description, translations) + ]; + } + renderADMLPresentation() { + return `${this.renderADMLPresentationContents()}>`; + } +} +class StringEnumPolicy extends BasePolicy { + constructor(name, category, minimumVersion, description, moduleName, enum_, enumDescriptions) { + super(PolicyType.StringEnum, name, category, minimumVersion, description, moduleName); + this.enum_ = enum_; + this.enumDescriptions = enumDescriptions; + } + renderADMXElements() { + return [ + ``, + ...this.enum_.map((value, index) => ` ${value}`), + `` + ]; + } + renderADMLStrings(translations) { + return [ + ...super.renderADMLStrings(translations), + ...this.enumDescriptions.map(e => this.renderADMLString(e, translations)) + ]; + } + renderADMLPresentationContents() { + return ``; + } +} const StringQ = { Q: `[ (string (string_fragment) @value) @@ -103,11 +169,11 @@ function getPolicy(moduleName, settingNode, policyNode, categories) { if (type !== 'string') { throw new Error(`Can't create policy from setting type '${type}' (needs implementing)`); } - const _enum = getStringArrayProperty(settingNode, 'enum'); - if (!_enum) { + const enum_ = getStringArrayProperty(settingNode, 'enum'); + if (!enum_) { throw new Error(`Missing required 'enum' property.`); } - if (!isStringArray(_enum)) { + if (!isStringArray(enum_)) { throw new Error(`Property 'enum' should not be localized.`); } const enumDescriptions = getStringArrayProperty(settingNode, 'enumDescriptions'); @@ -130,7 +196,7 @@ function getPolicy(moduleName, settingNode, policyNode, categories) { category = { name: categoryName }; categories.set(categoryKey, category); } - return { policyType: PolicyType.StringEnum, name, minimumVersion, description, type, moduleName, enum: _enum, enumDescriptions, category }; + return new StringEnumPolicy(name, category, minimumVersion, description, moduleName, enum_, enumDescriptions); } function getPolicies(moduleName, node) { const query = new Parser.Query(typescript, ` @@ -169,22 +235,6 @@ async function getFiles(root) { }); } // --- -function renderADMXPolicy(regKey, policy) { - switch (policy.policyType) { - case PolicyType.StringEnum: - return ` - - - - - ${policy.enum.map((value, index) => `${value}`).join(`\n `)} - - - `; - default: - throw new Error(`Unexpected policy type: ${policy.type}`); - } -} function renderADMX(regKey, versions, categories, policies) { versions = versions.map(v => v.replace(/\./g, '_')); return ` @@ -203,56 +253,11 @@ function renderADMX(regKey, versions, categories, policies) { ${categories.map(c => ``).join(`\n `)} - ${policies.map(p => renderADMXPolicy(regKey, p)).join(`\n `)} + ${policies.map(p => p.renderADMX(regKey)).flat().join(`\n `)} `; } -function renderADMLString(policy, nlsString, translations) { - let value; - if (translations) { - const moduleTranslations = translations[policy.moduleName]; - if (moduleTranslations) { - value = moduleTranslations[nlsString.nlsKey]; - } - } - if (!value) { - value = nlsString.value; - } - return `${value}`; -} -function pushADMLString(arr, policy, value, translations) { - if (isNlsString(value)) { - arr.push(renderADMLString(policy, value, translations)); - } -} -function pushADMLStrings(arr, policy, values, translations) { - for (const value of values) { - pushADMLString(arr, policy, value, translations); - } -} -function renderADMLStrings(policy, translations) { - const result = [ - `${policy.name}` - ]; - pushADMLString(result, policy, policy.description, translations); - switch (policy.policyType) { - case PolicyType.StringEnum: - pushADMLStrings(result, policy, policy.enumDescriptions, translations); - break; - default: - throw new Error(`Unexpected policy type: ${policy.type}`); - } - return result; -} -function renderADMLPresentation(policy, _translations) { - switch (policy.policyType) { - case PolicyType.StringEnum: - return ``; - default: - throw new Error(`Unexpected policy type: ${policy.type}`); - } -} function renderADML(appName, versions, categories, policies, translations) { return ` @@ -263,10 +268,10 @@ function renderADML(appName, versions, categories, policies, translations) { ${appName} ${versions.map(v => `${appName} ${v} or later`)} ${categories.map(c => `${c.name.value}`)} - ${policies.map(p => renderADMLStrings(p, translations)).flat().join(`\n `)} + ${policies.map(p => p.renderADMLStrings(translations)).flat().join(`\n `)} - ${policies.map(p => renderADMLPresentation(p, translations)).join(`\n `)} + ${policies.map(p => p.renderADMLPresentation()).join(`\n `)} diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 237cda9091309..2e657f25bd892 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -35,23 +35,102 @@ enum PolicyType { StringEnum } -interface BasePolicy { - readonly name: string; - readonly policyType: PolicyType; +interface Policy { readonly category: Category; readonly minimumVersion: string; - readonly description: NlsString; - readonly moduleName: string; + renderADMX(regKey: string): string[]; + renderADMLStrings(translations?: LanguageTranslations): string[]; + renderADMLPresentation(): string; } -interface StringEnumPolicy extends BasePolicy { - readonly policyType: PolicyType.StringEnum; - readonly type: 'string'; - readonly enum: string[]; - readonly enumDescriptions: NlsString[]; +abstract class BasePolicy implements Policy { + constructor( + protected policyType: PolicyType, + protected name: string, + readonly category: Category, + readonly minimumVersion: string, + protected description: NlsString, + protected moduleName: string, + ) { } + + protected renderADMLString(nlsString: NlsString, translations?: LanguageTranslations): string { + let value: string | undefined; + + if (translations) { + const moduleTranslations = translations[this.moduleName]; + + if (moduleTranslations) { + value = moduleTranslations[nlsString.nlsKey]; + } + } + + if (!value) { + value = nlsString.value; + } + + return `${value}`; + } + + renderADMX(regKey: string) { + return [ + ``, + ` `, + ` `, + ` `, + ...this.renderADMXElements(), + ` `, + `` + ]; + } + + protected abstract renderADMXElements(): string[]; + + renderADMLStrings(translations?: LanguageTranslations) { + return [ + `${this.name}`, + this.renderADMLString(this.description, translations) + ]; + } + + renderADMLPresentation(): string { + return `${this.renderADMLPresentationContents()}>`; + } + + protected abstract renderADMLPresentationContents(): string; } -type Policy = StringEnumPolicy; +class StringEnumPolicy extends BasePolicy { + constructor( + name: string, + category: Category, + minimumVersion: string, + description: NlsString, + moduleName: string, + protected enum_: string[], + protected enumDescriptions: NlsString[], + ) { + super(PolicyType.StringEnum, name, category, minimumVersion, description, moduleName); + } + + protected renderADMXElements(): string[] { + return [ + ``, + ...this.enum_.map((value, index) => ` ${value}`), + `` + ]; + } + + renderADMLStrings(translations?: LanguageTranslations) { + return [ + ...super.renderADMLStrings(translations), + ...this.enumDescriptions.map(e => this.renderADMLString(e, translations)) + ]; + } + + renderADMLPresentationContents() { + return ``; + } +} // --- @@ -165,13 +244,13 @@ function getPolicy(moduleName: string, settingNode: Parser.SyntaxNode, policyNod throw new Error(`Can't create policy from setting type '${type}' (needs implementing)`); } - const _enum = getStringArrayProperty(settingNode, 'enum'); + const enum_ = getStringArrayProperty(settingNode, 'enum'); - if (!_enum) { + if (!enum_) { throw new Error(`Missing required 'enum' property.`); } - if (!isStringArray(_enum)) { + if (!isStringArray(enum_)) { throw new Error(`Property 'enum' should not be localized.`); } @@ -201,7 +280,7 @@ function getPolicy(moduleName: string, settingNode: Parser.SyntaxNode, policyNod categories.set(categoryKey, category); } - return { policyType: PolicyType.StringEnum, name, minimumVersion, description, type, moduleName, enum: _enum, enumDescriptions, category }; + return new StringEnumPolicy(name, category, minimumVersion, description, moduleName, enum_, enumDescriptions); } function getPolicies(moduleName: string, node: Parser.SyntaxNode): Policy[] { @@ -247,23 +326,6 @@ async function getFiles(root: string): Promise { // --- -function renderADMXPolicy(regKey: string, policy: Policy) { - switch (policy.policyType) { - case PolicyType.StringEnum: - return ` - - - - - ${policy.enum.map((value, index) => `${value}`).join(`\n `)} - - - `; - default: - throw new Error(`Unexpected policy type: ${policy.type}`); - } -} - function renderADMX(regKey: string, versions: string[], categories: Category[], policies: Policy[]) { versions = versions.map(v => v.replace(/\./g, '_')); @@ -283,69 +345,12 @@ function renderADMX(regKey: string, versions: string[], categories: Category[], ${categories.map(c => ``).join(`\n `)} - ${policies.map(p => renderADMXPolicy(regKey, p)).join(`\n `)} + ${policies.map(p => p.renderADMX(regKey)).flat().join(`\n `)} `; } -function renderADMLString(policy: Policy, nlsString: NlsString, translations?: LanguageTranslations): string { - let value: string | undefined; - - if (translations) { - const moduleTranslations = translations[policy.moduleName]; - - if (moduleTranslations) { - value = moduleTranslations[nlsString.nlsKey]; - } - } - - if (!value) { - value = nlsString.value; - } - - return `${value}`; -} - -function pushADMLString(arr: string[], policy: Policy, value: string | NlsString | undefined, translations?: LanguageTranslations): void { - if (isNlsString(value)) { - arr.push(renderADMLString(policy, value, translations)); - } -} - -function pushADMLStrings(arr: string[], policy: Policy, values: (string | NlsString)[], translations?: LanguageTranslations): void { - for (const value of values) { - pushADMLString(arr, policy, value, translations); - } -} - -function renderADMLStrings(policy: Policy, translations?: LanguageTranslations): string[] { - const result: string[] = [ - `${policy.name}` - ]; - - pushADMLString(result, policy, policy.description, translations); - - switch (policy.policyType) { - case PolicyType.StringEnum: - pushADMLStrings(result, policy, policy.enumDescriptions, translations); - break; - default: - throw new Error(`Unexpected policy type: ${policy.type}`); - } - - return result; -} - -function renderADMLPresentation(policy: Policy, _translations?: LanguageTranslations): string { - switch (policy.policyType) { - case PolicyType.StringEnum: - return ``; - default: - throw new Error(`Unexpected policy type: ${policy.type}`); - } -} - function renderADML(appName: string, versions: string[], categories: Category[], policies: Policy[], translations?: LanguageTranslations) { return ` @@ -356,10 +361,10 @@ function renderADML(appName: string, versions: string[], categories: Category[], ${appName} ${versions.map(v => `${appName} ${v} or later`)} ${categories.map(c => `${c.name.value}`)} - ${policies.map(p => renderADMLStrings(p, translations)).flat().join(`\n `)} + ${policies.map(p => p.renderADMLStrings(translations)).flat().join(`\n `)} - ${policies.map(p => renderADMLPresentation(p, translations)).join(`\n `)} + ${policies.map(p => p.renderADMLPresentation()).join(`\n `)} From 16025c457e5d322934ad1b2962b3bbcfeba8929b Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 3 May 2022 20:47:43 +0200 Subject: [PATCH 19/32] :lipstick: --- build/lib/policies.js | 4 ++-- build/lib/policies.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index 2b3cae09d82c5..3de6fce8408fa 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -52,7 +52,7 @@ class BasePolicy { return [ ``, ` `, - ` `, + ` `, ` `, ...this.renderADMXElements(), ` `, @@ -66,7 +66,7 @@ class BasePolicy { ]; } renderADMLPresentation() { - return `${this.renderADMLPresentationContents()}>`; + return `${this.renderADMLPresentationContents()}`; } } class StringEnumPolicy extends BasePolicy { diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 2e657f25bd892..853b300b715db 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -75,7 +75,7 @@ abstract class BasePolicy implements Policy { return [ ``, ` `, - ` `, + ` `, ` `, ...this.renderADMXElements(), ` `, @@ -93,7 +93,7 @@ abstract class BasePolicy implements Policy { } renderADMLPresentation(): string { - return `${this.renderADMLPresentationContents()}>`; + return `${this.renderADMLPresentationContents()}`; } protected abstract renderADMLPresentationContents(): string; From 44e07e65c425c8ace28a1a6374518dd0aeefbd45 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 3 May 2022 20:51:31 +0200 Subject: [PATCH 20/32] do not localize supported version --- build/lib/policies.js | 2 +- build/lib/policies.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index 3de6fce8408fa..8f37c888df86b 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -266,7 +266,7 @@ function renderADML(appName, versions, categories, policies, translations) { ${appName} - ${versions.map(v => `${appName} ${v} or later`)} + ${versions.map(v => `${appName} >= ${v}`)} ${categories.map(c => `${c.name.value}`)} ${policies.map(p => p.renderADMLStrings(translations)).flat().join(`\n `)} diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 853b300b715db..d839568ff11e2 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -359,7 +359,7 @@ function renderADML(appName: string, versions: string[], categories: Category[], ${appName} - ${versions.map(v => `${appName} ${v} or later`)} + ${versions.map(v => `${appName} >= ${v}`)} ${categories.map(c => `${c.name.value}`)} ${policies.map(p => p.renderADMLStrings(translations)).flat().join(`\n `)} From 43a486e5df20f03fdcc5c052a83ab033447938fc Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 4 May 2022 11:46:03 +0200 Subject: [PATCH 21/32] fix build --- build/gulpfile.vscode.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index 14a534fa83862..39375792cf275 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -331,8 +331,8 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op result = es.merge(result, gulp.src('resources/win32/VisualElementsManifest.xml', { base: 'resources/win32' }) .pipe(rename(product.nameShort + '.VisualElementsManifest.xml'))); - result = es.merge(result, gulp.src('.build/policies/win32/**', { base: '.build/policies/win32' })) - .pipe(rename(f => f.dirname += `policies/${f.dirname}`)); + result = es.merge(result, gulp.src('.build/policies/win32/**', { base: '.build/policies/win32' }) + .pipe(rename(f => f.dirname += `policies/${f.dirname}`))); } else if (platform === 'linux') { result = es.merge(result, gulp.src('resources/linux/bin/code.sh', { base: '.' }) From f30c76445a609f4ee1451a83f6b8a5acd6bf7b4e Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 4 May 2022 20:24:13 +0200 Subject: [PATCH 22/32] build: fix policy definition generation --- .../azure-pipelines/win32/product-build-win32.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build/azure-pipelines/win32/product-build-win32.yml b/build/azure-pipelines/win32/product-build-win32.yml index 6d99d80f558ef..b58d4cde52dc8 100644 --- a/build/azure-pipelines/win32/product-build-win32.yml +++ b/build/azure-pipelines/win32/product-build-win32.yml @@ -118,6 +118,13 @@ steps: displayName: Download Electron condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) + - powershell: | + . build/azure-pipelines/win32/exec.ps1 + $ErrorActionPreference = "Stop" + exec { node build\lib\policies } + displayName: Generate Group Policy definitions + condition: and(succeeded(), ne(variables['VSCODE_PUBLISH'], 'false')) + - powershell: | . build/azure-pipelines/win32/exec.ps1 $ErrorActionPreference = "Stop" @@ -291,13 +298,6 @@ steps: searchFolder: "$(Build.ArtifactStagingDirectory)/test-results" condition: and(succeededOrFailed(), eq(variables['VSCODE_STEP_ON_IT'], 'false'), ne(variables['VSCODE_ARCH'], 'arm64')) - - powershell: | - . build/azure-pipelines/win32/exec.ps1 - $ErrorActionPreference = "Stop" - exec { node build\lib\policies } - displayName: Generate Group Policy - condition: and(succeeded(), ne(variables['VSCODE_PUBLISH'], 'false')) - - task: UseDotNet@2 inputs: version: 3.x From ad2f2205b74cc328674ab2b91bdd600c018a410b Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 4 May 2022 20:35:51 +0200 Subject: [PATCH 23/32] policy generation should run on distro only --- build/lib/policies.js | 29 +++++++++++++++++++++++------ build/lib/policies.ts | 34 ++++++++++++++++++++++++++++------ 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index 8f37c888df86b..5b25282f17413 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -306,13 +306,20 @@ const Languages = { 'tr': 'tr-tr', 'pl': 'pl-pl', }; -async function getLatestStableVersion() { - const res = await (0, node_fetch_1.default)(`https://update.code.visualstudio.com/api/update/darwin/stable/latest`); +async function getLatestStableVersion(updateUrl) { + const res = await (0, node_fetch_1.default)(`${updateUrl}/api/update/darwin/stable/latest`); const { name: version } = await res.json(); return version; } -async function getNLS(languageId, version) { - const res = await (0, node_fetch_1.default)(`https://ms-ceintl.vscode-unpkg.net/ms-ceintl/vscode-language-pack-${languageId}/${version}/extension/translations/main.i18n.json`); +async function getNLS(resourceUrlTemplate, languageId, version) { + const resource = { + publisher: 'ms-ceintl', + name: `vscode-language-pack-${languageId}`, + version, + path: 'extension/translations/main.i18n.json' + }; + const url = resourceUrlTemplate.replace(/\{([^}]+)\}/g, (_, key) => resource[key]); + const res = await (0, node_fetch_1.default)(url); const { contents: result } = await res.json(); return result; } @@ -332,9 +339,19 @@ async function parsePolicies() { return policies; } async function getTranslations() { - const version = await getLatestStableVersion(); + const updateUrl = product.updateUrl; + if (!updateUrl) { + console.warn(`Skipping policy localization: No 'updateUrl' found in 'product.json'.`); + return []; + } + const resourceUrlTemplate = product.extensionsGallery?.resourceUrlTemplate; + if (!resourceUrlTemplate) { + console.warn(`Skipping policy localization: No 'resourceUrlTemplate' found in 'product.json'.`); + return []; + } + const version = await getLatestStableVersion(updateUrl); const languageIds = Object.keys(Languages); - return await Promise.all(languageIds.map(languageId => getNLS(languageId, version) + return await Promise.all(languageIds.map(languageId => getNLS(resourceUrlTemplate, languageId, version) .then(languageTranslations => ({ languageId, languageTranslations })))); } async function main() { diff --git a/build/lib/policies.ts b/build/lib/policies.ts index d839568ff11e2..05a6d01f7a10c 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -409,14 +409,22 @@ const Languages = { type LanguageTranslations = { [moduleName: string]: { [nlsKey: string]: string } }; type Translations = { languageId: string; languageTranslations: LanguageTranslations }[]; -async function getLatestStableVersion() { - const res = await fetch(`https://update.code.visualstudio.com/api/update/darwin/stable/latest`); +async function getLatestStableVersion(updateUrl: string) { + const res = await fetch(`${updateUrl}/api/update/darwin/stable/latest`); const { name: version } = await res.json() as { name: string }; return version; } -async function getNLS(languageId: string, version: string) { - const res = await fetch(`https://ms-ceintl.vscode-unpkg.net/ms-ceintl/vscode-language-pack-${languageId}/${version}/extension/translations/main.i18n.json`); +async function getNLS(resourceUrlTemplate: string, languageId: string, version: string) { + const resource = { + publisher: 'ms-ceintl', + name: `vscode-language-pack-${languageId}`, + version, + path: 'extension/translations/main.i18n.json' + }; + + const url = resourceUrlTemplate.replace(/\{([^}]+)\}/g, (_, key) => resource[key as keyof typeof resource]); + const res = await fetch(url); const { contents: result } = await res.json() as { contents: LanguageTranslations }; return result; } @@ -442,11 +450,25 @@ async function parsePolicies(): Promise { } async function getTranslations(): Promise { - const version = await getLatestStableVersion(); + const updateUrl = product.updateUrl; + + if (!updateUrl) { + console.warn(`Skipping policy localization: No 'updateUrl' found in 'product.json'.`); + return []; + } + + const resourceUrlTemplate = product.extensionsGallery?.resourceUrlTemplate; + + if (!resourceUrlTemplate) { + console.warn(`Skipping policy localization: No 'resourceUrlTemplate' found in 'product.json'.`); + return []; + } + + const version = await getLatestStableVersion(updateUrl); const languageIds = Object.keys(Languages); return await Promise.all(languageIds.map( - languageId => getNLS(languageId, version) + languageId => getNLS(resourceUrlTemplate, languageId, version) .then(languageTranslations => ({ languageId, languageTranslations })) )); } From c532174b5ba729dabc445918f925f202ec38e2be Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 4 May 2022 20:50:19 +0200 Subject: [PATCH 24/32] policy: extract category from config title --- build/lib/policies.js | 63 ++++++------ build/lib/policies.ts | 98 +++++++++---------- .../common/configurationRegistry.ts | 15 ++- .../common/update.config.contribution.ts | 1 - 4 files changed, 88 insertions(+), 89 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index 5b25282f17413..071277069aa3c 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -26,6 +26,19 @@ var PolicyType; (function (PolicyType) { PolicyType[PolicyType["StringEnum"] = 0] = "StringEnum"; })(PolicyType || (PolicyType = {})); +function renderADMLString(prefix, moduleName, nlsString, translations) { + let value; + if (translations) { + const moduleTranslations = translations[moduleName]; + if (moduleTranslations) { + value = moduleTranslations[nlsString.nlsKey]; + } + } + if (!value) { + value = nlsString.value; + } + return `${value}`; +} class BasePolicy { constructor(policyType, name, category, minimumVersion, description, moduleName) { this.policyType = policyType; @@ -36,17 +49,7 @@ class BasePolicy { this.moduleName = moduleName; } renderADMLString(nlsString, translations) { - let value; - if (translations) { - const moduleTranslations = translations[this.moduleName]; - if (moduleTranslations) { - value = moduleTranslations[nlsString.nlsKey]; - } - } - if (!value) { - value = nlsString.value; - } - return `${value}`; + return renderADMLString(this.name, this.moduleName, nlsString, translations); } renderADMX(regKey) { return [ @@ -139,20 +142,26 @@ function getStringProperty(node, key) { function getStringArrayProperty(node, key) { return getProperty(StringArrayQ, node, key); } -// --- -function getPolicy(moduleName, settingNode, policyNode, categories) { +function getPolicy(moduleName, configurationNode, settingNode, policyNode, categories) { const name = getStringProperty(policyNode, 'name'); if (!name) { throw new Error(`Missing required 'name' property.`); } - if (isNlsString(name)) { + else if (isNlsString(name)) { throw new Error(`Property 'name' should be a literal string.`); } + const categoryName = getStringProperty(configurationNode, 'title'); + if (!categoryName) { + throw new Error(`Missing required 'title' property.`); + } + else if (!isNlsString(categoryName)) { + throw new Error(`Property 'title' should be localized.`); + } const minimumVersion = getStringProperty(policyNode, 'minimumVersion'); if (!minimumVersion) { throw new Error(`Missing required 'minimumVersion' property.`); } - if (isNlsString(minimumVersion)) { + else if (isNlsString(minimumVersion)) { throw new Error(`Property 'minimumVersion' should be a literal string.`); } const description = getStringProperty(settingNode, 'description'); @@ -173,27 +182,20 @@ function getPolicy(moduleName, settingNode, policyNode, categories) { if (!enum_) { throw new Error(`Missing required 'enum' property.`); } - if (!isStringArray(enum_)) { + else if (!isStringArray(enum_)) { throw new Error(`Property 'enum' should not be localized.`); } const enumDescriptions = getStringArrayProperty(settingNode, 'enumDescriptions'); if (!enumDescriptions) { throw new Error(`Missing required 'enumDescriptions' property.`); } - if (!isNlsStringArray(enumDescriptions)) { + else if (!isNlsStringArray(enumDescriptions)) { throw new Error(`Property 'enumDescriptions' should be localized.`); } - const categoryName = getStringProperty(policyNode, 'category'); - if (!categoryName) { - throw new Error(`Missing required 'category' property.`); - } - else if (!isNlsString(categoryName)) { - throw new Error(`Property 'category' should be localized.`); - } const categoryKey = `${categoryName.nlsKey}:${categoryName.value}`; let category = categories.get(categoryKey); if (!category) { - category = { name: categoryName }; + category = { moduleName, name: categoryName }; categories.set(categoryKey, category); } return new StringEnumPolicy(name, category, minimumVersion, description, moduleName, enum_, enumDescriptions); @@ -212,18 +214,18 @@ function getPolicies(moduleName, node) { value: (object) @policy )) )) @setting - ))) + )) @configuration) ) ) `); const categories = new Map(); return query.matches(node).map(m => { + const configurationNode = m.captures.filter(c => c.name === 'configuration')[0].node; const settingNode = m.captures.filter(c => c.name === 'setting')[0].node; const policyNode = m.captures.filter(c => c.name === 'policy')[0].node; - return getPolicy(moduleName, settingNode, policyNode, categories); + return getPolicy(moduleName, configurationNode, settingNode, policyNode, categories); }); } -// --- async function getFiles(root) { return new Promise((c, e) => { const result = []; @@ -234,7 +236,6 @@ async function getFiles(root) { stream.on('end', () => c(result)); }); } -// --- function renderADMX(regKey, versions, categories, policies) { versions = versions.map(v => v.replace(/\./g, '_')); return ` @@ -267,7 +268,7 @@ function renderADML(appName, versions, categories, policies, translations) { ${appName} ${versions.map(v => `${appName} >= ${v}`)} - ${categories.map(c => `${c.name.value}`)} + ${categories.map(c => renderADMLString('Category', c.moduleName, c.name, translations))} ${policies.map(p => p.renderADMLStrings(translations)).flat().join(`\n `)} @@ -290,7 +291,6 @@ function renderGP(policies, translations) { ] }; } -// --- const Languages = { 'fr': 'fr-fr', 'it': 'it-it', @@ -323,7 +323,6 @@ async function getNLS(resourceUrlTemplate, languageId, version) { const { contents: result } = await res.json(); return result; } -// --- async function parsePolicies() { const parser = new Parser(); parser.setLanguage(typescript); diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 05a6d01f7a10c..fb9e8765e151c 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -28,6 +28,7 @@ function isNlsStringArray(value: (string | NlsString)[]): value is NlsString[] { } interface Category { + readonly moduleName: string; readonly name: NlsString; } @@ -43,6 +44,24 @@ interface Policy { renderADMLPresentation(): string; } +function renderADMLString(prefix: string, moduleName: string, nlsString: NlsString, translations?: LanguageTranslations): string { + let value: string | undefined; + + if (translations) { + const moduleTranslations = translations[moduleName]; + + if (moduleTranslations) { + value = moduleTranslations[nlsString.nlsKey]; + } + } + + if (!value) { + value = nlsString.value; + } + + return `${value}`; +} + abstract class BasePolicy implements Policy { constructor( protected policyType: PolicyType, @@ -54,21 +73,7 @@ abstract class BasePolicy implements Policy { ) { } protected renderADMLString(nlsString: NlsString, translations?: LanguageTranslations): string { - let value: string | undefined; - - if (translations) { - const moduleTranslations = translations[this.moduleName]; - - if (moduleTranslations) { - value = moduleTranslations[nlsString.nlsKey]; - } - } - - if (!value) { - value = nlsString.value; - } - - return `${value}`; + return renderADMLString(this.name, this.moduleName, nlsString, translations); } renderADMX(regKey: string) { @@ -132,8 +137,6 @@ class StringEnumPolicy extends BasePolicy { } } -// --- - interface QType { Q: string; value(matches: Parser.QueryMatch[]): T | undefined; @@ -201,26 +204,34 @@ function getStringArrayProperty(node: Parser.SyntaxNode, key: string): (string | return getProperty(StringArrayQ, node, key); } -// --- - -function getPolicy(moduleName: string, settingNode: Parser.SyntaxNode, policyNode: Parser.SyntaxNode, categories: Map): Policy { +function getPolicy( + moduleName: string, + configurationNode: Parser.SyntaxNode, + settingNode: Parser.SyntaxNode, + policyNode: Parser.SyntaxNode, + categories: Map +): Policy { const name = getStringProperty(policyNode, 'name'); if (!name) { throw new Error(`Missing required 'name' property.`); + } else if (isNlsString(name)) { + throw new Error(`Property 'name' should be a literal string.`); } - if (isNlsString(name)) { - throw new Error(`Property 'name' should be a literal string.`); + const categoryName = getStringProperty(configurationNode, 'title'); + + if (!categoryName) { + throw new Error(`Missing required 'title' property.`); + } else if (!isNlsString(categoryName)) { + throw new Error(`Property 'title' should be localized.`); } const minimumVersion = getStringProperty(policyNode, 'minimumVersion'); if (!minimumVersion) { throw new Error(`Missing required 'minimumVersion' property.`); - } - - if (isNlsString(minimumVersion)) { + } else if (isNlsString(minimumVersion)) { throw new Error(`Property 'minimumVersion' should be a literal string.`); } @@ -228,9 +239,7 @@ function getPolicy(moduleName: string, settingNode: Parser.SyntaxNode, policyNod if (!description) { throw new Error(`Missing required 'description' property.`); - } - - if (!isNlsString(description)) { + } if (!isNlsString(description)) { throw new Error(`Property 'description' should be localized.`); } @@ -248,9 +257,7 @@ function getPolicy(moduleName: string, settingNode: Parser.SyntaxNode, policyNod if (!enum_) { throw new Error(`Missing required 'enum' property.`); - } - - if (!isStringArray(enum_)) { + } else if (!isStringArray(enum_)) { throw new Error(`Property 'enum' should not be localized.`); } @@ -258,25 +265,15 @@ function getPolicy(moduleName: string, settingNode: Parser.SyntaxNode, policyNod if (!enumDescriptions) { throw new Error(`Missing required 'enumDescriptions' property.`); - } - - if (!isNlsStringArray(enumDescriptions)) { + } else if (!isNlsStringArray(enumDescriptions)) { throw new Error(`Property 'enumDescriptions' should be localized.`); } - const categoryName = getStringProperty(policyNode, 'category'); - - if (!categoryName) { - throw new Error(`Missing required 'category' property.`); - } else if (!isNlsString(categoryName)) { - throw new Error(`Property 'category' should be localized.`); - } - const categoryKey = `${categoryName.nlsKey}:${categoryName.value}`; let category = categories.get(categoryKey); if (!category) { - category = { name: categoryName }; + category = { moduleName, name: categoryName }; categories.set(categoryKey, category); } @@ -297,7 +294,7 @@ function getPolicies(moduleName: string, node: Parser.SyntaxNode): Policy[] { value: (object) @policy )) )) @setting - ))) + )) @configuration) ) ) `); @@ -305,14 +302,13 @@ function getPolicies(moduleName: string, node: Parser.SyntaxNode): Policy[] { const categories = new Map(); return query.matches(node).map(m => { + const configurationNode = m.captures.filter(c => c.name === 'configuration')[0].node; const settingNode = m.captures.filter(c => c.name === 'setting')[0].node; const policyNode = m.captures.filter(c => c.name === 'policy')[0].node; - return getPolicy(moduleName, settingNode, policyNode, categories); + return getPolicy(moduleName, configurationNode, settingNode, policyNode, categories); }); } -// --- - async function getFiles(root: string): Promise { return new Promise((c, e) => { const result: string[] = []; @@ -324,8 +320,6 @@ async function getFiles(root: string): Promise { }); } -// --- - function renderADMX(regKey: string, versions: string[], categories: Category[], policies: Policy[]) { versions = versions.map(v => v.replace(/\./g, '_')); @@ -360,7 +354,7 @@ function renderADML(appName: string, versions: string[], categories: Category[], ${appName} ${versions.map(v => `${appName} >= ${v}`)} - ${categories.map(c => `${c.name.value}`)} + ${categories.map(c => renderADMLString('Category', c.moduleName, c.name, translations))} ${policies.map(p => p.renderADMLStrings(translations)).flat().join(`\n `)} @@ -388,8 +382,6 @@ function renderGP(policies: Policy[], translations: Translations) { }; } -// --- - const Languages = { 'fr': 'fr-fr', 'it': 'it-it', @@ -429,8 +421,6 @@ async function getNLS(resourceUrlTemplate: string, languageId: string, version: return result; } -// --- - async function parsePolicies(): Promise { const parser = new Parser(); parser.setLanguage(typescript); diff --git a/src/vs/platform/configuration/common/configurationRegistry.ts b/src/vs/platform/configuration/common/configurationRegistry.ts index a1940fa22a7cd..1f424d52cb76c 100644 --- a/src/vs/platform/configuration/common/configurationRegistry.ts +++ b/src/vs/platform/configuration/common/configurationRegistry.ts @@ -128,9 +128,16 @@ export const enum ConfigurationScope { } export interface PolicyConfiguration { + + /** + * The policy name. + */ readonly name: string; - readonly minimumVersion: `1.${number}`; - readonly category: string; + + /** + * The Code version in which this policy was introduced. + */ + readonly minimumVersion: `${number}.${number}`; } export interface IConfigurationPropertySchema extends IJSONSchema { @@ -182,6 +189,10 @@ export interface IConfigurationPropertySchema extends IJSONSchema { */ order?: number; + /** + * When specified, this setting's value can always be overwritten by + * a system-wide policy. + */ policy?: PolicyConfiguration; } diff --git a/src/vs/platform/update/common/update.config.contribution.ts b/src/vs/platform/update/common/update.config.contribution.ts index ff5dec1cc42c5..4134233def670 100644 --- a/src/vs/platform/update/common/update.config.contribution.ts +++ b/src/vs/platform/update/common/update.config.contribution.ts @@ -31,7 +31,6 @@ configurationRegistry.registerConfiguration({ policy: { name: 'UpdateMode', minimumVersion: '1.67', - category: localize('update', "Update") } }, 'update.channel': { From 40c2994ffa4f1a64052176353aa5da4f6a57debd Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 4 May 2022 21:09:32 +0200 Subject: [PATCH 25/32] policy types --- build/lib/policies.js | 72 +++++++++++++++++++------------- build/lib/policies.ts | 97 ++++++++++++++++++++++++++++--------------- 2 files changed, 108 insertions(+), 61 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index 071277069aa3c..ebf0a4686c6dd 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -78,6 +78,27 @@ class StringEnumPolicy extends BasePolicy { this.enum_ = enum_; this.enumDescriptions = enumDescriptions; } + static from(name, category, minimumVersion, description, moduleName, settingNode) { + const type = getStringProperty(settingNode, 'type'); + if (type !== 'string') { + return undefined; + } + const enum_ = getStringArrayProperty(settingNode, 'enum'); + if (!enum_) { + return undefined; + } + if (!isStringArray(enum_)) { + throw new Error(`Property 'enum' should not be localized.`); + } + const enumDescriptions = getStringArrayProperty(settingNode, 'enumDescriptions'); + if (!enumDescriptions) { + throw new Error(`Missing required 'enumDescriptions' property.`); + } + else if (!isNlsStringArray(enumDescriptions)) { + throw new Error(`Property 'enumDescriptions' should be localized.`); + } + return new StringEnumPolicy(name, category, minimumVersion, description, moduleName, enum_, enumDescriptions); + } renderADMXElements() { return [ ``, @@ -121,6 +142,9 @@ const StringQ = { const StringArrayQ = { Q: `(array ${StringQ.Q})`, value(matches) { + if (matches.length === 0) { + return undefined; + } return matches.map(match => { return StringQ.value([match]); }); @@ -142,6 +166,10 @@ function getStringProperty(node, key) { function getStringArrayProperty(node, key) { return getProperty(StringArrayQ, node, key); } +// TODO: add more policy types +const PolicyTypes = [ + StringEnumPolicy +]; function getPolicy(moduleName, configurationNode, settingNode, policyNode, categories) { const name = getStringProperty(policyNode, 'name'); if (!name) { @@ -157,6 +185,12 @@ function getPolicy(moduleName, configurationNode, settingNode, policyNode, categ else if (!isNlsString(categoryName)) { throw new Error(`Property 'title' should be localized.`); } + const categoryKey = `${categoryName.nlsKey}:${categoryName.value}`; + let category = categories.get(categoryKey); + if (!category) { + category = { moduleName, name: categoryName }; + categories.set(categoryKey, category); + } const minimumVersion = getStringProperty(policyNode, 'minimumVersion'); if (!minimumVersion) { throw new Error(`Missing required 'minimumVersion' property.`); @@ -171,34 +205,16 @@ function getPolicy(moduleName, configurationNode, settingNode, policyNode, categ if (!isNlsString(description)) { throw new Error(`Property 'description' should be localized.`); } - const type = getStringProperty(settingNode, 'type'); - if (!type) { - throw new Error(`Missing required 'type' property.`); - } - if (type !== 'string') { - throw new Error(`Can't create policy from setting type '${type}' (needs implementing)`); - } - const enum_ = getStringArrayProperty(settingNode, 'enum'); - if (!enum_) { - throw new Error(`Missing required 'enum' property.`); - } - else if (!isStringArray(enum_)) { - throw new Error(`Property 'enum' should not be localized.`); - } - const enumDescriptions = getStringArrayProperty(settingNode, 'enumDescriptions'); - if (!enumDescriptions) { - throw new Error(`Missing required 'enumDescriptions' property.`); - } - else if (!isNlsStringArray(enumDescriptions)) { - throw new Error(`Property 'enumDescriptions' should be localized.`); + let result; + for (const policyType of PolicyTypes) { + if (result = policyType.from(name, category, minimumVersion, description, moduleName, settingNode)) { + break; + } } - const categoryKey = `${categoryName.nlsKey}:${categoryName.value}`; - let category = categories.get(categoryKey); - if (!category) { - category = { moduleName, name: categoryName }; - categories.set(categoryKey, category); + if (!result) { + throw new Error(`Failed to parse policy '${name}'.`); } - return new StringEnumPolicy(name, category, minimumVersion, description, moduleName, enum_, enumDescriptions); + return result; } function getPolicies(moduleName, node) { const query = new Parser.Query(typescript, ` @@ -212,8 +228,8 @@ function getPolicies(moduleName, node) { value: (object (pair key: [(property_identifier)(string)] @policyKey (#eq? @policyKey policy) value: (object) @policy - )) - )) @setting + )) @setting + )) )) @configuration) ) ) diff --git a/build/lib/policies.ts b/build/lib/policies.ts index fb9e8765e151c..d07ff35e8be24 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -105,7 +105,43 @@ abstract class BasePolicy implements Policy { } class StringEnumPolicy extends BasePolicy { - constructor( + + static from( + name: string, + category: Category, + minimumVersion: string, + description: NlsString, + moduleName: string, + settingNode: Parser.SyntaxNode + ): StringEnumPolicy | undefined { + const type = getStringProperty(settingNode, 'type'); + + if (type !== 'string') { + return undefined; + } + + const enum_ = getStringArrayProperty(settingNode, 'enum'); + + if (!enum_) { + return undefined; + } + + if (!isStringArray(enum_)) { + throw new Error(`Property 'enum' should not be localized.`); + } + + const enumDescriptions = getStringArrayProperty(settingNode, 'enumDescriptions'); + + if (!enumDescriptions) { + throw new Error(`Missing required 'enumDescriptions' property.`); + } else if (!isNlsStringArray(enumDescriptions)) { + throw new Error(`Property 'enumDescriptions' should be localized.`); + } + + return new StringEnumPolicy(name, category, minimumVersion, description, moduleName, enum_, enumDescriptions); + } + + private constructor( name: string, category: Category, minimumVersion: string, @@ -175,6 +211,10 @@ const StringArrayQ: QType<(string | NlsString)[]> = { Q: `(array ${StringQ.Q})`, value(matches: Parser.QueryMatch[]): (string | NlsString)[] | undefined { + if (matches.length === 0) { + return undefined; + } + return matches.map(match => { return StringQ.value([match]) as string | NlsString; }); @@ -204,6 +244,11 @@ function getStringArrayProperty(node: Parser.SyntaxNode, key: string): (string | return getProperty(StringArrayQ, node, key); } +// TODO: add more policy types +const PolicyTypes = [ + StringEnumPolicy +]; + function getPolicy( moduleName: string, configurationNode: Parser.SyntaxNode, @@ -227,6 +272,14 @@ function getPolicy( throw new Error(`Property 'title' should be localized.`); } + const categoryKey = `${categoryName.nlsKey}:${categoryName.value}`; + let category = categories.get(categoryKey); + + if (!category) { + category = { moduleName, name: categoryName }; + categories.set(categoryKey, category); + } + const minimumVersion = getStringProperty(policyNode, 'minimumVersion'); if (!minimumVersion) { @@ -243,41 +296,19 @@ function getPolicy( throw new Error(`Property 'description' should be localized.`); } - const type = getStringProperty(settingNode, 'type'); - - if (!type) { - throw new Error(`Missing required 'type' property.`); - } - - if (type !== 'string') { - throw new Error(`Can't create policy from setting type '${type}' (needs implementing)`); - } + let result: Policy | undefined; - const enum_ = getStringArrayProperty(settingNode, 'enum'); - - if (!enum_) { - throw new Error(`Missing required 'enum' property.`); - } else if (!isStringArray(enum_)) { - throw new Error(`Property 'enum' should not be localized.`); - } - - const enumDescriptions = getStringArrayProperty(settingNode, 'enumDescriptions'); - - if (!enumDescriptions) { - throw new Error(`Missing required 'enumDescriptions' property.`); - } else if (!isNlsStringArray(enumDescriptions)) { - throw new Error(`Property 'enumDescriptions' should be localized.`); + for (const policyType of PolicyTypes) { + if (result = policyType.from(name, category, minimumVersion, description, moduleName, settingNode)) { + break; + } } - const categoryKey = `${categoryName.nlsKey}:${categoryName.value}`; - let category = categories.get(categoryKey); - - if (!category) { - category = { moduleName, name: categoryName }; - categories.set(categoryKey, category); + if (!result) { + throw new Error(`Failed to parse policy '${name}'.`); } - return new StringEnumPolicy(name, category, minimumVersion, description, moduleName, enum_, enumDescriptions); + return result; } function getPolicies(moduleName: string, node: Parser.SyntaxNode): Policy[] { @@ -292,8 +323,8 @@ function getPolicies(moduleName: string, node: Parser.SyntaxNode): Policy[] { value: (object (pair key: [(property_identifier)(string)] @policyKey (#eq? @policyKey policy) value: (object) @policy - )) - )) @setting + )) @setting + )) )) @configuration) ) ) From c1e70cd425d319add2ea2bc1edefaa35a1bc2610 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Sat, 7 May 2022 13:46:23 +0200 Subject: [PATCH 26/32] StringPolicy --- build/lib/policies.js | 21 ++++++++++++++++++++- build/lib/policies.ts | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index ebf0a4686c6dd..b9b90dfaa17f2 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -72,6 +72,24 @@ class BasePolicy { return `${this.renderADMLPresentationContents()}`; } } +class StringPolicy extends BasePolicy { + static from(name, category, minimumVersion, description, moduleName, settingNode) { + const type = getStringProperty(settingNode, 'type'); + if (type !== 'string') { + return undefined; + } + return new StringPolicy(name, category, minimumVersion, description, moduleName); + } + constructor(name, category, minimumVersion, description, moduleName) { + super(PolicyType.StringEnum, name, category, minimumVersion, description, moduleName); + } + renderADMXElements() { + return [``]; + } + renderADMLPresentationContents() { + return ``; + } +} class StringEnumPolicy extends BasePolicy { constructor(name, category, minimumVersion, description, moduleName, enum_, enumDescriptions) { super(PolicyType.StringEnum, name, category, minimumVersion, description, moduleName); @@ -168,7 +186,8 @@ function getStringArrayProperty(node, key) { } // TODO: add more policy types const PolicyTypes = [ - StringEnumPolicy + StringEnumPolicy, + StringPolicy, ]; function getPolicy(moduleName, configurationNode, settingNode, policyNode, categories) { const name = getStringProperty(policyNode, 'name'); diff --git a/build/lib/policies.ts b/build/lib/policies.ts index d07ff35e8be24..ffc46f3843b40 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -104,6 +104,44 @@ abstract class BasePolicy implements Policy { protected abstract renderADMLPresentationContents(): string; } +class StringPolicy extends BasePolicy { + + static from( + name: string, + category: Category, + minimumVersion: string, + description: NlsString, + moduleName: string, + settingNode: Parser.SyntaxNode + ): StringPolicy | undefined { + const type = getStringProperty(settingNode, 'type'); + + if (type !== 'string') { + return undefined; + } + + return new StringPolicy(name, category, minimumVersion, description, moduleName); + } + + private constructor( + name: string, + category: Category, + minimumVersion: string, + description: NlsString, + moduleName: string, + ) { + super(PolicyType.StringEnum, name, category, minimumVersion, description, moduleName); + } + + protected renderADMXElements(): string[] { + return [``]; + } + + renderADMLPresentationContents() { + return ``; + } +} + class StringEnumPolicy extends BasePolicy { static from( @@ -246,7 +284,8 @@ function getStringArrayProperty(node: Parser.SyntaxNode, key: string): (string | // TODO: add more policy types const PolicyTypes = [ - StringEnumPolicy + StringEnumPolicy, + StringPolicy, ]; function getPolicy( From 70ce316c521e5bc7c9f19329dc159ac2599ccd1d Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Sat, 7 May 2022 13:53:59 +0200 Subject: [PATCH 27/32] BooleanPolicy --- build/lib/policies.js | 23 +++++++++++++++++++++++ build/lib/policies.ts | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/build/lib/policies.js b/build/lib/policies.js index b9b90dfaa17f2..a0c7a30f5fa5a 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -72,6 +72,28 @@ class BasePolicy { return `${this.renderADMLPresentationContents()}`; } } +class BooleanPolicy extends BasePolicy { + static from(name, category, minimumVersion, description, moduleName, settingNode) { + const type = getStringProperty(settingNode, 'type'); + if (type !== 'boolean') { + return undefined; + } + return new BooleanPolicy(name, category, minimumVersion, description, moduleName); + } + constructor(name, category, minimumVersion, description, moduleName) { + super(PolicyType.StringEnum, name, category, minimumVersion, description, moduleName); + } + renderADMXElements() { + return [ + ``, + ` `, + `` + ]; + } + renderADMLPresentationContents() { + return `${this.name}`; + } +} class StringPolicy extends BasePolicy { static from(name, category, minimumVersion, description, moduleName, settingNode) { const type = getStringProperty(settingNode, 'type'); @@ -186,6 +208,7 @@ function getStringArrayProperty(node, key) { } // TODO: add more policy types const PolicyTypes = [ + BooleanPolicy, StringEnumPolicy, StringPolicy, ]; diff --git a/build/lib/policies.ts b/build/lib/policies.ts index ffc46f3843b40..9a4b6758f4209 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -104,6 +104,48 @@ abstract class BasePolicy implements Policy { protected abstract renderADMLPresentationContents(): string; } +class BooleanPolicy extends BasePolicy { + + static from( + name: string, + category: Category, + minimumVersion: string, + description: NlsString, + moduleName: string, + settingNode: Parser.SyntaxNode + ): BooleanPolicy | undefined { + const type = getStringProperty(settingNode, 'type'); + + if (type !== 'boolean') { + return undefined; + } + + return new BooleanPolicy(name, category, minimumVersion, description, moduleName); + } + + private constructor( + name: string, + category: Category, + minimumVersion: string, + description: NlsString, + moduleName: string, + ) { + super(PolicyType.StringEnum, name, category, minimumVersion, description, moduleName); + } + + protected renderADMXElements(): string[] { + return [ + ``, + ` `, + `` + ]; + } + + renderADMLPresentationContents() { + return `${this.name}`; + } +} + class StringPolicy extends BasePolicy { static from( @@ -284,6 +326,7 @@ function getStringArrayProperty(node: Parser.SyntaxNode, key: string): (string | // TODO: add more policy types const PolicyTypes = [ + BooleanPolicy, StringEnumPolicy, StringPolicy, ]; From 862a2723379d1c2238cdcc624a5abc3e69cf7eb6 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Sat, 7 May 2022 14:17:30 +0200 Subject: [PATCH 28/32] IntPolicy --- build/lib/policies.js | 46 +++++++++++++++++++++++++- build/lib/policies.ts | 75 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 119 insertions(+), 2 deletions(-) diff --git a/build/lib/policies.js b/build/lib/policies.js index a0c7a30f5fa5a..3e2a10df350e1 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -94,6 +94,32 @@ class BooleanPolicy extends BasePolicy { return `${this.name}`; } } +class IntPolicy extends BasePolicy { + constructor(name, category, minimumVersion, description, moduleName, defaultValue) { + super(PolicyType.StringEnum, name, category, minimumVersion, description, moduleName); + this.defaultValue = defaultValue; + } + static from(name, category, minimumVersion, description, moduleName, settingNode) { + const type = getStringProperty(settingNode, 'type'); + if (type !== 'number') { + return undefined; + } + const defaultValue = getIntProperty(settingNode, 'default'); + if (typeof defaultValue === 'undefined') { + throw new Error(`Missing required 'default' property.`); + } + return new IntPolicy(name, category, minimumVersion, description, moduleName, defaultValue); + } + renderADMXElements() { + return [ + `` + // `` + ]; + } + renderADMLPresentationContents() { + return `${this.name}`; + } +} class StringPolicy extends BasePolicy { static from(name, category, minimumVersion, description, moduleName, settingNode) { const type = getStringProperty(settingNode, 'type'); @@ -156,6 +182,20 @@ class StringEnumPolicy extends BasePolicy { return ``; } } +const IntQ = { + Q: `(number) @value`, + value(matches) { + const match = matches[0]; + if (!match) { + return undefined; + } + const value = match.captures.filter(c => c.name === 'value')[0]?.node.text; + if (!value) { + throw new Error(`Missing required 'value' property.`); + } + return parseInt(value); + } +}; const StringQ = { Q: `[ (string (string_fragment) @value) @@ -200,6 +240,9 @@ function getProperty(qtype, node, key) { )`); return qtype.value(query.matches(node)); } +function getIntProperty(node, key) { + return getProperty(IntQ, node, key); +} function getStringProperty(node, key) { return getProperty(StringQ, node, key); } @@ -209,6 +252,7 @@ function getStringArrayProperty(node, key) { // TODO: add more policy types const PolicyTypes = [ BooleanPolicy, + IntPolicy, StringEnumPolicy, StringPolicy, ]; @@ -262,7 +306,7 @@ function getPolicies(moduleName, node) { const query = new Parser.Query(typescript, ` ( (call_expression - function: (member_expression object: (identifier) property: (property_identifier) @registerConfigurationFn) (#eq? @registerConfigurationFn registerConfiguration) + function: (member_expression property: (property_identifier) @registerConfigurationFn) (#eq? @registerConfigurationFn registerConfiguration) arguments: (arguments (object (pair key: [(property_identifier)(string)] @propertiesKey (#eq? @propertiesKey properties) value: (object (pair diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 9a4b6758f4209..62ea4d561e59d 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -146,6 +146,54 @@ class BooleanPolicy extends BasePolicy { } } +class IntPolicy extends BasePolicy { + + static from( + name: string, + category: Category, + minimumVersion: string, + description: NlsString, + moduleName: string, + settingNode: Parser.SyntaxNode + ): IntPolicy | undefined { + const type = getStringProperty(settingNode, 'type'); + + if (type !== 'number') { + return undefined; + } + + const defaultValue = getIntProperty(settingNode, 'default'); + + if (typeof defaultValue === 'undefined') { + throw new Error(`Missing required 'default' property.`); + } + + return new IntPolicy(name, category, minimumVersion, description, moduleName, defaultValue); + } + + private constructor( + name: string, + category: Category, + minimumVersion: string, + description: NlsString, + moduleName: string, + protected readonly defaultValue: number, + ) { + super(PolicyType.StringEnum, name, category, minimumVersion, description, moduleName); + } + + protected renderADMXElements(): string[] { + return [ + `` + // `` + ]; + } + + renderADMLPresentationContents() { + return `${this.name}`; + } +} + class StringPolicy extends BasePolicy { static from( @@ -258,6 +306,26 @@ interface QType { value(matches: Parser.QueryMatch[]): T | undefined; } +const IntQ: QType = { + Q: `(number) @value`, + + value(matches: Parser.QueryMatch[]): number | undefined { + const match = matches[0]; + + if (!match) { + return undefined; + } + + const value = match.captures.filter(c => c.name === 'value')[0]?.node.text; + + if (!value) { + throw new Error(`Missing required 'value' property.`); + } + + return parseInt(value); + } +}; + const StringQ: QType = { Q: `[ (string (string_fragment) @value) @@ -316,6 +384,10 @@ function getProperty(qtype: QType, node: Parser.SyntaxNode, key: string): return qtype.value(query.matches(node)); } +function getIntProperty(node: Parser.SyntaxNode, key: string): number | undefined { + return getProperty(IntQ, node, key); +} + function getStringProperty(node: Parser.SyntaxNode, key: string): string | NlsString | undefined { return getProperty(StringQ, node, key); } @@ -327,6 +399,7 @@ function getStringArrayProperty(node: Parser.SyntaxNode, key: string): (string | // TODO: add more policy types const PolicyTypes = [ BooleanPolicy, + IntPolicy, StringEnumPolicy, StringPolicy, ]; @@ -397,7 +470,7 @@ function getPolicies(moduleName: string, node: Parser.SyntaxNode): Policy[] { const query = new Parser.Query(typescript, ` ( (call_expression - function: (member_expression object: (identifier) property: (property_identifier) @registerConfigurationFn) (#eq? @registerConfigurationFn registerConfiguration) + function: (member_expression property: (property_identifier) @registerConfigurationFn) (#eq? @registerConfigurationFn registerConfiguration) arguments: (arguments (object (pair key: [(property_identifier)(string)] @propertiesKey (#eq? @propertiesKey properties) value: (object (pair From 46c3868f079d03d9eb906685d0d69b0ee11bc56a Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Mon, 9 May 2022 07:31:09 +0200 Subject: [PATCH 29/32] argh --- build/gulpfile.vscode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index 39375792cf275..7b3a5043154da 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -332,7 +332,7 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op .pipe(rename(product.nameShort + '.VisualElementsManifest.xml'))); result = es.merge(result, gulp.src('.build/policies/win32/**', { base: '.build/policies/win32' }) - .pipe(rename(f => f.dirname += `policies/${f.dirname}`))); + .pipe(rename(f => f.dirname = `policies/${f.dirname}`))); } else if (platform === 'linux') { result = es.merge(result, gulp.src('resources/linux/bin/code.sh', { base: '.' }) From c1a1fe24453e117c2292ca6ef6bd769940e6e139 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 10 May 2022 10:20:55 +0200 Subject: [PATCH 30/32] bump cache salt --- build/.cachesalt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/.cachesalt b/build/.cachesalt index 5eb7ff93bd887..30d07f237259f 100644 --- a/build/.cachesalt +++ b/build/.cachesalt @@ -1 +1 @@ -2022-03-02T05:48:19.264Z +2022-05-10T08:20:50.162Z From dd12a4eb36e9a57d7efe95ff1c567eb7779e5b01 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 10 May 2022 12:20:19 +0200 Subject: [PATCH 31/32] fix build --- build/lib/tsb/builder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/lib/tsb/builder.ts b/build/lib/tsb/builder.ts index 2f8753dd1199a..d5bec6ee97b0d 100644 --- a/build/lib/tsb/builder.ts +++ b/build/lib/tsb/builder.ts @@ -360,7 +360,7 @@ export function createTypeScriptBuilder(config: IConfiguration, projectFile: str const MB = 1024 * 1024; log('[tsb]', 'time:', colors.yellow((Date.now() - t1) + 'ms'), - 'mem:', colors.cyan(Math.ceil(headNow / MB) + 'MB'), colors.bgcyan('delta: ' + Math.ceil((headNow - headUsed) / MB)) + 'mem:', colors.cyan(Math.ceil(headNow / MB) + 'MB'), colors.bgCyan('delta: ' + Math.ceil((headNow - headUsed) / MB)) ); headUsed = headNow; } From df19868a955687a67b28f33895470c5c3fd78aa1 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 10 May 2022 12:31:00 +0200 Subject: [PATCH 32/32] compile build --- build/lib/tsb/builder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/lib/tsb/builder.js b/build/lib/tsb/builder.js index f0e1958df7e37..cb700a5407701 100644 --- a/build/lib/tsb/builder.js +++ b/build/lib/tsb/builder.js @@ -286,7 +286,7 @@ function createTypeScriptBuilder(config, projectFile, cmd) { if (config.verbose) { const headNow = process.memoryUsage().heapUsed; const MB = 1024 * 1024; - log('[tsb]', 'time:', colors.yellow((Date.now() - t1) + 'ms'), 'mem:', colors.cyan(Math.ceil(headNow / MB) + 'MB'), colors.bgcyan('delta: ' + Math.ceil((headNow - headUsed) / MB))); + log('[tsb]', 'time:', colors.yellow((Date.now() - t1) + 'ms'), 'mem:', colors.cyan(Math.ceil(headNow / MB) + 'MB'), colors.bgCyan('delta: ' + Math.ceil((headNow - headUsed) / MB))); headUsed = headNow; } });