Initial support for updating/downgrading cores.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta
2019-11-14 21:06:51 +01:00
parent 7077303a36
commit fdda4a72d0
27 changed files with 195 additions and 65 deletions

View File

@@ -1,3 +1,4 @@
import { Installable } from './installable';
export interface ArduinoComponent {
readonly name: string;
@@ -6,8 +7,8 @@ export interface ArduinoComponent {
readonly description: string;
readonly moreInfoLink?: string;
readonly availableVersions: string[];
readonly availableVersions: Installable.Version[];
readonly installable: boolean;
readonly installedVersion?: string;
readonly installedVersion?: Installable.Version;
}

View File

@@ -170,6 +170,12 @@ export interface BoardPackage extends ArduinoComponent {
id: string;
boards: Board[];
}
export namespace BoardPackage {
/**
* Most recent version comes first, then the previous versions. (`1.8.1`, `1.6.3`, `1.6.2`, `1.6.1` and so on.)
*/
export const VERSION_COMPARATOR = (left: string, right: string) => naturalCompare(right, left);
}
export interface Board {
name: string

View File

@@ -1,3 +1,11 @@
export interface Installable<T> {
install(item: T): Promise<void>;
}
import { ArduinoComponent } from './arduino-component';
export interface Installable<T extends ArduinoComponent> {
/**
* If `options.version` is specified, that will be installed. Otherwise, `item.availableVersions[0]`.
*/
install(options: { item: T, version?: Installable.Version }): Promise<void>;
}
export namespace Installable {
export type Version = string;
}

View File

@@ -5,14 +5,9 @@ import { ArduinoComponent } from './arduino-component';
export const LibraryServicePath = '/services/library-service';
export const LibraryService = Symbol('LibraryService');
export interface LibraryService extends Installable<Library>, Searchable<Library> {
install(library: Library): Promise<void>;
install(options: { item: Library, version?: Installable.Version }): Promise<void>;
}
export interface Library extends ArduinoComponent {
readonly builtIn?: boolean;
}
export namespace Library {
// TODO: figure out whether we need a dedicated `version` type.
export type Version = string;
}