mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-06-04 03:06:32 +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:
parent
852bf9b73e
commit
4fa2024266
@ -122,7 +122,7 @@
|
||||
],
|
||||
"arduino": {
|
||||
"cli": {
|
||||
"version": "0.18.1"
|
||||
"version": "0.18.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
});
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ export class LibraryListWidget extends ListWidget<LibraryPackage> {
|
||||
searchable: service,
|
||||
installable: service,
|
||||
itemLabel: (item: LibraryPackage) => item.name,
|
||||
itemDeprecated: (item: LibraryPackage) => item.deprecated,
|
||||
itemRenderer
|
||||
});
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ export namespace ComponentList {
|
||||
export interface Props<T extends ArduinoComponent> {
|
||||
readonly items: T[];
|
||||
readonly itemLabel: (item: T) => string;
|
||||
readonly itemDeprecated: (item: T) => boolean;
|
||||
readonly itemRenderer: ListItemRenderer<T>;
|
||||
readonly install: (item: T, version?: Installable.Version) => Promise<void>;
|
||||
readonly uninstall: (item: T) => Promise<void>;
|
||||
|
@ -56,10 +56,11 @@ export class FilterableListContainer<T extends ArduinoComponent> extends React.C
|
||||
}
|
||||
|
||||
protected renderComponentList(): React.ReactNode {
|
||||
const { itemLabel, resolveContainer, itemRenderer } = this.props;
|
||||
const { itemLabel, itemDeprecated, resolveContainer, itemRenderer } = this.props;
|
||||
return <ComponentList<T>
|
||||
items={this.state.items}
|
||||
itemLabel={itemLabel}
|
||||
itemDeprecated={itemDeprecated}
|
||||
itemRenderer={itemRenderer}
|
||||
install={this.install.bind(this)}
|
||||
uninstall={this.uninstall.bind(this)}
|
||||
@ -78,8 +79,17 @@ export class FilterableListContainer<T extends ArduinoComponent> extends React.C
|
||||
}
|
||||
|
||||
protected sort(items: T[]): T[] {
|
||||
const { itemLabel } = this.props;
|
||||
return items.sort((left, right) => itemLabel(left).localeCompare(itemLabel(right)));
|
||||
// debugger;
|
||||
const { itemLabel, itemDeprecated } = this.props;
|
||||
return items.sort((left, right) => {
|
||||
|
||||
// always put deprecated items at the bottom of the list
|
||||
if (itemDeprecated(left)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return itemLabel(left).localeCompare(itemLabel(right))
|
||||
});
|
||||
}
|
||||
|
||||
protected async install(item: T, version: Installable.Version): Promise<void> {
|
||||
@ -121,6 +131,7 @@ export namespace FilterableListContainer {
|
||||
readonly container: ListWidget<T>;
|
||||
readonly searchable: Searchable<T>;
|
||||
readonly itemLabel: (item: T) => string;
|
||||
readonly itemDeprecated: (item: T) => boolean;
|
||||
readonly itemRenderer: ListItemRenderer<T>;
|
||||
readonly resolveContainer: (element: HTMLElement) => void;
|
||||
readonly resolveFocus: (element: HTMLElement | undefined) => void;
|
||||
|
@ -102,6 +102,7 @@ export abstract class ListWidget<T extends ArduinoComponent> extends ReactWidget
|
||||
install={this.install.bind(this)}
|
||||
uninstall={this.uninstall.bind(this)}
|
||||
itemLabel={this.options.itemLabel}
|
||||
itemDeprecated={this.options.itemDeprecated}
|
||||
itemRenderer={this.options.itemRenderer}
|
||||
filterTextChangeEvent={this.filterTextChangeEmitter.event}
|
||||
messageService={this.messageService}
|
||||
@ -133,6 +134,7 @@ export namespace ListWidget {
|
||||
readonly installable: Installable<T>;
|
||||
readonly searchable: Searchable<T>;
|
||||
readonly itemLabel: (item: T) => string;
|
||||
readonly itemDeprecated: (item: T) => boolean;
|
||||
readonly itemRenderer: ListItemRenderer<T>;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ import { Installable } from './installable';
|
||||
|
||||
export interface ArduinoComponent {
|
||||
readonly name: string;
|
||||
readonly deprecated: boolean;
|
||||
readonly author: string;
|
||||
readonly summary: string;
|
||||
readonly description: string;
|
||||
|
@ -210,6 +210,7 @@ export class BoardsServiceImpl extends CoreClientAware implements BoardsService
|
||||
availableVersions: [platform.getLatest()],
|
||||
description: platform.getBoardsList().map(b => b.getName()).join(', '),
|
||||
installable: true,
|
||||
deprecated: platform.getDeprecated(),
|
||||
summary: 'Boards included in this package:',
|
||||
installedVersion,
|
||||
boards: platform.getBoardsList().map(b => <Board>{ name: b.getName(), fqbn: b.getFqbn() }),
|
||||
|
@ -152,6 +152,9 @@ export class Platform extends jspb.Message {
|
||||
getManuallyInstalled(): boolean;
|
||||
setManuallyInstalled(value: boolean): Platform;
|
||||
|
||||
getDeprecated(): boolean;
|
||||
setDeprecated(value: boolean): Platform;
|
||||
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): Platform.AsObject;
|
||||
@ -174,6 +177,7 @@ export namespace Platform {
|
||||
email: string,
|
||||
boardsList: Array<Board.AsObject>,
|
||||
manuallyInstalled: boolean,
|
||||
deprecated: boolean,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -955,7 +955,8 @@ proto.cc.arduino.cli.commands.v1.Platform.toObject = function(includeInstance, m
|
||||
email: jspb.Message.getFieldWithDefault(msg, 7, ""),
|
||||
boardsList: jspb.Message.toObjectList(msg.getBoardsList(),
|
||||
proto.cc.arduino.cli.commands.v1.Board.toObject, includeInstance),
|
||||
manuallyInstalled: jspb.Message.getBooleanFieldWithDefault(msg, 9, false)
|
||||
manuallyInstalled: jspb.Message.getBooleanFieldWithDefault(msg, 9, false),
|
||||
deprecated: jspb.Message.getBooleanFieldWithDefault(msg, 10, false)
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
@ -1029,6 +1030,10 @@ proto.cc.arduino.cli.commands.v1.Platform.deserializeBinaryFromReader = function
|
||||
var value = /** @type {boolean} */ (reader.readBool());
|
||||
msg.setManuallyInstalled(value);
|
||||
break;
|
||||
case 10:
|
||||
var value = /** @type {boolean} */ (reader.readBool());
|
||||
msg.setDeprecated(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
@ -1122,6 +1127,13 @@ proto.cc.arduino.cli.commands.v1.Platform.serializeBinaryToWriter = function(mes
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getDeprecated();
|
||||
if (f) {
|
||||
writer.writeBool(
|
||||
10,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1307,6 +1319,24 @@ proto.cc.arduino.cli.commands.v1.Platform.prototype.setManuallyInstalled = funct
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional bool deprecated = 10;
|
||||
* @return {boolean}
|
||||
*/
|
||||
proto.cc.arduino.cli.commands.v1.Platform.prototype.getDeprecated = function() {
|
||||
return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 10, false));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {boolean} value
|
||||
* @return {!proto.cc.arduino.cli.commands.v1.Platform} returns this
|
||||
*/
|
||||
proto.cc.arduino.cli.commands.v1.Platform.prototype.setDeprecated = function(value) {
|
||||
return jspb.Message.setProto3BooleanField(this, 10, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -81,6 +81,11 @@ export class CompileRequest extends jspb.Message {
|
||||
getExportBinaries(): google_protobuf_wrappers_pb.BoolValue | undefined;
|
||||
setExportBinaries(value?: google_protobuf_wrappers_pb.BoolValue): CompileRequest;
|
||||
|
||||
clearLibraryList(): void;
|
||||
getLibraryList(): Array<string>;
|
||||
setLibraryList(value: Array<string>): CompileRequest;
|
||||
addLibrary(value: string, index?: number): string;
|
||||
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): CompileRequest.AsObject;
|
||||
@ -115,6 +120,7 @@ export namespace CompileRequest {
|
||||
|
||||
sourceOverrideMap: Array<[string, string]>,
|
||||
exportBinaries?: google_protobuf_wrappers_pb.BoolValue.AsObject,
|
||||
libraryList: Array<string>,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ if (goog.DEBUG && !COMPILED) {
|
||||
* @private {!Array<number>}
|
||||
* @const
|
||||
*/
|
||||
proto.cc.arduino.cli.commands.v1.CompileRequest.repeatedFields_ = [8,15];
|
||||
proto.cc.arduino.cli.commands.v1.CompileRequest.repeatedFields_ = [8,15,24];
|
||||
|
||||
|
||||
|
||||
@ -145,7 +145,8 @@ proto.cc.arduino.cli.commands.v1.CompileRequest.toObject = function(includeInsta
|
||||
clean: jspb.Message.getBooleanFieldWithDefault(msg, 19, false),
|
||||
createCompilationDatabaseOnly: jspb.Message.getBooleanFieldWithDefault(msg, 21, false),
|
||||
sourceOverrideMap: (f = msg.getSourceOverrideMap()) ? f.toObject(includeInstance, undefined) : [],
|
||||
exportBinaries: (f = msg.getExportBinaries()) && google_protobuf_wrappers_pb.BoolValue.toObject(includeInstance, f)
|
||||
exportBinaries: (f = msg.getExportBinaries()) && google_protobuf_wrappers_pb.BoolValue.toObject(includeInstance, f),
|
||||
libraryList: (f = jspb.Message.getRepeatedField(msg, 24)) == null ? undefined : f
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
@ -266,6 +267,10 @@ proto.cc.arduino.cli.commands.v1.CompileRequest.deserializeBinaryFromReader = fu
|
||||
reader.readMessage(value,google_protobuf_wrappers_pb.BoolValue.deserializeBinaryFromReader);
|
||||
msg.setExportBinaries(value);
|
||||
break;
|
||||
case 24:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.addLibrary(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
@ -434,6 +439,13 @@ proto.cc.arduino.cli.commands.v1.CompileRequest.serializeBinaryToWriter = functi
|
||||
google_protobuf_wrappers_pb.BoolValue.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = message.getLibraryList();
|
||||
if (f.length > 0) {
|
||||
writer.writeRepeatedString(
|
||||
24,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -877,6 +889,43 @@ proto.cc.arduino.cli.commands.v1.CompileRequest.prototype.hasExportBinaries = fu
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* repeated string library = 24;
|
||||
* @return {!Array<string>}
|
||||
*/
|
||||
proto.cc.arduino.cli.commands.v1.CompileRequest.prototype.getLibraryList = function() {
|
||||
return /** @type {!Array<string>} */ (jspb.Message.getRepeatedField(this, 24));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {!Array<string>} value
|
||||
* @return {!proto.cc.arduino.cli.commands.v1.CompileRequest} returns this
|
||||
*/
|
||||
proto.cc.arduino.cli.commands.v1.CompileRequest.prototype.setLibraryList = function(value) {
|
||||
return jspb.Message.setField(this, 24, value || []);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @param {number=} opt_index
|
||||
* @return {!proto.cc.arduino.cli.commands.v1.CompileRequest} returns this
|
||||
*/
|
||||
proto.cc.arduino.cli.commands.v1.CompileRequest.prototype.addLibrary = function(value, opt_index) {
|
||||
return jspb.Message.addToRepeatedField(this, 24, value, opt_index);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Clears the list making it empty but non-null.
|
||||
* @return {!proto.cc.arduino.cli.commands.v1.CompileRequest} returns this
|
||||
*/
|
||||
proto.cc.arduino.cli.commands.v1.CompileRequest.prototype.clearLibraryList = function() {
|
||||
return this.setLibraryList([]);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* List of repeated fields within this message type.
|
||||
|
@ -910,4 +910,5 @@ export enum LibraryLocation {
|
||||
LIBRARY_LOCATION_USER = 1,
|
||||
LIBRARY_LOCATION_PLATFORM_BUILTIN = 2,
|
||||
LIBRARY_LOCATION_REFERENCED_PLATFORM_BUILTIN = 3,
|
||||
LIBRARY_LOCATION_UNMANAGED = 4,
|
||||
}
|
||||
|
@ -6593,7 +6593,8 @@ proto.cc.arduino.cli.commands.v1.LibraryLocation = {
|
||||
LIBRARY_LOCATION_IDE_BUILTIN: 0,
|
||||
LIBRARY_LOCATION_USER: 1,
|
||||
LIBRARY_LOCATION_PLATFORM_BUILTIN: 2,
|
||||
LIBRARY_LOCATION_REFERENCED_PLATFORM_BUILTIN: 3
|
||||
LIBRARY_LOCATION_REFERENCED_PLATFORM_BUILTIN: 3,
|
||||
LIBRARY_LOCATION_UNMANAGED: 4
|
||||
};
|
||||
|
||||
goog.object.extend(exports, proto.cc.arduino.cli.commands.v1);
|
||||
|
@ -249,6 +249,7 @@ function toLibrary(pkg: Partial<LibraryPackage>, lib: LibraryRelease | Library,
|
||||
label: '',
|
||||
exampleUris: [],
|
||||
installable: false,
|
||||
deprecated: false,
|
||||
location: 0,
|
||||
...pkg,
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user