Skip to content

Commit a539eff

Browse files
committed
Add advanced uninstaller UI + installedAt store
Signed-off-by: paulober <[email protected]>
1 parent 55b849f commit a539eff

File tree

16 files changed

+1326
-118
lines changed

16 files changed

+1326
-118
lines changed

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
"onWebviewPanel:newPicoProject",
6868
"onWebviewPanel:newPicoMicroPythonProject",
6969
"onWebviewPanel:newPicoRustProject",
70-
"onWebviewPanel:newPicoZephyrProject"
70+
"onWebviewPanel:newPicoZephyrProject",
71+
"onWebviewPanel:uninstaller"
7172
],
7273
"contributes": {
7374
"commands": [
@@ -273,6 +274,11 @@
273274
"title": "Get Zephyr SDK path",
274275
"category": "Raspberry Pi Pico",
275276
"enablement": "false"
277+
},
278+
{
279+
"command": "raspberry-pi-pico.openUninstaller",
280+
"title": "Open Uninstaller",
281+
"category": "Raspberry Pi Pico"
276282
}
277283
],
278284
"configuration": {

src/commands/cmdIds.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,5 @@ export const SWITCH_SDK = "switchSDK";
4444
export const UNINSTALL_PICO_SDK = "uninstallPicoSDK";
4545

4646
export const UPDATE_OPENOCD = "updateOpenOCD";
47+
48+
export const OPEN_UNINSTALLER = "openUninstaller";

src/commands/openUninstaller.mts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { Uri } from "vscode";
2+
import { Command } from "./command.mjs";
3+
import { OPEN_UNINSTALLER } from "./cmdIds.mjs";
4+
import { UninstallerPanel } from "../webview/uninstallerPanel.mjs";
5+
6+
export default class OpenUninstallerCommand extends Command {
7+
private readonly _extensionUri: Uri;
8+
9+
constructor(extensionUri: Uri) {
10+
super(OPEN_UNINSTALLER);
11+
12+
this._extensionUri = extensionUri;
13+
}
14+
15+
execute(): void {
16+
UninstallerPanel.createOrShow(this._extensionUri);
17+
}
18+
}

src/extension.mts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ import {
6767
downloadAndInstallOpenOCD,
6868
} from "./utils/download.mjs";
6969
import { getSupportedToolchains } from "./utils/toolchainUtil.mjs";
70-
import {
71-
NewProjectPanel,
72-
getWebviewOptions,
73-
} from "./webview/newProjectPanel.mjs";
70+
import { NewProjectPanel } from "./webview/newProjectPanel.mjs";
7471
import GithubApiCache from "./utils/githubApiCache.mjs";
7572
import ClearGithubApiCacheCommand from "./commands/clearGithubApiCache.mjs";
7673
import { ContextKeys } from "./contextKeys.mjs";
@@ -125,6 +122,9 @@ import {
125122
} from "./models/zephyrBoards.mjs";
126123
import { NewZephyrProjectPanel } from "./webview/newZephyrProjectPanel.mjs";
127124
import LastUsedDepsStore from "./utils/lastUsedDeps.mjs";
125+
import { getWebviewOptions } from "./webview/sharedFunctions.mjs";
126+
import { UninstallerPanel } from "./webview/uninstallerPanel.mjs";
127+
import OpenUninstallerCommand from "./commands/openUninstaller.mjs";
128128

129129
export async function activate(context: ExtensionContext): Promise<void> {
130130
Logger.info(LoggerSource.extension, "Extension activation triggered");
@@ -183,6 +183,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
183183
new UpdateOpenOCDCommand(),
184184
new SbomTargetPathDebugCommand(),
185185
new SbomTargetPathReleaseCommand(),
186+
new OpenUninstallerCommand(context.extensionUri),
186187
];
187188

188189
// register all command handlers
@@ -243,6 +244,17 @@ export async function activate(context: ExtensionContext): Promise<void> {
243244
})
244245
);
245246

247+
context.subscriptions.push(
248+
window.registerWebviewPanelSerializer(UninstallerPanel.viewType, {
249+
// eslint-disable-next-line @typescript-eslint/require-await
250+
async deserializeWebviewPanel(webviewPanel: WebviewPanel): Promise<void> {
251+
// Reset the webview options so we use latest uri for `localResourceRoots`.
252+
webviewPanel.webview.options = getWebviewOptions(context.extensionUri);
253+
UninstallerPanel.revive(webviewPanel, context.extensionUri);
254+
},
255+
})
256+
);
257+
246258
context.subscriptions.push(
247259
window.registerTreeDataProvider(
248260
PicoProjectActivityBar.viewType,

src/logger.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export enum LoggerSource {
4646
projectRust = "projectRust",
4747
zephyrSetup = "setupZephyr",
4848
projectZephyr = "projectZephyr",
49+
uninstallUtil = "uninstallUtil",
4950
}
5051

5152
/**

src/models/dependency.mts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,23 @@ export const ALL_DEPS: DependencyMeta[] = [
3131
{ id: "7zip", label: "7-Zip", platforms: ["win32"], versioned: false },
3232
{ id: "pico-sdk-tools", label: "Pico SDK Tools" },
3333
{ id: "picotool", label: "Picotool" },
34+
{ id: "zephyr", label: "Zephyr" },
3435
];
36+
37+
// version -> YYYY-MM-DD (local)
38+
export type VersionMap = Record<string, string>;
39+
// dep -> VersionMap
40+
export type DepVersionDb = Record<DepId, VersionMap>;
41+
42+
export const INSTALL_ROOT_ALIAS: Partial<Record<DepId, string>> = {
43+
// eslint-disable-next-line @typescript-eslint/naming-convention
44+
"pico-sdk": "sdk",
45+
// eslint-disable-next-line @typescript-eslint/naming-convention
46+
"pico-sdk-tools": "tools",
47+
// eslint-disable-next-line @typescript-eslint/naming-convention
48+
"arm-toolchain": "toolchain",
49+
// eslint-disable-next-line @typescript-eslint/naming-convention
50+
"riscv-toolchain": "toolchain",
51+
zephyr: "zephyr_workspace",
52+
// others default to their depId
53+
};

src/ui.mts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,20 @@ enum StatusBarItemKey {
1919

2020
const STATUS_BAR_ITEMS: {
2121
[key: string]: {
22+
name: string;
2223
text: string;
2324
rustText?: string;
2425
zephyrText?: string;
2526
command: string;
2627
tooltip: string;
28+
rustTooltip?: string;
2729
zephyrTooltip?: string;
2830
rustSupport: boolean;
2931
zephyrSupport: boolean;
3032
};
3133
} = {
3234
[StatusBarItemKey.compile]: {
35+
name: "Raspberry Pi Pico - Compile Project",
3336
// alt. "$(gear) Compile"
3437
text: "$(file-binary) Compile",
3538
command: `${extensionName}.${COMPILE_PROJECT}`,
@@ -38,6 +41,7 @@ const STATUS_BAR_ITEMS: {
3841
zephyrSupport: true,
3942
},
4043
[StatusBarItemKey.run]: {
44+
name: "Raspberry Pi Pico - Run Project",
4145
// alt. "$(gear) Compile"
4246
text: "$(run) Run",
4347
command: `${extensionName}.${RUN_PROJECT}`,
@@ -46,6 +50,7 @@ const STATUS_BAR_ITEMS: {
4650
zephyrSupport: true,
4751
},
4852
[StatusBarItemKey.picoSDKQuickPick]: {
53+
name: "Raspberry Pi Pico - Select SDK Version",
4954
text: "Pico SDK: <version>",
5055
zephyrText: "Zephyr version: <version>",
5156
command: `${extensionName}.${SWITCH_SDK}`,
@@ -55,10 +60,12 @@ const STATUS_BAR_ITEMS: {
5560
zephyrSupport: true,
5661
},
5762
[StatusBarItemKey.picoBoardQuickPick]: {
63+
name: "Raspberry Pi Pico - Select Board",
5864
text: "Board: <board>",
5965
rustText: "Chip: <chip>",
6066
command: `${extensionName}.${SWITCH_BOARD}`,
61-
tooltip: "Select Chip",
67+
tooltip: "Select board",
68+
rustTooltip: "Select Chip",
6269
rustSupport: true,
6370
zephyrSupport: true,
6471
},
@@ -78,6 +85,7 @@ export default class UI {
7885
Object.entries(STATUS_BAR_ITEMS).forEach(([key, value]) => {
7986
this._items[key] = this.createStatusBarItem(
8087
key,
88+
value.name,
8189
value.text,
8290
value.command,
8391
value.tooltip
@@ -102,6 +110,13 @@ export default class UI {
102110
if (STATUS_BAR_ITEMS[item.id].zephyrTooltip) {
103111
item.tooltip = STATUS_BAR_ITEMS[item.id].zephyrTooltip;
104112
}
113+
} else if (isRustProject) {
114+
if (STATUS_BAR_ITEMS[item.id].rustText) {
115+
item.text = STATUS_BAR_ITEMS[item.id].rustText!;
116+
}
117+
if (STATUS_BAR_ITEMS[item.id].rustTooltip) {
118+
item.tooltip = STATUS_BAR_ITEMS[item.id].rustTooltip;
119+
}
105120
}
106121
item.show();
107122
});
@@ -160,11 +175,13 @@ export default class UI {
160175

161176
private createStatusBarItem(
162177
key: string,
178+
name: string,
163179
text: string,
164180
command: string,
165181
tooltip: string
166182
): StatusBarItem {
167183
const item = window.createStatusBarItem(key, StatusBarAlignment.Right);
184+
item.name = name;
168185
item.text = text;
169186
item.command = command;
170187
item.tooltip = tooltip;

0 commit comments

Comments
 (0)