Updating sample extension to expose SDK commands
This commit is contained in:
Родитель
b9c6ec1e82
Коммит
fbf2da7ac9
|
@ -10,7 +10,8 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"vscode-dotnet-runtime": "file:../vscode-dotnet-runtime-extension",
|
||||
"vscode-dotnet-runtime-library": "file:../vscode-dotnet-runtime-library"
|
||||
"vscode-dotnet-runtime-library": "file:../vscode-dotnet-runtime-library",
|
||||
"vscode-dotnet-sdk": "file:../vscode-dotnet-sdk-extension"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^8.0.3",
|
||||
|
@ -9409,6 +9410,42 @@
|
|||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"../vscode-dotnet-sdk-extension": {
|
||||
"name": "vscode-dotnet-sdk",
|
||||
"version": "0.0.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/chai": "^4.2.7",
|
||||
"@types/mocha": "^8.0.3",
|
||||
"@types/node": "12.0.0",
|
||||
"@types/rimraf": "2.0.2",
|
||||
"@types/vscode": "^1.41.0",
|
||||
"chai": "^4.2.0",
|
||||
"child_process": "^1.0.2",
|
||||
"diff": ">=3.5.0",
|
||||
"glob": "^7.1.5",
|
||||
"hmac-drbg": "^1.0.1",
|
||||
"is-online": "^8.2.1",
|
||||
"mocha": "^8.1.3",
|
||||
"open": "^7.0.2",
|
||||
"rimraf": "2.6.3",
|
||||
"shelljs": "^0.8.3",
|
||||
"ts-loader": "^6.2.1",
|
||||
"tslint": "^5.20.1",
|
||||
"typescript": "3.4.5",
|
||||
"vscode-dotnet-runtime-library": "file:../vscode-dotnet-runtime-library",
|
||||
"vscode-dotnet-uninstall-library": "file:../vscode-dotnet-uninstall-library",
|
||||
"vscode-test": "^1.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"copy-webpack-plugin": "^6.1.1",
|
||||
"webpack": "^4.41.5",
|
||||
"webpack-cli": "^3.3.10"
|
||||
},
|
||||
"engines": {
|
||||
"vscode": "^1.41.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/code-frame": {
|
||||
"version": "7.12.13",
|
||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.13.tgz",
|
||||
|
@ -10608,6 +10645,10 @@
|
|||
"resolved": "../vscode-dotnet-runtime-library",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/vscode-dotnet-sdk": {
|
||||
"resolved": "../vscode-dotnet-sdk-extension",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
|
@ -21715,6 +21756,35 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"vscode-dotnet-sdk": {
|
||||
"version": "file:../vscode-dotnet-sdk-extension",
|
||||
"requires": {
|
||||
"@types/chai": "^4.2.7",
|
||||
"@types/mocha": "^8.0.3",
|
||||
"@types/node": "12.0.0",
|
||||
"@types/rimraf": "2.0.2",
|
||||
"@types/vscode": "^1.41.0",
|
||||
"chai": "^4.2.0",
|
||||
"child_process": "^1.0.2",
|
||||
"copy-webpack-plugin": "^6.1.1",
|
||||
"diff": ">=3.5.0",
|
||||
"glob": "^7.1.5",
|
||||
"hmac-drbg": "^1.0.1",
|
||||
"is-online": "^8.2.1",
|
||||
"mocha": "^8.1.3",
|
||||
"open": "^7.0.2",
|
||||
"rimraf": "2.6.3",
|
||||
"shelljs": "^0.8.3",
|
||||
"ts-loader": "^6.2.1",
|
||||
"tslint": "^5.20.1",
|
||||
"typescript": "3.4.5",
|
||||
"vscode-dotnet-runtime-library": "file:../vscode-dotnet-runtime-library",
|
||||
"vscode-dotnet-uninstall-library": "file:../vscode-dotnet-uninstall-library",
|
||||
"vscode-test": "^1.3.0",
|
||||
"webpack": "^4.41.5",
|
||||
"webpack-cli": "^3.3.10"
|
||||
}
|
||||
},
|
||||
"which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
|
|
|
@ -20,34 +20,52 @@
|
|||
"onCommand:sample.dotnet.acquire",
|
||||
"onCommand:sample.dotnet.uninstallAll",
|
||||
"onCommand:sample.dotnet.concurrentTest",
|
||||
"onCommand:sample.dotnet.showAcquisitionLog"
|
||||
"onCommand:sample.dotnet.showAcquisitionLog",
|
||||
"onCommand:sample.dotnet-sdk.acquire",
|
||||
"onCommand:sample.dotnet-sdk.uninstallAll",
|
||||
"onCommand:sample.dotnet-sdk.showAcquisitionLog"
|
||||
],
|
||||
"main": "./out/extension.js",
|
||||
"contributes": {
|
||||
"commands": [
|
||||
{
|
||||
"command": "sample.helloworld",
|
||||
"title": "Run a dynamically acquired .NET Core Hello World App",
|
||||
"title": "Run a dynamically acquired .NET Hello World App",
|
||||
"category": "Sample"
|
||||
},
|
||||
{
|
||||
"command": "sample.dotnet.acquire",
|
||||
"title": "Acquire .NET Core runtime",
|
||||
"title": "Acquire .NET runtime",
|
||||
"category": "Sample"
|
||||
},
|
||||
{
|
||||
"command": "sample.dotnet.uninstallAll",
|
||||
"title": "Uninstall all .NET Core runtimes",
|
||||
"title": "Uninstall all .NET runtimes",
|
||||
"category": "Sample"
|
||||
},
|
||||
{
|
||||
"command": "sample.dotnet.concurrentTest",
|
||||
"title": "Concurrently acquire all 2.X dotnets",
|
||||
"title": "Concurrently acquire all 2.X .NET Core runtimes",
|
||||
"category": "Sample"
|
||||
},
|
||||
{
|
||||
"command": "sample.dotnet.showAcquisitionLog",
|
||||
"title": "Show .NET Core runtime acquisition log",
|
||||
"title": "Show .NET runtime acquisition log",
|
||||
"category": "Sample"
|
||||
},
|
||||
{
|
||||
"command": "sample.dotnet-sdk.acquire",
|
||||
"title": "Acquire .NET SDK",
|
||||
"category": "Sample"
|
||||
},
|
||||
{
|
||||
"command": "sample.dotnet-sdk.uninstallAll",
|
||||
"title": "Uninstall all .NET SDKs",
|
||||
"category": "Sample"
|
||||
},
|
||||
{
|
||||
"command": "sample.dotnet-sdk.showAcquisitionLog",
|
||||
"title": "Show .NET SDK acquisition log",
|
||||
"category": "Sample"
|
||||
}
|
||||
]
|
||||
|
@ -61,7 +79,8 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"vscode-dotnet-runtime": "file:../vscode-dotnet-runtime-extension",
|
||||
"vscode-dotnet-runtime-library": "file:../vscode-dotnet-runtime-library"
|
||||
"vscode-dotnet-runtime-library": "file:../vscode-dotnet-runtime-library",
|
||||
"vscode-dotnet-sdk": "file:../vscode-dotnet-sdk-extension"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^8.0.3",
|
||||
|
|
|
@ -7,7 +7,8 @@ import * as cp from 'child_process';
|
|||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import { IDotnetAcquireResult } from 'vscode-dotnet-runtime-library';
|
||||
import * as extension from 'vscode-dotnet-runtime';
|
||||
import * as runtimeExtension from 'vscode-dotnet-runtime';
|
||||
import * as sdkExtension from 'vscode-dotnet-sdk';
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
|
@ -18,7 +19,8 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
NOTE: This sample should technically have the following in its package.json:
|
||||
|
||||
"extensionDependencies": [
|
||||
"ms-dotnettools.vscode-dotnet-runtime"
|
||||
"ms-dotnettools.vscode-dotnet-runtime",
|
||||
"ms-dotnettools.vscode-dotnet-sdk"
|
||||
]
|
||||
|
||||
This would enable the sample to require the vscode-dotnet-runtime extension
|
||||
|
@ -29,10 +31,13 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
*/
|
||||
|
||||
const requestingExtensionId = 'ms-dotnettools.sample-extension';
|
||||
extension.activate(context);
|
||||
runtimeExtension.activate(context);
|
||||
sdkExtension.activate(context);
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// -------------------runtime extension registrations------------------------
|
||||
|
||||
const sampleHelloWorldRegistration = vscode.commands.registerCommand('sample.helloworld', async () => {
|
||||
try {
|
||||
await vscode.commands.executeCommand('dotnet.showAcquisitionLog');
|
||||
|
@ -109,7 +114,7 @@ ${stderr}`);
|
|||
vscode.window.showErrorMessage(error.toString());
|
||||
}
|
||||
});
|
||||
const sampleshowAcquisitionLogRegistration = vscode.commands.registerCommand('sample.dotnet.showAcquisitionLog', async () => {
|
||||
const sampleShowAcquisitionLogRegistration = vscode.commands.registerCommand('sample.dotnet.showAcquisitionLog', async () => {
|
||||
try {
|
||||
await vscode.commands.executeCommand('dotnet.showAcquisitionLog');
|
||||
} catch (error) {
|
||||
|
@ -122,5 +127,46 @@ ${stderr}`);
|
|||
sampleAcquireRegistration,
|
||||
sampleDotnetUninstallAllRegistration,
|
||||
sampleConcurrentTest,
|
||||
sampleshowAcquisitionLogRegistration);
|
||||
sampleShowAcquisitionLogRegistration);
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// ---------------------sdk extension registrations--------------------------
|
||||
|
||||
const sampleSDKAcquireRegistration = vscode.commands.registerCommand('sample.dotnet-sdk.acquire', async (version) => {
|
||||
if (!version) {
|
||||
version = await vscode.window.showInputBox({
|
||||
placeHolder: '5.0',
|
||||
value: '5.0',
|
||||
prompt: '.NET SDK version, i.e. 5.0',
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
await vscode.commands.executeCommand('dotnet-sdk.showAcquisitionLog');
|
||||
await vscode.commands.executeCommand('dotnet-sdk.acquire', { version, requestingExtensionId });
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage(error.toString());
|
||||
}
|
||||
});
|
||||
const sampleSDKDotnetUninstallAllRegistration = vscode.commands.registerCommand('sample.dotnet-sdk.uninstallAll', async () => {
|
||||
try {
|
||||
await vscode.commands.executeCommand('dotnet-sdk.uninstallAll');
|
||||
vscode.window.showInformationMessage('.NET SDKs uninstalled.');
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage(error.toString());
|
||||
}
|
||||
});
|
||||
const sampleSDKShowAcquisitionLogRegistration = vscode.commands.registerCommand('sample.dotnet-sdk.showAcquisitionLog', async () => {
|
||||
try {
|
||||
await vscode.commands.executeCommand('dotnet-sdk.showAcquisitionLog');
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage(error.toString());
|
||||
}
|
||||
});
|
||||
|
||||
context.subscriptions.push(
|
||||
sampleSDKAcquireRegistration,
|
||||
sampleSDKDotnetUninstallAllRegistration,
|
||||
sampleSDKShowAcquisitionLogRegistration);
|
||||
}
|
||||
|
|
|
@ -60,11 +60,6 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
|
|||
const extensionConfiguration = extensionContext !== undefined && extensionContext.extensionConfiguration ?
|
||||
extensionContext.extensionConfiguration :
|
||||
vscode.workspace.getConfiguration(configPrefix);
|
||||
const extension = vscode.extensions.getExtension(dotnetCoreAcquisitionExtensionId);
|
||||
|
||||
if (!extension) {
|
||||
throw new Error(`Could not resolve dotnet acquisition extension '${dotnetCoreAcquisitionExtensionId}' location`);
|
||||
}
|
||||
|
||||
const eventStreamContext = {
|
||||
displayChannelName,
|
||||
|
|
|
@ -55,11 +55,6 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
|
|||
const extensionConfiguration = extensionContext !== undefined && extensionContext.extensionConfiguration ?
|
||||
extensionContext.extensionConfiguration :
|
||||
vscode.workspace.getConfiguration(configPrefix);
|
||||
const extension = vscode.extensions.getExtension(dotnetCoreAcquisitionExtensionId);
|
||||
|
||||
if (!extension) {
|
||||
throw new Error(`Could not resolve dotnet acquisition extension '${dotnetCoreAcquisitionExtensionId}' location`);
|
||||
}
|
||||
|
||||
const eventStreamContext = {
|
||||
displayChannelName,
|
||||
|
@ -112,27 +107,14 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
|
|||
const pathResult = callWithErrorHandling(async () => {
|
||||
eventStream.post(new DotnetSDKAcquisitionStarted());
|
||||
|
||||
let version: string | undefined = commandContext ? commandContext.version : undefined;
|
||||
if (!version) {
|
||||
version = await vscode.window.showInputBox({
|
||||
placeHolder: '5.0',
|
||||
value: '5.0',
|
||||
prompt: '.NET version, i.e. 5.0',
|
||||
});
|
||||
}
|
||||
if (!version) {
|
||||
displayWorker.showErrorMessage('No .NET SDK version provided', () => { /* No callback needed */ });
|
||||
return undefined;
|
||||
}
|
||||
|
||||
eventStream.post(new DotnetAcquisitionRequested(version!));
|
||||
const resolvedVersion = await versionResolver.getFullSDKVersion(version!);
|
||||
eventStream.post(new DotnetAcquisitionRequested(commandContext.version, commandContext.requestingExtensionId));
|
||||
const resolvedVersion = await versionResolver.getFullSDKVersion(commandContext.version);
|
||||
const dotnetPath = await acquisitionWorker.acquireSDK(resolvedVersion);
|
||||
displayWorker.showInformationMessage(`.NET SDK ${version} installed to ${dotnetPath.dotnetPath}`, () => { /* No callback needed */ });
|
||||
displayWorker.showInformationMessage(`.NET SDK ${commandContext.version} installed to ${dotnetPath.dotnetPath}`, () => { /* No callback needed */ });
|
||||
const pathEnvVar = path.dirname(dotnetPath.dotnetPath);
|
||||
setPathEnvVar(pathEnvVar, displayWorker);
|
||||
return dotnetPath;
|
||||
}, issueContext(undefined, 'acquireSDK'));
|
||||
}, issueContext(commandContext.errorConfiguration, 'acquireSDK'));
|
||||
return pathResult;
|
||||
});
|
||||
const dotnetUninstallAllRegistration = vscode.commands.registerCommand(`${commandPrefix}.${commandKeys.uninstallAll}`, async (commandContext: IDotnetUninstallContext | undefined) => {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
],
|
||||
"sourceMap": true,
|
||||
"rootDir": "src",
|
||||
"declaration": true,
|
||||
"strict": true /* enable all strict type-checking options */
|
||||
},
|
||||
"exclude": [
|
||||
|
|
Загрузка…
Ссылка в новой задаче