initial
This commit is contained in:
Коммит
3317b37e45
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/naming-convention": "warn",
|
||||
"@typescript-eslint/semi": "warn",
|
||||
"curly": "warn",
|
||||
"eqeqeq": "warn",
|
||||
"no-throw-literal": "warn",
|
||||
"semi": "off"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
dist
|
||||
out
|
||||
node_modules
|
||||
.vscode-test/
|
||||
*.vsix
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"dbaeumer.vscode-eslint"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
// A launch configuration that compiles the extension and then opens it inside a new window
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Run Extension",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"--extensionDevelopmentPath=${workspaceFolder}"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/out/**/*.js"
|
||||
],
|
||||
"preLaunchTask": "${defaultBuildTask}"
|
||||
},
|
||||
{
|
||||
"name": "Extension Tests",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"--extensionDevelopmentPath=${workspaceFolder}",
|
||||
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/out/test/**/*.js"
|
||||
],
|
||||
"preLaunchTask": "${defaultBuildTask}"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
"files.exclude": {
|
||||
"out": false // set this to true to hide the "out" folder with the compiled JS files
|
||||
},
|
||||
"search.exclude": {
|
||||
"out": true // set this to false to include "out" folder in search results
|
||||
},
|
||||
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
|
||||
"typescript.tsc.autoDetect": "off"
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "watch",
|
||||
"problemMatcher": "$tsc-watch",
|
||||
"isBackground": true,
|
||||
"presentation": {
|
||||
"reveal": "never"
|
||||
},
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
.vscode/**
|
||||
.vscode-test/**
|
||||
src/**
|
||||
**/*.js.map
|
||||
.gitignore
|
||||
.yarnrc
|
||||
vsc-extension-quickstart.md
|
||||
**/tsconfig.json
|
||||
**/.eslintrc.json
|
||||
**/*.map
|
||||
**/*.ts
|
|
@ -0,0 +1 @@
|
|||
--ignore-engines true
|
|
@ -0,0 +1,6 @@
|
|||
# Change Log
|
||||
|
||||
0.0.1
|
||||
- Initial version
|
||||
|
||||
[See here for the latest release notes.](https://github.com/microsoft/vscode-docs/blob/master/remote-release-notes)
|
|
@ -0,0 +1,73 @@
|
|||
MICROSOFT PRE-RELEASE SOFTWARE LICENSE TERMS
|
||||
MICROSOFT VISUAL STUDIO CODE REMOTE DEVELOPMENT EXTENSIONS
|
||||
|
||||
These license terms are an agreement between you and Microsoft Corporation (or based on where you live, one of its affiliates). They apply to the pre-release software named above. The terms also apply to any Microsoft services or updates for the software, except to the extent those have additional terms.
|
||||
|
||||
IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW.
|
||||
|
||||
1. INSTALLATION AND USE RIGHTS.
|
||||
a. General. You may use a copy of the software with each validly licensed copy of Microsoft Visual Studio Code. You may not use the software if you do not have a license for Microsoft Visual Studio Code. You may copy and install files from the software onto your application development devices, including physical devices and virtual machines or containers on those machines, which are (i) owned by you and located on-premises or hosted on your own private cloud or data center, or (ii) remote devices, virtual machines, or containers which are dedicated solely to your use and hosted for you on Microsoft Azure or by other cloud hosting providers (collectively, “Development Devices”). You and others in your organization may use these files on your Development Devices solely to develop and test applications. For clarity, “applications” means applications developed by you and others in your organization who are each licensed to use Microsoft Visual Studio Code.
|
||||
b. Demo Use. The uses permitted above include use of the software in demonstrating your applications.
|
||||
c. Third Party Components. The software may include third party components with separate legal notices or governed by other agreements, as may be described in the ThirdPartyNotices file(s) accompanying the software.
|
||||
d. Extensions. The software gives you the option to download other Microsoft and third party software packages from our extension marketplace or package managers. Those packages are under their own licenses, and not this agreement. Microsoft does not distribute, license or provide any warranties for any of the third party packages. By accessing or using our extension marketplace, you agree to the extension marketplace terms located at https://aka.ms/vsmarketplace-ToU.
|
||||
|
||||
2. PRE-RELEASE SOFTWARE. The software is a pre-release version. It may not work the way a final version of the software will. Microsoft may change it for the final, commercial version. We also may not release a commercial version. Microsoft is not obligated to provide maintenance, technical support or updates to you for the software.
|
||||
|
||||
3. ONLINE SERVICES IN THE SOFTWARE. Some features of the software make use of online services to provide you with updates to the software or extensions, to download or install additional software to enable use of this software, or to enable you to retrieve content, collaborate with others, or otherwise supplement your development. As used throughout this agreement, the term “software” includes these online service features.
|
||||
|
||||
4. DATA.
|
||||
a. Data Collection. The software may collect information about you and your use of the software, and send that to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may opt-out of many of these scenarios, but not all, as described in the product documentation located at https://code.visualstudio.com/docs/supporting/faq#_how-to-disable-telemetry-reporting. There may also be some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with Microsoft’s privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
|
||||
b. Processing of Personal Data. To the extent Microsoft is a processor or subprocessor of personal data in connection with the software, Microsoft makes the commitments in the European Union General Data Protection Regulation Terms of the Online Services Terms to all customers effective May 25, 2018, at https://go.microsoft.com/?linkid=9840733.
|
||||
|
||||
5. UPDATES. The software may periodically check for updates and download and install them for you. You may obtain updates only from Microsoft or authorized sources. Microsoft may need to update your system to provide you with updates. You agree to receive these automatic updates without any additional notice. Updates may not include or support all existing software features, services, or peripheral devices.
|
||||
|
||||
6. FEEDBACK. If you give feedback about the software to Microsoft, you give to Microsoft, without charge, the right to use, share and commercialize your feedback in any way and for any purpose. You will not give feedback that is subject to a license that requires Microsoft to license its software or documentation to third parties because we include your feedback in them. These rights survive this agreement.
|
||||
|
||||
7. SCOPE OF LICENSE. The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use the software only as expressly permitted in this agreement. In doing so, you must comply with any technical limitations in the software that only allow you to use it in certain ways. For example, if Microsoft technically limits or disables extensibility for the software, you may not extend the software by, among other things, loading or injecting into the software any non-Microsoft add-ins, macros, or packages; modifying the software registry settings; or adding features or functionality equivalent to that found in other Visual Studio products. You may not:
|
||||
* work around any technical limitations in the software;
|
||||
* reverse engineer, decompile or disassemble the software, or otherwise attempt to derive the source code for the software, except and to the extent required by third party licensing terms governing use of certain open source components that may be included with the software;
|
||||
* remove, minimize, block or modify any notices of Microsoft or its suppliers in the software;
|
||||
* use the software in any way that is against the law;
|
||||
* host, share, publish, rent or lease the software; or
|
||||
* provide the software as a stand-alone or integrated offering or combine it with any of your applications for others to use.
|
||||
|
||||
8. SUPPORT SERVICES. Because the software is “as is,” we may not provide support services for it.
|
||||
|
||||
9. ENTIRE AGREEMENT. This agreement, and the terms for supplements, updates, Internet-based services and support services that you use, are the entire agreement for the software and support services.
|
||||
|
||||
10. EXPORT RESTRICTIONS. You must comply with all domestic and international export laws and regulations that apply to the software, which include restrictions on destinations, end users and end use. For further information on export restrictions, visit (aka.ms/exporting).
|
||||
|
||||
11. APPLICABLE LAW. If you acquired the software in the United States, Washington State law applies to interpretation of and claims for breach of this agreement, and the laws of the state where you live apply to all other claims. If you acquired the software in any other country, its laws apply.
|
||||
|
||||
12. CONSUMER RIGHTS; REGIONAL VARIATIONS. This agreement describes certain legal rights. You may have other rights, including consumer rights, under the laws of your state or country. Separate and apart from your relationship with Microsoft, you may also have rights with respect to the party from which you acquired the software. This agreement does not change those other rights if the laws of your state or country do not permit it to do so. For example, if you acquired the software in one of the below regions, or mandatory country law applies, then the following provisions apply to you:
|
||||
a. Australia. You have statutory guarantees under the Australian Consumer Law and nothing in this agreement is intended to affect those rights.
|
||||
b. Canada. If you acquired the software in Canada, you may stop receiving updates by turning off the automatic update feature, disconnecting your device from the Internet (if and when you re-connect to the Internet, however, the software will resume checking for and installing updates), or uninstalling the software. The product documentation, if any, may also specify how to turn off updates for your specific device or software.
|
||||
c. Germany and Austria.
|
||||
(i) Warranty. The properly licensed software will perform substantially as described in any Microsoft materials that accompany the software. However, Microsoft gives no contractual guarantee in relation to the licensed software.
|
||||
(ii) Limitation of Liability. In case of intentional conduct, gross negligence, claims based on the Product Liability Act, as well as, in case of death or personal or physical injury, Microsoft is liable according to the statutory law.
|
||||
Subject to the foregoing clause (ii), Microsoft will only be liable for slight negligence if Microsoft is in breach of such material contractual obligations, the fulfillment of which facilitate the due performance of this agreement, the breach of which would endanger the purpose of this agreement and the compliance with which a party may constantly trust in (so-called "cardinal obligations"). In other cases of slight negligence, Microsoft will not be liable for slight negligence.
|
||||
|
||||
13. LEGAL EFFECT. This agreement describes certain legal rights. You may have other rights under the laws of your country. You may also have rights with respect to the party from whom you acquired the software. This agreement does not change your rights under the laws of your country if the laws of your country do not permit it to do so.
|
||||
|
||||
14. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED “AS-IS.” YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES OR CONDITIONS. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, MICROSOFT EXCLUDES THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
|
||||
15. LIMITATION ON AND EXCLUSION OF DAMAGES. YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES.
|
||||
|
||||
This limitation applies to (a) anything related to the software, services, content (including code) on third party Internet sites, or third party programs; and (b) claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law.
|
||||
|
||||
It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your country may not allow the exclusion or limitation of incidental, consequential or other damages.
|
||||
|
||||
Please note: As the software is distributed in Quebec, Canada, some of the clauses in this agreement are provided below in French.
|
||||
|
||||
Remarque : Ce logiciel étant distribué au Québec, Canada, certaines des clauses dans ce contrat sont fournies ci-dessous en français.
|
||||
|
||||
EXONÉRATION DE GARANTIE. Le logiciel visé par une licence est offert « tel quel ». Toute utilisation de ce logiciel est à votre seule risque et péril. Microsoft n’accorde aucune autre garantie expresse. Vous pouvez bénéficier de droits additionnels en vertu du droit local sur la protection des consommateurs, que ce contrat ne peut modifier. La ou elles sont permises par le droit locale, les garanties implicites de qualité marchande, d’adéquation à un usage particulier et d’absence de contrefaçon sont exclues.
|
||||
|
||||
LIMITATION DES DOMMAGES-INTÉRÊTS ET EXCLUSION DE RESPONSABILITÉ POUR LES DOMMAGES. Vous pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages directs uniquement à hauteur de 5,00 $ US. Vous ne pouvez prétendre à aucune indemnisation pour les autres dommages, y compris les dommages spéciaux, indirects ou accessoires et pertes de bénéfices.
|
||||
|
||||
Cette limitation concerne :
|
||||
* tout ce qui est relié au logiciel, aux services ou au contenu (y compris le code) figurant sur des sites Internet tiers ou dans des programmes tiers ; et
|
||||
* les réclamations au titre de violation de contrat ou de garantie, ou au titre de responsabilité stricte, de négligence ou d’une autre faute dans la limite autorisée par la loi en vigueur.
|
||||
Elle s’applique également, même si Microsoft connaissait ou devrait connaître l’éventualité d’un tel dommage. Si votre pays n’autorise pas l’exclusion ou la limitation de responsabilité pour les dommages indirects, accessoires ou de quelque nature que ce soit, il se peut que la limitation ou l’exclusion ci-dessus ne s’appliquera pas à votre égard.
|
||||
|
||||
EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous pourriez avoir d’autres droits prévus par les lois de votre pays. Le présent contrat ne modifie pas les droits que vous confèrent les lois de votre pays si celles-ci ne le permettent pas.
|
|
@ -0,0 +1,5 @@
|
|||
# Windows Subsystem for Linux Recommender
|
||||
|
||||
The **Remote - WSL recommender extension** adds commands that recommends ands help installing the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl) and the [Remote WSL extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl).
|
||||
|
||||
This extension is bundled with Visual Studio Code. It can be disabled but not uninstalled.
|
|
@ -0,0 +1,46 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
|
||||
const packageJSON = require('../package.json');
|
||||
|
||||
function getExtensionPath(dataFolder) {
|
||||
const wslExtensionsPath = path.join(os.homedir(), dataFolder, 'extensions');
|
||||
if (!fs.statSync(wslExtensionsPath).isDirectory()) {
|
||||
throw new Error('extensions folder not found at ' + wslExtensionsPath);
|
||||
}
|
||||
|
||||
const wslExtensionPath = path.join(wslExtensionsPath, 'ms-vscode-remote.remote-wsl-recommender-' + packageJSON.version);
|
||||
if (!fs.existsSync(wslExtensionPath)) {
|
||||
fs.mkdirSync(wslExtensionPath);
|
||||
}
|
||||
return wslExtensionPath;
|
||||
}
|
||||
|
||||
function copy(fileNames, srcDir, targetDir) {
|
||||
for (let file of fileNames) {
|
||||
let localPath = path.join(srcDir, file);
|
||||
let targetPath = path.join(targetDir, file);
|
||||
|
||||
if (!fs.statSync(localPath).isDirectory()) {
|
||||
console.log(`Copy ${file} to ${targetPath}`);
|
||||
fs.copyFileSync(localPath, targetPath);
|
||||
} else {
|
||||
if (!fs.existsSync(targetPath)) {
|
||||
fs.mkdirSync(targetPath);
|
||||
}
|
||||
let files = fs.readdirSync(localPath);
|
||||
copy(files, localPath, targetPath);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const srcDir = path.resolve(__dirname, '..');
|
||||
const wslExtensionPath = getExtensionPath(process.argv[2]);
|
||||
|
||||
copy(['dist', 'package.json', 'package.nls.json'], srcDir, wslExtensionPath);
|
|
@ -0,0 +1,102 @@
|
|||
{
|
||||
"name": "remote-wsl-recommender",
|
||||
"displayName": "%displayName%",
|
||||
"description": "%description%",
|
||||
"publisher": "ms-vscode-remote",
|
||||
"version": "0.0.1",
|
||||
"license": "SEE LICENSE IN LICENSE.txt",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Microsoft/vscode-remote-release.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Microsoft/vscode-remote-release/issues"
|
||||
},
|
||||
"engines": {
|
||||
"vscode": "^1.52.0"
|
||||
},
|
||||
"categories": [
|
||||
"Other"
|
||||
],
|
||||
"keywords": [
|
||||
"remote",
|
||||
"wsl",
|
||||
"remote development"
|
||||
],
|
||||
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
|
||||
"activationEvents": [
|
||||
"onCommand:remote-wsl-recommender.openFolder",
|
||||
"onCommand:remote-wsl-recommender.getStarted",
|
||||
"onStartupFinished"
|
||||
],
|
||||
"main": "./dist/extension.js",
|
||||
"enableProposedApi": true,
|
||||
"contributes": {
|
||||
"commands": [
|
||||
{
|
||||
"command": "remote-wsl-recommender.openFolder",
|
||||
"title": "Open Folder in WSL",
|
||||
"category": "Remote-WSL"
|
||||
},
|
||||
{
|
||||
"command": "remote-wsl-recommender.getStarted",
|
||||
"title": "Getting Started With WSL",
|
||||
"category": "Remote-WSL"
|
||||
}
|
||||
],
|
||||
"menus": {
|
||||
"commandPalette": [
|
||||
{
|
||||
"command": "remote-wsl-recommender.openFolder",
|
||||
"when": "remote-wsl-recommender.open_folder"
|
||||
},
|
||||
{
|
||||
"command": "remote-wsl-recommender.getStarted",
|
||||
"when": "false"
|
||||
}
|
||||
],
|
||||
"statusBar/windowIndicator": [
|
||||
{
|
||||
"command": "remote-wsl-recommender.openFolder",
|
||||
"when": "remote-wsl-recommender.open_folder",
|
||||
"group": "0_local_wsl@2"
|
||||
},
|
||||
{
|
||||
"command": "remote-wsl-recommender.getStarted",
|
||||
"when": "remote-wsl-recommender.show_doc",
|
||||
"group": "0_local_wsl@9"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "webpack --mode production",
|
||||
"compile": "webpack --mode none && yarn lint",
|
||||
"watch": "webpack --mode none --watch",
|
||||
"lint": "eslint src --ext ts",
|
||||
"pretest": "yarn run compile",
|
||||
"test": "node ./out/test/runTest.js",
|
||||
"patch-insiders": "yarn compile && node ./build/patch-local.js .vscode-insiders",
|
||||
"patch-dev": "yarn compile && node ./build/patch-local.js .vscode-oss-dev"
|
||||
},
|
||||
"dependencies": {
|
||||
"vscode-extension-telemetry": "0.1.1",
|
||||
"vscode-nls": "^5.0.0",
|
||||
"vscode-tas-client": "^0.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/vscode": "^1.52.0",
|
||||
"@types/node": "^14.0.27",
|
||||
"@types/copy-webpack-plugin": "^6.0.3",
|
||||
"eslint": "^7.6.0",
|
||||
"@typescript-eslint/eslint-plugin": "^3.8.0",
|
||||
"@typescript-eslint/parser": "^3.8.0",
|
||||
"typescript": "^4.0.2",
|
||||
"copy-webpack-plugin": "^6.0.3",
|
||||
"webpack": "^4.43.0",
|
||||
"webpack-cli": "^3.3.11",
|
||||
"ts-loader": "^7.0.5",
|
||||
"vsce": "^1.77.0",
|
||||
"vscode-nls-dev": "^3.3.1"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"displayName": "WSL Recommender",
|
||||
"description": "Recommends using the Windows Subsystem for Linux (WSL) and the Remote WSL extension."
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { promisify } from 'util';
|
||||
|
||||
import * as nls from 'vscode-nls';
|
||||
import { Experiment, Recommendation, setupTelemetry } from './telemetry';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export const REMOTE_WSL_RECOMMENDER_EXT_ID = 'ms-vscode-remote.remote-wsl-recommender';
|
||||
const REMOTE_WSL_EXT_ID = 'ms-vscode-remote.remote-wsl';
|
||||
|
||||
const CONTEXT_RECOMMEND_WSL_OPEN_FOLDER = 'remote-wsl-recommender.open_folder';
|
||||
const CONTEXT_RECOMMEND_WSL_SHOW_DOC = 'remote-wsl-recommender.show_doc';
|
||||
|
||||
const WIN10_1903 = { label: 'Windows 10, May 2019 Update, version 1903', build: 18362 };
|
||||
const WIN10_2004 = { label: 'Windows 10, May 2020 Update, version 2004', build: 19041 };
|
||||
|
||||
const WSL_DOC_URL = 'https://aka.ms/vscode-remote/wsl/getting-started';
|
||||
|
||||
export async function activate(context: vscode.ExtensionContext) {
|
||||
if (process.platform !== 'win32' || getWindowsBuildNumber() < WIN10_1903.build || vscode.env.remoteName) {
|
||||
return;
|
||||
}
|
||||
if (vscode.extensions.getExtension(REMOTE_WSL_EXT_ID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const telemetry = setupTelemetry(context);
|
||||
const enableOpenFolder = await telemetry.isExperimentEnabled(Experiment.openWSLFolder);
|
||||
if (enableOpenFolder) {
|
||||
vscode.commands.executeCommand('setContext', CONTEXT_RECOMMEND_WSL_OPEN_FOLDER, true);
|
||||
}
|
||||
|
||||
const enableShowDoc = await telemetry.isExperimentEnabled(Experiment.openWSLDocumentation);
|
||||
if (enableShowDoc) {
|
||||
vscode.commands.executeCommand('setContext', CONTEXT_RECOMMEND_WSL_SHOW_DOC, true);
|
||||
}
|
||||
|
||||
const subscriptions = context.subscriptions;
|
||||
subscriptions.push(vscode.commands.registerCommand('remote-wsl-recommender.openFolder', async () => {
|
||||
telemetry.reportCommand(Experiment.openWSLFolder);
|
||||
const isWSLInstalled = await checkIfWSLInstalled();
|
||||
if (!isWSLInstalled) {
|
||||
telemetry.reportRecommendation(Recommendation.installWSL, 'show');
|
||||
const installWSL = 'Install WSL';
|
||||
const response = await vscode.window.showErrorMessage(localize('installWSL', 'The Windows Subsystem for Linux is not yet installed in Windows. Click the button to learn more.', installWSL));
|
||||
if (response === installWSL) {
|
||||
telemetry.reportRecommendation(Recommendation.installWSL, 'open');
|
||||
await vscode.env.openExternal(vscode.Uri.parse('https://aka.ms/vscode-remote/wsl/install-wsl'));
|
||||
} else {
|
||||
telemetry.reportRecommendation(Recommendation.installWSL, 'close');
|
||||
}
|
||||
} else {
|
||||
telemetry.reportRecommendation(Recommendation.installWSLRemote, 'show');
|
||||
const installRemoteWSL = localize('configureButton', 'Install Extension');
|
||||
const res = await vscode.window.showInformationMessage(localize('installRemoteWSL', 'Ok to install the Remote-WSL extension? The extension allows to open a Visual Studio Code window where commands, extensions and the terminal run in Linux.'), installRemoteWSL);
|
||||
if (res === installRemoteWSL) {
|
||||
telemetry.reportRecommendation(Recommendation.installWSLRemote, 'open');
|
||||
await vscode.commands.executeCommand('workbench.extensions.action.showExtensionsWithIds', [REMOTE_WSL_EXT_ID]);
|
||||
} else {
|
||||
telemetry.reportRecommendation(Recommendation.installWSLRemote, 'close');
|
||||
}
|
||||
}
|
||||
// Start-Process wsl.exe -- -Verb runAs
|
||||
}));
|
||||
|
||||
subscriptions.push(vscode.commands.registerCommand('remote-wsl-recommender.getStarted', async () => {
|
||||
telemetry.reportCommand(Experiment.openWSLDocumentation);
|
||||
return vscode.env.openExternal(vscode.Uri.parse(WSL_DOC_URL));
|
||||
}));
|
||||
}
|
||||
|
||||
// this method is called when your extension is deactivated
|
||||
export function deactivate() { }
|
||||
|
||||
async function checkIfWSLInstalled(): Promise<boolean> {
|
||||
const dllPath = getLxssManagerDllPath();
|
||||
return !!(dllPath && await fileExists(dllPath));
|
||||
}
|
||||
|
||||
function getLxssManagerDllPath(): string | undefined {
|
||||
const is32ProcessOn64Windows = process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432');
|
||||
const systemRoot = process.env['SystemRoot'];
|
||||
if (systemRoot) {
|
||||
return path.join(systemRoot, is32ProcessOn64Windows ? 'Sysnative' : 'System32', 'lxss', 'LxssManager.dll');
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async function fileExists(location: string) {
|
||||
return promisify(fs.exists)(location);
|
||||
}
|
||||
|
||||
let windowsBuildNumber: number | undefined;
|
||||
|
||||
function getWindowsBuildNumber(): number {
|
||||
if (typeof windowsBuildNumber !== 'number') {
|
||||
const osVersion = (/(\d+)\.(\d+)\.(\d+)/g).exec(os.release());
|
||||
if (osVersion && osVersion.length === 4) {
|
||||
windowsBuildNumber = parseInt(osVersion[3]);
|
||||
} else {
|
||||
windowsBuildNumber = 0;
|
||||
}
|
||||
}
|
||||
return windowsBuildNumber;
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import TelemetryReporter from 'vscode-extension-telemetry';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { getExperimentationService, TargetPopulation, IExperimentationTelemetry } from 'vscode-tas-client';
|
||||
import { REMOTE_WSL_RECOMMENDER_EXT_ID } from './extension';
|
||||
|
||||
export function enableTelemetry(): boolean {
|
||||
return vscode.workspace.getConfiguration().get('telemetry.enableTelemetry') !== false;
|
||||
}
|
||||
|
||||
export function enableExperiments(): boolean {
|
||||
return vscode.workspace.getConfiguration().get('remote.WSLRecommender.allExperiments') === true;
|
||||
}
|
||||
|
||||
export enum Experiment {
|
||||
openWSLFolder = 'openWSLFolder',
|
||||
openWSLDocumentation = 'openWSLDocumentation'
|
||||
}
|
||||
|
||||
export enum Recommendation {
|
||||
installWSL = 'installWSL',
|
||||
installWSLRemote = 'installWSLRemote',
|
||||
}
|
||||
|
||||
export function setupTelemetry(context: vscode.ExtensionContext): WSLRemoteTelemetry {
|
||||
|
||||
const wslExtension = vscode.extensions.getExtension(REMOTE_WSL_RECOMMENDER_EXT_ID);
|
||||
if (!wslExtension) {
|
||||
throw new Error(`${REMOTE_WSL_RECOMMENDER_EXT_ID} not found in extensions.`);
|
||||
}
|
||||
const extensionPackage = wslExtension.packageJSON;
|
||||
|
||||
const { name, publisher, version, aiKey } = extensionPackage;
|
||||
|
||||
const baseReporter = new TelemetryReporter(`${publisher}.${name}`, version, aiKey);
|
||||
context.subscriptions.push(baseReporter);
|
||||
|
||||
const reporter = new ExperimentationTelemetry(baseReporter);
|
||||
const target = getTargetPopulation();
|
||||
|
||||
/* __GDPR__
|
||||
"query-expfeature" : {
|
||||
"ABExp.queriedFeature": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
const experimentService = getExperimentationService(`${publisher}.${name}`, version, target, reporter, context.globalState);
|
||||
return {
|
||||
reportRecommendation(kind: Recommendation, outcome: 'open' | 'hide' | 'show' | 'close'): void {
|
||||
if (!enableTelemetry()) {
|
||||
return;
|
||||
}
|
||||
/* __GDPR__
|
||||
"recommendation" : {
|
||||
"kind" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"outcome" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
const data: Record<string, string> = { kind, outcome };
|
||||
reporter.sendTelemetryEvent('recommendation', data);
|
||||
},
|
||||
reportCommand(experiment: Experiment): void {
|
||||
if (!enableTelemetry()) {
|
||||
return;
|
||||
}
|
||||
/* __GDPR__
|
||||
"command" : {
|
||||
"kind" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
const data: Record<string, string> = { };
|
||||
reporter.sendTelemetryEvent('command', data);
|
||||
},
|
||||
isExperimentEnabled(experiment: Experiment): Promise<boolean> {
|
||||
return enableExperiments() ? Promise.resolve(true) : experimentService.isCachedFlightEnabled(experiment);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export interface WSLRemoteTelemetry {
|
||||
reportRecommendation(kind: Recommendation, outcome: 'open' | 'hide' | 'show' | 'close'): void;
|
||||
reportCommand(kind: Experiment): void ;
|
||||
isExperimentEnabled(experiment: Experiment): Promise<boolean>;
|
||||
}
|
||||
class ExperimentationTelemetry implements IExperimentationTelemetry {
|
||||
|
||||
private sharedProperties: Record<string, string> = {};
|
||||
|
||||
constructor(private baseReporter: TelemetryReporter) { }
|
||||
|
||||
sendTelemetryEvent(eventName: string, properties?: Record<string, string>, measurements?: Record<string, number>) {
|
||||
this.baseReporter.sendTelemetryEvent(eventName, {
|
||||
...this.sharedProperties,
|
||||
...properties
|
||||
}, measurements);
|
||||
}
|
||||
|
||||
setSharedProperty(name: string, value: string): void {
|
||||
this.sharedProperties[name] = value;
|
||||
}
|
||||
|
||||
postEvent(eventName: string, props: Map<string, string>): void {
|
||||
const event: Record<string, string> = {};
|
||||
for (const [key, value] of props) {
|
||||
event[key] = value;
|
||||
}
|
||||
this.sendTelemetryEvent(eventName, event);
|
||||
}
|
||||
}
|
||||
|
||||
function getTargetPopulation() {
|
||||
const { quality } = getProductConfiguration(vscode.env.appRoot);
|
||||
switch (quality) {
|
||||
case 'stable': return TargetPopulation.Public;
|
||||
case 'insider': return TargetPopulation.Insiders;
|
||||
case 'exploration': return TargetPopulation.Internal;
|
||||
case undefined: return TargetPopulation.Team;
|
||||
default: return TargetPopulation.Public;
|
||||
}
|
||||
}
|
||||
|
||||
export interface IProductConfiguration {
|
||||
commit?: string;
|
||||
quality: string;
|
||||
serverDataFolderName?: string;
|
||||
updateUrl: string;
|
||||
}
|
||||
|
||||
let product: IProductConfiguration;
|
||||
|
||||
export function getProductConfiguration(appRoot: string): IProductConfiguration {
|
||||
if (!product) {
|
||||
const content = fs.readFileSync(path.join(appRoot, 'product.json')).toString();
|
||||
product = JSON.parse(content) as IProductConfiguration;
|
||||
}
|
||||
return product;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"outDir": "out",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"sourceMap": true,
|
||||
"rootDir": "src",
|
||||
"strict": true /* enable all strict type-checking options */
|
||||
/* Additional Checks */
|
||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
".vscode-test"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
//@ts-check
|
||||
/** @typedef {import('webpack').Configuration} WebpackConfig **/
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
const { NLSBundlePlugin } = require('vscode-nls-dev/lib/webpack-bundler');
|
||||
|
||||
const pkgPath = path.join(__dirname, 'package.json');
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
||||
const id = `${pkg.publisher}.${pkg.name}`;
|
||||
|
||||
/** @type WebpackConfig */
|
||||
module.exports = {
|
||||
entry: {
|
||||
extension: './src/extension.ts'
|
||||
},
|
||||
mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production')
|
||||
target: 'node', // extensions run in a node context
|
||||
node: {
|
||||
__dirname: false // leave the __dirname-behaviour intact
|
||||
},
|
||||
resolve: {
|
||||
mainFields: ['module', 'main'],
|
||||
extensions: ['.ts', '.js'] // support ts-files and js-files
|
||||
},
|
||||
module: {
|
||||
rules: [{
|
||||
test: /\.ts$/,
|
||||
exclude: /node_modules/,
|
||||
use: [{
|
||||
// vscode-nls-dev loader:
|
||||
// * rewrite nls-calls
|
||||
loader: 'vscode-nls-dev/lib/webpack-loader',
|
||||
options: {
|
||||
base: path.join(__dirname, 'src')
|
||||
}
|
||||
}, {
|
||||
// configure TypeScript loader:
|
||||
// * enable sources maps for end-to-end source maps
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
compilerOptions: {
|
||||
sourceMap: true,
|
||||
}
|
||||
}
|
||||
}]
|
||||
}]
|
||||
},
|
||||
externals: {
|
||||
'vscode': 'commonjs vscode',
|
||||
},
|
||||
output: {
|
||||
filename: '[name].js',
|
||||
path: path.join(__dirname, 'dist'),
|
||||
libraryTarget: "commonjs",
|
||||
devtoolModuleFilenameTemplate: "../[resource-path]",
|
||||
},
|
||||
devtool: 'source-map',
|
||||
plugins: [
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [
|
||||
{ from: 'src', to: '.', globOptions: { ignore: ['**/test/**', '**/*.ts'] }, noErrorOnMissing: true }
|
||||
]
|
||||
}),
|
||||
new NLSBundlePlugin(id)
|
||||
],
|
||||
};
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче