Import project from database (#10326)

* Initial changes for Import database as new project

* Functionally complete code

* Initial changes for Import database as new project

* Functionally complete code

* Resolved conflicts with latest changes. Also did some code refactoring.

* Addressed comments. Added unit tests.

* Addressed comments

* Moved ExtractTarget enum from azdata to mssql

* Addressed comments

* Fixed indentation in project templates
This commit is contained in:
Sakshi Sharma
2020-05-26 16:08:24 -07:00
committed by GitHub
parent f0d86f8acb
commit 9a55b0275d
21 changed files with 604 additions and 50 deletions

View File

@@ -55,3 +55,65 @@ async function createTestFile(contents: string, fileName: string, folderPath?: s
return filePath;
}
/**
* TestFolder directory structure
* - file1.sql
* - folder1
* -file1.sql
* -file2.sql
* -file3.sql
* -file4.sql
* -file5.sql
* - folder2
* -file1.sql
* -file2.sql
* -file3.sql
* -file4.sql
* -file5.sql
* - file2.txt
*
* @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 createDummyFileStructure(createList?: boolean, list?: string[], testFolderPath?: string): Promise<string> {
testFolderPath = testFolderPath ?? await generateTestFolderPath();
let filePath = path.join(testFolderPath, 'file1.sql');
await fs.open(filePath, 'w');
if (createList) {
list?.push(testFolderPath);
list?.push(filePath);
}
for (let dirCount = 1; dirCount <= 2; dirCount++) {
let dirName = path.join(testFolderPath, `folder${dirCount}`);
await fs.mkdir(dirName, { recursive: true });
if (createList) {
list?.push(dirName);
}
for (let fileCount = 1; fileCount <= 5; fileCount++) {
let fileName = path.join(dirName, `file${fileCount}.sql`);
await fs.open(fileName, 'w');
if (createList) {
list?.push(fileName);
}
}
}
filePath = path.join(testFolderPath, 'file2.txt');
await fs.open(filePath, 'w');
if (createList) {
list?.push(filePath);
}
return testFolderPath;
}
export async function createListOfFiles(filePath?: string): Promise<string[]> {
let fileFolderList: string[] = [];
await createDummyFileStructure(true, fileFolderList, filePath);
return fileFolderList;
}