├── .npmignore ├── .prettierrc.json ├── tsconfig.json ├── CHANGELOG.md ├── ci.yml ├── package.json ├── LICENSE ├── .gitignore ├── README.md ├── SECURITY.md ├── yarn.lock └── index.ts /.npmignore: -------------------------------------------------------------------------------- 1 | /* 2 | !/index.js 3 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "semi": false, 4 | "singleQuote": true, 5 | "trailingComma": "none", 6 | "arrowParens": "avoid" 7 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2022", 4 | "lib": [ 5 | "ES2022" 6 | ], 7 | "module": "commonjs", 8 | "moduleResolution": "node", 9 | "esModuleInterop": true, 10 | "sourceMap": true 11 | }, 12 | "files": [ 13 | "index.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### 0.4.0 | 2023-06-05 2 | 3 | - Rename to `@vscode/dts` 4 | - Increase minumum require Node.js version to 14 5 | - Add support for HTTPS_PROXY environment variable 6 | 7 | ### 0.3.1 | 2019-09-11 8 | 9 | - Improve help message. 10 | 11 | ### 0.3.0 | 2019-09-11 12 | 13 | - Add `-f` flag to `npx vscode-dts master -f` for forced removal of conflicting types. 14 | - When `@types/vscode` is present, remove `@types/vscode` folder entirely instead of just removing `@types/vscode/index.d.ts`. 15 | - Allow `npx vscode-dts dev `. [#2](https://github.com/microsoft/vscode-dts/issues/2). 16 | 17 | ### 0.2.0 | 2019-06-25 18 | 19 | - Public release. 20 | -------------------------------------------------------------------------------- /ci.yml: -------------------------------------------------------------------------------- 1 | trigger: 2 | batch: true 3 | branches: 4 | include: 5 | - main 6 | 7 | pr: [main] 8 | 9 | resources: 10 | repositories: 11 | - repository: templates 12 | type: github 13 | name: microsoft/vscode-engineering 14 | ref: main 15 | endpoint: Monaco 16 | 17 | parameters: 18 | - name: publishPackage 19 | displayName: 🚀 Publish 20 | type: boolean 21 | default: false 22 | 23 | extends: 24 | template: azure-pipelines/npm-package/pipeline.yml@templates 25 | parameters: 26 | npmPackages: 27 | - name: dts 28 | buildSteps: 29 | - script: yarn install --frozen-lockfile 30 | - script: yarn compile 31 | testPlatforms: [] 32 | 33 | publishPackage: ${{ parameters.publishPackage }} 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@vscode/dts", 3 | "version": "0.4.1", 4 | "description": "CLI utility for downloading vscode.d.ts and vscode.proposed.d.ts", 5 | "author": { 6 | "name": "Microsoft Corporation" 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/microsoft/vscode-dts.git" 11 | }, 12 | "bin": "index.js", 13 | "scripts": { 14 | "compile": "tsc -p .", 15 | "watch": "tsc -w -p .", 16 | "prepublishOnly": "tsc -p ." 17 | }, 18 | "license": "MIT", 19 | "dependencies": { 20 | "https-proxy-agent": "^7.0.0", 21 | "minimist": "^1.2.8", 22 | "prompts": "^2.4.2" 23 | }, 24 | "devDependencies": { 25 | "@types/minimist": "^1.2.2", 26 | "@types/node": "^14.0.0", 27 | "@types/prompts": "^2.4.4", 28 | "@types/rimraf": "^3.0.2", 29 | "typescript": "^5.1.3" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # IDE files 2 | .vscode/ 3 | 4 | # Logs 5 | logs 6 | *.log 7 | npm-debug.log* 8 | yarn-debug.log* 9 | yarn-error.log* 10 | 11 | # Runtime data 12 | pids 13 | *.pid 14 | *.seed 15 | *.pid.lock 16 | 17 | # Directory for instrumented libs generated by jscoverage/JSCover 18 | lib-cov 19 | 20 | # Coverage directory used by tools like istanbul 21 | coverage 22 | 23 | # nyc test coverage 24 | .nyc_output 25 | 26 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 27 | .grunt 28 | 29 | # Bower dependency directory (https://bower.io/) 30 | bower_components 31 | 32 | # node-waf configuration 33 | .lock-wscript 34 | 35 | # Compiled binary addons (https://nodejs.org/api/addons.html) 36 | build/Release 37 | 38 | # Dependency directories 39 | node_modules/ 40 | jspm_packages/ 41 | 42 | # TypeScript v1 declaration files 43 | typings/ 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional eslint cache 49 | .eslintcache 50 | 51 | # Optional REPL history 52 | .node_repl_history 53 | 54 | # Output of 'npm pack' 55 | *.tgz 56 | 57 | # Yarn Integrity file 58 | .yarn-integrity 59 | 60 | # dotenv environment variables file 61 | .env 62 | 63 | # next.js build output 64 | .next 65 | 66 | #source maps 67 | *.js.map 68 | *.js 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vscode-dts 2 | 3 | CLI utility for downloading vscode.d.ts and vscode.proposed.d.ts 4 | 5 | ## Usage 6 | 7 | ```bash 8 | ~ > npx vscode-dts 9 | vscode-dts: CLI utility for downloading vscode.d.ts and vscode.proposed..d.ts 10 | 11 | Usage: 12 | - npx vscode-dts dev Download vscode.proposaled..d.ts files 13 | - npx vscode-dts dev Download vscode.proposaled..d.ts files from git tag/branch of microsoft/vscode 14 | - npx vscode-dts Download vscode.d.ts from git tag/branch of microsoft/vscode 15 | - npx vscode-dts -f Download vscode.d.ts and remove conflicting types in node_modules/@types/vscode 16 | - npx vscode-dts Print Help 17 | - npx vscode-dts -h Print Help 18 | - npx vscode-dts --help Print Help 19 | ``` 20 | 21 | ## License 22 | 23 | [MIT](LICENSE) 24 | 25 | ## Contributing 26 | 27 | This project welcomes contributions and suggestions. Most contributions require you to agree to a 28 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us 29 | the rights to use your contribution. For details, visit https://cla.microsoft.com. 30 | 31 | When you submit a pull request, a CLA-bot will automatically determine whether you need to provide 32 | a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions 33 | provided by the bot. You will only need to do this once across all repos using our CLA. 34 | 35 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 36 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or 37 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 38 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@types/events@*": 6 | version "3.0.0" 7 | resolved "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz" 8 | 9 | "@types/glob@*": 10 | version "7.1.1" 11 | resolved "https://registry.npmjs.org/@types/glob/-/glob-7.1.1.tgz" 12 | dependencies: 13 | "@types/events" "*" 14 | "@types/minimatch" "*" 15 | "@types/node" "*" 16 | 17 | "@types/minimatch@*": 18 | version "3.0.3" 19 | resolved "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz" 20 | 21 | "@types/minimist@^1.2.2": 22 | version "1.2.5" 23 | resolved "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.5.tgz" 24 | integrity sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag== 25 | 26 | "@types/node@*", "@types/node@^14.0.0": 27 | version "14.18.63" 28 | resolved "https://registry.npmjs.org/@types/node/-/node-14.18.63.tgz" 29 | integrity sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ== 30 | 31 | "@types/prompts@^2.4.4": 32 | version "2.4.9" 33 | resolved "https://registry.npmjs.org/@types/prompts/-/prompts-2.4.9.tgz" 34 | integrity sha512-qTxFi6Buiu8+50/+3DGIWLHM6QuWsEKugJnnP6iv2Mc4ncxE4A/OJkjuVOA+5X0X1S/nq5VJRa8Lu+nwcvbrKA== 35 | dependencies: 36 | "@types/node" "*" 37 | kleur "^3.0.3" 38 | 39 | "@types/rimraf@^3.0.2": 40 | version "3.0.2" 41 | resolved "https://registry.npmjs.org/@types/rimraf/-/rimraf-3.0.2.tgz" 42 | integrity sha512-F3OznnSLAUxFrCEu/L5PY8+ny8DtcFRjx7fZZ9bycvXRi3KPTRS9HOitGZwvPg0juRhXFWIeKX58cnX5YqLohQ== 43 | dependencies: 44 | "@types/glob" "*" 45 | "@types/node" "*" 46 | 47 | agent-base@^7.0.2: 48 | version "7.1.1" 49 | resolved "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz" 50 | integrity sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA== 51 | dependencies: 52 | debug "^4.3.4" 53 | 54 | debug@^4.3.4, debug@4: 55 | version "4.3.5" 56 | resolved "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz" 57 | integrity sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg== 58 | dependencies: 59 | ms "2.1.2" 60 | 61 | https-proxy-agent@^7.0.0: 62 | version "7.0.5" 63 | resolved "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz" 64 | integrity sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw== 65 | dependencies: 66 | agent-base "^7.0.2" 67 | debug "4" 68 | 69 | kleur@^3.0.3: 70 | version "3.0.3" 71 | resolved "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz" 72 | integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== 73 | 74 | minimist@^1.2.8: 75 | version "1.2.8" 76 | resolved "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz" 77 | integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== 78 | 79 | ms@2.1.2: 80 | version "2.1.2" 81 | resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" 82 | integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== 83 | 84 | prompts@^2.4.2: 85 | version "2.4.2" 86 | resolved "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz" 87 | integrity sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q== 88 | dependencies: 89 | kleur "^3.0.3" 90 | sisteransi "^1.0.5" 91 | 92 | sisteransi@^1.0.5: 93 | version "1.0.5" 94 | resolved "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz" 95 | integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg== 96 | 97 | typescript@^5.1.3: 98 | version "5.5.2" 99 | resolved "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz" 100 | integrity sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew== 101 | -------------------------------------------------------------------------------- /index.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import https from 'https' 4 | import fs from 'fs' 5 | import path from 'path' 6 | import os from 'os' 7 | import prompts from 'prompts' 8 | import minimist from 'minimist' 9 | import { HttpsProxyAgent } from 'https-proxy-agent' 10 | import * as url from "url" 11 | 12 | const argv = minimist(process.argv.slice(2)) 13 | 14 | if (argv._.length === 0 || argv['h'] || argv['help']) { 15 | console.log(getHelpMessage()) 16 | } else if (argv._[0] === 'dev') { 17 | handleDev(argv._[1]) 18 | } else if (argv._[0]) { 19 | handleDefaultDownload(argv._[0], argv['f']) 20 | } 21 | 22 | function handleDev(gitTagOrBranch: string = 'main') { 23 | 24 | const proposalNames = getEnabledApiProposals(); 25 | if (proposalNames.length === 0) { 26 | console.error(`No proposals in the "enabledApiProposals"-property of package.json found.`) 27 | return; 28 | } 29 | 30 | for (const info of proposalNames) { 31 | 32 | const idx = info.lastIndexOf('@'); 33 | const name = idx < 0 ? info : info.slice(0, idx); 34 | const version = idx < 0 ? undefined : info.slice(idx + 1); 35 | 36 | const url = `https://raw.githubusercontent.com/microsoft/vscode/${gitTagOrBranch}/src/vscode-dts/vscode.proposed.${name}.d.ts` 37 | const outPath = path.resolve(process.cwd(), `./vscode.proposed.${name}.d.ts`) 38 | console.log(`Downloading vscode.proposed.${toGreenString(name)}.d.ts\nTo: ${outPath}\nFrom: ${url}`) 39 | 40 | download(url, outPath) 41 | .then(async () => { 42 | if (version) { 43 | const src = await fs.promises.readFile(outPath, 'utf-8'); 44 | const versionRegex = /\/\/\s*version:\s*(\d+)/i; 45 | const versionMatch = versionRegex.exec(src)[1]; 46 | if (versionMatch !== version) { 47 | console.log(toRedString(`Version mismatch for ${name}: Latest is ${versionMatch}, the request version ${version} DOES NOT exist.`)); 48 | } 49 | } 50 | }) 51 | .catch(err => console.error(err)) 52 | } 53 | 54 | console.log('Read more about proposed API at: https://code.visualstudio.com/api/advanced-topics/using-proposed-api') 55 | } 56 | 57 | function getEnabledApiProposals(): string[] { 58 | let dir = process.cwd(); 59 | while (true) { 60 | const packageJsonPath = path.resolve(dir, './package.json'); 61 | try { 62 | const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')) 63 | return Array.isArray(packageJson.enabledApiProposals) ? packageJson.enabledApiProposals : [] 64 | } catch { 65 | // continue 66 | } 67 | 68 | const next = path.dirname(dir); 69 | if (next === dir) { 70 | return []; 71 | } else { 72 | dir = next; 73 | } 74 | } 75 | } 76 | 77 | function handleDefaultDownload(gitTagOrBranch: string, force?: boolean) { 78 | // handle master->main rename for old consumers 79 | if (gitTagOrBranch === 'master') { 80 | gitTagOrBranch = 'main' 81 | } 82 | 83 | const url = `https://raw.githubusercontent.com/microsoft/vscode/${gitTagOrBranch}/src/vscode-dts/vscode.d.ts` 84 | const legacyUrl = `https://raw.githubusercontent.com/microsoft/vscode/${gitTagOrBranch}/src/vs/vscode.d.ts` 85 | const outPath = path.resolve(process.cwd(), './vscode.d.ts') 86 | console.log(`Downloading vscode.d.ts\nTo: ${outPath}\nFrom: ${url}`) 87 | 88 | download(url, outPath).catch(() => download(legacyUrl, outPath)).then(() => { 89 | if (force) { 90 | forceRemoveNodeModulesTypes() 91 | } else { 92 | removeNodeModulesTypes() 93 | } 94 | }) 95 | } 96 | 97 | function getHelpMessage() { 98 | return [ 99 | 'vscode-dts: CLI utility for downloading vscode.d.ts and vscode.proposed..d.ts', 100 | '', 101 | 'Usage:', 102 | ' - npx vscode-dts dev Download vscode.proposaled..d.ts files', 103 | ' - npx vscode-dts dev Download vscode.proposaled..d.ts files from git tag/branch of microsoft/vscode', 104 | ' - npx vscode-dts Download vscode.d.ts from git tag/branch of microsoft/vscode', 105 | ' - npx vscode-dts -f Download vscode.d.ts and remove conflicting types in node_modules/@types/vscode', 106 | ' - npx vscode-dts Print Help', 107 | ' - npx vscode-dts -h Print Help', 108 | ' - npx vscode-dts --help Print Help' 109 | ].join(os.EOL) 110 | } 111 | 112 | function download(link: string, outPath: string) { 113 | 114 | return new Promise((resolve, reject) => { 115 | 116 | const options: https.RequestOptions = url.parse(link); 117 | 118 | if (process.env.HTTPS_PROXY) { 119 | options.agent = new HttpsProxyAgent(process.env.HTTPS_PROXY); 120 | } 121 | 122 | https.get(options, (res) => { 123 | if (res.statusCode !== 200) { 124 | reject(`Failed to get ${link}`) 125 | return 126 | } 127 | 128 | const outStream = fs.createWriteStream(outPath) 129 | outStream.on('close', () => { 130 | resolve() 131 | }) 132 | 133 | res.pipe(outStream) 134 | }); 135 | }) 136 | } 137 | 138 | function forceRemoveNodeModulesTypes() { 139 | if (fs.existsSync('node_modules/vscode/vscode.d.ts')) { 140 | fs.unlinkSync('node_modules/vscode/vscode.d.ts') 141 | console.log('Removed node_modules/vscode/vscode.d.ts') 142 | } else if (fs.existsSync('node_modules/@types/vscode/index.d.ts')) { 143 | fs.rm('node_modules/@types/vscode', { force: true, recursive: true }, err => { 144 | if (err) { 145 | console.error('Failed to remove node_modules/@types/vscode') 146 | console.error(err) 147 | } else { 148 | console.log('Removed node_modules/@types/vscode') 149 | } 150 | }) 151 | } 152 | } 153 | 154 | function removeNodeModulesTypes() { 155 | if (fs.existsSync('node_modules/vscode/vscode.d.ts')) { 156 | prompts({ 157 | type: 'confirm', 158 | name: 'value', 159 | message: 'Remove conflicting vscode typing at node_modules/vscode/vscode.d.ts?' 160 | }).then(res => { 161 | if (res.value) { 162 | fs.unlinkSync('node_modules/vscode/vscode.d.ts') 163 | console.log('Removed node_modules/vscode/vscode.d.ts') 164 | } 165 | }) 166 | } else if (fs.existsSync('node_modules/@types/vscode/index.d.ts')) { 167 | prompts({ 168 | type: 'confirm', 169 | name: 'value', 170 | message: 'Remove conflicting vscode typing at node_modules/@types/vscode?' 171 | }).then(res => { 172 | if (res.value) { 173 | fs.rm('node_modules/@types/vscode', { force: true, recursive: true }, err => { 174 | if (err) { 175 | console.error('Failed to remove node_modules/@types/vscode') 176 | console.error(err) 177 | } else { 178 | console.log('Removed node_modules/@types/vscode') 179 | } 180 | }) 181 | } 182 | }) 183 | } 184 | } 185 | 186 | function toRedString(s: string) { 187 | return `\x1b[31m${s}\x1b[0m` 188 | } 189 | 190 | function toGreenString(s: string) { 191 | return `\x1b[32m${s}\x1b[0m` 192 | } 193 | --------------------------------------------------------------------------------