Skip to content
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

feat(explorer/build): add button to rebuild #1224

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@
"icon": "$(play)",
"description": "%titanium.commands.build.run.description%"
},
{
"command": "titanium.build.rebuild",
"title": "%titanium.commands.build.rebuild.title%",
"category": "Titanium",
"icon": "$(debug-restart)",
"description": "%titanium.commands.build.rebuild.description%"
},
{
"command": "titanium.build.debug",
"title": "%titanium.commands.build.debug.title%",
Expand Down Expand Up @@ -711,6 +718,11 @@
"when": "view == titanium.view.buildExplorer",
"group": "navigation@2"
},
{
"command": "titanium.build.rebuild",
"when": "view == titanium.view.buildExplorer && titanium:build:running",
"group": "navigation@2"
},
{
"command": "titanium.build.stop",
"when": "view == titanium.view.buildExplorer && titanium:build:running",
Expand Down
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"titanium.commands.build.setLiveViewEnabled.title": "Enable LiveView",
"titanium.commands.build.setLiveViewDisabled.title": "Disable LiveView",
"titanium.commands.build.run.title": "Build",
"titanium.commands.build.run.description": "Build a Titanium project",
"titanium.commands.build.rebuild.title": "Rebuild",
"titanium.commands.build.rebuild.description": "Rebuild last project build",
"titanium.commands.build.debug.title": "Debug",
"titanium.commands.build.debug.description": "Debug a Titanium project",
"titanium.commands.package.run.title": "Package",
Expand Down
1 change: 1 addition & 0 deletions src/commands/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export enum Commands {
OpenReleaseNotes = 'titanium.updates.openReleaseNotes',
OpenUrl = 'titanium.openUrl',
Package = 'titanium.package.run',
Rebuild = 'titanium.build.rebuild',
RefreshExplorer = 'titanium.explorer.refresh',
RefreshHelp = 'titanium.helpExplorer.refresh',
SelectUpdates = 'titanium.updates.select',
Expand Down
26 changes: 24 additions & 2 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

import { ExtensionContainer } from '../container';
import { Commands } from './common';
import { GlobalState } from '../constants';
import { GlobalState, WorkspaceState } from '../constants';
import { buildApplication } from './buildApp';
import { buildModule } from './buildModule';
import { DeviceNode, DistributeNode, OSVerNode, PlatformNode, TargetNode, UpdateNode } from '../explorer/nodes';
import { sleep } from '../common/utils';
import { packageApplication } from './packageApp';
import { packageModule } from './packageModule';
import { promptForWorkspaceFolder, quickPick } from '../quickpicks';
import { KeystoreInfo, LogLevel } from '../types/common';
import { KeystoreInfo, LastBuildState, LogLevel } from '../types/common';
import { configuration } from '../configuration';
import { AlloyComponentExtension, AlloyComponentFolder, AlloyComponentType, generateComponent, generateModel } from './alloyGenerate';
import { debugSessionInformation, DEBUG_SESSION_VALUE } from '../tasks/tasksHelper';
Expand All @@ -25,7 +25,7 @@
import { readJSON } from 'fs-extra';
import { startup } from '../extension';

export function registerCommand (commandId: string, callback: (...args: any[]) => unknown): void {

Check warning on line 28 in src/commands/index.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
ExtensionContainer.context.subscriptions.push(
vscode.commands.registerCommand(commandId, async (...args: unknown[]) => {
return callback(...args);
Expand Down Expand Up @@ -220,6 +220,28 @@
registerCommand(Commands.FixEnvironmentIssues, async () => {
startup();
});

registerCommand(Commands.Rebuild, async () => {
if (ExtensionContainer.context.globalState.get<boolean>(GlobalState.Running)) {
await vscode.commands.executeCommand(Commands.StopBuild);
await sleep(100);
}

const lastBuildState = ExtensionContainer.context.workspaceState.get<LastBuildState>(WorkspaceState.LastBuildState);

if (!lastBuildState) {
return;
}

const { type, folder } = await promptForWorkspaceFolder({ apps: true, modules: true, placeHolder: 'Please select a project to build' });
const node = new DeviceNode('', lastBuildState.platform, lastBuildState.target, lastBuildState?.deviceId, lastBuildState.target);

if (type === 'app') {
return buildApplication(node, folder);
} else if (type === 'module') {
return buildModule(undefined, folder);
}
});
}

export * from './common';
Expand Down
Loading