Skip to content

Commit dd002c9

Browse files
feat: add setting to disable automatic board/library update checks (#108)
1 parent 86285af commit dd002c9

8 files changed

Lines changed: 55 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33
All notable changes to the Arduino Maker Workshop extension will be documented in this file.
44

5+
## Version 1.1.4
6+
- Added a setting to disable automatic board/library update checks for offline usage ([issue #108](https://github.com/thelastoutpostworkshop/arduino-maker-workshop/issues/108))
7+
58
## Version 1.1.3
69

710
- Support for Windows ARM (Serial Monitor not supported) thanks to [jfthuong](https://github.com/jfthuong) ([issue #5](https://github.com/thelastoutpostworkshop/arduino-maker-workshop/issues/5))
811
- Arduino CLI 1.4.1
912
- Persist upload/monitor ports by address while keeping the label visible (fixes Wi-Fi board uploads like UNO Q; backwards compatible with existing port labels) ([issue #103](https://github.com/thelastoutpostworkshop/arduino-maker-workshop/issues/103))
1013
- Added a command to clear Arduino CLI caches and refresh board/library data ([issue #102](https://github.com/thelastoutpostworkshop/arduino-maker-workshop/issues/102))
1114

15+
1216
## Version 1.1.2
1317

1418
- Fixed board examples mixed with library examples and board examples not refreshed when a board change ([issue #100](https://github.com/thelastoutpostworkshop/arduino-maker-workshop/issues/100))

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ All the platforms supported by the [Arduino CLI](https://arduino.github.io/ardui
3737
* You can set the user directory, equivalent of the Arduino IDE's 'sketchbook' directory. Library Manager installations are made to the libraries subdirectory of the user directory
3838
* You can change the Arduino CLI used (*not recommended*) instead of using the built-in Arduino CLI (*recommended*)
3939
* You can disable automatic port detection on Windows
40+
* You can disable automatic board/library update checks (useful for offline usage)
4041
* You can enable or disable verbose compilation (default is verbose)
4142

4243
## Features

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Arduino Maker Workshop",
44
"publisher": "TheLastOutpostWorkshop",
55
"description": "The ultimate tool for makers to bring Arduino projects to life!",
6-
"version": "1.1.3",
6+
"version": "1.1.4",
77
"engines": {
88
"vscode": "^1.93.0"
99
},
@@ -144,6 +144,12 @@
144144
"scope": "machine",
145145
"description": "Disable automatic port detection (only applies on Windows)."
146146
},
147+
"arduinoMakerWorkshop.disableAutoUpdateChecks": {
148+
"type": "boolean",
149+
"default": false,
150+
"scope": "machine",
151+
"description": "Disable automatic checks for board/library updates (useful for offline use)."
152+
},
147153
"arduinoMakerWorkshop.verboseCompile": {
148154
"type": "boolean",
149155
"default": true,

src/VueWebviewPanel.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { commands, Disposable, Webview, WebviewPanel, window, Uri, ViewColumn, E
22
import { getUri } from "./utilities/getUri";
33
import { getNonce } from "./utilities/getNonce";
44
import { ARDUINO_ERRORS, ARDUINO_MESSAGES, BacktraceDecodeFrame, BacktraceDecodeResult, ESP32_PARTITION_BUILDER_BASE_URL, PROFILES_STATUS, SketchProjectFile, WebviewToExtensionMessage } from './shared/messages';
5-
import { arduinoCLI, arduinoExtensionChannel, arduinoProject, arduinoYaml, changeTheme, compile, loadArduinoConfiguration, openExample, shouldDetectPorts, updateStateCompileUpload } from "./extension";
5+
import { arduinoCLI, arduinoExtensionChannel, arduinoProject, arduinoYaml, changeTheme, compile, loadArduinoConfiguration, openExample, shouldCheckForUpdates, shouldDetectPorts, updateStateCompileUpload } from "./extension";
66

77
const path = require('path');
88
const os = require('os');
@@ -14,6 +14,7 @@ export class VueWebviewPanel {
1414
private readonly _panel: WebviewPanel;
1515
private _disposables: Disposable[] = [];
1616
public static currentPanel: VueWebviewPanel | undefined;
17+
private static readonly EMPTY_OUTDATED_PAYLOAD = JSON.stringify({ platforms: [], libraries: [] });
1718
private usbChange() {
1819
if (shouldDetectPorts()) {
1920
VueWebviewPanel.sendMessage({ command: ARDUINO_MESSAGES.REQUEST_BOARD_CONNECTED, errorMessage: "", payload: "" });
@@ -173,12 +174,31 @@ export class VueWebviewPanel {
173174
arduinoCLI.setBuildResult(false);
174175
break;
175176
case ARDUINO_MESSAGES.CLI_UPDATE_INDEX:
176-
arduinoCLI.getCoreUpdate().then(() => {
177-
arduinoCLI.getOutdatedBoardAndLib().then((result) => {
178-
message.payload = result;
177+
{
178+
const forceRefresh = !!message.payload?.force;
179+
if (!forceRefresh && !shouldCheckForUpdates()) {
180+
message.payload = VueWebviewPanel.EMPTY_OUTDATED_PAYLOAD;
181+
message.errorMessage = "";
179182
VueWebviewPanel.sendMessage(message);
180-
});
181-
});
183+
break;
184+
}
185+
186+
arduinoCLI.getCoreUpdate()
187+
.catch(() => {
188+
arduinoExtensionChannel.appendLine("Arduino index update failed.");
189+
})
190+
.then(() => arduinoCLI.getOutdatedBoardAndLib())
191+
.then((result) => {
192+
message.payload = result;
193+
message.errorMessage = "";
194+
VueWebviewPanel.sendMessage(message);
195+
})
196+
.catch(() => {
197+
message.payload = VueWebviewPanel.EMPTY_OUTDATED_PAYLOAD;
198+
message.errorMessage = "";
199+
VueWebviewPanel.sendMessage(message);
200+
});
201+
}
182202
break;
183203
case ARDUINO_MESSAGES.CLI_INSTALL_CORE_VERSION:
184204
const coreToUpdate = message.payload;

src/cli.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { commands, OutputChannel, Uri, window, workspace, ExtensionContext, ProgressLocation } from "vscode";
2-
import { arduinoCLI, arduinoExtensionChannel, arduinoProject, arduinoYaml, compileOutputView, compileStatusBarExecuting, compileStatusBarItem, compileStatusBarNotExecuting, loadArduinoConfiguration, updateStateCompileUpload, uploadStatusBarExecuting, uploadStatusBarItem, uploadStatusBarNotExecuting } from "./extension";
2+
import { arduinoCLI, arduinoExtensionChannel, arduinoProject, arduinoYaml, compileOutputView, compileStatusBarExecuting, compileStatusBarItem, compileStatusBarNotExecuting, loadArduinoConfiguration, shouldCheckForUpdates, updateStateCompileUpload, uploadStatusBarExecuting, uploadStatusBarItem, uploadStatusBarNotExecuting } from "./extension";
33
import { ArduinoCLIStatus, BuildOptions, CompileResult, PROFILES_STATUS } from "./shared/messages";
44
import { getSerialMonitorApi, MonitorPortSettings, SerialMonitorApi, Version } from "@microsoft/vscode-serial-monitor-api";
55
import { COMPILE_RESULT_FILE, VSCODE_FOLDER } from "./ArduinoProject";
@@ -89,7 +89,13 @@ export class ArduinoCLI {
8989
() => this.cliArgs.getVersionArguments(),
9090
"CLI: Failed to get Arduino CLI version information", { caching: CacheState.NO, ttl: 0 }
9191
);
92-
arduinoCLI.getCoreUpdate();
92+
if (shouldCheckForUpdates()) {
93+
this.getCoreUpdate().catch(() => {
94+
arduinoExtensionChannel.appendLine("Automatic board/library update check failed.");
95+
});
96+
} else {
97+
arduinoExtensionChannel.appendLine("Automatic board/library update checks are disabled.");
98+
}
9399
return (JSON.parse(result));
94100
}
95101

src/extension.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,12 @@ export function shouldDetectPorts(): boolean {
350350
return true; // Proceed with port detection
351351
}
352352

353+
export function shouldCheckForUpdates(): boolean {
354+
const config = workspace.getConfiguration('arduinoMakerWorkshop');
355+
const disableAutoUpdateChecks = config.get<boolean>('disableAutoUpdateChecks', false);
356+
return !disableAutoUpdateChecks;
357+
}
358+
353359
function changeUserDirectory() {
354360
const config = workspace.getConfiguration('arduinoMakerWorkshop.arduinoCLI');
355361
const userDirectory = config.get<string>('userDirectory', '');

vue_webview/src/components/Toolbox.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ onMounted(() => {
1111
});
1212
1313
const libraryToUpdate = computed(() => {
14-
return !!store.outdated?.libraries;
14+
return Array.isArray(store.outdated?.libraries) && store.outdated.libraries.length > 0;
1515
});
1616
const boardToUpdate = computed(() => {
17-
return !!store.outdated?.platforms;
17+
return Array.isArray(store.outdated?.platforms) && store.outdated.platforms.length > 0;
1818
});
1919
2020
</script>

vue_webview/src/stores/useVsCodeStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export const useVsCodeStore = defineStore('vsCode', {
292292
}
293293
break;
294294
case ARDUINO_MESSAGES.CLI_UPDATE_INDEX:
295-
if (!this.outdated) {
295+
if (message.payload?.force || !this.outdated) {
296296
vscode.postMessage(message);
297297
}
298298
break;

0 commit comments

Comments
 (0)