Initial Pre-post deployment changes (#11703)

* Update Open Project to display pre-post deployment scripts in the project tree

* Address comments

* Fixed tests

* Update nonDeployScripts to noneDeployScripts and throw a warning message instead of informational message for prePostDeployCount
This commit is contained in:
Sakshi Sharma
2020-08-19 01:06:29 -07:00
committed by GitHub
parent 0f063d3a2e
commit e90341b3d2
7 changed files with 188 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ import * as utils from '../common/utils';
import * as xmlFormat from 'xml-formatter';
import * as os from 'os';
import { Uri } from 'vscode';
import { Uri, window } from 'vscode';
import { promises as fs } from 'fs';
import { DataSource } from './dataSources/dataSources';
@@ -25,6 +25,9 @@ export class Project {
public importedTargets: string[] = [];
public databaseReferences: IDatabaseReferenceProjectEntry[] = [];
public sqlCmdVariables: Record<string, string> = {};
public preDeployScripts: ProjectEntry[] = [];
public postDeployScripts: ProjectEntry[] = [];
public noneDeployScripts: ProjectEntry[] = [];
public get projectFolderPath() {
return Uri.file(path.dirname(this.projectFilePath)).fsPath;
@@ -70,6 +73,32 @@ export class Project {
this.files.push(this.createProjectEntry(folderElements[f].getAttribute(constants.Include), EntryType.Folder));
}
}
// find all pre-deployment scripts to include
let preDeployScriptCount: number = 0;
const preDeploy = itemGroup.getElementsByTagName(constants.PreDeploy);
for (let pre = 0; pre < preDeploy.length; pre++) {
this.preDeployScripts.push(this.createProjectEntry(preDeploy[pre].getAttribute(constants.Include), EntryType.File));
preDeployScriptCount++;
}
// find all post-deployment scripts to include
let postDeployScriptCount: number = 0;
const postDeploy = itemGroup.getElementsByTagName(constants.PostDeploy);
for (let post = 0; post < postDeploy.length; post++) {
this.postDeployScripts.push(this.createProjectEntry(postDeploy[post].getAttribute(constants.Include), EntryType.File));
postDeployScriptCount++;
}
if (preDeployScriptCount > 1 || postDeployScriptCount > 1) {
window.showWarningMessage(constants.prePostDeployCount, constants.okString);
}
// find all none-deployment scripts to include
const noneItems = itemGroup.getElementsByTagName(constants.None);
for (let n = 0; n < noneItems.length; n++) {
this.noneDeployScripts.push(this.createProjectEntry(noneItems[n].getAttribute(constants.Include), EntryType.File));
}
}
// find all import statements to include

View File

@@ -55,7 +55,12 @@ export class ProjectRootTreeItem extends BaseProjectTreeItem {
* Processes the list of files in a project file to constructs the tree
*/
private construct() {
for (const entry of this.project.files) {
let treeItemList = this.project.files
.concat(this.project.preDeployScripts)
.concat(this.project.postDeployScripts)
.concat(this.project.noneDeployScripts);
for (const entry of treeItemList) {
if (entry.type !== EntryType.File && entry.relativePath.startsWith(RelativeOuterPath)) {
continue;
}