From a73eb0386b64a76da30336f763973a9db165655b Mon Sep 17 00:00:00 2001 From: Barbara Valdez <34872381+barbaravaldez@users.noreply.github.com> Date: Tue, 7 Jun 2022 10:12:41 -0700 Subject: [PATCH] Extend sql bindings api (#19651) --- extensions/sql-bindings/src/common/azureFunctionsUtils.ts | 4 ++-- extensions/sql-bindings/src/extension.ts | 5 ++++- extensions/sql-bindings/src/sql-bindings.d.ts | 6 ++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/extensions/sql-bindings/src/common/azureFunctionsUtils.ts b/extensions/sql-bindings/src/common/azureFunctionsUtils.ts index 3e0ea91937..81b404f052 100644 --- a/extensions/sql-bindings/src/common/azureFunctionsUtils.ts +++ b/extensions/sql-bindings/src/common/azureFunctionsUtils.ts @@ -237,7 +237,7 @@ export function waitForNewHostFile(): IFileFunctionObject { * Adds the required nuget package to the project * @param selectedProjectFile is the users selected project file path */ -export async function addNugetReferenceToProjectFile(selectedProjectFile: string): Promise { +export async function addSqlNugetReferenceToProjectFile(selectedProjectFile: string): Promise { await utils.executeCommand(`dotnet add "${selectedProjectFile}" package ${constants.sqlExtensionPackageName} --prerelease`); } @@ -531,7 +531,7 @@ export async function promptAndUpdateConnectionStringSetting(projectUri: vscode. } } // Add sql extension package reference to project. If the reference is already there, it doesn't get added again - await addNugetReferenceToProjectFile(projectUri.fsPath); + await addSqlNugetReferenceToProjectFile(projectUri.fsPath); } else { // if no AF project was found or there's more than one AF functions project in the workspace, // ask for the user to input the setting name diff --git a/extensions/sql-bindings/src/extension.ts b/extensions/sql-bindings/src/extension.ts index 86420ae230..29a554aff2 100644 --- a/extensions/sql-bindings/src/extension.ts +++ b/extensions/sql-bindings/src/extension.ts @@ -7,7 +7,7 @@ import { IConnectionInfo, ITreeNodeInfo } from 'vscode-mssql'; import { IExtension, BindingType, GetAzureFunctionsResult, ResultStatus, IConnectionStringInfo } from 'sql-bindings'; import { addSqlBinding, createAzureFunction, getAzureFunctions } from './services/azureFunctionsService'; import { launchAddSqlBindingQuickpick } from './dialogs/addSqlBindingQuickpick'; -import { promptForBindingType, promptAndUpdateConnectionStringSetting, promptForObjectName } from './common/azureFunctionsUtils'; +import { promptForBindingType, promptAndUpdateConnectionStringSetting, promptForObjectName, addSqlNugetReferenceToProjectFile } from './common/azureFunctionsUtils'; export async function activate(context: vscode.ExtensionContext): Promise { // register the add sql binding command @@ -34,6 +34,9 @@ export async function activate(context: vscode.ExtensionContext): Promise => { return getAzureFunctions(filePath); + }, + addSqlNugetReferenceToProjectFile: async (projectFile: string): Promise => { + return addSqlNugetReferenceToProjectFile(projectFile); } }; } diff --git a/extensions/sql-bindings/src/sql-bindings.d.ts b/extensions/sql-bindings/src/sql-bindings.d.ts index 61b0910d73..c6b44a391b 100644 --- a/extensions/sql-bindings/src/sql-bindings.d.ts +++ b/extensions/sql-bindings/src/sql-bindings.d.ts @@ -63,6 +63,12 @@ declare module 'sql-bindings' { * @returns array of names of Azure Functions in the file */ getAzureFunctions(filePath: string): Promise; + + /** + * Adds the required nuget package to the project + * @param selectedProjectFile is the users selected project file path + */ + addSqlNugetReferenceToProjectFile(selectedProjectFile: string): Promise } /**