balena-cli/typings/balena-device-init.d.ts
Akis Kesoglou 8291c96e69 Make specifying the version during configuration optional
`version` used to be optional but it seems we recently had to make it a required parameter. However it really feels redundant when all it’s used for is to determine whether the command should issue a legacy user API key or a provisioning key.

This makes version optional but tries to figure it out by itself by reading os-release from the image's boot partition. This is not foul-proof however, and while it'll work with most recent images it won't work with all and in that case it'll bail out and only then warn the user to specify it via the --version argument.

Change-type: minor
2018-11-16 19:39:43 +02:00

84 lines
1.7 KiB
TypeScript

declare module 'balena-device-init' {
import * as Promise from 'bluebird';
import { EventEmitter } from 'events';
import { DeviceType } from 'balena-sdk';
interface OperationState {
operation:
| CopyOperation
| ReplaceOperation
| RunScriptOperation
| BurnOperation;
percentage: number;
}
interface Operation {
command: string;
}
interface CopyOperation extends Operation {
command: 'copy';
from: { path: string };
to: { path: string };
}
interface ReplaceOperation extends Operation {
command: 'replace';
copy: string;
replace: string;
file: {
path: string;
};
}
interface RunScriptOperation extends Operation {
command: 'run-script';
script: string;
arguments?: string[];
}
interface BurnOperation extends Operation {
command: 'burn';
image?: string;
}
interface BurnProgress {
type: 'write' | 'check';
percentage: number;
transferred: number;
length: number;
remaining: number;
eta: number;
runtime: number;
delta: number;
speed: number;
}
interface InitializeEmitter {
on(event: 'stdout', callback: (msg: string) => void): void;
on(event: 'stderr', callback: (msg: string) => void): void;
on(event: 'state', callback: (state: OperationState) => void): void;
on(event: 'burn', callback: (state: BurnProgress) => void): void;
}
export function configure(
image: string,
manifest: DeviceType,
config: {},
options?: {},
): Promise<InitializeEmitter>;
export function initialize(
image: string,
manifest: DeviceType,
config: {},
): Promise<InitializeEmitter>;
export function getImageOsVersion(
image: string,
manifest: DeviceType,
): Promise<string | null>;
export function getImageManifest(image: string): Promise<DeviceType | null>;
}