Skip to content

Commit 4fa2024

Browse files
committed
[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
1 parent 852bf9b commit 4fa2024

16 files changed

+135
-11
lines changed

Diff for: arduino-ide-extension/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
],
123123
"arduino": {
124124
"cli": {
125-
"version": "0.18.1"
125+
"version": "0.18.2"
126126
}
127127
}
128128
}

Diff for: arduino-ide-extension/src/browser/boards/boards-auto-installer.ts

+17-3
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,27 @@ export class BoardsAutoInstaller implements FrontendApplicationContribution {
4343
if (selectedBoard && !this.notifications.find(board => Board.sameAs(board, selectedBoard))) {
4444
this.notifications.push(selectedBoard);
4545
this.boardsService.search({}).then(packages => {
46-
const candidates = packages
47-
.filter(pkg => BoardsPackage.contains(selectedBoard, pkg))
46+
47+
// filter packagesForBoard selecting matches from the cli (installed packages)
48+
// and matches based on the board name
49+
// NOTE: this ensures the Deprecated & new packages are all in the array
50+
// so that we can check if any of the valid packages is already installed
51+
const packagesForBoard = packages.filter(pkg => BoardsPackage.contains(selectedBoard, pkg) || pkg.boards.some(board => board.name === selectedBoard.name));
52+
53+
// check if one of the packages for the board is already installed. if so, no hint
54+
if (packagesForBoard.some(({ installedVersion }) => !!installedVersion)) { return; }
55+
56+
// filter the installable (not installed) packages,
57+
// CLI returns the packages already sorted with the deprecated ones at the end of the list
58+
// in order to ensure the new ones are preferred
59+
const candidates = packagesForBoard
4860
.filter(({ installable, installedVersion }) => installable && !installedVersion);
61+
4962
const candidate = candidates[0];
5063
if (candidate) {
64+
const version = candidate.availableVersions[0] ? `[v ${candidate.availableVersions[0]}]` : '';
5165
// tslint:disable-next-line:max-line-length
52-
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 => {
66+
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 => {
5367
const index = this.notifications.findIndex(board => Board.sameAs(board, selectedBoard));
5468
if (index !== -1) {
5569
this.notifications.splice(index, 1);

Diff for: arduino-ide-extension/src/browser/boards/boards-list-widget.ts

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class BoardsListWidget extends ListWidget<BoardsPackage> {
2020
searchable: service,
2121
installable: service,
2222
itemLabel: (item: BoardsPackage) => item.name,
23+
itemDeprecated: (item: BoardsPackage) => item.deprecated,
2324
itemRenderer
2425
});
2526
}

Diff for: arduino-ide-extension/src/browser/library/library-list-widget.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class LibraryListWidget extends ListWidget<LibraryPackage> {
2424
searchable: service,
2525
installable: service,
2626
itemLabel: (item: LibraryPackage) => item.name,
27+
itemDeprecated: (item: LibraryPackage) => item.deprecated,
2728
itemRenderer
2829
});
2930
}

Diff for: arduino-ide-extension/src/browser/widgets/component-list/component-list.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export namespace ComponentList {
4242
export interface Props<T extends ArduinoComponent> {
4343
readonly items: T[];
4444
readonly itemLabel: (item: T) => string;
45+
readonly itemDeprecated: (item: T) => boolean;
4546
readonly itemRenderer: ListItemRenderer<T>;
4647
readonly install: (item: T, version?: Installable.Version) => Promise<void>;
4748
readonly uninstall: (item: T) => Promise<void>;

Diff for: arduino-ide-extension/src/browser/widgets/component-list/filterable-list-container.tsx

+14-3
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ export class FilterableListContainer<T extends ArduinoComponent> extends React.C
5656
}
5757

5858
protected renderComponentList(): React.ReactNode {
59-
const { itemLabel, resolveContainer, itemRenderer } = this.props;
59+
const { itemLabel, itemDeprecated, resolveContainer, itemRenderer } = this.props;
6060
return <ComponentList<T>
6161
items={this.state.items}
6262
itemLabel={itemLabel}
63+
itemDeprecated={itemDeprecated}
6364
itemRenderer={itemRenderer}
6465
install={this.install.bind(this)}
6566
uninstall={this.uninstall.bind(this)}
@@ -78,8 +79,17 @@ export class FilterableListContainer<T extends ArduinoComponent> extends React.C
7879
}
7980

8081
protected sort(items: T[]): T[] {
81-
const { itemLabel } = this.props;
82-
return items.sort((left, right) => itemLabel(left).localeCompare(itemLabel(right)));
82+
// debugger;
83+
const { itemLabel, itemDeprecated } = this.props;
84+
return items.sort((left, right) => {
85+
86+
// always put deprecated items at the bottom of the list
87+
if (itemDeprecated(left)) {
88+
return 1;
89+
}
90+
91+
return itemLabel(left).localeCompare(itemLabel(right))
92+
});
8393
}
8494

8595
protected async install(item: T, version: Installable.Version): Promise<void> {
@@ -121,6 +131,7 @@ export namespace FilterableListContainer {
121131
readonly container: ListWidget<T>;
122132
readonly searchable: Searchable<T>;
123133
readonly itemLabel: (item: T) => string;
134+
readonly itemDeprecated: (item: T) => boolean;
124135
readonly itemRenderer: ListItemRenderer<T>;
125136
readonly resolveContainer: (element: HTMLElement) => void;
126137
readonly resolveFocus: (element: HTMLElement | undefined) => void;

Diff for: arduino-ide-extension/src/browser/widgets/component-list/list-widget.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export abstract class ListWidget<T extends ArduinoComponent> extends ReactWidget
102102
install={this.install.bind(this)}
103103
uninstall={this.uninstall.bind(this)}
104104
itemLabel={this.options.itemLabel}
105+
itemDeprecated={this.options.itemDeprecated}
105106
itemRenderer={this.options.itemRenderer}
106107
filterTextChangeEvent={this.filterTextChangeEmitter.event}
107108
messageService={this.messageService}
@@ -133,6 +134,7 @@ export namespace ListWidget {
133134
readonly installable: Installable<T>;
134135
readonly searchable: Searchable<T>;
135136
readonly itemLabel: (item: T) => string;
137+
readonly itemDeprecated: (item: T) => boolean;
136138
readonly itemRenderer: ListItemRenderer<T>;
137139
}
138140
}

Diff for: arduino-ide-extension/src/common/protocol/arduino-component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Installable } from './installable';
22

33
export interface ArduinoComponent {
44
readonly name: string;
5+
readonly deprecated: boolean;
56
readonly author: string;
67
readonly summary: string;
78
readonly description: string;

Diff for: arduino-ide-extension/src/node/boards-service-impl.ts

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ export class BoardsServiceImpl extends CoreClientAware implements BoardsService
210210
availableVersions: [platform.getLatest()],
211211
description: platform.getBoardsList().map(b => b.getName()).join(', '),
212212
installable: true,
213+
deprecated: platform.getDeprecated(),
213214
summary: 'Boards included in this package:',
214215
installedVersion,
215216
boards: platform.getBoardsList().map(b => <Board>{ name: b.getName(), fqbn: b.getFqbn() }),

Diff for: arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/common_pb.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ export class Platform extends jspb.Message {
152152
getManuallyInstalled(): boolean;
153153
setManuallyInstalled(value: boolean): Platform;
154154

155+
getDeprecated(): boolean;
156+
setDeprecated(value: boolean): Platform;
157+
155158

156159
serializeBinary(): Uint8Array;
157160
toObject(includeInstance?: boolean): Platform.AsObject;
@@ -174,6 +177,7 @@ export namespace Platform {
174177
email: string,
175178
boardsList: Array<Board.AsObject>,
176179
manuallyInstalled: boolean,
180+
deprecated: boolean,
177181
}
178182
}
179183

Diff for: arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/common_pb.js

+31-1
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,8 @@ proto.cc.arduino.cli.commands.v1.Platform.toObject = function(includeInstance, m
955955
email: jspb.Message.getFieldWithDefault(msg, 7, ""),
956956
boardsList: jspb.Message.toObjectList(msg.getBoardsList(),
957957
proto.cc.arduino.cli.commands.v1.Board.toObject, includeInstance),
958-
manuallyInstalled: jspb.Message.getBooleanFieldWithDefault(msg, 9, false)
958+
manuallyInstalled: jspb.Message.getBooleanFieldWithDefault(msg, 9, false),
959+
deprecated: jspb.Message.getBooleanFieldWithDefault(msg, 10, false)
959960
};
960961

961962
if (includeInstance) {
@@ -1029,6 +1030,10 @@ proto.cc.arduino.cli.commands.v1.Platform.deserializeBinaryFromReader = function
10291030
var value = /** @type {boolean} */ (reader.readBool());
10301031
msg.setManuallyInstalled(value);
10311032
break;
1033+
case 10:
1034+
var value = /** @type {boolean} */ (reader.readBool());
1035+
msg.setDeprecated(value);
1036+
break;
10321037
default:
10331038
reader.skipField();
10341039
break;
@@ -1122,6 +1127,13 @@ proto.cc.arduino.cli.commands.v1.Platform.serializeBinaryToWriter = function(mes
11221127
f
11231128
);
11241129
}
1130+
f = message.getDeprecated();
1131+
if (f) {
1132+
writer.writeBool(
1133+
10,
1134+
f
1135+
);
1136+
}
11251137
};
11261138

11271139

@@ -1307,6 +1319,24 @@ proto.cc.arduino.cli.commands.v1.Platform.prototype.setManuallyInstalled = funct
13071319
};
13081320

13091321

1322+
/**
1323+
* optional bool deprecated = 10;
1324+
* @return {boolean}
1325+
*/
1326+
proto.cc.arduino.cli.commands.v1.Platform.prototype.getDeprecated = function() {
1327+
return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 10, false));
1328+
};
1329+
1330+
1331+
/**
1332+
* @param {boolean} value
1333+
* @return {!proto.cc.arduino.cli.commands.v1.Platform} returns this
1334+
*/
1335+
proto.cc.arduino.cli.commands.v1.Platform.prototype.setDeprecated = function(value) {
1336+
return jspb.Message.setProto3BooleanField(this, 10, value);
1337+
};
1338+
1339+
13101340

13111341

13121342

Diff for: arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/compile_pb.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ export class CompileRequest extends jspb.Message {
8181
getExportBinaries(): google_protobuf_wrappers_pb.BoolValue | undefined;
8282
setExportBinaries(value?: google_protobuf_wrappers_pb.BoolValue): CompileRequest;
8383

84+
clearLibraryList(): void;
85+
getLibraryList(): Array<string>;
86+
setLibraryList(value: Array<string>): CompileRequest;
87+
addLibrary(value: string, index?: number): string;
88+
8489

8590
serializeBinary(): Uint8Array;
8691
toObject(includeInstance?: boolean): CompileRequest.AsObject;
@@ -115,6 +120,7 @@ export namespace CompileRequest {
115120

116121
sourceOverrideMap: Array<[string, string]>,
117122
exportBinaries?: google_protobuf_wrappers_pb.BoolValue.AsObject,
123+
libraryList: Array<string>,
118124
}
119125
}
120126

Diff for: arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/compile_pb.js

+51-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ if (goog.DEBUG && !COMPILED) {
9393
* @private {!Array<number>}
9494
* @const
9595
*/
96-
proto.cc.arduino.cli.commands.v1.CompileRequest.repeatedFields_ = [8,15];
96+
proto.cc.arduino.cli.commands.v1.CompileRequest.repeatedFields_ = [8,15,24];
9797

9898

9999

@@ -145,7 +145,8 @@ proto.cc.arduino.cli.commands.v1.CompileRequest.toObject = function(includeInsta
145145
clean: jspb.Message.getBooleanFieldWithDefault(msg, 19, false),
146146
createCompilationDatabaseOnly: jspb.Message.getBooleanFieldWithDefault(msg, 21, false),
147147
sourceOverrideMap: (f = msg.getSourceOverrideMap()) ? f.toObject(includeInstance, undefined) : [],
148-
exportBinaries: (f = msg.getExportBinaries()) && google_protobuf_wrappers_pb.BoolValue.toObject(includeInstance, f)
148+
exportBinaries: (f = msg.getExportBinaries()) && google_protobuf_wrappers_pb.BoolValue.toObject(includeInstance, f),
149+
libraryList: (f = jspb.Message.getRepeatedField(msg, 24)) == null ? undefined : f
149150
};
150151

151152
if (includeInstance) {
@@ -266,6 +267,10 @@ proto.cc.arduino.cli.commands.v1.CompileRequest.deserializeBinaryFromReader = fu
266267
reader.readMessage(value,google_protobuf_wrappers_pb.BoolValue.deserializeBinaryFromReader);
267268
msg.setExportBinaries(value);
268269
break;
270+
case 24:
271+
var value = /** @type {string} */ (reader.readString());
272+
msg.addLibrary(value);
273+
break;
269274
default:
270275
reader.skipField();
271276
break;
@@ -434,6 +439,13 @@ proto.cc.arduino.cli.commands.v1.CompileRequest.serializeBinaryToWriter = functi
434439
google_protobuf_wrappers_pb.BoolValue.serializeBinaryToWriter
435440
);
436441
}
442+
f = message.getLibraryList();
443+
if (f.length > 0) {
444+
writer.writeRepeatedString(
445+
24,
446+
f
447+
);
448+
}
437449
};
438450

439451

@@ -877,6 +889,43 @@ proto.cc.arduino.cli.commands.v1.CompileRequest.prototype.hasExportBinaries = fu
877889
};
878890

879891

892+
/**
893+
* repeated string library = 24;
894+
* @return {!Array<string>}
895+
*/
896+
proto.cc.arduino.cli.commands.v1.CompileRequest.prototype.getLibraryList = function() {
897+
return /** @type {!Array<string>} */ (jspb.Message.getRepeatedField(this, 24));
898+
};
899+
900+
901+
/**
902+
* @param {!Array<string>} value
903+
* @return {!proto.cc.arduino.cli.commands.v1.CompileRequest} returns this
904+
*/
905+
proto.cc.arduino.cli.commands.v1.CompileRequest.prototype.setLibraryList = function(value) {
906+
return jspb.Message.setField(this, 24, value || []);
907+
};
908+
909+
910+
/**
911+
* @param {string} value
912+
* @param {number=} opt_index
913+
* @return {!proto.cc.arduino.cli.commands.v1.CompileRequest} returns this
914+
*/
915+
proto.cc.arduino.cli.commands.v1.CompileRequest.prototype.addLibrary = function(value, opt_index) {
916+
return jspb.Message.addToRepeatedField(this, 24, value, opt_index);
917+
};
918+
919+
920+
/**
921+
* Clears the list making it empty but non-null.
922+
* @return {!proto.cc.arduino.cli.commands.v1.CompileRequest} returns this
923+
*/
924+
proto.cc.arduino.cli.commands.v1.CompileRequest.prototype.clearLibraryList = function() {
925+
return this.setLibraryList([]);
926+
};
927+
928+
880929

881930
/**
882931
* List of repeated fields within this message type.

Diff for: arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/lib_pb.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -910,4 +910,5 @@ export enum LibraryLocation {
910910
LIBRARY_LOCATION_USER = 1,
911911
LIBRARY_LOCATION_PLATFORM_BUILTIN = 2,
912912
LIBRARY_LOCATION_REFERENCED_PLATFORM_BUILTIN = 3,
913+
LIBRARY_LOCATION_UNMANAGED = 4,
913914
}

Diff for: arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/lib_pb.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -6593,7 +6593,8 @@ proto.cc.arduino.cli.commands.v1.LibraryLocation = {
65936593
LIBRARY_LOCATION_IDE_BUILTIN: 0,
65946594
LIBRARY_LOCATION_USER: 1,
65956595
LIBRARY_LOCATION_PLATFORM_BUILTIN: 2,
6596-
LIBRARY_LOCATION_REFERENCED_PLATFORM_BUILTIN: 3
6596+
LIBRARY_LOCATION_REFERENCED_PLATFORM_BUILTIN: 3,
6597+
LIBRARY_LOCATION_UNMANAGED: 4
65976598
};
65986599

65996600
goog.object.extend(exports, proto.cc.arduino.cli.commands.v1);

Diff for: arduino-ide-extension/src/node/library-service-server-impl.ts

+1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ function toLibrary(pkg: Partial<LibraryPackage>, lib: LibraryRelease | Library,
249249
label: '',
250250
exampleUris: [],
251251
installable: false,
252+
deprecated: false,
252253
location: 0,
253254
...pkg,
254255

0 commit comments

Comments
 (0)