Load profile support for sql project deploy (#10948)

* load database name from profile.xml

* load sqlcmd variables from profile

* Add warning text

* add tests

* fix file filter for windows

* add comments

* show SQLCMD variables in a table

* reset dialog before testing readPublishProfile callback
This commit is contained in:
Kim Santiago
2020-06-18 17:44:28 -07:00
committed by GitHub
parent eaf753f79e
commit 6ad33aa879
10 changed files with 205 additions and 11 deletions

View File

@@ -5,6 +5,7 @@
import * as vscode from 'vscode';
import * as os from 'os';
import * as constants from '../common/constants';
import { promises as fs } from 'fs';
/**
@@ -95,3 +96,20 @@ export function getSafeNonWindowsPath(filePath: string): string {
filePath = filePath.split('\\').join('/').split('"').join('');
return '"' + filePath + '"';
}
/**
* Read SQLCMD variables from xmlDoc and return them
* @param xmlDoc xml doc to read SQLCMD variables from. Format must be the same that sqlproj and publish profiles use
*/
export function readSqlCmdVariables(xmlDoc: any): Record<string, string> {
let sqlCmdVariables: Record<string, string> = {};
for (let i = 0; i < xmlDoc.documentElement.getElementsByTagName(constants.SqlCmdVariable).length; i++) {
const sqlCmdVar = xmlDoc.documentElement.getElementsByTagName(constants.SqlCmdVariable)[i];
const varName = sqlCmdVar.getAttribute(constants.Include);
const varValue = sqlCmdVar.getElementsByTagName(constants.DefaultValue)[0].childNodes[0].nodeValue;
sqlCmdVariables[varName] = varValue;
}
return sqlCmdVariables;
}