Correcting log messages during autorest execution selection (#17434)

* Correcting log messages during autorest execution choice

* Combining redundant strings

* Correcting icon + loc

* Fixing typo
This commit is contained in:
Benjin Dubishar
2021-10-22 09:01:11 -04:00
committed by GitHub
parent dc0651aef7
commit 86320155ed
3 changed files with 22 additions and 16 deletions

View File

@@ -227,8 +227,7 @@ export const browseButtonText = localize('browseButtonText', "Browse folder");
export const selectFolderStructure = localize('selectFolderStructure', "Select folder structure");
export const folderStructureLabel = localize('folderStructureLabel', "Folder structure");
export const WorkspaceFileExtension = '.code-workspace';
export const browseEllipsis = localize('browseEllipsis', "Browse...");
export const browseEllipsisWithIcon = `$(folder) ${browseEllipsis}`;
export const browseEllipsisWithIcon = `$(folder) ${localize('browseEllipsis', "Browse...")}`;
export const selectProjectLocation = localize('selectProjectLocation', "Select project location");
export const ProjectParentDirectoryNotExistError = (location: string): string => { return localize('dataworkspace.projectParentDirectoryNotExistError', "The selected project location '{0}' does not exist or is not a directory.", location); };
export const ProjectDirectoryAlreadyExistError = (projectName: string, location: string): string => { return localize('dataworkspace.projectDirectoryAlreadyExistError', "There is already a directory named '{0}' in the selected location: '{1}'.", projectName, location); };
@@ -423,9 +422,12 @@ export enum DatabaseProjectItemType {
// AutoRest
export const autorestPostDeploymentScriptName = 'PostDeploymentScript.sql';
export const nodeButNotAutorestFound = localize('nodeButNotAutorestFound', "Autorest tool not found in system path, but found Node.js. Running via npx. Please execute 'npm install autorest -g' to install permanently.");
export const nodeButNotAutorestFound = localize('nodeButNotAutorestFound', "Autorest tool not found in system path, but found Node.js. Prompting user for how to proceed. Execute 'npm install autorest -g' to install permanently and avoid this message.");
export const nodeNotFound = localize('nodeNotFound', "Neither Autorest nor Node.js (npx) found in system path. Please install Node.js for Autorest generation to work.");
export const nodeButNotAutorestFoundPrompt = localize('nodeButNotAutorestFoundPrompt', "Autorest is not installed. To proceed, choose whether to run Autorest from a temporary location via 'npx' or install Autorest globally then run.");
export const userSelectionInstallGlobally = localize('userSelectionInstallGlobally', "User selected to install autorest gloablly. Installing now...");
export const userSelectionRunNpx = localize('userSelectionRunNpx', "User selected to run via npx.");
export const userSelectionCancelled = localize('userSelectionCancelled', "User has cancelled selection for how to run autorest.");
export const installGlobally = localize('installGlobally', "Install globally");
export const runViaNpx = localize('runViaNpx', "Run via npx");

View File

@@ -834,7 +834,7 @@ export class ProjectsController {
public async selectAutorestSpecFile(): Promise<string | undefined> {
let quickpickSelection = await vscode.window.showQuickPick(
[constants.browseEllipsis],
[constants.browseEllipsisWithIcon],
{ title: constants.selectSpecFile, ignoreFocusOut: true });
if (!quickpickSelection) {
return;

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { DoNotAskAgain, Install, nodeButNotAutorestFound, nodeNotFound, nodeButNotAutorestFoundPrompt, runViaNpx, installGlobally } from '../common/constants';
import * as constants from '../common/constants';
import * as utils from '../common/utils';
import * as semver from 'semver';
import { DBProjectConfigurationKey } from './netcoreTool';
@@ -45,19 +45,24 @@ export class AutorestHelper extends ShellExecutionHelper {
if (await utils.detectCommandInstallation(autorestCommand)) {
return autorestCommand;
}
else if (await utils.detectCommandInstallation(npxCommand)) {
this._outputChannel.appendLine(constants.nodeButNotAutorestFound);
const response = await vscode.window.showInformationMessage(constants.nodeButNotAutorestFoundPrompt, constants.installGlobally, constants.runViaNpx);
if (await utils.detectCommandInstallation(npxCommand)) {
this._outputChannel.appendLine(nodeButNotAutorestFound);
const response = await vscode.window.showInformationMessage(nodeButNotAutorestFoundPrompt, installGlobally, runViaNpx);
if (response === installGlobally) {
if (response === constants.installGlobally) {
this._outputChannel.appendLine(constants.userSelectionInstallGlobally);
await this.runStreamedCommand('npm install autorest -g', this._outputChannel);
return autorestCommand;
} else if (response === runViaNpx) {
} else if (response === constants.runViaNpx) {
this._outputChannel.appendLine(constants.userSelectionRunNpx);
return `${npxCommand} ${autorestCommand}`;
} else {
this._outputChannel.appendLine(constants.userSelectionCancelled);
}
}
else {
this._outputChannel.appendLine(constants.nodeNotFound);
}
return undefined;
}
@@ -75,18 +80,17 @@ export class AutorestHelper extends ShellExecutionHelper {
// unable to find autorest or npx
if (vscode.workspace.getConfiguration(DBProjectConfigurationKey)[nodejsDoNotAskAgainKey] !== true) {
this._outputChannel.appendLine(nodeNotFound);
return; // user doesn't want to be prompted about installing it
}
// prompt user to install Node.js
const result = await vscode.window.showErrorMessage(nodeNotFound, DoNotAskAgain, Install);
const result = await vscode.window.showErrorMessage(constants.nodeNotFound, constants.DoNotAskAgain, constants.Install);
if (result === Install) {
if (result === constants.Install) {
//open install link
const nodejsInstallationUrl = 'https://nodejs.dev/download';
await vscode.env.openExternal(vscode.Uri.parse(nodejsInstallationUrl));
} else if (result === DoNotAskAgain) {
} else if (result === constants.DoNotAskAgain) {
const config = vscode.workspace.getConfiguration(DBProjectConfigurationKey);
await config.update(nodejsDoNotAskAgainKey, true, vscode.ConfigurationTarget.Global);
}