mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-12 19:59:27 +00:00
[atl-1280] Board packages hints
handle cornercase when 2 packages are associated to the same board updated cli version and grpc support deprecated cores in the boards manager bump cli version Bump ArduinoCLI version to latest release Add package version in notification
This commit is contained in:
committed by
Francesco Stasi
parent
852bf9b73e
commit
4fa2024266
@@ -43,13 +43,27 @@ export class BoardsAutoInstaller implements FrontendApplicationContribution {
|
||||
if (selectedBoard && !this.notifications.find(board => Board.sameAs(board, selectedBoard))) {
|
||||
this.notifications.push(selectedBoard);
|
||||
this.boardsService.search({}).then(packages => {
|
||||
const candidates = packages
|
||||
.filter(pkg => BoardsPackage.contains(selectedBoard, pkg))
|
||||
|
||||
// filter packagesForBoard selecting matches from the cli (installed packages)
|
||||
// and matches based on the board name
|
||||
// NOTE: this ensures the Deprecated & new packages are all in the array
|
||||
// so that we can check if any of the valid packages is already installed
|
||||
const packagesForBoard = packages.filter(pkg => BoardsPackage.contains(selectedBoard, pkg) || pkg.boards.some(board => board.name === selectedBoard.name));
|
||||
|
||||
// check if one of the packages for the board is already installed. if so, no hint
|
||||
if (packagesForBoard.some(({ installedVersion }) => !!installedVersion)) { return; }
|
||||
|
||||
// filter the installable (not installed) packages,
|
||||
// CLI returns the packages already sorted with the deprecated ones at the end of the list
|
||||
// in order to ensure the new ones are preferred
|
||||
const candidates = packagesForBoard
|
||||
.filter(({ installable, installedVersion }) => installable && !installedVersion);
|
||||
|
||||
const candidate = candidates[0];
|
||||
if (candidate) {
|
||||
const version = candidate.availableVersions[0] ? `[v ${candidate.availableVersions[0]}]` : '';
|
||||
// tslint:disable-next-line:max-line-length
|
||||
this.messageService.info(`The \`"${candidate.name}"\` core has to be installed for the currently selected \`"${selectedBoard.name}"\` board. Do you want to install it now?`, 'Install Manually', 'Yes').then(async answer => {
|
||||
this.messageService.info(`The \`"${candidate.name} ${version}"\` core has to be installed for the currently selected \`"${selectedBoard.name}"\` board. Do you want to install it now?`, 'Install Manually', 'Yes').then(async answer => {
|
||||
const index = this.notifications.findIndex(board => Board.sameAs(board, selectedBoard));
|
||||
if (index !== -1) {
|
||||
this.notifications.splice(index, 1);
|
||||
|
||||
@@ -20,6 +20,7 @@ export class BoardsListWidget extends ListWidget<BoardsPackage> {
|
||||
searchable: service,
|
||||
installable: service,
|
||||
itemLabel: (item: BoardsPackage) => item.name,
|
||||
itemDeprecated: (item: BoardsPackage) => item.deprecated,
|
||||
itemRenderer
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user