Skip to content

Commit

Permalink
Many small bugfixes (#229)
Browse files Browse the repository at this point in the history
* add vscode folder files only if doesnt exists

* win py paths update esp-idf versions

* fix examples title and html

* show framework if path exists, win settings docs

* update readme

* update readme

* rm items type

* check rainmaker undefined tooltip label

* rm unused type

* mv item cmd construction val framework dir

* void type promise
  • Loading branch information
brianignacio5 committed Dec 25, 2020
1 parent 828691e commit 9d25a29
Show file tree
Hide file tree
Showing 20 changed files with 186 additions and 107 deletions.
22 changes: 17 additions & 5 deletions README.md
Expand Up @@ -115,14 +115,18 @@ Click <kbd>F1</kbd> to show Visual studio code actions, then type **ESP-IDF** to
| Open ESP-IDF Terminal | <kbd>⌘</kbd> <kbd>E</kbd> <kbd>T</kbd> | <kbd>Ctrl</kbd> <kbd>E</kbd> <kbd>T</kbd> |
| Pick a workspace folder | | |
| Size analysis of the binaries | <kbd>⌘</kbd> <kbd>E</kbd> <kbd>S</kbd> | <kbd>Ctrl</kbd> <kbd>E</kbd> <kbd>S</kbd> |
| Show ESP-IDF Examples Projects | | |
| Show Examples Projects | | |
| Add Editor coverage | | |
| Remove Editor coverage | | |
| Get HTML Coverage Report for project | | |
| Search in documentation... | <kbd>⌘</kbd> <kbd>E</kbd> <kbd>D</kbd> | <kbd>Ctrl</kbd> <kbd>E</kbd> <kbd>D</kbd> |
| Install ESP-ADF | | |
| Install ESP-MDF | | |

The **Add Arduino ESP32 as ESP-IDF Component** command will add [Arduino ESP32](https://github.com/espressif/arduino-esp32) as a ESP-IDF component in your current directory with in `${CURRENT_FOLDER}/components/arduino`. You can also use **Create ESP-IDF project** with the `arduino-as-component` template to create a new project folder that includes arduino as ESP-IDF component.

The **Show Examples Projects** command allows you create a new project using one of the examples in ESP-IDF, ESP-ADF or ESP-MDF directory if related configuration settings are set. The **Install ESP-ADF** will clone ESP-ADF and set `idf.espAdfPath` (`idf.espAdfPathWin` in Windows). **Install ESP-MDF** will clone ESP-MDF and set `idf.espMdfPath` (`idf.espMdfPathWin` in Windows).

## ESP-IDF Configure extension

Initial configuration is done easily by executing **ESP-IDF: Configure ESP-IDF extension** Please take a look at [ONBOARDING](./docs/ONBOARDING.md) for more in-depth detail. This window is always shown when extension is activated which you can disable with `idf.showOnboardingOnInit`.
Expand All @@ -149,8 +153,15 @@ These are the configuration settings that ESP-IDF extension contributes to your
| Setting ID | Description |
| ---------------------------- | ----------------------------------------------------------------------------- |
| `idf.espIdfPath` | Path to locate ESP-IDF framework (IDF_PATH) |
| `idf.espIdfPathWin` | Path to locate ESP-IDF framework in Windows (IDF_PATH) |
| `idf.espAdfPath` | Path to locate ESP-ADF framework (ADF_PATH) |
| `idf.espAdfPathWin` | Path to locate ESP-ADF framework in Windows (ADF_PATH) |
| `idf.espMdfPath` | Path to locate ESP-MDF framework (MDF_PATH) |
| `idf.espMdfPathWin` | Path to locate ESP-MDF framework in Windows (MDF_PATH) |
| `idf.toolsPath` | Path to locate ESP-IDF Tools (IDF_TOOLS_PATH) |
| `idf.toolsPathWin` | Path to locate ESP-IDF Tools in Windows (IDF_TOOLS_PATH) |
| `idf.pythonBinPath` | Python absolute binary path used to execute ESP-IDF Python Scripts |
| `idf.pythonBinPathWin` | Python absolute binary path used to execute ESP-IDF Python Scripts in Windows |
| `idf.customExtraPaths` | Paths to be appended to \$PATH |
| `idf.customExtraVars` | Variables to be added to system environment variables |
| `idf.useIDFKconfigStyle` | Enable style validation for Kconfig files |
Expand All @@ -172,10 +183,11 @@ When you use the command **ESP-IDF: Set Espressif device target** it will overri

These settings are specific to the ESP32 Chip/ Board

| Setting | Description |
| ------------------- | ---------------------------- |
| `idf.port` | Path of selected device port |
| `idf.flashBaudRate` | Flash Baud rate |
| Setting | Description |
| ------------------- | --------------------------------------- |
| `idf.port` | Path of selected device port |
| `idf.portWin` | Path of selected device port in Windows |
| `idf.flashBaudRate` | Flash Baud rate |

The ESP-IDF Monitor default baud rate value is taken from your project's skdconfig `CONFIG_ESPTOOLPY_MONITOR_BAUD` (idf.py monitor' baud rate).
This value can be override by setting the environment variable `IDF_MONITOR_BAUD` or `MONITORBAUD` in your system environment variables or this extension's `idf.customExtraVars` configuration setting.
Expand Down
12 changes: 12 additions & 0 deletions docs/ONBOARDING.md
Expand Up @@ -34,6 +34,18 @@ If you installed ESP-IDF and ESP-IDF Tools following [ESP-IDF Get Started](https

where UPDATED_PATH is the "Updated PATH variable" generated by `$IDF_PATH/export.sh`, PYTHON_INTERPRETER is the "Using Python interpreter in" generated by `$IDF_PATH/export.sh`, the device port is your device serial port (COM1, /dev/cu.usbserial-1433401, etc) and idf.openOcdConfigs are the config files used for OpenOCD for your device (they are relative to OPENOCD_SCRIPTS directory).

Make sure to install the extension and extension debug adapter Python requirements by running the following commands in your terminal:

```
PYTHON_INTERPRETER -m pip install -r EXTENSION_PATH/requirements.txt
```

```
PYTHON_INTERPRETER -m pip install -r EXTENSION_PATH/esp_debug_adapter/requirements.txt
```

where EXTENSION_PATH is `%USERPROFILE%\.vscode\extensions\espressif.esp-idf-extension-VERSION` on Windows and `$HOME/.vscode/extensions/espressif.esp-idf-extension-VERSION` on Linux/MacOS.

### Using Preferences: Open Settings (UI)

This is the same as previous sections but the name of each configuration setting is the description given in the [Readme ESP-IDF Settings section](./../README.md).
Expand Down
2 changes: 1 addition & 1 deletion i18n/en/package.i18n.json
Expand Up @@ -15,7 +15,7 @@
"espIdf.flashDevice.title": "ESP-IDF: Flash your project",
"espIdf.monitorDevice.title": "ESP-IDF: Monitor your device",
"espIdf.onboarding.title": "ESP-IDF: Configure ESP-IDF extension",
"espIdf.examples.title": "ESP-IDF: Show ESP-IDF Examples Projects",
"espIdf.examples.title": "ESP-IDF: Show Examples Projects",
"espIdf.buildFlashMonitor.title": "ESP-IDF: Build, Flash and start a monitor on your device",
"espIdf.pickAWorkspaceFolder.title": "ESP-IDF: Pick a workspace folder",
"espIdf.size.title": "ESP-IDF: Size analysis of the binaries",
Expand Down
2 changes: 1 addition & 1 deletion i18n/es/package.i18n.json
Expand Up @@ -15,7 +15,7 @@
"espIdf.flashDevice.title": "ESP-IDF: Programar el dispositivo",
"espIdf.monitorDevice.title": "ESP-IDF: Monitorear el dispositivo",
"espIdf.onboarding.title": "ESP-IDF: Configurar la extension ESP-IDF",
"espIdf.examples.title": "ESP-IDF: Mostrar ejemplos de proyectos ESP-IDF",
"espIdf.examples.title": "ESP-IDF: Mostrar ejemplos de proyectos",
"espIdf.buildFlashMonitor.title": "ESP-IDF: Construir, Programar y empezar monitor de dispositivo",
"espIdf.pickAWorkspaceFolder.title": "ESP-IDF: Elige una carpeta de trabajo",
"espIdf.size.title": "ESP-IDF: Size analysis of the binaries",
Expand Down
2 changes: 1 addition & 1 deletion i18n/zh-CN/package.i18n.json
Expand Up @@ -15,7 +15,7 @@
"espIdf.flashDevice.title": "ESP-IDF:烧写项目",
"espIdf.monitorDevice.title": "ESP-IDF:监视设备输出",
"espIdf.onboarding.title": "ESP-IDF:配置 ESP-IDF 插件",
"espIdf.examples.title": "ESP-IDF:展示 ESP-IDF 示例项目",
"espIdf.examples.title": "ESP-IDF:展示示例项目",
"espIdf.buildFlashMonitor.title": "ESP-IDF:构建、烧写项目并启动监视器",
"espIdf.pickAWorkspaceFolder.title": "ESP-IDF:选择工作文件夹",
"espIdf.size.title": "ESP-IDF:分析二进制文件的大小",
Expand Down
7 changes: 5 additions & 2 deletions idf_versions.txt
@@ -1,5 +1,8 @@
v4.0.1
v3.3.2
v4.1
v4.0.2
v3.3.4
release/v4.2
release/v4.1
release/v4.0
release/v3.3
master
2 changes: 1 addition & 1 deletion package.nls.json
Expand Up @@ -15,7 +15,7 @@
"espIdf.flashDevice.title": "ESP-IDF: Flash your project",
"espIdf.monitorDevice.title": "ESP-IDF: Monitor your device",
"espIdf.onboarding.title": "ESP-IDF: Configure ESP-IDF extension",
"espIdf.examples.title": "ESP-IDF: Show ESP-IDF Examples Projects",
"espIdf.examples.title": "ESP-IDF: Show Examples Projects",
"espIdf.buildFlashMonitor.title": "ESP-IDF: Build, Flash and start a monitor on your device",
"espIdf.pickAWorkspaceFolder.title": "ESP-IDF: Pick a workspace folder",
"espIdf.size.title": "ESP-IDF: Size analysis of the binaries",
Expand Down
2 changes: 1 addition & 1 deletion src/common/abstractCloning.ts
Expand Up @@ -44,7 +44,7 @@ export class AbstractCloning {
progress: Progress<{ message?: string; increment?: number }>,
installDir: string
) {
return new Promise((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
this.cloneProcess = spawn(
"git",
[
Expand Down
2 changes: 1 addition & 1 deletion src/espIdf/arduino/addArduinoComponent.ts
Expand Up @@ -49,7 +49,7 @@ export class ArduinoComponentInstaller {
}
const componentsDir = join(this.projectDir, "components");
await ensureDir(componentsDir);
return new Promise((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
this.cloneProcess = spawn(
`git`,
[
Expand Down
2 changes: 1 addition & 1 deletion src/espIdf/menuconfig/confServerProcess.ts
Expand Up @@ -176,7 +176,7 @@ export class ConfserverProcess {

progress.report({ increment: 10, message: "Loading default values..." });

return new Promise((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
getSdkconfigProcess.stderr.on("data", (data) => {
if (isStringNotEmpty(data.toString())) {
ConfserverProcess.instance.printError(data.toString());
Expand Down
68 changes: 33 additions & 35 deletions src/examples/ExamplesPanel.ts
Expand Up @@ -29,18 +29,20 @@ export class ExamplesPlanel {

public static createOrShow(
extensionPath: string,
targetFrameworkFolder: string
targetFrameworkFolder: string,
targetDesc: string
) {
const column = vscode.window.activeTextEditor
? vscode.window.activeTextEditor.viewColumn
: undefined;
: vscode.ViewColumn.One;
if (ExamplesPlanel.currentPanel) {
ExamplesPlanel.currentPanel.panel.reveal(column);
} else {
ExamplesPlanel.currentPanel = new ExamplesPlanel(
extensionPath,
column || vscode.ViewColumn.One,
targetFrameworkFolder
column,
targetFrameworkFolder,
targetDesc
);
}
}
Expand All @@ -52,11 +54,12 @@ export class ExamplesPlanel {
private constructor(
extensionPath: string,
column: vscode.ViewColumn,
targetFrameworkFolder: string
targetFrameworkFolder: string,
targetDesc: string
) {
const onBoardingPanelTitle = locDic.localize(
"examples.panelName",
"ESP-IDF Examples"
`${targetDesc} Examples`
);
this.panel = vscode.window.createWebviewPanel(
ExamplesPlanel.viewType,
Expand Down Expand Up @@ -191,37 +194,32 @@ export class ExamplesPlanel {
smartypants: false,
});
let contentStr = marked(content);
const srcLinkRegex = /src\s*=\s*"(.+?)"/g;
const matches = contentStr.match(srcLinkRegex);
if (matches && matches.length > 0) {
for (let m of matches) {
const unresolvedPath = m
.replace('src="', "")
.replace('src ="', "")
.replace('"', "");
const absPath = `src="${this.panel.webview.asWebviewUri(
vscode.Uri.file(path.resolve(examplePath, unresolvedPath))
)}"`;
contentStr = contentStr.replace(m, absPath);
}
const srcLinkRegex = new RegExp(/src\s*=\s*"(.+?)"/g);
let match: RegExpExecArray;
while ((match = srcLinkRegex.exec(contentStr)) !== null) {
const unresolvedPath = match[1];
const absPath = `src="${this.panel.webview.asWebviewUri(
vscode.Uri.file(path.resolve(examplePath, unresolvedPath))
)}"`;
contentStr = contentStr.replace(match[0], absPath);
}
const srcEncodedRegex = /&lt;img src=&quot;(.*?)&quot;\s?&gt;/g;
const nextMatches = contentStr.match(srcEncodedRegex);
if (nextMatches && nextMatches.length > 0) {
for (let m of nextMatches) {
const pathToResolve = m.match(/(?:src=&quot;)(.*?)(?:&quot;)/);
const height = m.match(/(?:height=&quot;)(.*?)(?:&quot;)/);
const altText = m.match(/(?:alt=&quot;)(.*?)(?:&quot;)/);
const absPath = `<img src="${this.panel.webview.asWebviewUri(
vscode.Uri.file(path.resolve(examplePath, pathToResolve[1]))
)}" ${
height && height.length > 0 ? 'height="' + height[1] + '"' : ""
} alt="${
altText && altText.length > 0 ? '"alt=' + altText[1] + '"' : ""
} >`;
contentStr = contentStr.replace(m, absPath);
}
const srcEncodedRegex = new RegExp(/&lt;img src=&quot;(.*?)&quot;\s?&gt;/g);
let encodedMatch: RegExpExecArray;
while ((encodedMatch = srcEncodedRegex.exec(contentStr)) !== null) {
const pathToResolve = encodedMatch[0].match(
/(?:src=&quot;)(.*?)(?:&quot;)/
);
const height = encodedMatch[0].match(/(?:height=&quot;)(.*?)(?:&quot;)/);
const width = encodedMatch[0].match(/(?:width=&quot;)(.*?)(?:&quot;)/);
const altText = encodedMatch[0].match(/(?:alt=&quot;)(.*?)(?:&quot;)/);
const absPath = `<img src="${this.panel.webview.asWebviewUri(
vscode.Uri.file(path.resolve(examplePath, pathToResolve[1]))
)}" ${height && height.length > 0 ? `height="${height[1]}"` : ""} ${
width && width.length > 0 ? `width="${width[1]}"` : ""
} ${altText && altText.length > 0 ? `alt="${altText[1]}"` : ""} >`;
contentStr = contentStr.replace(encodedMatch[0], absPath);
}
contentStr = contentStr.replace(/&lt;/g, "<").replace(/&gt;/g, ">");
return contentStr;
}

Expand Down
56 changes: 39 additions & 17 deletions src/extension.ts
Expand Up @@ -821,8 +821,16 @@ export async function activate(context: vscode.ExtensionContext) {

registerIDFCommand("espIdf.createVsCodeFolder", () => {
PreCheck.perform([openFolderCheck], async () => {
await utils.createVscodeFolder(workspaceRoot.fsPath);
Logger.infoNotify("ESP-IDF VSCode files have been added to project.");
try {
await utils.createVscodeFolder(workspaceRoot.fsPath);
Logger.infoNotify(
"ESP-IDF vscode files have been added to the project."
);
} catch (error) {
const errMsg = error.message || "Error creating .vscode folder";
Logger.errorNotify(errMsg, error);
return;
}
});
});

Expand Down Expand Up @@ -1003,21 +1011,34 @@ export async function activate(context: vscode.ExtensionContext) {
const espMdfPath = idfConf.readParameter(
"idf.espMdfPath"
) as string;

const pickItems = [];
const doesIdfPathExists = await utils.dirExistPromise(espIdfPath);
if (doesIdfPathExists) {
pickItems.push({
description: "ESP-IDF",
label: `Use current ESP-IDF (${espIdfPath})`,
target: espIdfPath,
});
}
const doesAdfPathExists = await utils.dirExistPromise(espAdfPath);
if (doesAdfPathExists) {
pickItems.push({
description: "ESP-ADF",
label: `Use current ESP-ADF (${espAdfPath})`,
target: espAdfPath,
});
}
const doesMdfPathExists = await utils.dirExistPromise(espMdfPath);
if (doesMdfPathExists) {
pickItems.push({
description: "ESP-MDF",
label: `Use current ESP-MDF (${espMdfPath})`,
target: espMdfPath,
});
}
const examplesFolder = await vscode.window.showQuickPick(
[
{
label: `Use current ESP-IDF (${espIdfPath})`,
target: espIdfPath,
},
{
label: `Use current ESP-ADF (${espAdfPath})`,
target: espAdfPath,
},
{
label: `Use current ESP-MDF (${espMdfPath})`,
target: espMdfPath,
},
],
pickItems,
{ placeHolder: "Select framework to use" }
);
if (!examplesFolder) {
Expand All @@ -1033,7 +1054,8 @@ export async function activate(context: vscode.ExtensionContext) {
}
ExamplesPlanel.createOrShow(
context.extensionPath,
examplesFolder.target
examplesFolder.target,
examplesFolder.description
);
} catch (error) {
Logger.errorNotify(error.message, error);
Expand Down
2 changes: 1 addition & 1 deletion src/installManager.ts
Expand Up @@ -88,7 +88,7 @@ export class InstallManager {
}

public installZipFile(zipFilePath: string, destPath: string) {
return new Promise(async (resolve, reject) => {
return new Promise<void>(async (resolve, reject) => {
await pathExists(zipFilePath).then((doesZipFileExists) => {
if (!doesZipFileExists) {
return reject(`File ${zipFilePath} doesn't exist.`);
Expand Down
10 changes: 2 additions & 8 deletions src/onboarding/espIdfDownload.ts
Expand Up @@ -199,14 +199,8 @@ export function createEspIdfLinkList(data: Buffer, splitString: string) {
return {
filename: `esp-idf-${versionForRelease}.zip`,
name: version + " (release branch)",
url: versionZip.replace(
versionRegex,
version.replace("release/", "")
),
mirror: mirrorZip.replace(
versionRegex,
version.replace("release/", "")
),
url: versionZip.replace(versionRegex, versionForRelease),
mirror: mirrorZip.replace(versionRegex, versionForRelease),
};
} else {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/pythonManager.ts
Expand Up @@ -340,7 +340,7 @@ export async function getPythonBinListWindows(workingDir: string) {
.then((installPaths) => {
const binPaths = installPaths.trim().split("\r\n");
for (const iPath of binPaths) {
const trimPath = iPath.trim().split(/\s+/);
const trimPath = iPath.trim().split(/\s{2,}/);
if (trimPath[0] === "ExecutablePath") {
paths.push(trimPath[trimPath.length - 1]);
}
Expand Down
21 changes: 14 additions & 7 deletions src/rainmaker/view/item.ts
Expand Up @@ -38,20 +38,27 @@ export class RMakerItem extends TreeItem {
this._meta = v;
}

constructor(type: RMakerItemType, label?: string) {
constructor(type: RMakerItemType, label?: string, tooltip?: string) {
super(label);
this.type = type;
this.contextValue = type.toString();
this.collapsibleState = TreeItemCollapsibleState.None;
this.command = {
title: label,
command: "",
tooltip: tooltip,
};
}

public set commandId(v: string) {
this.command = {
command: v,
title: typeof this.label === "string" ? this.label : this.label.label,
tooltip:
typeof this.tooltip === "string" ? this.tooltip : this.tooltip.value,
};
if (!this.command) {
this.command = {
title: "",
command: v,
tooltip: "",
};
}
this.command.command = v;
}

public set themeIcon(v: string) {
Expand Down

0 comments on commit 9d25a29

Please sign in to comment.