mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 09:35:39 -05:00
SQL Database Projects backend swap to DacFx/Tools Service (#22451)
* Move call to STS move api into project.ts (#22071) * move call to STS move api into project.ts * remove undefined * Remove convert to sdk style code (#22081) * remove convert to sdk style code * remove from package.json * Merging latest from main (#22097) * [SQL-Migration] Login migrations telemetry (#22038) This PR enhances telemetry for login migrations (and in the following ways: Add details for starting migration (number of logins migrating, type of logins) Log Migration result (number of errors per step, duration of each step, type of logins, if system error occurred) Add sql-migration extension to our telemetry Adds details when trying to connect to target Tracks clicking "done" from the wizard Fixes bucketizing for navigating telemetry in the login migration wizard Sample usage of kusto query for new telemetry: RawEventsADS | where EventName contains 'sql-migration' | extend view = tostring(Properties['view']) | extend action = tostring(Properties['action']) | extend buttonPressed = tostring(Properties['buttonpressed']) | extend pageTitle = tostring(Properties['pagetitle']) | extend adsVersion = tostring(Properties['common.adsversion']) | extend targetType = tostring(Properties['targettype']) | extend tenantId = tostring(Properties['tenantid']) | extend subscriptionId = tostring(Properties['subscriptionid']) | where view contains "login" //| where adsVersion contains "1.42.0-insider" | where ClientTimestamp >= ago(18h) | project EventName, ClientTimestamp, SessionId, view, pageTitle, action, buttonPressed, targetType , tenantId, subscriptionId , adsVersion, OSVersion, Properties * Add Secure Enclaves dropdown with customizable Advanced options (#22019) * Update extension READMEs (#22079) * Fix query-history README images (#22084) * [Loc] update to mssql and sql-migration xlf files (#22087) * [Loc] small fix to Portuguese lcl file (#22088) * [Loc] small fix to Portuguese lcl file * remove newline * Adding None bindings to the sqlProjects service (#22085) * Adding None bindings * updating names of None bindings --------- Co-authored-by: AkshayMata <akam520@gmail.com> Co-authored-by: Cheena Malhotra <13396919+cheenamalhotra@users.noreply.github.com> Co-authored-by: Charles Gagnon <chgagnon@microsoft.com> Co-authored-by: Alex Ma <alma1@microsoft.com> * Swap add and update sqlcmd variables in sql projects to use STS apis (#22086) * delete sqlcmd variable working * undo add * remove variable from add and update sqlcmd variable apis * hookup add and edit sqlcmd variable * update vscode-mssql.d.ts * move add and edit to project.ts * update STS and tests * move delete sqlcmd variable to project.ts (#22104) * add test for add and edit sqlcmd variable (#22107) * Swapping property access to STS (#22115) * checkpoint * Adding sqlproj property bindings * Swapping out property loading and setting * consolidating to this.sqlProjService * Update dacpac reference to use STS api (#22116) * Update add dacpac reference to use STS api * remove changes for project ref * validate unset settings from add database reference dialog * update one more place getting sqlprojservice * addressing comments * fix path for dacpac reference (#22143) * Swap add project reference to call STS (#22148) * initial changes for swapping add project reference * fix include path * move common logic to helper function * read sqlcmd variables from STS (#22147) * Swapping .sqlproj- and crossplat compatibility-related functions to use STS (#22146) * Supporting roundtrip * Updating sqlproj style checks and cross-platform compatibility to use STS * removing unnecessary awaits * Fixing assertions * Adding roundtrip update confirmations * test cleanup * cleaning up comment; localizing error * Swap add system db reference (#22171) * swap adding system database references * fix tests * remove only in test * Read database references from STS (#22179) * Read database references from STS * fix system dacpac names * fix project reference name * Swap changeTargetPlatform to call STS (#22172) * swap changeTargetPlatform to call STS * Address comments * De-duplicating enum for SystemDatabase (#22196) * Deudping SystemDatabase enum * simplifying enum refs * Removing the now-unused imports code from SqlProjects (#22199) * Removing unused importTargets entries * whitespace; also to retrigger github checks on correct branch * Hooking in Move() for Nones and PublishProfiles (#22200) * Swap delete database reference to call STS (#22215) * initial changes * update contracts * remove unnecessary info from SystemDatabaseReferenceProjectEntry * uppercase master and msdb * cleanup * update test * update comment * undo change in projectController.ts * remove unused system dacpac helper functions (#22204) * more cleanup of project.ts (#22242) * fix a couple database reference tests (#22248) * Organizing sqlcmd variable and db reference code (#22284) * organize database references and sqlcmd variable functions * separate database reference tests * Script and folder get + add support (#22166) * Initial sqlobjectscripts * adding mock filter * test fixing * another test passing * swapping pre/post/none checkpoint * awaiters * convert addExistingItem * swapping folders * removing print * stripping out project folder and file readers * adding some regions * Updating sqlproj style checks and cross-platform compatibility to use STS * Updating sqlproj style checks and cross-platform compatibility to use STS * added type property to tree items * projectController swapovers * removing imported targets * Deleting the last of the TS XML parsing! * Removing old functions * renamed readNoneScripts to readNoneItems * fixing path passed to STS calls * remove system dacpac tests that were moved to DacFx (#22299) * fix error when opening file after adding a file to sql project (#22309) * fix error when opening file after adding a file to sql project * remove unused import * fix exclude for table and externalStreamingJob (#22310) * add reload project (#22313) * set DSP from STS (#22320) * fix adding post-deployment script and existing item (#22317) * Test cleanup for .sqlproj content operations (#22330) * Fixing up tests * sqlproj content operations tests * remove only * Cleanup * Correcting collation * cleanup constants.ts (#22336) * fix folders not showing in project tree (#22319) * Fix project controller tests (#22327) * fixing ProjectController tests after swap * remove only from database reference tests * change system dbs back to lowercase in sql projects (#22353) * Bump tools service * Updated yarn.lock file * pass SystemDacpacsLocation when building legacy style sql projects (#22329) * Benjin/fix types (#22365) * Updated yarn.lock file * Fixing types * fix projectController tests (#22375) * Fixing the deletion flow for files and folders (#22366) * checkpoint * PR feedback * Fixing up SDK-style operations project test group (#22377) * Fixing up SDK-style project test group * Removing .only * Fixing up database reference tests (#22380) * Fixing DB reference test group * Extra cleanup * removing only * Consolidating None and PublishProfile; lighting up test (#22382) * Lighting up project property tests (#22395) * Checkpoint * Lighting up project property tests * removing timeout * Fixing buildHelper test (#22400) * Unskipping up roundtrip test (#22397) * Refactoring database references to split literalVariable from databaseName (#22412) * refactoring database references to split databaseVariableLiteralValue out from databaseName * renaming more properties * Removing branch in entry population * removing only * Fixing baselines for delete test * PR feedback * Fixing up ProjectTree tests (#22419) * Fixing up projectTree tests * remove only * Updating projectController exclude test (#22413) * Updating test * moving filtering for external folders to readFolders() method * Removing EntryType import * fix ups (#22435) * adding extra info for test failure * hide exclude folder from context menu until it's supported (#22454) * Adding current test name to generated folder to avoid conflicts (#22478) * Adding current test name to generated folder to avoid conflicts * passing correct test parameter in * Adding trimming and entropy * Deleting unused baselines (#22497) * Replacing addToProject() with addSqlObjectScripts() (#22489) * checkpoint * Fixing test * Updating file scraper function to filter only to .sql files (no folders, no txt) * changing var names to reflect that the lists only contain .sql scripts --------- Co-authored-by: Kim Santiago <31145923+kisantia@users.noreply.github.com> Co-authored-by: AkshayMata <akam520@gmail.com> Co-authored-by: Cheena Malhotra <13396919+cheenamalhotra@users.noreply.github.com> Co-authored-by: Charles Gagnon <chgagnon@microsoft.com> Co-authored-by: Alex Ma <alma1@microsoft.com>
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SystemDatabase } from 'mssql';
|
||||
import { Uri } from 'vscode';
|
||||
import { SystemDatabase } from './projectEntry';
|
||||
|
||||
export interface IDatabaseReferenceSettings {
|
||||
databaseName?: string;
|
||||
databaseVariableLiteralValue?: string;
|
||||
suppressMissingDependenciesErrors: boolean;
|
||||
}
|
||||
|
||||
@@ -15,18 +15,19 @@ export interface ISystemDatabaseReferenceSettings extends IDatabaseReferenceSett
|
||||
systemDb: SystemDatabase;
|
||||
}
|
||||
|
||||
export interface IDacpacReferenceSettings extends IDatabaseReferenceSettings {
|
||||
dacpacFileLocation: Uri;
|
||||
export interface IUserDatabaseReferenceSettings extends IDatabaseReferenceSettings {
|
||||
databaseName?: string;
|
||||
databaseVariable?: string;
|
||||
serverName?: string;
|
||||
serverVariable?: string;
|
||||
}
|
||||
|
||||
export interface IProjectReferenceSettings extends IDatabaseReferenceSettings {
|
||||
export interface IDacpacReferenceSettings extends IUserDatabaseReferenceSettings {
|
||||
dacpacFileLocation: Uri;
|
||||
}
|
||||
|
||||
export interface IProjectReferenceSettings extends IUserDatabaseReferenceSettings {
|
||||
projectRelativePath: Uri | undefined;
|
||||
projectName: string;
|
||||
projectGuid: string;
|
||||
databaseVariable?: string;
|
||||
serverName?: string;
|
||||
serverVariable?: string;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -44,25 +44,29 @@ export class FileProjectEntry extends ProjectEntry implements IFileProjectEntry
|
||||
}
|
||||
|
||||
export class DacpacReferenceProjectEntry extends FileProjectEntry implements IDatabaseReferenceProjectEntry {
|
||||
databaseSqlCmdVariableValue?: string;
|
||||
databaseSqlCmdVariableName?: string;
|
||||
databaseVariableLiteralValue?: string;
|
||||
databaseSqlCmdVariable?: string;
|
||||
serverName?: string;
|
||||
serverSqlCmdVariable?: string;
|
||||
serverSqlCmdVariableName?: string;
|
||||
serverSqlCmdVariableValue?: string;
|
||||
suppressMissingDependenciesErrors: boolean;
|
||||
|
||||
constructor(settings: IDacpacReferenceSettings) {
|
||||
super(settings.dacpacFileLocation, '', EntryType.DatabaseReference);
|
||||
this.databaseSqlCmdVariable = settings.databaseVariable;
|
||||
this.databaseVariableLiteralValue = settings.databaseName;
|
||||
this.serverName = settings.serverName;
|
||||
this.serverSqlCmdVariable = settings.serverVariable;
|
||||
super(settings.dacpacFileLocation, /* relativePath doesn't get set for database references */ '', EntryType.DatabaseReference);
|
||||
this.suppressMissingDependenciesErrors = settings.suppressMissingDependenciesErrors;
|
||||
|
||||
this.databaseVariableLiteralValue = settings.databaseVariableLiteralValue;
|
||||
this.databaseSqlCmdVariableName = settings.databaseName;
|
||||
this.databaseSqlCmdVariableValue = settings.databaseVariable;
|
||||
|
||||
this.serverSqlCmdVariableName = settings.serverName;
|
||||
this.serverSqlCmdVariableValue = settings.serverVariable;
|
||||
}
|
||||
|
||||
/**
|
||||
* File name that gets displayed in the project tree
|
||||
*/
|
||||
public get databaseName(): string {
|
||||
public get referenceName(): string {
|
||||
return path.parse(utils.getPlatformSafeFileEntryPath(this.fsUri.fsPath)).name;
|
||||
}
|
||||
|
||||
@@ -73,49 +77,44 @@ export class DacpacReferenceProjectEntry extends FileProjectEntry implements IDa
|
||||
}
|
||||
|
||||
export class SystemDatabaseReferenceProjectEntry extends FileProjectEntry implements IDatabaseReferenceProjectEntry {
|
||||
constructor(uri: Uri, public ssdtUri: Uri, public databaseVariableLiteralValue: string | undefined, public suppressMissingDependenciesErrors: boolean) {
|
||||
super(uri, '', EntryType.DatabaseReference);
|
||||
constructor(public referenceName: string, public databaseVariableLiteralValue: string | undefined, public suppressMissingDependenciesErrors: boolean) {
|
||||
super(Uri.file(referenceName), referenceName, EntryType.DatabaseReference);
|
||||
}
|
||||
|
||||
/**
|
||||
* File name that gets displayed in the project tree
|
||||
* Returns the name of the system database - this is used for deleting the system database reference
|
||||
*/
|
||||
public get databaseName(): string {
|
||||
return path.parse(utils.getPlatformSafeFileEntryPath(this.fsUri.fsPath)).name;
|
||||
}
|
||||
|
||||
public override pathForSqlProj(): string {
|
||||
// need to remove the leading slash for system database path for build to work on Windows
|
||||
return utils.convertSlashesForSqlProj(this.fsUri.path.substring(1));
|
||||
}
|
||||
|
||||
public ssdtPathForSqlProj(): string {
|
||||
// need to remove the leading slash for system database path for build to work on Windows
|
||||
return utils.convertSlashesForSqlProj(this.ssdtUri.path.substring(1));
|
||||
return this.referenceName;
|
||||
}
|
||||
}
|
||||
|
||||
export class SqlProjectReferenceProjectEntry extends FileProjectEntry implements IDatabaseReferenceProjectEntry {
|
||||
projectName: string;
|
||||
projectGuid: string;
|
||||
databaseVariableLiteralValue?: string;
|
||||
databaseSqlCmdVariable?: string;
|
||||
serverName?: string;
|
||||
serverSqlCmdVariable?: string;
|
||||
suppressMissingDependenciesErrors: boolean;
|
||||
public projectName: string;
|
||||
public projectGuid: string;
|
||||
public databaseVariableLiteralValue?: string;
|
||||
public databaseSqlCmdVariableName?: string;
|
||||
public databaseSqlCmdVariableValue?: string;
|
||||
public serverSqlCmdVariableName?: string;
|
||||
public serverSqlCmdVariableValue?: string;
|
||||
public suppressMissingDependenciesErrors: boolean;
|
||||
|
||||
constructor(settings: IProjectReferenceSettings) {
|
||||
super(settings.projectRelativePath!, '', EntryType.DatabaseReference);
|
||||
super(settings.projectRelativePath!, /* relativePath doesn't get set for database references */ '', EntryType.DatabaseReference);
|
||||
|
||||
this.projectName = settings.projectName;
|
||||
this.projectGuid = settings.projectGuid;
|
||||
this.databaseSqlCmdVariable = settings.databaseVariable;
|
||||
this.databaseVariableLiteralValue = settings.databaseName;
|
||||
this.serverName = settings.serverName;
|
||||
this.serverSqlCmdVariable = settings.serverVariable;
|
||||
this.suppressMissingDependenciesErrors = settings.suppressMissingDependenciesErrors;
|
||||
|
||||
this.databaseVariableLiteralValue = settings.databaseVariableLiteralValue;
|
||||
this.databaseSqlCmdVariableName = settings.databaseName;
|
||||
this.databaseSqlCmdVariableValue = settings.databaseVariable;
|
||||
|
||||
this.serverSqlCmdVariableName = settings.serverName;
|
||||
this.serverSqlCmdVariableValue = settings.serverVariable;
|
||||
}
|
||||
|
||||
public get databaseName(): string {
|
||||
public get referenceName(): string {
|
||||
return this.projectName;
|
||||
}
|
||||
|
||||
@@ -136,8 +135,3 @@ export enum DatabaseReferenceLocation {
|
||||
differentDatabaseSameServer,
|
||||
differentDatabaseDifferentServer
|
||||
}
|
||||
|
||||
export enum SystemDatabase {
|
||||
master,
|
||||
msdb
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
import { DatabaseProjectItemType } from '../../common/constants';
|
||||
|
||||
/**
|
||||
* Base class for an item that appears in the ADS project tree
|
||||
@@ -21,6 +22,10 @@ export abstract class BaseProjectTreeItem {
|
||||
|
||||
abstract get treeItem(): vscode.TreeItem;
|
||||
|
||||
abstract get type(): DatabaseProjectItemType;
|
||||
|
||||
public entryKey?: string;
|
||||
|
||||
public get friendlyName(): string {
|
||||
return path.parse(this.relativeProjectUri.path).base;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ export class DatabaseReferencesTreeItem extends BaseProjectTreeItem {
|
||||
*/
|
||||
constructor(projectNodeName: string, sqlprojUri: vscode.Uri, databaseReferences: IDatabaseReferenceProjectEntry[]) {
|
||||
super(vscode.Uri.file(path.join(projectNodeName, constants.databaseReferencesNodeName)), sqlprojUri);
|
||||
|
||||
this.construct(databaseReferences);
|
||||
}
|
||||
|
||||
@@ -44,9 +43,13 @@ export class DatabaseReferencesTreeItem extends BaseProjectTreeItem {
|
||||
return this.references;
|
||||
}
|
||||
|
||||
public get type(): constants.DatabaseProjectItemType {
|
||||
return constants.DatabaseProjectItemType.referencesRoot;
|
||||
}
|
||||
|
||||
public get treeItem(): vscode.TreeItem {
|
||||
const refFolderItem = new vscode.TreeItem(this.relativeProjectUri, vscode.TreeItemCollapsibleState.Collapsed);
|
||||
refFolderItem.contextValue = constants.DatabaseProjectItemType.referencesRoot;
|
||||
refFolderItem.contextValue = this.type;
|
||||
refFolderItem.iconPath = IconPathHelper.referenceGroup;
|
||||
|
||||
return refFolderItem;
|
||||
@@ -55,17 +58,22 @@ export class DatabaseReferencesTreeItem extends BaseProjectTreeItem {
|
||||
|
||||
export class DatabaseReferenceTreeItem extends BaseProjectTreeItem {
|
||||
constructor(private reference: IDatabaseReferenceProjectEntry, referencesNodeRelativeProjectUri: vscode.Uri, sqlprojUri: vscode.Uri) {
|
||||
super(vscode.Uri.file(path.join(referencesNodeRelativeProjectUri.fsPath, reference.databaseName)), sqlprojUri);
|
||||
super(vscode.Uri.file(path.join(referencesNodeRelativeProjectUri.fsPath, reference.referenceName)), sqlprojUri);
|
||||
this.entryKey = this.friendlyName;
|
||||
}
|
||||
|
||||
public get children(): BaseProjectTreeItem[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
public get type(): constants.DatabaseProjectItemType {
|
||||
return constants.DatabaseProjectItemType.reference;
|
||||
}
|
||||
|
||||
public get treeItem(): vscode.TreeItem {
|
||||
const refItem = new vscode.TreeItem(this.relativeProjectUri, vscode.TreeItemCollapsibleState.None);
|
||||
refItem.label = this.reference.databaseName;
|
||||
refItem.contextValue = constants.DatabaseProjectItemType.reference;
|
||||
refItem.label = this.reference.referenceName;
|
||||
refItem.contextValue = this.type;
|
||||
refItem.iconPath = IconPathHelper.referenceDatabase;
|
||||
|
||||
return refItem;
|
||||
|
||||
@@ -16,19 +16,25 @@ import { IconPathHelper } from '../../common/iconHelper';
|
||||
export class FolderNode extends BaseProjectTreeItem {
|
||||
public fileChildren: { [childName: string]: (FolderNode | FileNode) } = {};
|
||||
public fileSystemUri: vscode.Uri;
|
||||
public override entryKey: string;
|
||||
|
||||
constructor(folderPath: vscode.Uri, sqlprojUri: vscode.Uri) {
|
||||
constructor(folderPath: vscode.Uri, sqlprojUri: vscode.Uri, entryKey: string) {
|
||||
super(fsPathToProjectUri(folderPath, sqlprojUri), sqlprojUri);
|
||||
this.fileSystemUri = folderPath;
|
||||
this.entryKey = entryKey;
|
||||
}
|
||||
|
||||
public get children(): BaseProjectTreeItem[] {
|
||||
return Object.values(this.fileChildren).sort(sortFileFolderNodes);
|
||||
}
|
||||
|
||||
public get type(): DatabaseProjectItemType {
|
||||
return DatabaseProjectItemType.folder;
|
||||
}
|
||||
|
||||
public get treeItem(): vscode.TreeItem {
|
||||
const folderItem = new vscode.TreeItem(this.fileSystemUri, vscode.TreeItemCollapsibleState.Collapsed);
|
||||
folderItem.contextValue = DatabaseProjectItemType.folder;
|
||||
folderItem.contextValue = this.type;
|
||||
folderItem.iconPath = IconPathHelper.folder;
|
||||
|
||||
return folderItem;
|
||||
@@ -40,10 +46,12 @@ export class FolderNode extends BaseProjectTreeItem {
|
||||
*/
|
||||
export abstract class FileNode extends BaseProjectTreeItem {
|
||||
public fileSystemUri: vscode.Uri;
|
||||
public override entryKey: string;
|
||||
|
||||
constructor(filePath: vscode.Uri, sqlprojUri: vscode.Uri) {
|
||||
constructor(filePath: vscode.Uri, sqlprojUri: vscode.Uri, entryKey: string) {
|
||||
super(fsPathToProjectUri(filePath, sqlprojUri, true), sqlprojUri);
|
||||
this.fileSystemUri = filePath;
|
||||
this.entryKey = entryKey;
|
||||
}
|
||||
|
||||
public get children(): BaseProjectTreeItem[] {
|
||||
@@ -68,64 +76,92 @@ export abstract class FileNode extends BaseProjectTreeItem {
|
||||
export class SqlObjectFileNode extends FileNode {
|
||||
public override get treeItem(): vscode.TreeItem {
|
||||
const treeItem = super.treeItem;
|
||||
treeItem.contextValue = DatabaseProjectItemType.sqlObjectScript;
|
||||
treeItem.contextValue = this.type;
|
||||
|
||||
return treeItem;
|
||||
}
|
||||
|
||||
public get type(): DatabaseProjectItemType {
|
||||
return DatabaseProjectItemType.sqlObjectScript;
|
||||
}
|
||||
}
|
||||
|
||||
export class ExternalStreamingJobFileNode extends SqlObjectFileNode {
|
||||
public override get treeItem(): vscode.TreeItem {
|
||||
const treeItem = super.treeItem;
|
||||
treeItem.contextValue = DatabaseProjectItemType.externalStreamingJob;
|
||||
treeItem.contextValue = this.type;
|
||||
|
||||
return treeItem;
|
||||
}
|
||||
|
||||
public override get type(): DatabaseProjectItemType {
|
||||
return DatabaseProjectItemType.externalStreamingJob;
|
||||
}
|
||||
}
|
||||
|
||||
export class TableFileNode extends SqlObjectFileNode {
|
||||
public override get treeItem(): vscode.TreeItem {
|
||||
const treeItem = super.treeItem;
|
||||
treeItem.contextValue = DatabaseProjectItemType.table;
|
||||
treeItem.contextValue = this.type;
|
||||
|
||||
return treeItem;
|
||||
}
|
||||
|
||||
public override get type(): DatabaseProjectItemType {
|
||||
return DatabaseProjectItemType.table;
|
||||
}
|
||||
}
|
||||
|
||||
export class PreDeployNode extends FileNode {
|
||||
public override get treeItem(): vscode.TreeItem {
|
||||
const treeItem = super.treeItem;
|
||||
treeItem.contextValue = DatabaseProjectItemType.preDeploymentScript;
|
||||
treeItem.contextValue = this.type;
|
||||
|
||||
return treeItem;
|
||||
}
|
||||
|
||||
public get type(): DatabaseProjectItemType {
|
||||
return DatabaseProjectItemType.preDeploymentScript;
|
||||
}
|
||||
}
|
||||
|
||||
export class PostDeployNode extends FileNode {
|
||||
public override get treeItem(): vscode.TreeItem {
|
||||
const treeItem = super.treeItem;
|
||||
treeItem.contextValue = DatabaseProjectItemType.postDeploymentScript;
|
||||
treeItem.contextValue = this.type;
|
||||
|
||||
return treeItem;
|
||||
}
|
||||
|
||||
public get type(): DatabaseProjectItemType {
|
||||
return DatabaseProjectItemType.postDeploymentScript;
|
||||
}
|
||||
}
|
||||
|
||||
export class NoneNode extends FileNode {
|
||||
public override get treeItem(): vscode.TreeItem {
|
||||
const treeItem = super.treeItem;
|
||||
treeItem.contextValue = DatabaseProjectItemType.noneFile;
|
||||
treeItem.contextValue = this.type;
|
||||
|
||||
return treeItem;
|
||||
}
|
||||
|
||||
public get type(): DatabaseProjectItemType {
|
||||
return DatabaseProjectItemType.noneFile;
|
||||
}
|
||||
}
|
||||
|
||||
export class PublishProfileNode extends FileNode {
|
||||
public override get treeItem(): vscode.TreeItem {
|
||||
const treeItem = super.treeItem;
|
||||
treeItem.contextValue = DatabaseProjectItemType.publishProfile;
|
||||
treeItem.contextValue = this.type;
|
||||
|
||||
return treeItem;
|
||||
}
|
||||
|
||||
public get type(): DatabaseProjectItemType {
|
||||
return DatabaseProjectItemType.publishProfile;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,12 +10,13 @@ import * as fileTree from './fileFolderTreeItem';
|
||||
import { Project } from '../project';
|
||||
import * as utils from '../../common/utils';
|
||||
import { DatabaseReferencesTreeItem } from './databaseReferencesTreeItem';
|
||||
import { DatabaseProjectItemType, RelativeOuterPath, ExternalStreamingJob, sqlprojExtension, CollapseProjectNodesKey } from '../../common/constants';
|
||||
import { DatabaseProjectItemType, RelativeOuterPath, ExternalStreamingJob, sqlprojExtension, CollapseProjectNodesKey, errorPrefix } from '../../common/constants';
|
||||
import { IconPathHelper } from '../../common/iconHelper';
|
||||
import { FileProjectEntry } from '../projectEntry';
|
||||
import { EntryType } from 'sqldbproj';
|
||||
import { DBProjectConfigurationKey } from '../../tools/netcoreTool';
|
||||
import { SqlCmdVariablesTreeItem } from './sqlcmdVariableTreeItem';
|
||||
import { ProjectType } from 'mssql';
|
||||
|
||||
/**
|
||||
* TreeNode root that represents an entire project
|
||||
@@ -51,62 +52,62 @@ export class ProjectRootTreeItem extends BaseProjectTreeItem {
|
||||
public get treeItem(): vscode.TreeItem {
|
||||
const collapsibleState = vscode.workspace.getConfiguration(DBProjectConfigurationKey)[CollapseProjectNodesKey] ? vscode.TreeItemCollapsibleState.Collapsed : vscode.TreeItemCollapsibleState.Expanded;
|
||||
const projectItem = new vscode.TreeItem(this.fileSystemUri, collapsibleState);
|
||||
projectItem.contextValue = this.project.isSdkStyleProject ? DatabaseProjectItemType.project : DatabaseProjectItemType.legacyProject;
|
||||
projectItem.contextValue = this.type;
|
||||
projectItem.iconPath = IconPathHelper.databaseProject;
|
||||
projectItem.label = this.projectNodeName;
|
||||
|
||||
return projectItem;
|
||||
}
|
||||
|
||||
public get type(): DatabaseProjectItemType {
|
||||
return this.project.sqlProjStyle === ProjectType.SdkStyle ? DatabaseProjectItemType.project : DatabaseProjectItemType.legacyProject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the list of files in a project file to constructs the tree
|
||||
*/
|
||||
private construct() {
|
||||
// folders
|
||||
// Note: folders must be sorted to ensure that parent folders come before their children
|
||||
for (const folder of this.project.folders.sort((a, b) => a.relativePath < b.relativePath ? -1 : (a.relativePath > b.relativePath ? 1 : 0))) {
|
||||
const newNode = new fileTree.FolderNode(folder.fsUri, this.projectFileUri, folder.relativePath);
|
||||
this.addNode(newNode, folder);
|
||||
}
|
||||
|
||||
// pre deploy scripts
|
||||
for (const preDeployEntry of this.project.preDeployScripts) {
|
||||
const newNode = new fileTree.PreDeployNode(preDeployEntry.fsUri, this.projectFileUri);
|
||||
const newNode = new fileTree.PreDeployNode(preDeployEntry.fsUri, this.projectFileUri, preDeployEntry.relativePath);
|
||||
this.addNode(newNode, preDeployEntry);
|
||||
}
|
||||
|
||||
// post deploy scripts
|
||||
for (const postDeployEntry of this.project.postDeployScripts) {
|
||||
const newNode = new fileTree.PostDeployNode(postDeployEntry.fsUri, this.projectFileUri);
|
||||
const newNode = new fileTree.PostDeployNode(postDeployEntry.fsUri, this.projectFileUri, postDeployEntry.relativePath);
|
||||
this.addNode(newNode, postDeployEntry);
|
||||
}
|
||||
|
||||
// none scripts
|
||||
for (const noneEntry of this.project.noneDeployScripts) {
|
||||
const newNode = new fileTree.NoneNode(noneEntry.fsUri, this.projectFileUri);
|
||||
const newNode = new fileTree.NoneNode(noneEntry.fsUri, this.projectFileUri, noneEntry.relativePath);
|
||||
this.addNode(newNode, noneEntry);
|
||||
}
|
||||
|
||||
// publish profiles
|
||||
for (const publishProfile of this.project.publishProfiles) {
|
||||
const newNode = new fileTree.PublishProfileNode(publishProfile.fsUri, this.projectFileUri);
|
||||
const newNode = new fileTree.PublishProfileNode(publishProfile.fsUri, this.projectFileUri, publishProfile.relativePath);
|
||||
this.addNode(newNode, publishProfile);
|
||||
}
|
||||
|
||||
// sql object scripts and folders
|
||||
// sql object scripts
|
||||
for (const entry of this.project.files) {
|
||||
let newNode: fileTree.FolderNode | fileTree.FileNode;
|
||||
let newNode: fileTree.FileNode;
|
||||
|
||||
switch (entry.type) {
|
||||
case EntryType.File:
|
||||
if (entry.sqlObjectType === ExternalStreamingJob) {
|
||||
newNode = new fileTree.ExternalStreamingJobFileNode(entry.fsUri, this.projectFileUri);
|
||||
} else if (entry.containsCreateTableStatement) {
|
||||
newNode = new fileTree.TableFileNode(entry.fsUri, this.projectFileUri);
|
||||
}
|
||||
else {
|
||||
newNode = new fileTree.SqlObjectFileNode(entry.fsUri, this.projectFileUri);
|
||||
}
|
||||
|
||||
break;
|
||||
case EntryType.Folder:
|
||||
newNode = new fileTree.FolderNode(entry.fsUri, this.projectFileUri);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unknown EntryType: '${entry.type}'`);
|
||||
if (entry.sqlObjectType === ExternalStreamingJob) {
|
||||
newNode = new fileTree.ExternalStreamingJobFileNode(entry.fsUri, this.projectFileUri, entry.relativePath);
|
||||
} else if (entry.containsCreateTableStatement) {
|
||||
newNode = new fileTree.TableFileNode(entry.fsUri, this.projectFileUri, entry.relativePath);
|
||||
} else {
|
||||
newNode = new fileTree.SqlObjectFileNode(entry.fsUri, this.projectFileUri, entry.relativePath);
|
||||
}
|
||||
|
||||
this.addNode(newNode, entry);
|
||||
@@ -138,23 +139,26 @@ export class ProjectRootTreeItem extends BaseProjectTreeItem {
|
||||
return this; // if nothing left after trimming the entry itself, must been root
|
||||
}
|
||||
|
||||
if (relativePathParts[0] === RelativeOuterPath) {
|
||||
if (relativePathParts[0] === RelativeOuterPath) { // scripts external to the project folder are always parented by the project root node because external folders aren't supported
|
||||
return this;
|
||||
}
|
||||
|
||||
let current: fileTree.FolderNode | ProjectRootTreeItem = this;
|
||||
let current: fileTree.FolderNode | ProjectRootTreeItem = this; // start with the Project root node
|
||||
|
||||
for (const part of relativePathParts) {
|
||||
for (const part of relativePathParts) { // iterate from the project root, down the path to the entry in question
|
||||
if (current.fileChildren[part] === undefined) {
|
||||
const parentPath = current instanceof ProjectRootTreeItem ? path.dirname(current.fileSystemUri.fsPath) : current.fileSystemUri.fsPath;
|
||||
current.fileChildren[part] = new fileTree.FolderNode(vscode.Uri.file(path.join(parentPath, part)), this.projectFileUri);
|
||||
// DacFx.Projects populates the list of folders with those implicitly included via parentage.
|
||||
// e.g. <Folder Include="MySchema\Tables"> and <Build Include="MySchema\SomeScript.sql"> both result in the "MySchema" folder being automatically added,
|
||||
// even if there's no <Folder Include="MySchema"> entry.
|
||||
// Project tree unit tests need to explicitly include parent folders because they bypass DacFx's logic, or they'll hit this error.
|
||||
throw new Error(errorPrefix(`All parent nodes for ${relativePathParts} should have already been added.`));
|
||||
}
|
||||
|
||||
if (current.fileChildren[part] instanceof fileTree.FileNode) {
|
||||
return current;
|
||||
return current; // if we've made it to the node in question, we're done
|
||||
}
|
||||
else {
|
||||
current = current.fileChildren[part] as fileTree.FolderNode | ProjectRootTreeItem;
|
||||
current = current.fileChildren[part] as fileTree.FolderNode; // otherwise, shift the current node down, and repeat
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +45,13 @@ export class SqlCmdVariablesTreeItem extends BaseProjectTreeItem {
|
||||
return this.sqlcmdVariableTreeItems;
|
||||
}
|
||||
|
||||
public get type(): constants.DatabaseProjectItemType {
|
||||
return constants.DatabaseProjectItemType.sqlcmdVariablesRoot;
|
||||
}
|
||||
|
||||
public get treeItem(): vscode.TreeItem {
|
||||
const sqlCmdVariableFolderItem = new vscode.TreeItem(this.relativeProjectUri, vscode.TreeItemCollapsibleState.Collapsed);
|
||||
sqlCmdVariableFolderItem.contextValue = constants.DatabaseProjectItemType.sqlcmdVariablesRoot;
|
||||
sqlCmdVariableFolderItem.contextValue = this.type;
|
||||
sqlCmdVariableFolderItem.iconPath = IconPathHelper.sqlCmdVariablesGroup;
|
||||
|
||||
return sqlCmdVariableFolderItem;
|
||||
@@ -60,16 +64,21 @@ export class SqlCmdVariablesTreeItem extends BaseProjectTreeItem {
|
||||
export class SqlCmdVariableTreeItem extends BaseProjectTreeItem {
|
||||
constructor(private sqlcmdVar: string, sqlCmdNodeRelativeProjectUri: vscode.Uri, sqlprojUri: vscode.Uri,) {
|
||||
super(vscode.Uri.file(path.join(sqlCmdNodeRelativeProjectUri.fsPath, sqlcmdVar)), sqlprojUri);
|
||||
this.entryKey = this.friendlyName;
|
||||
}
|
||||
|
||||
public get children(): BaseProjectTreeItem[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
public get type(): constants.DatabaseProjectItemType {
|
||||
return constants.DatabaseProjectItemType.sqlcmdVariable;
|
||||
}
|
||||
|
||||
public get treeItem(): vscode.TreeItem {
|
||||
const sqlcmdVariableItem = new vscode.TreeItem(this.relativeProjectUri, vscode.TreeItemCollapsibleState.None);
|
||||
sqlcmdVariableItem.label = this.sqlcmdVar;
|
||||
sqlcmdVariableItem.contextValue = constants.DatabaseProjectItemType.sqlcmdVariable;
|
||||
sqlcmdVariableItem.contextValue = this.type;
|
||||
sqlcmdVariableItem.iconPath = IconPathHelper.sqlCmdVariable;
|
||||
|
||||
return sqlcmdVariableItem;
|
||||
|
||||
Reference in New Issue
Block a user