Swap create new project api for sql projects (#21971)

This commit is contained in:
Kim Santiago
2023-02-21 10:00:56 -08:00
committed by GitHub
parent 66edf059be
commit 7761c3b171
5 changed files with 29 additions and 28 deletions

View File

@@ -183,14 +183,7 @@ export class ProjectsController {
}
const targetPlatform = creationParams.targetPlatform ? constants.targetPlatformToVersion.get(creationParams.targetPlatform)! : constants.defaultDSP;
const macroDict: Record<string, string> = {
'PROJECT_NAME': creationParams.newProjName,
'PROJECT_GUID': creationParams.projectGuid ?? UUID.generateUuid().toUpperCase(),
'PROJECT_DSP': targetPlatform
};
let newProjFileContents = creationParams.sdkStyle ? templates.macroExpansion(templates.newSdkSqlProjectTemplate, macroDict) : templates.macroExpansion(templates.newSqlProjectTemplate, macroDict);
const sdkStyle = creationParams.sdkStyle ? mssql.ProjectType.SdkStyle : mssql.ProjectType.LegacyStyle;
let newProjFileName = creationParams.newProjName;
@@ -204,9 +197,8 @@ export class ProjectsController {
throw new Error(constants.projectAlreadyExists(newProjFileName, path.parse(newProjFilePath).dir));
}
const projectFolderPath = path.dirname(newProjFilePath);
await fs.mkdir(projectFolderPath, { recursive: true });
await fs.writeFile(newProjFilePath, newProjFileContents);
const sqlProjectsService = await utils.getSqlProjectsService();
await sqlProjectsService.newProject(newProjFilePath, sdkStyle, targetPlatform);
await this.addTemplateFiles(newProjFilePath, creationParams.projectTypeId);

View File

@@ -54,23 +54,6 @@ describe('ProjectsController', function (): void {
describe('project controller operations', function (): void {
describe('Project file operations and prompting', function (): void {
it('Should create new sqlproj file with correct values', async function (): Promise<void> {
const projController = new ProjectsController(testContext.outputChannel);
const projFileDir = path.join(testUtils.generateBaseFolderName(), `TestProject_${new Date().getTime()}`);
const projFilePath = await projController.createNewProject({
newProjName: 'TestProjectName',
folderUri: vscode.Uri.file(projFileDir),
projectTypeId: constants.emptySqlDatabaseProjectTypeId,
projectGuid: 'BA5EBA11-C0DE-5EA7-ACED-BABB1E70A575',
sdkStyle: false
});
let projFileText = (await fs.readFile(projFilePath)).toString();
should(projFileText).equal(baselines.newProjectFileBaseline);
});
it('Should create new sqlproj file with correct specified target platform', async function (): Promise<void> {
const projController = new ProjectsController(testContext.outputChannel);
const projFileDir = path.join(testUtils.generateBaseFolderName(), `TestProject_${new Date().getTime()}`);