Expose adding files and folders in sql database projects (#14391)

* expose addToProject in dataworkspace.d.ts

* remove changes in data workspace extension

* add sqldbproj.d.ts

* change list to be Uris instead of strings

* don't add files/folders if any don't exist

* fix test on windows
This commit is contained in:
Kim Santiago
2021-02-23 18:15:38 -08:00
committed by GitHub
parent d5385f66d3
commit c05cece683
10 changed files with 85 additions and 35 deletions

View File

@@ -11,7 +11,7 @@ import * as path from 'path';
import { ProjectsController } from './projectController';
import { NetCoreTool } from '../tools/netcoreTool';
import { IconPathHelper } from '../common/iconHelper';
import { IProjectProvider, WorkspaceTreeItem } from 'dataworkspace';
import { WorkspaceTreeItem } from 'dataworkspace';
import { SqlDatabaseProjectProvider } from '../projectProvider/projectProvider';
/**
@@ -37,7 +37,7 @@ export default class MainController implements vscode.Disposable {
public deactivate(): void {
}
public async activate(): Promise<IProjectProvider> {
public async activate(): Promise<SqlDatabaseProjectProvider> {
await this.initializeDatabaseProjects();
return new SqlDatabaseProjectProvider(this.projectsController);
}

View File

@@ -768,7 +768,7 @@ export class ProjectsController {
const project = await Project.openProject(newProjFilePath);
await this.createProjectFromDatabaseApiCall(model); // Call ExtractAPI in DacFx Service
let fileFolderList: string[] = model.extractTarget === mssql.ExtractTarget.file ? [model.filePath] : await this.generateList(model.filePath); // Create a list of all the files and directories to be added to project
let fileFolderList: vscode.Uri[] = model.extractTarget === mssql.ExtractTarget.file ? [vscode.Uri.file(model.filePath)] : await this.generateList(model.filePath); // Create a list of all the files and directories to be added to project
await project.addToProject(fileFolderList); // Add generated file structure to the project
@@ -811,8 +811,8 @@ export class ProjectsController {
/**
* Generate a flat list of all files and folder under a folder.
*/
public async generateList(absolutePath: string): Promise<string[]> {
let fileFolderList: string[] = [];
public async generateList(absolutePath: string): Promise<vscode.Uri[]> {
let fileFolderList: vscode.Uri[] = [];
if (!await utils.exists(absolutePath)) {
if (await utils.exists(absolutePath + constants.sqlFileExtension)) {
@@ -831,13 +831,13 @@ export class ProjectsController {
const stat = await fs.stat(filepath);
if (stat.isDirectory()) {
fileFolderList.push(filepath);
fileFolderList.push(vscode.Uri.file(filepath));
(await fs
.readdir(filepath))
.forEach((f: string) => files.push(path.join(filepath, f)));
}
else if (stat.isFile()) {
fileFolderList.push(filepath);
fileFolderList.push(vscode.Uri.file(filepath));
}
}