Skip to content

VsCode Tasks PR1 : Introducing default build property with create project quickpics #26315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions extensions/data-workspace/src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const SdkStyleProject = localize('dataworkspace.sdkStyleProject', "SDK-st
export const LearnMore = localize('dataworkspace.learnMore', "Learn More");
export const YesRecommended = localize('dataworkspace.yesRecommended', "Yes (Recommended)");
export const No = localize('dataworkspace.no', "No");
export const Yes = localize('dataworkspace.yes', "Yes");
export const SdkLearnMorePlaceholder = localize('dataworkspace.sdkLearnMorePlaceholder', "Click \"Learn More\" button for more information about SDK-style projects");
export const Default = localize('dataworkspace.default', "Default");
export const SelectTargetPlatform = localize('dataworkspace.selectTargetPlatform', "Select Target Platform");
Expand All @@ -69,6 +70,7 @@ export const reservedWindowsFilenameErrorMessage = localize('reservedWindowsFile
export const reservedValueErrorMessage = localize('reservedValueErrorMessage', "Reserved file name. Choose another name and try again");
export const trailingWhitespaceErrorMessage = localize('trailingWhitespaceErrorMessage', "File name cannot start or end with whitespace");
export const tooLongFilenameErrorMessage = localize('tooLongFilenameErrorMessage', "File name cannot be over 255 characters");
export const confirmCreateProjectWithBuildTaskDialogName = localize('confirmCreateProjectWithBuildTaskDialogName', "Do you want to configure SQL project build as the default build configuration for this folder?");

//Open Existing Dialog
export const OpenExistingDialogTitle = localize('dataworkspace.openExistingDialogTitle', "Open Existing Project");
Expand Down
3 changes: 2 additions & 1 deletion extensions/data-workspace/src/common/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ export interface IWorkspaceService {
* @param projectTypeId The project type id
* @param projectTargetPlatform The target platform of the project
* @param sdkStyleProject Whether or not the project is SDK-style
* @param configureDefaultBuild Whether or not to configure the default build
*/
createProject(name: string, location: vscode.Uri, projectTypeId: string, projectTargetPlatform?: string, sdkStyleProject?: boolean): Promise<vscode.Uri>;
createProject(name: string, location: vscode.Uri, projectTypeId: string, projectTargetPlatform?: string, sdkStyleProject?: boolean, configureDefaultBuild?: boolean): Promise<vscode.Uri>;

/**
* Clones git repository and adds projects to workspace
Expand Down
8 changes: 7 additions & 1 deletion extensions/data-workspace/src/dataworkspace.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ declare module 'dataworkspace' {
* @param projectTypeId the identifier of the selected project type
* @param projectTargetPlatform the target platform of the project
* @param sdkStyleProject whether or not a project is SDK-style
* @param configureDefaultBuild whether or not to configure default build
*/
createProject(name: string, location: vscode.Uri, projectTypeId: string, projectTargetPlatform?: string, sdkStyleProject?: boolean): Promise<vscode.Uri>;
createProject(name: string, location: vscode.Uri, projectTypeId: string, projectTargetPlatform?: string, sdkStyleProject?: boolean, configureDefaultBuild?: boolean): Promise<vscode.Uri>;

/**
* Gets the project data corresponding to the project file, to be placed in the dashboard container
Expand Down Expand Up @@ -189,6 +190,11 @@ declare module 'dataworkspace' {
* Location where clicking on the Learn More to know more about project type will go
*/
readonly learnMoreUrl?: string

/**
* Whether or not the project has a default build configuration
*/
readonly configureDefaultBuild?: boolean;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion extensions/data-workspace/src/dialogs/newProjectDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class NewProjectDialogModel {
location: string = '';
targetPlatform?: string;
sdkStyleProject?: boolean;
configureDefaultBuild: boolean = false;
}

export async function openSpecificProjectNewProjectDialog(projectType: IProjectType, workspaceService: WorkspaceService): Promise<vscode.Uri | undefined> {
Expand Down Expand Up @@ -90,7 +91,7 @@ export class NewProjectDialog extends DialogBase {
.withAdditionalProperties({ projectFileExtension: this.model.projectFileExtension, projectTemplateId: this.model.projectTypeId })
.send();

this.projectUri = await this.workspaceService.createProject(this.model.name, vscode.Uri.file(this.model.location), this.model.projectTypeId, this.model.targetPlatform, this.model.sdkStyleProject);
this.projectUri = await this.workspaceService.createProject(this.model.name, vscode.Uri.file(this.model.location), this.model.projectTypeId, this.model.targetPlatform, this.model.sdkStyleProject, this.model.configureDefaultBuild);
this.newProjectDialogComplete?.resolve();
}
catch (err) {
Expand Down
12 changes: 11 additions & 1 deletion extensions/data-workspace/src/dialogs/newProjectQuickpick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,17 @@ export async function createNewProjectWithQuickpick(workspaceService: WorkspaceS
}
}

await workspaceService.createProject(projectName, vscode.Uri.file(projectLocation), projectType.id, targetPlatform, sdkStyle);
// 8. Configure Sql project default build or not
let configureDefaultBuild = await vscode.window.showQuickPick(
[constants.Yes, constants.No],
{ title: constants.confirmCreateProjectWithBuildTaskDialogName, ignoreFocusOut: true }
);

if (!configureDefaultBuild) {
// User cancelled
return;
}
await workspaceService.createProject(projectName, vscode.Uri.file(projectLocation), projectType.id, targetPlatform, sdkStyle, configureDefaultBuild === constants.Yes);

// Add info message with 'learn more' button if project type has a link
// for user to learn more about the project type
Expand Down
4 changes: 2 additions & 2 deletions extensions/data-workspace/src/services/workspaceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ export class WorkspaceService implements IWorkspaceService {
return ProjectProviderRegistry.getProviderByProjectExtension(projectType);
}

async createProject(name: string, location: vscode.Uri, projectTypeId: string, projectTargetVersion?: string, sdkStyleProject?: boolean): Promise<vscode.Uri> {
async createProject(name: string, location: vscode.Uri, projectTypeId: string, projectTargetVersion?: string, sdkStyleProject?: boolean, configureDefaultBuild?: boolean): Promise<vscode.Uri> {
const provider = ProjectProviderRegistry.getProviderByProjectType(projectTypeId);
if (provider) {
const projectFile = await provider.createProject(name, location, projectTypeId, projectTargetVersion, sdkStyleProject);
const projectFile = await provider.createProject(name, location, projectTypeId, projectTargetVersion, sdkStyleProject, configureDefaultBuild);
await this.addProjectsToWorkspace([projectFile]);
this._onDidWorkspaceProjectsChange.fire();
return projectFile;
Expand Down
34 changes: 34 additions & 0 deletions extensions/data-workspace/src/test/workspaceService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,38 @@ suite('WorkspaceService', function (): void {
should.strictEqual(updateWorkspaceFoldersStub.calledOnce, true, 'updateWorkspaceFolders should have been called');
onWorkspaceProjectsChangedDisposable.dispose();
});

test('createProject passes all property', async () => {
this.timeout(30000);
// Create a new instance of WorkspaceService
const service = new WorkspaceService();

// Stub the createProject method so we can verify how it's called
const createProjectStub = sinon.stub(service, 'createProject').resolves();

// Define test parameters
const name = 'TestProject';
const location = vscode.Uri.file('/tmp/TestProject');
const projectTypeId = 'sqlproj';
const projectTargetVersion = 'SqlAzureV12';
const sdkStyleProject = true;
const configureDefaultBuild = true;

// Call the method under test with all parameters, including configureDefaultBuild
await service.createProject(name, location, projectTypeId, projectTargetVersion, sdkStyleProject, configureDefaultBuild);

// Assert that createProject was called exactly once
should.strictEqual(createProjectStub.calledOnce, true, 'createProject should have been called once');

// Get the arguments with which createProject was called
const callArgs = createProjectStub.getCall(0).args;

// Assert each argument matches what we passed in
should.strictEqual(callArgs[0], name, 'name should match');
should.strictEqual(callArgs[1], location, 'location should match');
should.strictEqual(callArgs[2], projectTypeId, 'projectTypeId should match');
should.strictEqual(callArgs[3], projectTargetVersion, 'projectTargetVersion should match');
should.strictEqual(callArgs[4], sdkStyleProject, 'sdkStyleProject should match');
should.strictEqual(callArgs[5], configureDefaultBuild, 'configureDefaultBuild should be true');
});
});