Skip to content

πŸ’‘[Feature]: Create one task for bundle & package each (Fix - 386) #397

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 5 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
Binary file modified assets/images/tasks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/constants/Commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export const Commands = {
// Webviews
samplesGallery: `${EXTENSION_NAME}.samplesGallery`,

// Bundle
bundleProject: `${EXTENSION_NAME}.bundleProject`,

// Package
packageProject: `${EXTENSION_NAME}.packageProject`,

// Serving
serveProject: `${EXTENSION_NAME}.serveProject`,

Expand Down
6 changes: 2 additions & 4 deletions src/panels/CommandPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,10 @@ export class CommandPanel {
private static taskTreeView() {
const taskCommands: ActionTreeItem[] = [
new ActionTreeItem('Build project', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp build'),
new ActionTreeItem('Bundle project (local)', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp bundle'),
new ActionTreeItem('Bundle project (production)', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp bundle --ship'),
new ActionTreeItem('Bundle project', '', { name: 'debug-start', custom: false }, undefined, Commands.bundleProject),
new ActionTreeItem('Clean project', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp clean'),
new ActionTreeItem('Deploy project assets to Azure Storage', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp deploy-azure-storage'),
new ActionTreeItem('Package (local)', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp package-solution'),
new ActionTreeItem('Package (production)', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp package-solution --ship'),
new ActionTreeItem('Package', '', { name: 'debug-start', custom: false }, undefined, Commands.packageProject),
new ActionTreeItem('Serve', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp serve'),
new ActionTreeItem('Serve (nobrowser)', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp serve --nobrowser'),
new ActionTreeItem('Serve from configuration', '', { name: 'debug-start', custom: false }, undefined, Commands.serveProject),
Expand Down
39 changes: 39 additions & 0 deletions src/services/executeWrappers/TerminalCommandExecuter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export class TerminalCommandExecuter {
subscriptions.push(
commands.registerCommand(Commands.serveProject, TerminalCommandExecuter.serveProject)
);
subscriptions.push(
commands.registerCommand(Commands.bundleProject, TerminalCommandExecuter.bundleProject)
);
subscriptions.push(
commands.registerCommand(Commands.packageProject, TerminalCommandExecuter.packageProject)
);
subscriptions.push(
commands.registerCommand(Commands.executeTerminalCommand, TerminalCommandExecuter.runCommand)
);
Expand Down Expand Up @@ -93,6 +99,39 @@ export class TerminalCommandExecuter {
commands.executeCommand(Commands.executeTerminalCommand, `gulp serve --config=${answer}`);
}

/**
* Bundles the project based on the environment type selected by the user.
*/
public static async bundleProject() {
const answer = await TerminalCommandExecuter.environmentTypePrompt();

if (answer) {
commands.executeCommand(Commands.executeTerminalCommand, `gulp bundle${answer === 'local' ? '' : ' --ship'}`);
}
}

/**
* Prompts the user to select an environment type and executes the appropriate
* Gulp command to package the project based on the user's selection.
*/
public static async packageProject() {
const answer = await TerminalCommandExecuter.environmentTypePrompt();

if (answer) {
commands.executeCommand(Commands.executeTerminalCommand, `gulp package-solution${answer === 'local' ? '' : ' --ship'}`);
}
}

/**
* Prompts the user to select the target environment type.
*/
private static async environmentTypePrompt(): Promise<string | undefined> {
return await window.showQuickPick(['local', 'production'], {
title: 'Select the target environment',
ignoreFocusOut: true
});
}

/**
* Initializes the shell path for executing terminal commands.
* If the shell path is an object with a `path` property, it sets the `shellPath` to that value.
Expand Down