mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-16 17:22:29 -05:00
Prompts user for desired action when autorest is not installed (#17305)
* Giving user option to install autorest globally or run via npx * Adds message for when no files are generated (no models in spec) * Adding test * Reinstating the rest of the test suite * PR feedback * Fixing tests to stub new prompt when test runner doesn't have autorest installed * PR feedback * fix typo * fix typo
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { DoNotAskAgain, Install, nodeButNotAutorestFound, nodeNotFound } from '../common/constants';
|
||||
import { DoNotAskAgain, Install, nodeButNotAutorestFound, nodeNotFound, nodeButNotAutorestFoundPrompt, runViaNpx, installGlobally } from '../common/constants';
|
||||
import * as utils from '../common/utils';
|
||||
import * as semver from 'semver';
|
||||
import { DBProjectConfigurationKey } from './netcoreTool';
|
||||
@@ -48,7 +48,15 @@ export class AutorestHelper extends ShellExecutionHelper {
|
||||
|
||||
if (await utils.detectCommandInstallation(npxCommand)) {
|
||||
this._outputChannel.appendLine(nodeButNotAutorestFound);
|
||||
return `${npxCommand} ${autorestCommand}`;
|
||||
|
||||
const response = await vscode.window.showInformationMessage(nodeButNotAutorestFoundPrompt, installGlobally, runViaNpx);
|
||||
|
||||
if (response === installGlobally) {
|
||||
await this.runStreamedCommand('npm install autorest -g', this._outputChannel);
|
||||
return autorestCommand;
|
||||
} else if (response === runViaNpx) {
|
||||
return `${npxCommand} ${autorestCommand}`;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
@@ -63,7 +71,7 @@ export class AutorestHelper extends ShellExecutionHelper {
|
||||
public async generateAutorestFiles(specPath: string, outputFolder: string): Promise<string | undefined> {
|
||||
const commandExecutable = await this.detectInstallation();
|
||||
|
||||
if (commandExecutable === undefined) {
|
||||
if (!commandExecutable) {
|
||||
// unable to find autorest or npx
|
||||
|
||||
if (vscode.workspace.getConfiguration(DBProjectConfigurationKey)[nodejsDoNotAskAgainKey] !== true) {
|
||||
|
||||
Reference in New Issue
Block a user