mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
add types instead of using any in project.ts (#18091)
This commit is contained in:
@@ -586,11 +586,11 @@ export class Project implements ISqlProject {
|
|||||||
await this.createCleanFileNode(beforeBuildNode);
|
await this.createCleanFileNode(beforeBuildNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async createCleanFileNode(parentNode: any): Promise<void> {
|
private async createCleanFileNode(parentNode: Element): Promise<void> {
|
||||||
const deleteFileNode = this.projFileXmlDoc!.createElement(constants.Delete);
|
const deleteFileNode = this.projFileXmlDoc!.createElement(constants.Delete);
|
||||||
deleteFileNode.setAttribute(constants.Files, constants.ProjJsonToClean);
|
deleteFileNode.setAttribute(constants.Files, constants.ProjJsonToClean);
|
||||||
parentNode.appendChild(deleteFileNode);
|
parentNode.appendChild(deleteFileNode);
|
||||||
await this.serializeToProjFile(this.projFileXmlDoc);
|
await this.serializeToProjFile(this.projFileXmlDoc!);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -740,7 +740,7 @@ export class Project implements ISqlProject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.serializeToProjFile(this.projFileXmlDoc);
|
await this.serializeToProjFile(this.projFileXmlDoc!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -881,7 +881,7 @@ export class Project implements ISqlProject {
|
|||||||
sqlObjectType);
|
sqlObjectType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private findOrCreateItemGroup(containedTag?: string, prePostScriptExist?: { scriptExist: boolean; }): any {
|
private findOrCreateItemGroup(containedTag?: string, prePostScriptExist?: { scriptExist: boolean; }): Element {
|
||||||
let outputItemGroup = undefined;
|
let outputItemGroup = undefined;
|
||||||
|
|
||||||
// search for a particular item goup if a child type is provided
|
// search for a particular item goup if a child type is provided
|
||||||
@@ -990,7 +990,7 @@ export class Project implements ISqlProject {
|
|||||||
if (this.isSdkStyleProject) {
|
if (this.isSdkStyleProject) {
|
||||||
// write any changes from removing an include node and get the current files included in the project
|
// write any changes from removing an include node and get the current files included in the project
|
||||||
if (deleted) {
|
if (deleted) {
|
||||||
await this.serializeToProjFile(this.projFileXmlDoc);
|
await this.serializeToProjFile(this.projFileXmlDoc!);
|
||||||
}
|
}
|
||||||
const currentFiles = await this.readFilesInProject();
|
const currentFiles = await this.readFilesInProject();
|
||||||
|
|
||||||
@@ -1007,24 +1007,26 @@ export class Project implements ISqlProject {
|
|||||||
throw new Error(constants.unableToFindObject(path, constants.fileObject));
|
throw new Error(constants.unableToFindObject(path, constants.fileObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
private removeNode(includeString: string, nodes: any): boolean {
|
private removeNode(includeString: string, nodes: HTMLCollectionOf<Element>): boolean {
|
||||||
for (let i = 0; i < nodes.length; i++) {
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
const parent = nodes[i].parentNode;
|
const parent = nodes[i].parentNode;
|
||||||
|
|
||||||
|
if (parent) {
|
||||||
if (nodes[i].getAttribute(constants.Include) === utils.convertSlashesForSqlProj(includeString)) {
|
if (nodes[i].getAttribute(constants.Include) === utils.convertSlashesForSqlProj(includeString)) {
|
||||||
parent.removeChild(nodes[i]);
|
parent.removeChild(nodes[i]);
|
||||||
|
|
||||||
// delete ItemGroup if this was the only entry
|
// delete ItemGroup if this was the only entry
|
||||||
// only want element nodes, not text nodes
|
// only want element nodes, not text nodes
|
||||||
const otherChildren = Array.from(parent.childNodes).filter((c: any) => c.childNodes);
|
const otherChildren = Array.from(parent.childNodes).filter((c: ChildNode) => c.childNodes);
|
||||||
|
|
||||||
if (otherChildren.length === 0) {
|
if (otherChildren.length === 0) {
|
||||||
parent.parentNode.removeChild(parent);
|
parent.parentNode?.removeChild(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1095,7 +1097,7 @@ export class Project implements ISqlProject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async writeToSqlProjAndUpdateFilesFolders(): Promise<void> {
|
private async writeToSqlProjAndUpdateFilesFolders(): Promise<void> {
|
||||||
await this.serializeToProjFile(this.projFileXmlDoc);
|
await this.serializeToProjFile(this.projFileXmlDoc!);
|
||||||
const projFileText = await fs.readFile(this._projectFilePath);
|
const projFileText = await fs.readFile(this._projectFilePath);
|
||||||
this.projFileXmlDoc = new xmldom.DOMParser().parseFromString(projFileText.toString());
|
this.projFileXmlDoc = new xmldom.DOMParser().parseFromString(projFileText.toString());
|
||||||
this._files = await this.readFilesInProject();
|
this._files = await this.readFilesInProject();
|
||||||
@@ -1170,7 +1172,7 @@ export class Project implements ISqlProject {
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async addDatabaseReferenceChildren(referenceNode: any, entry: IDatabaseReferenceProjectEntry): Promise<void> {
|
private async addDatabaseReferenceChildren(referenceNode: Element, entry: IDatabaseReferenceProjectEntry): Promise<void> {
|
||||||
const suppressMissingDependenciesErrorNode = this.projFileXmlDoc!.createElement(constants.SuppressMissingDependenciesErrors);
|
const suppressMissingDependenciesErrorNode = this.projFileXmlDoc!.createElement(constants.SuppressMissingDependenciesErrors);
|
||||||
const suppressMissingDependenciesErrorTextNode = this.projFileXmlDoc!.createTextNode(entry.suppressMissingDependenciesErrors ? constants.True : constants.False);
|
const suppressMissingDependenciesErrorTextNode = this.projFileXmlDoc!.createTextNode(entry.suppressMissingDependenciesErrors ? constants.True : constants.False);
|
||||||
suppressMissingDependenciesErrorNode.appendChild(suppressMissingDependenciesErrorTextNode);
|
suppressMissingDependenciesErrorNode.appendChild(suppressMissingDependenciesErrorTextNode);
|
||||||
@@ -1202,7 +1204,7 @@ export class Project implements ISqlProject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private addProjectReferenceChildren(referenceNode: any, entry: SqlProjectReferenceProjectEntry): void {
|
private addProjectReferenceChildren(referenceNode: Element, entry: SqlProjectReferenceProjectEntry): void {
|
||||||
// project name
|
// project name
|
||||||
const nameElement = this.projFileXmlDoc!.createElement(constants.Name);
|
const nameElement = this.projFileXmlDoc!.createElement(constants.Name);
|
||||||
const nameTextNode = this.projFileXmlDoc!.createTextNode(entry.projectName);
|
const nameTextNode = this.projFileXmlDoc!.createTextNode(entry.projectName);
|
||||||
@@ -1237,7 +1239,7 @@ export class Project implements ISqlProject {
|
|||||||
this._sqlCmdVariables[entry.variableName] = <string>entry.defaultValue;
|
this._sqlCmdVariables[entry.variableName] = <string>entry.defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private addSqlCmdVariableChildren(sqlCmdVariableNode: any, entry: SqlCmdVariableProjectEntry): void {
|
private addSqlCmdVariableChildren(sqlCmdVariableNode: Element, entry: SqlCmdVariableProjectEntry): void {
|
||||||
// add default value
|
// add default value
|
||||||
const defaultValueNode = this.projFileXmlDoc!.createElement(constants.DefaultValue);
|
const defaultValueNode = this.projFileXmlDoc!.createElement(constants.DefaultValue);
|
||||||
const defaultValueText = this.projFileXmlDoc!.createTextNode(entry.defaultValue);
|
const defaultValueText = this.projFileXmlDoc!.createTextNode(entry.defaultValue);
|
||||||
@@ -1272,7 +1274,7 @@ export class Project implements ISqlProject {
|
|||||||
return highestNumber + 1;
|
return highestNumber + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async updateImportedTargetsToProjFile(condition: string, projectAttributeVal: string, oldImportNode?: any): Promise<any> {
|
private async updateImportedTargetsToProjFile(condition: string, projectAttributeVal: string, oldImportNode?: Element): Promise<Element> {
|
||||||
const importNode = this.projFileXmlDoc!.createElement(constants.Import);
|
const importNode = this.projFileXmlDoc!.createElement(constants.Import);
|
||||||
importNode.setAttribute(constants.Condition, condition);
|
importNode.setAttribute(constants.Condition, condition);
|
||||||
importNode.setAttribute(constants.Project, projectAttributeVal);
|
importNode.setAttribute(constants.Project, projectAttributeVal);
|
||||||
@@ -1285,7 +1287,7 @@ export class Project implements ISqlProject {
|
|||||||
this._importedTargets.push(projectAttributeVal); // Add new import target to the list
|
this._importedTargets.push(projectAttributeVal); // Add new import target to the list
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.serializeToProjFile(this.projFileXmlDoc);
|
await this.serializeToProjFile(this.projFileXmlDoc!);
|
||||||
return importNode;
|
return importNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1298,7 +1300,7 @@ export class Project implements ISqlProject {
|
|||||||
|
|
||||||
this.findOrCreateItemGroup(constants.PackageReference).appendChild(packageRefNode);
|
this.findOrCreateItemGroup(constants.PackageReference).appendChild(packageRefNode);
|
||||||
|
|
||||||
await this.serializeToProjFile(this.projFileXmlDoc);
|
await this.serializeToProjFile(this.projFileXmlDoc!);
|
||||||
}
|
}
|
||||||
|
|
||||||
public containsSSDTOnlySystemDatabaseReferences(): boolean {
|
public containsSSDTOnlySystemDatabaseReferences(): boolean {
|
||||||
@@ -1368,7 +1370,7 @@ export class Project implements ISqlProject {
|
|||||||
break; // not required but adding so that we dont miss when we add new items
|
break; // not required but adding so that we dont miss when we add new items
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.serializeToProjFile(this.projFileXmlDoc);
|
await this.serializeToProjFile(this.projFileXmlDoc!);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async removeFromProjFile(entries: ProjectEntry | ProjectEntry[]): Promise<void> {
|
private async removeFromProjFile(entries: ProjectEntry | ProjectEntry[]): Promise<void> {
|
||||||
@@ -1399,17 +1401,17 @@ export class Project implements ISqlProject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.serializeToProjFile(this.projFileXmlDoc);
|
await this.serializeToProjFile(this.projFileXmlDoc!);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async serializeToProjFile(projFileContents: any): Promise<void> {
|
private async serializeToProjFile(projFileContents: Document): Promise<void> {
|
||||||
let xml = new xmldom.XMLSerializer().serializeToString(projFileContents);
|
let xml = new xmldom.XMLSerializer().serializeToString(projFileContents);
|
||||||
xml = xmlFormat(xml, <any>{
|
xml = xmlFormat(xml, <xmlFormat.Options>{
|
||||||
collapseContent: true,
|
collapseContent: true,
|
||||||
indentation: ' ',
|
indentation: ' ',
|
||||||
lineSeparator: os.EOL,
|
lineSeparator: os.EOL,
|
||||||
whiteSpaceAtEndOfSelfclosingTag: true
|
whiteSpaceAtEndOfSelfclosingTag: true
|
||||||
}); // TODO: replace <any>
|
});
|
||||||
|
|
||||||
await fs.writeFile(this._projectFilePath, xml);
|
await fs.writeFile(this._projectFilePath, xml);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user