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

Patch v3.5.0 #165

Merged
merged 4 commits into from
Nov 22, 2023
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ All notable changes to the "MicroPico" extension will be documented in this file

---

## [3.5.0] - 2023-11-22

# Added
- `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)

# Changed
- Updated dependencies

# Removed
- Settings auto-update workaround from the extension renaming process (Fixes #164)

## [3.4.3] - 2023-11-10

# Changed
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"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.

> __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)__
> __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)__

Works with:
| Platform | x64 | arm64 | armhf |
Expand All @@ -17,6 +17,7 @@ Works with:
- Pseudo terminal integration for communication with MicroPython REPL on a Pico (w) board (with support for tab-completion)
- Running / Transferring files to / from your board
- Built-in virtual-workspace provider for Raspberry Pi Pico (W) boards
- Switch between auto-completion and IntelliSense for MicroPython ports RPi Pico, RPi Pico (W) and ESP32 (requires pip installed an in PATH)

![Preview](images/preview.gif)

Expand Down
750 changes: 492 additions & 258 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 21 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pico-w-go",
"displayName": "MicroPico",
"description": "Auto-completion, remote workspace and a REPL console integration for the Raspberry Pi Pico (W) with MicroPython firmware.",
"version": "3.4.3",
"version": "3.5.0",
"publisher": "paulober",
"license": "MPL-2.0",
"homepage": "https://github.com/paulober/MicroPico/blob/main/README.md",
Expand Down Expand Up @@ -59,7 +59,8 @@
],
"cpu": [
"x64",
"arm64"
"arm64",
"arm"
],
"minimumNodeVersion": 18,
"contributes": {
Expand Down Expand Up @@ -165,6 +166,11 @@
"title": "Help > Check for firmware updates",
"category": "MicroPico"
},
{
"command": "micropico.extra.switchStubs",
"title": "Extra > Switch stubs",
"category": "MicroPico"
},
{
"command": "micropico.listCommands",
"title": "List all Commands",
Expand Down Expand Up @@ -506,31 +512,35 @@
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.5",
"@types/fs-extra": "^11.0.4",
"@types/lodash": "^4.14.201",
"@types/mocha": "^10.0.4",
"@types/lodash": "^4.14.202",
"@types/mocha": "^10.0.6",
"@types/node": "^18.x",
"@types/uuid": "^9.0.7",
"@types/vscode": "^1.82.0",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"@vscode/test-electron": "^2.3.6",
"eslint": "^8.53.0",
"@types/which": "^3.0.3",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"@vscode/test-electron": "^2.3.7",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"glob": "^9.3.4",
"mocha": "^10.2.0",
"rollup": "^4.3.0",
"rollup": "^4.5.1",
"rollup-plugin-copy": "^3.5.0",
"typescript": "^5.2.2"
"typescript": "^5.3.2"
},
"dependencies": {
"@paulober/pyboard-serial-com": "^2.0.5",
"axios": "^1.6.2",
"fs-extra": "^11.1.1",
"lodash": "^4.17.21",
"rimraf": "^5.0.5",
"uuid": "^9.0.1"
"uuid": "^9.0.1",
"which": "^4.0.0"
}
}
3 changes: 3 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { nodeResolve } from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import copy from 'rollup-plugin-copy';
import json from '@rollup/plugin-json';

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

Expand Down Expand Up @@ -35,5 +36,7 @@ export default {
tsconfig: 'tsconfig.json',
}),
isProduction && terser(),
// required by axios
json(),
],
};
79 changes: 78 additions & 1 deletion src/activator.mts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import {
openSettings,
writeIntoClipboard,
} from "./api.mjs";
import Stubs from "./stubs.mjs";
import Stubs, {
displayStringToStubPort,
fetchAvailableStubsVersions,
installIncludedStubs,
installStubsByVersion,
stubPortToDisplayString,
} from "./stubs.mjs";
import Settings, { SettingsKey } from "./settings.mjs";
import { PyboardRunner, PyOutType } from "@paulober/pyboard-serial-com";
import type {
Expand Down Expand Up @@ -1068,6 +1074,77 @@ export default class Activator {
);
context.subscriptions.push(disposable);

// [Command] Check for firmware updates
disposable = vscode.commands.registerCommand(
commandPrefix + "extra.switchStubs",
async () => {
const versions: string[] = [];

Object.entries(await fetchAvailableStubsVersions()).forEach(
([key, values]) => {
// Map each value to "key - value" and push to resultArray
versions.push(
...values.map(
value => `${stubPortToDisplayString(key)} - ${value}`
)
);
}
);

// show quick pick
const version = await vscode.window.showQuickPick(
["Included", ...versions],
{
canPickMany: false,
placeHolder: "Select the stubs version you want to use",
ignoreFocusOut: false,
}
);

if (version === undefined) {
return;
}

if (version.toLowerCase() === "included") {
await installIncludedStubs();

void vscode.window.showInformationMessage("Included stubs selected.");
} else {
await vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
title: "Downloading stubs, this may take a while...",
cancellable: false,
},
async (progress, token) => {
// cancellation is not possible
token.onCancellationRequested(() => undefined);
const versionParts = version.split(" - ");

// TODO: implement cancellation
const result = await installStubsByVersion(
versionParts[1],
displayStringToStubPort(versionParts[0])
);

if (result) {
progress.report({
increment: 100,
message: "Stubs installed.",
});
void vscode.window.showInformationMessage("Stubs installed.");
} else {
void vscode.window.showErrorMessage(
"Stubs installation failed."
);
}
}
);
}
}
);
context.subscriptions.push(disposable);

return this.ui;
}

Expand Down
19 changes: 19 additions & 0 deletions src/osHelper.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { lstat } from "fs";
import { readFile, stat, writeFile } from "fs/promises";
import { rimrafSync } from "rimraf";

export async function pathExists(path: string): Promise<boolean> {
try {
Expand Down Expand Up @@ -42,3 +44,20 @@ export async function writeJsonFile<T>(
);
}
}

export function removeJunction(junctionPath: string): Promise<boolean> {
return new Promise(resolve => {
lstat(junctionPath, (err, stats) => {
if (err) {
//reject(err);
resolve(false);
} else if (stats.isSymbolicLink()) {
const result = rimrafSync(junctionPath);
resolve(result);
} else {
//reject(new Error(`${junctionPath} is not a directory junction.`));
resolve(false);
}
});
});
}
Loading
Loading