Skip to content

Commit 0ee67c1

Browse files
authored
Merge pull request #165 from paulober/develop
Patch v3.5.0
2 parents 0ea5d02 + 637423f commit 0ee67c1

File tree

8 files changed

+778
-296
lines changed

8 files changed

+778
-296
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ All notable changes to the "MicroPico" extension will be documented in this file
1010

1111
---
1212

13+
## [3.5.0] - 2023-11-22
14+
15+
# Added
16+
- `micropico.extra.switchStubs` command to switch between MicroPython stubs for different MicroPython versions and ports (RPi Pico, RPi Pico (W) and ESP32) (Thanks to @Josverl) (Fixes #164)
17+
18+
# Changed
19+
- Updated dependencies
20+
21+
# Removed
22+
- Settings auto-update workaround from the extension renaming process (Fixes #164)
23+
1324
## [3.4.3] - 2023-11-10
1425

1526
# Changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
"MicroPico" is a Visual Studio Code extension designed to simplify and accelerate the development of MicroPython projects for the Raspberry Pi Pico and Pico W boards. This tool streamlines the coding process, providing code highlighting, auto-completion, code snippets, and project management features, all tailored for the seamless development experience with MicroPython on Raspberry Pi Pico and Pico W microcontrollers.
44

5-
> __Auto-completion based on Raspberry Pi Pico W MicroPython firmware: [RPI_PICO_W-20231005-v1.21.0.uf2](https://micropython.org/resources/firmware/RPI_PICO_W-20231005-v1.21.0.uf2) from the [micropython-stubs project](https://github.com/Josverl/micropython-stubs)__
5+
> __Included auto-completion based on Raspberry Pi Pico W MicroPython firmware: [RPI_PICO_W-20231005-v1.21.0.uf2](https://micropython.org/resources/firmware/RPI_PICO_W-20231005-v1.21.0.uf2) from the [micropython-stubs project](https://github.com/Josverl/micropython-stubs)__
66
77
Works with:
88
| Platform | x64 | arm64 | armhf |
@@ -17,6 +17,7 @@ Works with:
1717
- Pseudo terminal integration for communication with MicroPython REPL on a Pico (w) board (with support for tab-completion)
1818
- Running / Transferring files to / from your board
1919
- Built-in virtual-workspace provider for Raspberry Pi Pico (W) boards
20+
- Switch between auto-completion and IntelliSense for MicroPython ports RPi Pico, RPi Pico (W) and ESP32 (requires pip installed an in PATH)
2021

2122
![Preview](images/preview.gif)
2223

package-lock.json

Lines changed: 492 additions & 258 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "pico-w-go",
33
"displayName": "MicroPico",
44
"description": "Auto-completion, remote workspace and a REPL console integration for the Raspberry Pi Pico (W) with MicroPython firmware.",
5-
"version": "3.4.3",
5+
"version": "3.5.0",
66
"publisher": "paulober",
77
"license": "MPL-2.0",
88
"homepage": "https://github.com/paulober/MicroPico/blob/main/README.md",
@@ -59,7 +59,8 @@
5959
],
6060
"cpu": [
6161
"x64",
62-
"arm64"
62+
"arm64",
63+
"arm"
6364
],
6465
"minimumNodeVersion": 18,
6566
"contributes": {
@@ -165,6 +166,11 @@
165166
"title": "Help > Check for firmware updates",
166167
"category": "MicroPico"
167168
},
169+
{
170+
"command": "micropico.extra.switchStubs",
171+
"title": "Extra > Switch stubs",
172+
"category": "MicroPico"
173+
},
168174
{
169175
"command": "micropico.listCommands",
170176
"title": "List all Commands",
@@ -506,31 +512,35 @@
506512
},
507513
"devDependencies": {
508514
"@rollup/plugin-commonjs": "^25.0.7",
515+
"@rollup/plugin-json": "^6.0.1",
509516
"@rollup/plugin-node-resolve": "^15.2.3",
510517
"@rollup/plugin-terser": "^0.4.4",
511518
"@rollup/plugin-typescript": "^11.1.5",
512519
"@types/fs-extra": "^11.0.4",
513-
"@types/lodash": "^4.14.201",
514-
"@types/mocha": "^10.0.4",
520+
"@types/lodash": "^4.14.202",
521+
"@types/mocha": "^10.0.6",
515522
"@types/node": "^18.x",
516523
"@types/uuid": "^9.0.7",
517524
"@types/vscode": "^1.82.0",
518-
"@typescript-eslint/eslint-plugin": "^6.10.0",
519-
"@typescript-eslint/parser": "^6.10.0",
520-
"@vscode/test-electron": "^2.3.6",
521-
"eslint": "^8.53.0",
525+
"@types/which": "^3.0.3",
526+
"@typescript-eslint/eslint-plugin": "^6.12.0",
527+
"@typescript-eslint/parser": "^6.12.0",
528+
"@vscode/test-electron": "^2.3.7",
529+
"eslint": "^8.54.0",
522530
"eslint-config-prettier": "^9.0.0",
523531
"glob": "^9.3.4",
524532
"mocha": "^10.2.0",
525-
"rollup": "^4.3.0",
533+
"rollup": "^4.5.1",
526534
"rollup-plugin-copy": "^3.5.0",
527-
"typescript": "^5.2.2"
535+
"typescript": "^5.3.2"
528536
},
529537
"dependencies": {
530538
"@paulober/pyboard-serial-com": "^2.0.5",
539+
"axios": "^1.6.2",
531540
"fs-extra": "^11.1.1",
532541
"lodash": "^4.17.21",
533542
"rimraf": "^5.0.5",
534-
"uuid": "^9.0.1"
543+
"uuid": "^9.0.1",
544+
"which": "^4.0.0"
535545
}
536546
}

rollup.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { nodeResolve } from '@rollup/plugin-node-resolve';
33
import terser from '@rollup/plugin-terser';
44
import typescript from '@rollup/plugin-typescript';
55
import copy from 'rollup-plugin-copy';
6+
import json from '@rollup/plugin-json';
67

78
const isProduction = process.env.BUILD === 'production';
89

@@ -35,5 +36,7 @@ export default {
3536
tsconfig: 'tsconfig.json',
3637
}),
3738
isProduction && terser(),
39+
// required by axios
40+
json(),
3841
],
3942
};

src/activator.mts

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ import {
99
openSettings,
1010
writeIntoClipboard,
1111
} from "./api.mjs";
12-
import Stubs from "./stubs.mjs";
12+
import Stubs, {
13+
displayStringToStubPort,
14+
fetchAvailableStubsVersions,
15+
installIncludedStubs,
16+
installStubsByVersion,
17+
stubPortToDisplayString,
18+
} from "./stubs.mjs";
1319
import Settings, { SettingsKey } from "./settings.mjs";
1420
import { PyboardRunner, PyOutType } from "@paulober/pyboard-serial-com";
1521
import type {
@@ -1068,6 +1074,77 @@ export default class Activator {
10681074
);
10691075
context.subscriptions.push(disposable);
10701076

1077+
// [Command] Check for firmware updates
1078+
disposable = vscode.commands.registerCommand(
1079+
commandPrefix + "extra.switchStubs",
1080+
async () => {
1081+
const versions: string[] = [];
1082+
1083+
Object.entries(await fetchAvailableStubsVersions()).forEach(
1084+
([key, values]) => {
1085+
// Map each value to "key - value" and push to resultArray
1086+
versions.push(
1087+
...values.map(
1088+
value => `${stubPortToDisplayString(key)} - ${value}`
1089+
)
1090+
);
1091+
}
1092+
);
1093+
1094+
// show quick pick
1095+
const version = await vscode.window.showQuickPick(
1096+
["Included", ...versions],
1097+
{
1098+
canPickMany: false,
1099+
placeHolder: "Select the stubs version you want to use",
1100+
ignoreFocusOut: false,
1101+
}
1102+
);
1103+
1104+
if (version === undefined) {
1105+
return;
1106+
}
1107+
1108+
if (version.toLowerCase() === "included") {
1109+
await installIncludedStubs();
1110+
1111+
void vscode.window.showInformationMessage("Included stubs selected.");
1112+
} else {
1113+
await vscode.window.withProgress(
1114+
{
1115+
location: vscode.ProgressLocation.Notification,
1116+
title: "Downloading stubs, this may take a while...",
1117+
cancellable: false,
1118+
},
1119+
async (progress, token) => {
1120+
// cancellation is not possible
1121+
token.onCancellationRequested(() => undefined);
1122+
const versionParts = version.split(" - ");
1123+
1124+
// TODO: implement cancellation
1125+
const result = await installStubsByVersion(
1126+
versionParts[1],
1127+
displayStringToStubPort(versionParts[0])
1128+
);
1129+
1130+
if (result) {
1131+
progress.report({
1132+
increment: 100,
1133+
message: "Stubs installed.",
1134+
});
1135+
void vscode.window.showInformationMessage("Stubs installed.");
1136+
} else {
1137+
void vscode.window.showErrorMessage(
1138+
"Stubs installation failed."
1139+
);
1140+
}
1141+
}
1142+
);
1143+
}
1144+
}
1145+
);
1146+
context.subscriptions.push(disposable);
1147+
10711148
return this.ui;
10721149
}
10731150

src/osHelper.mts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { lstat } from "fs";
12
import { readFile, stat, writeFile } from "fs/promises";
3+
import { rimrafSync } from "rimraf";
24

35
export async function pathExists(path: string): Promise<boolean> {
46
try {
@@ -42,3 +44,20 @@ export async function writeJsonFile<T>(
4244
);
4345
}
4446
}
47+
48+
export function removeJunction(junctionPath: string): Promise<boolean> {
49+
return new Promise(resolve => {
50+
lstat(junctionPath, (err, stats) => {
51+
if (err) {
52+
//reject(err);
53+
resolve(false);
54+
} else if (stats.isSymbolicLink()) {
55+
const result = rimrafSync(junctionPath);
56+
resolve(result);
57+
} else {
58+
//reject(new Error(`${junctionPath} is not a directory junction.`));
59+
resolve(false);
60+
}
61+
});
62+
});
63+
}

0 commit comments

Comments
 (0)