mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Add nupkg database reference option for sql projects in vscode (#22882)
* add nupkg db ref option in vscode * add telemetry for nupkg db ref * update comment
This commit is contained in:
@@ -166,6 +166,7 @@ export const newText = localize('new', "New");
|
|||||||
export const selectDatabase = localize('selectDatabase', "Select database");
|
export const selectDatabase = localize('selectDatabase', "Select database");
|
||||||
export const done = localize('done', "Done");
|
export const done = localize('done', "Done");
|
||||||
export const nameMustNotBeEmpty = localize('nameMustNotBeEmpty', "Name must not be empty");
|
export const nameMustNotBeEmpty = localize('nameMustNotBeEmpty', "Name must not be empty");
|
||||||
|
export const versionMustNotBeEmpty = localize('versionMustNotBeEmpty', "Version must not be empty");
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ import * as constants from '../common/constants';
|
|||||||
import { getSqlProjectsInWorkspace, getSystemDatabase, validateSqlCmdVariableName } from '../common/utils';
|
import { getSqlProjectsInWorkspace, getSystemDatabase, validateSqlCmdVariableName } from '../common/utils';
|
||||||
import { DbServerValues, populateResultWithVars } from './utils';
|
import { DbServerValues, populateResultWithVars } from './utils';
|
||||||
import { AddDatabaseReferenceSettings } from '../controllers/projectController';
|
import { AddDatabaseReferenceSettings } from '../controllers/projectController';
|
||||||
import { IDacpacReferenceSettings, IProjectReferenceSettings, ISystemDatabaseReferenceSettings } from '../models/IDatabaseReferenceSettings';
|
import { IDacpacReferenceSettings, INugetPackageReferenceSettings, IProjectReferenceSettings, ISystemDatabaseReferenceSettings } from '../models/IDatabaseReferenceSettings';
|
||||||
import { Project } from '../models/project';
|
import { Project } from '../models/project';
|
||||||
import { getSystemDbOptions, promptDacpacLocation } from './addDatabaseReferenceDialog';
|
import { getSystemDbOptions, promptDacpacLocation } from './addDatabaseReferenceDialog';
|
||||||
import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/telemetry';
|
import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/telemetry';
|
||||||
|
import { ProjectType } from 'mssql';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -29,6 +30,11 @@ export async function addDatabaseReferenceQuickpick(project: Project): Promise<A
|
|||||||
[constants.projectLabel, constants.systemDatabase, constants.dacpacText] :
|
[constants.projectLabel, constants.systemDatabase, constants.dacpacText] :
|
||||||
[constants.systemDatabase, constants.dacpacText];
|
[constants.systemDatabase, constants.dacpacText];
|
||||||
|
|
||||||
|
// only add nupkg database reference option if project is SDK-style
|
||||||
|
if (project.sqlProjStyle === ProjectType.SdkStyle) {
|
||||||
|
referenceTypes.push(constants.nupkgText);
|
||||||
|
}
|
||||||
|
|
||||||
const referenceType = await vscode.window.showQuickPick(
|
const referenceType = await vscode.window.showQuickPick(
|
||||||
referenceTypes,
|
referenceTypes,
|
||||||
{ title: constants.referenceType, ignoreFocusOut: true });
|
{ title: constants.referenceType, ignoreFocusOut: true });
|
||||||
@@ -44,6 +50,8 @@ export async function addDatabaseReferenceQuickpick(project: Project): Promise<A
|
|||||||
return addSystemDatabaseReference(project);
|
return addSystemDatabaseReference(project);
|
||||||
case constants.dacpacText:
|
case constants.dacpacText:
|
||||||
return addDacpacReference(project);
|
return addDacpacReference(project);
|
||||||
|
case constants.nupkgText:
|
||||||
|
return addNupkgReference();
|
||||||
default:
|
default:
|
||||||
console.log(`Unknown reference type ${referenceType}`);
|
console.log(`Unknown reference type ${referenceType}`);
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -200,6 +208,75 @@ async function addDacpacReference(project: Project): Promise<IDacpacReferenceSet
|
|||||||
return referenceSettings;
|
return referenceSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function addNupkgReference(): Promise<INugetPackageReferenceSettings | undefined> {
|
||||||
|
// (steps continued from addDatabaseReferenceQuickpick)
|
||||||
|
// 2. Prompt for location
|
||||||
|
const location = await promptLocation();
|
||||||
|
if (!location) {
|
||||||
|
// User cancelled
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Prompt for NuGet package name
|
||||||
|
const nupkgName = await vscode.window.showInputBox(
|
||||||
|
{
|
||||||
|
title: constants.nupkgText,
|
||||||
|
placeHolder: constants.nupkgNamePlaceholder,
|
||||||
|
validateInput: (value) => {
|
||||||
|
return value ? undefined : constants.nameMustNotBeEmpty;
|
||||||
|
},
|
||||||
|
ignoreFocusOut: true
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!nupkgName) {
|
||||||
|
// User cancelled
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Prompt for NuGet package version
|
||||||
|
const nupkgVersion = await vscode.window.showInputBox(
|
||||||
|
{
|
||||||
|
title: constants.version,
|
||||||
|
placeHolder: constants.versionPlaceholder,
|
||||||
|
validateInput: (value) => {
|
||||||
|
return value ? undefined : constants.versionMustNotBeEmpty;
|
||||||
|
},
|
||||||
|
ignoreFocusOut: true
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!nupkgVersion) {
|
||||||
|
// User cancelled
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 5. Prompt for db/server values
|
||||||
|
const dbServerValues = await promptDbServerValues(location, path.parse(nupkgName).name);
|
||||||
|
if (!dbServerValues) {
|
||||||
|
// User cancelled
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. Prompt suppress unresolved ref errors
|
||||||
|
const suppressErrors = await promptSuppressUnresolvedRefErrors();
|
||||||
|
|
||||||
|
// 7. Construct result
|
||||||
|
|
||||||
|
const referenceSettings: INugetPackageReferenceSettings = {
|
||||||
|
packageName: nupkgName,
|
||||||
|
packageVersion: nupkgVersion,
|
||||||
|
suppressMissingDependenciesErrors: suppressErrors
|
||||||
|
};
|
||||||
|
|
||||||
|
populateResultWithVars(referenceSettings, dbServerValues);
|
||||||
|
|
||||||
|
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.addDatabaseReference)
|
||||||
|
.withAdditionalProperties({ referenceType: constants.nupkgText })
|
||||||
|
.send();
|
||||||
|
|
||||||
|
return referenceSettings;
|
||||||
|
}
|
||||||
|
|
||||||
async function promptLocation(): Promise<string | undefined> {
|
async function promptLocation(): Promise<string | undefined> {
|
||||||
return vscode.window.showQuickPick(
|
return vscode.window.showQuickPick(
|
||||||
constants.locationDropdownValues,
|
constants.locationDropdownValues,
|
||||||
|
|||||||
Reference in New Issue
Block a user