Add support for showing files for glob style sql projects (#17518)

* use glob to get files for new style msbuild sdk sqlproj

* add tests

* cleanup

* fix test

* don't show bin and obj files and folders

* handle other glob patterns

* fix duplicate entries getting added for glob patterns in project's folder
This commit is contained in:
Kim Santiago
2021-11-05 13:29:47 -07:00
committed by GitHub
parent c9be45b9c7
commit b8ea493f8c
8 changed files with 398 additions and 7 deletions

View File

@@ -115,6 +115,58 @@ export async function createDummyFileStructure(createList?: boolean, list?: Uri[
return testFolderPath;
}
/**
* TestFolder directory structure
* - file1.sql
* - folder1
* -file1.sql
* -file2.sql
* -file3.sql
* -file4.sql
* -file5.sql
* -Script.PostDeployment2.sql
* - folder2
* -file1.sql
* -file2.sql
* -file3.sql
* -file4.sql
* -file5.sql
* - file2.txt
* - Script.PreDeployment1.sql
* - Script.PreDeployment2.sql
* - Script.PostDeployment1.sql
*
* @param createList Boolean specifying to create a list of the files and folders been created
* @param list List of files and folders that are been created
*/
export async function createDummyFileStructureWithPrePostDeployScripts(createList?: boolean, list?: Uri[], testFolderPath?: string): Promise<string> {
testFolderPath = await createDummyFileStructure(createList, list, testFolderPath);
// add pre-deploy scripts
const predeployscript1 = path.join(testFolderPath, 'Script.PreDeployment1.sql');
await fs.writeFile(predeployscript1, '');
const predeployscript2 = path.join(testFolderPath, 'Script.PreDeployment2.sql');
await fs.writeFile(predeployscript2, '');
if (createList) {
list?.push(Uri.file(predeployscript1));
list?.push(Uri.file(predeployscript2));
}
// add post-deploy scripts
const postdeployscript1 = path.join(testFolderPath, 'Script.PostDeployment1.sql');
await fs.writeFile(postdeployscript1, '');
const postdeployscript2 = path.join(testFolderPath, 'folder1', 'Script.PostDeployment2.sql');
await fs.writeFile(postdeployscript2, '');
if (createList) {
list?.push(Uri.file(postdeployscript1));
list?.push(Uri.file(postdeployscript2));
}
return testFolderPath;
}
export async function createListOfFiles(filePath?: string): Promise<Uri[]> {
let fileFolderList: Uri[] = [];
@@ -122,3 +174,41 @@ export async function createListOfFiles(filePath?: string): Promise<Uri[]> {
return fileFolderList;
}
/**
* TestFolder directory structure
* - file1.sql
* - folder1
* -file1.sql
* -file2.sql
* -test1.sql
* -test2.sql
* -testLongerName.sql
* - folder2
* -file1.sql
* -file2.sql
*
*/
export async function createOtherDummyFiles(testFolderPath: string): Promise<string> {
let filePath = path.join(testFolderPath, 'file1.sql');
await fs.writeFile(filePath, '');
for (let dirCount = 1; dirCount <= 2; dirCount++) {
let dirName = path.join(testFolderPath, `folder${dirCount}`);
await fs.mkdir(dirName, { recursive: true });
for (let fileCount = 1; fileCount <= 2; fileCount++) {
let fileName = path.join(dirName, `file${fileCount}.sql`);
await fs.writeFile(fileName, '');
}
}
const test1 = path.join(testFolderPath, 'folder1', 'test1.sql');
await fs.writeFile(test1, '');
const test2 = path.join(testFolderPath, 'folder1', 'test2.sql');
await fs.writeFile(test2, '');
const testLongerName = path.join(testFolderPath, 'folder1', 'testLongerName.sql');
await fs.writeFile(testLongerName, '');
return testFolderPath;
}