This commit is contained in:
Otavio Jacobi 2024-03-08 12:10:16 -03:00
parent 5371fea588
commit 61c7ee6239
8 changed files with 119 additions and 806 deletions

View File

@ -1,74 +0,0 @@
/**
* @license
* Copyright 2016-2020 Balena Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Args } from '@oclif/core';
import Command from '../../command';
import { stripIndent } from '../../utils/lazy';
import { CommandHelp } from '../../utils/oclif-utils';
// 'Internal' commands are called during the execution of other commands.
// `osinit` is called during `os initialize`
// TODO: These should be refactored to modules/functions, and removed
// See previous `internal sudo` refactor:
// - https://github.com/balena-io/balena-cli/pull/1455/files
// - https://github.com/balena-io/balena-cli/pull/1455#discussion_r334308357
// - https://github.com/balena-io/balena-cli/pull/1455#discussion_r334308526
export default class OsinitCmd extends Command {
public static description = stripIndent`
Do actual init of the device with the preconfigured os image.
Don't use this command directly!
Use \`balena os initialize <image>\` instead.
`;
public static args = {
image: Args.string({
required: true,
}),
type: Args.string({
required: true,
}),
config: Args.string({
required: true,
}),
};
public static usage = (
'internal osinit ' +
new CommandHelp({ args: OsinitCmd.args }).defaultUsage()
).trim();
public static hidden = true;
public static root = true;
public static offlineCompatible = true;
public async run() {
const { args: params } = await this.parse(OsinitCmd);
const config = JSON.parse(params.config);
const { getManifest, osProgressHandler } = await import(
'../../utils/helpers'
);
const manifest = await getManifest(params.image, params.type);
const { initialize } = await import('balena-device-init');
const initializeEmitter = await initialize(params.image, manifest, config);
await osProgressHandler(initializeEmitter);
}
}

View File

@ -29,9 +29,20 @@ import {
devModeInfo,
secureBootInfo,
} from '../../utils/messages';
import { ImgConfig } from '../../utils/config';
const CONNECTIONS_FOLDER = '/system-connections';
type DeviceConfigDefinition = {
partition: number | { logical: number, primary: number },
image?: string,
path?: string
};
type Manifest = BalenaSdk.DeviceTypeJson.DeviceType & {
configuration?: { config?: DeviceConfigDefinition }
};
type FlagsDef = Interfaces.InferredFlags<typeof OsConfigureCmd.flags>;
interface Answers {
@ -172,7 +183,6 @@ export default class OsConfigureCmd extends Command {
await validateOptions(options);
const devInit = await import('balena-device-init');
const { promises: fs } = await import('fs');
const { generateDeviceConfig, generateApplicationConfig } = await import(
'../../utils/config'
@ -219,11 +229,10 @@ export default class OsConfigureCmd extends Command {
const { normalizeOsVersion } = await import('../../utils/normalization');
const osVersion = normalizeOsVersion(
options.version ||
(await getOsVersionFromImage(
params.image,
deviceTypeManifest,
devInit,
)),
(await getOsVersionFromImage(
params.image,
deviceTypeManifest,
)),
);
const { validateDevOptionAndWarn } = await import('../../utils/config');
@ -270,13 +279,11 @@ export default class OsConfigureCmd extends Command {
console.info('Configuring operating system image');
const image = params.image;
await helpers.osProgressHandler(
await devInit.configure(
image,
deviceTypeManifest,
configJson || {},
answers,
),
await addConfigurationToImage(
image,
deviceTypeManifest,
configJson || {},
answers,
);
if (options['system-connection']) {
@ -312,6 +319,21 @@ export default class OsConfigureCmd extends Command {
}
}
async function addConfigurationToImage(
image: string,
manifest: Manifest,
config: ImgConfig | object,
answers: Answers,
) {
// TODO: check if manifest.yocto.image check is needed...
const osVersion = await getOsVersionFromImage(image, manifest);
const bSemver = await import('balena-semver');
const major = bSemver.major(osVersion);
convertFilePathDefinition(manifest.configuration?.config);
console.log(image, manifest, config, answers);
}
async function validateOptions(options: FlagsDef) {
// The 'device' and 'application' options are declared "exclusive" in the oclif
// flag definitions above, so oclif will enforce that they are not both used together.
@ -329,6 +351,29 @@ async function validateOptions(options: FlagsDef) {
await Command.checkLoggedIn();
}
async function definitionForImage(imagePath: string, configDefinition: DeviceConfigDefinition) {
const definition = _.cloneDeep(configDefinition)
if (configDefinition.image != null) {
const path = await import('path');
definition.image = path.join(imagePath, configDefinition.image);
} else {
definition.image = imagePath;
}
return definition;
};
function convertFilePathDefinition(configDefinition: DeviceConfigDefinition) {
const definition = _.cloneDeep(configDefinition);
if (_.isObject(definition.partition)) {
if (definition.partition.logical != null) {
definition.partition = definition.partition.logical + 4;
} else {
definition.partition = definition.partition.primary;
}
}
return definition;
}
/**
* Wrapper around balena-device-init.getImageOsVersion(). Throws ExpectedError
* if the OS image could not be read or the OS version could not be extracted
@ -338,13 +383,38 @@ async function validateOptions(options: FlagsDef) {
*/
async function getOsVersionFromImage(
imagePath: string,
deviceTypeManifest: BalenaSdk.DeviceTypeJson.DeviceType,
devInit: typeof import('balena-device-init'),
deviceTypeManifest: Manifest,
): Promise<string> {
const osVersion = await devInit.getImageOsVersion(
imagePath,
deviceTypeManifest,
);
// TODO: check if all this is needed or if we can just assume { patition: 1 } for all
const config = deviceTypeManifest?.configuration?.config ?? { partition: 1 };
const definition = convertFilePathDefinition(await definitionForImage(imagePath, config));
definition.path = '/os-release';
const imagefs = await import('balena-image-fs');
const osReleaseString = await imagefs.interact(definition.image as string, definition.partition as number, (fs) => {
return promisify(fs.readFile)(definition.path as string, { encoding: 'utf8' });
});
const parsedOsRelease = _(osReleaseString)
.split('\n')
.map((line) => {
const match = line.match(/(.*)=(.*)/);
if (match) {
return [
match[1],
match[2].replace(/^"(.*)"$/, '$1').replace(/^'(.*)'$/, '$1')
]
} else {
return false;
}
})
.filter()
.fromPairs()
.value();
const osVersion = parsedOsRelease.NAME !== 'Resin OS' && parsedOsRelease.NAME !== 'balenaOS' ? null : parsedOsRelease.VERSION;
if (!osVersion) {
throw new ExpectedError(stripIndent`
Could not read OS version from the image. Please specify the balenaOS

View File

@ -1,102 +0,0 @@
/**
* @license
* Copyright 2016-2021 Balena Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Args } from '@oclif/core';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getCliForm, stripIndent } from '../../utils/lazy';
const INIT_WARNING_MESSAGE = `
Note: Initializing the device may ask for administrative permissions
because we need to access the raw devices directly.\
`;
export default class OsInitializeCmd extends Command {
public static description = stripIndent`
Initialize an os image for a device.
Initialize an os image for a device with a previously
configured operating system image and flash the
an external storage drive or the device's storage
medium depending on the device type.
${INIT_WARNING_MESSAGE}
`;
public static examples = [
'$ balena os initialize ../path/rpi.img --type raspberry-pi',
];
public static args = {
image: Args.string({
description: 'path to OS image',
required: true,
}),
};
public static usage = 'os initialize <image>';
public static flags = {
type: cf.deviceType,
drive: cf.drive,
yes: cf.yes,
help: cf.help,
};
public static authenticated = true;
public async run() {
const { args: params, flags: options } = await this.parse(OsInitializeCmd);
const { getManifest, sudo } = await import('../../utils/helpers');
console.info(`Initializing device ${INIT_WARNING_MESSAGE}`);
const manifest = await getManifest(params.image, options.type);
const answers = await getCliForm().run(manifest.initialization?.options, {
override: {
drive: options.drive,
},
});
if (answers.drive != null) {
const { confirm } = await import('../../utils/patterns');
await confirm(
options.yes,
`This will erase ${answers.drive}. Are you sure?`,
`Going to erase ${answers.drive}.`,
);
const { safeUmount } = await import('../../utils/umount');
await safeUmount(answers.drive);
}
await sudo([
'internal',
'osinit',
params.image,
options.type,
JSON.stringify(answers),
]);
if (answers.drive != null) {
const { safeUmount } = await import('../../utils/umount');
await safeUmount(answers.drive);
console.info(`You can safely remove ${answers.drive} now`);
}
}
}

View File

@ -14,13 +14,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import type { InitializeEmitter, OperationState } from 'balena-device-init';
import type * as BalenaSdk from 'balena-sdk';
import * as _ from 'lodash';
import * as os from 'node:os';
import { promisify } from 'util';
import { getBalenaSdk, getChalk, getVisuals } from './lazy';
import { getBalenaSdk } from './lazy';
export function getGroupDefaults(group: {
options: Array<{ name: string; default: string | number }>;
@ -32,25 +32,6 @@ export function getGroupDefaults(group: {
.value();
}
export function stateToString(state: OperationState) {
const percentage = _.padStart(`${state.percentage}`, 3, '0');
const chalk = getChalk();
const result = `${chalk.blue(percentage + '%')} ${chalk.cyan(
state.operation.command,
)}`;
switch (state.operation.command) {
case 'copy':
return `${result} ${state.operation.from.path} -> ${state.operation.to.path}`;
case 'replace':
return `${result} ${state.operation.file.path}, ${state.operation.copy} -> ${state.operation.replace}`;
case 'run-script':
return `${result} ${state.operation.script}`;
default:
throw new Error(`Unsupported operation: ${state.operation.command}`);
}
}
/**
* Execute a child process with admin / superuser privileges, prompting the user for
* elevation as needed, and taking care of shell-escaping arguments in a suitable way
@ -107,9 +88,17 @@ export async function getManifest(
image: string,
deviceType: string,
): Promise<BalenaSdk.DeviceTypeJson.DeviceType> {
const init = await import('balena-device-init');
const sdk = getBalenaSdk();
const manifest = await init.getImageManifest(image);
const imagefs = await import ('balena-image-fs');
const manifest = await imagefs.interact(image, 1, async (fs) => {
const readFileAsync = promisify(fs.readFile);
const manifest = await readFileAsync('/device-type.json', {
encoding: 'utf8',
});
return JSON.parse(manifest) as BalenaSdk.DeviceTypeJson.DeviceType;
});
if (
manifest != null &&
manifest.slug !== deviceType &&
@ -126,6 +115,13 @@ export async function getManifest(
);
}
export function getOperatingSystem():
| Exclude<NodeJS.Platform, 'darwin'>
| 'osx' {
const platform = os.platform();
return platform === 'darwin' ? 'osx' : platform;
}
export const areDeviceTypesCompatible = async (
appDeviceTypeSlug: string,
osDeviceTypeSlug: string,
@ -156,31 +152,6 @@ export const areDeviceTypesCompatible = async (
);
};
export async function osProgressHandler(step: InitializeEmitter) {
step.on('stdout', process.stdout.write.bind(process.stdout));
step.on('stderr', process.stderr.write.bind(process.stderr));
step.on('state', function (state) {
if (state.operation.command === 'burn') {
return;
}
console.log(exports.stateToString(state));
});
const visuals = getVisuals();
const progressBars = {
write: new visuals.Progress('Writing Device OS'),
check: new visuals.Progress('Validating Device OS'),
};
step.on('burn', (state) => progressBars[state.type].update(state));
await new Promise((resolve, reject) => {
step.on('error', reject);
step.on('end' as any, resolve);
});
}
export async function getAppWithArch(applicationName: string) {
const { getApplication } = await import('./sdk');
const balena = getBalenaSdk();

468
npm-shrinkwrap.json generated
View File

@ -21,9 +21,8 @@
"@types/update-notifier": "^4.1.1",
"@yao-pkg/pkg": "^5.11.1",
"balena-config-json": "^4.2.0",
"balena-device-init": "^6.0.0",
"balena-errors": "^4.7.3",
"balena-image-fs": "^7.0.6",
"balena-image-fs": "^7.2.2",
"balena-image-manager": "^10.0.1",
"balena-preload": "^15.0.1",
"balena-sdk": "^19.4.0",
@ -5611,21 +5610,6 @@
"partitioninfo": "^6.0.2"
}
},
"node_modules/balena-device-init": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/balena-device-init/-/balena-device-init-6.0.0.tgz",
"integrity": "sha512-c4/PTxyZjpndUtN8JGOj8+AEANBOQpCvK3Tb20ieRu98C6NJF0HYIrAlbXqvalBJc9KvqxjtSc9LlF5rAb522Q==",
"dependencies": {
"balena-image-fs": "^7.0.6",
"balena-semver": "^2.2.0",
"bluebird": "^3.7.2",
"lodash": "^4.17.15",
"reconfix": "1.0.0-v0-1-0-fork-46760acff4d165f5238bfac5e464256ef1944476",
"resin-device-operations": "^1.7.0",
"rindle": "^1.3.4",
"string-to-stream": "^1.1.1"
}
},
"node_modules/balena-errors": {
"version": "4.9.0",
"resolved": "https://registry.npmjs.org/balena-errors/-/balena-errors-4.9.0.tgz",
@ -5652,9 +5636,9 @@
}
},
"node_modules/balena-image-fs": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/balena-image-fs/-/balena-image-fs-7.2.0.tgz",
"integrity": "sha512-CRY0NEvpaueMK2dlRG5WJJxyTRMmCdPlg92kOru2nCNhOLg1pQ1LXSrcRVPcserUVGx7HRRwXSCoZ7XcehW9QQ==",
"version": "7.2.2",
"resolved": "https://registry.npmjs.org/balena-image-fs/-/balena-image-fs-7.2.2.tgz",
"integrity": "sha512-/ZzchTuDmPbuzNc3Ct+JJ5UEbRO19Ebgpo6jMORBz/2E/jVIUgfnwW35c4OxXPiDMYTpOpQMMvBZkoayDRHiXQ==",
"dependencies": {
"ext2fs": "^4.2.1",
"fatfs": "^0.10.8",
@ -6183,27 +6167,6 @@
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
"integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
},
"node_modules/bluebird-retry": {
"version": "0.10.1",
"resolved": "https://registry.npmjs.org/bluebird-retry/-/bluebird-retry-0.10.1.tgz",
"integrity": "sha1-zfdrAdSm3U/sTiyENgqKCQB/Z9o=",
"peerDependencies": {
"bluebird": ">=2.3.10"
}
},
"node_modules/bmapflash": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/bmapflash/-/bmapflash-1.2.2.tgz",
"integrity": "sha512-Reks9az43gzwNasI1ej3lHlfeak3ddWltSD5YJVqsBev79fxn1rTMcdJ0En+d2irkr5tJcU4c3dMn0pj2L49nQ==",
"dependencies": {
"bluebird": "^3.7.2",
"lodash": "^4.17.15",
"progress-stream": "^2.0.0",
"stream-chunker": "^1.2.8",
"through2": "^2.0.5",
"xml2js": "^0.4.23"
}
},
"node_modules/body-parser": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.1.tgz",
@ -7887,17 +7850,6 @@
"node": ">=0.10.0"
}
},
"node_modules/decompress-response": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz",
"integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==",
"dependencies": {
"mimic-response": "^2.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/deep-eql": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz",
@ -8121,11 +8073,6 @@
"resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz",
"integrity": "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g=="
},
"node_modules/dev-null-stream": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/dev-null-stream/-/dev-null-stream-0.0.1.tgz",
"integrity": "sha1-oqLie025mSjW2NRNXF9++9TLQ3I="
},
"node_modules/dezalgo": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz",
@ -8373,30 +8320,6 @@
"node": ">=8"
}
},
"node_modules/drivelist": {
"version": "8.0.10",
"resolved": "https://registry.npmjs.org/drivelist/-/drivelist-8.0.10.tgz",
"integrity": "sha512-2A/NCMn9jQ/9J1B8zohS8rnXQKDM6ZixLAlYS/rBeZV2NuSXJCMr/M8kKdr4vy95oOxKXi8NXk+IVrHCS3bung==",
"hasInstallScript": true,
"dependencies": {
"bindings": "^1.3.0",
"debug": "^3.1.0",
"mz": "^2.7.0",
"nan": "^2.14.0",
"prebuild-install": "^5.2.4"
},
"engines": {
"node": ">=6"
}
},
"node_modules/drivelist/node_modules/debug": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"dependencies": {
"ms": "^2.1.1"
}
},
"node_modules/duplexer": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz",
@ -8564,14 +8487,6 @@
"integrity": "sha512-CJAN+O0/yA1CKfRn9SXOGctSpEM7DCon/r/5r2eXFMY2zCCJBasFhcM5I+1kh3Ap11FsQCX+vGHceNPvpWKhoA==",
"dev": true
},
"node_modules/error": {
"version": "7.2.1",
"resolved": "https://registry.npmjs.org/error/-/error-7.2.1.tgz",
"integrity": "sha512-fo9HBvWnx3NGUKMvMwB/CBCMMrfEJgbDTVDEkPygA3Bdd3lM1OyCd+rbQ8BwnpF6GdVeOLDNmyL4N5Bg80ZvdA==",
"dependencies": {
"string-template": "~0.2.1"
}
},
"node_modules/error-ex": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
@ -9344,66 +9259,6 @@
"node": ">= 0.6"
}
},
"node_modules/etcher-image-write": {
"version": "9.1.6",
"resolved": "https://registry.npmjs.org/etcher-image-write/-/etcher-image-write-9.1.6.tgz",
"integrity": "sha512-Cm2qT342J45P2PXmBqDTNuLusy5CTkjF5IqAc6Wv57bYyYDngFMNMLWSWn74gUk38YvrdrMKYG+/2GhkWzK5qg==",
"dependencies": {
"bluebird": "^3.7.2",
"bluebird-retry": "^0.10.1",
"bmapflash": "^1.2.2",
"crc32-stream": "^1.0.1",
"debug": "^2.6.9",
"dev-null-stream": "0.0.1",
"drivelist": "^8.0.10",
"error": "^7.2.1",
"lodash": "^4.17.15",
"progress-stream": "^2.0.0",
"slice-stream2": "^2.0.1",
"stream-chunker": "^1.2.8",
"through2": "^2.0.5",
"tmp": "0.0.31"
},
"bin": {
"etcher-image-write": "bin/cli.js"
}
},
"node_modules/etcher-image-write/node_modules/crc32-stream": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-1.0.1.tgz",
"integrity": "sha512-268ICyK7W4/rqhDe1LOQIVdYk8mAi5NkASgNDyu21jdadLDTa/PZlV+N2VF8x61d8m9Wa2AzCaxk/LOVRzy8sA==",
"dependencies": {
"crc": "^3.4.4",
"readable-stream": "^2.0.0"
},
"engines": {
"node": ">= 0.10.0"
}
},
"node_modules/etcher-image-write/node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/etcher-image-write/node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
},
"node_modules/etcher-image-write/node_modules/tmp": {
"version": "0.0.31",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz",
"integrity": "sha512-lfyEfOppKvWNeId5CArFLwgwef+iCnbEIy0JWYf1httIEXnx4ndL4Dr1adw7hPgeQfSlTbc/gqn6iaKcROpw5Q==",
"dependencies": {
"os-tmpdir": "~1.0.1"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/etcher-sdk": {
"version": "9.0.6",
"resolved": "https://registry.npmjs.org/etcher-sdk/-/etcher-sdk-9.0.6.tgz",
@ -14435,17 +14290,6 @@
"node": ">=6"
}
},
"node_modules/mimic-response": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz",
"integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==",
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
@ -17567,34 +17411,6 @@
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
"node_modules/prebuild-install": {
"version": "5.3.6",
"resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.6.tgz",
"integrity": "sha512-s8Aai8++QQGi4sSbs/M1Qku62PFK49Jm1CbgXklGz4nmHveDq0wzJkg7Na5QbnO1uNH8K7iqx2EQ/mV0MZEmOg==",
"dependencies": {
"detect-libc": "^1.0.3",
"expand-template": "^2.0.3",
"github-from-package": "0.0.0",
"minimist": "^1.2.3",
"mkdirp-classic": "^0.5.3",
"napi-build-utils": "^1.0.1",
"node-abi": "^2.7.0",
"noop-logger": "^0.1.1",
"npmlog": "^4.0.1",
"pump": "^3.0.0",
"rc": "^1.2.7",
"simple-get": "^3.0.3",
"tar-fs": "^2.0.0",
"tunnel-agent": "^0.6.0",
"which-pm-runs": "^1.0.0"
},
"bin": {
"prebuild-install": "bin.js"
},
"engines": {
"node": ">=6"
}
},
"node_modules/preferred-pm": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/preferred-pm/-/preferred-pm-3.1.2.tgz",
@ -19395,19 +19211,6 @@
"node": ">=8.6.0 <9.0.0 || >=10.0.0"
}
},
"node_modules/resin-device-operations": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/resin-device-operations/-/resin-device-operations-1.7.0.tgz",
"integrity": "sha512-Znl7EEmXY5V/nfEi/Q+Ha998sZNPjG76dbfm/6di8l+GAhNoELY8F2JTmQo1z/XynONz1zRJ1FUJJOmw77SEiA==",
"dependencies": {
"balena-image-fs": "^7.0.6",
"bluebird": "^3.7.2",
"drivelist": "^8.0.10",
"etcher-image-write": "^9.1.6",
"lodash": "^4.17.15",
"rindle": "^1.3.0"
}
},
"node_modules/resin-discoverable-services": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/resin-discoverable-services/-/resin-discoverable-services-2.0.4.tgz",
@ -20437,16 +20240,6 @@
}
]
},
"node_modules/simple-get": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.1.tgz",
"integrity": "sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA==",
"dependencies": {
"decompress-response": "^4.2.0",
"once": "^1.3.1",
"simple-concat": "^1.0.0"
}
},
"node_modules/simple-git": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/simple-git/-/simple-git-3.14.1.tgz",
@ -20616,14 +20409,6 @@
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ=="
},
"node_modules/slice-stream2": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/slice-stream2/-/slice-stream2-2.0.1.tgz",
"integrity": "sha1-e9gO/BMjLsEVFLZlxLZBWv2mkbc=",
"dependencies": {
"through2": "^2.0.1"
}
},
"node_modules/smart-buffer": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
@ -20899,14 +20684,6 @@
"node": ">=0.10.0"
}
},
"node_modules/stream-chunker": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/stream-chunker/-/stream-chunker-1.2.8.tgz",
"integrity": "sha1-6zryyK7lJWzedvCh/qhjSDNtBPc=",
"dependencies": {
"through2": "~2.0.0"
}
},
"node_modules/stream-combiner": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.2.2.tgz",
@ -21002,11 +20779,6 @@
"editor": "^1.0.0"
}
},
"node_modules/string-template": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/string-template/-/string-template-0.2.1.tgz",
"integrity": "sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0="
},
"node_modules/string-to-stream": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string-to-stream/-/string-to-stream-1.1.1.tgz",
@ -23257,22 +23029,11 @@
"xml-js": "bin/cli.js"
}
},
"node_modules/xml2js": {
"version": "0.4.23",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz",
"integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==",
"dependencies": {
"sax": ">=0.6.0",
"xmlbuilder": "~11.0.0"
},
"engines": {
"node": ">=4.0.0"
}
},
"node_modules/xmlbuilder": {
"version": "11.0.1",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz",
"integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==",
"dev": true,
"engines": {
"node": ">=4.0"
}
@ -29617,21 +29378,6 @@
"partitioninfo": "^6.0.2"
}
},
"balena-device-init": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/balena-device-init/-/balena-device-init-6.0.0.tgz",
"integrity": "sha512-c4/PTxyZjpndUtN8JGOj8+AEANBOQpCvK3Tb20ieRu98C6NJF0HYIrAlbXqvalBJc9KvqxjtSc9LlF5rAb522Q==",
"requires": {
"balena-image-fs": "^7.0.6",
"balena-semver": "^2.2.0",
"bluebird": "^3.7.2",
"lodash": "^4.17.15",
"reconfix": "1.0.0-v0-1-0-fork-46760acff4d165f5238bfac5e464256ef1944476",
"resin-device-operations": "^1.7.0",
"rindle": "^1.3.4",
"string-to-stream": "^1.1.1"
}
},
"balena-errors": {
"version": "4.9.0",
"resolved": "https://registry.npmjs.org/balena-errors/-/balena-errors-4.9.0.tgz",
@ -29652,9 +29398,9 @@
}
},
"balena-image-fs": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/balena-image-fs/-/balena-image-fs-7.2.0.tgz",
"integrity": "sha512-CRY0NEvpaueMK2dlRG5WJJxyTRMmCdPlg92kOru2nCNhOLg1pQ1LXSrcRVPcserUVGx7HRRwXSCoZ7XcehW9QQ==",
"version": "7.2.2",
"resolved": "https://registry.npmjs.org/balena-image-fs/-/balena-image-fs-7.2.2.tgz",
"integrity": "sha512-/ZzchTuDmPbuzNc3Ct+JJ5UEbRO19Ebgpo6jMORBz/2E/jVIUgfnwW35c4OxXPiDMYTpOpQMMvBZkoayDRHiXQ==",
"requires": {
"ext2fs": "^4.2.1",
"fatfs": "^0.10.8",
@ -30082,25 +29828,6 @@
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
"integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
},
"bluebird-retry": {
"version": "0.10.1",
"resolved": "https://registry.npmjs.org/bluebird-retry/-/bluebird-retry-0.10.1.tgz",
"integrity": "sha1-zfdrAdSm3U/sTiyENgqKCQB/Z9o=",
"requires": {}
},
"bmapflash": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/bmapflash/-/bmapflash-1.2.2.tgz",
"integrity": "sha512-Reks9az43gzwNasI1ej3lHlfeak3ddWltSD5YJVqsBev79fxn1rTMcdJ0En+d2irkr5tJcU4c3dMn0pj2L49nQ==",
"requires": {
"bluebird": "^3.7.2",
"lodash": "^4.17.15",
"progress-stream": "^2.0.0",
"stream-chunker": "^1.2.8",
"through2": "^2.0.5",
"xml2js": "^0.4.23"
}
},
"body-parser": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.1.tgz",
@ -31397,14 +31124,6 @@
"integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==",
"dev": true
},
"decompress-response": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz",
"integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==",
"requires": {
"mimic-response": "^2.0.0"
}
},
"deep-eql": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz",
@ -31577,11 +31296,6 @@
"resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz",
"integrity": "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g=="
},
"dev-null-stream": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/dev-null-stream/-/dev-null-stream-0.0.1.tgz",
"integrity": "sha1-oqLie025mSjW2NRNXF9++9TLQ3I="
},
"dezalgo": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz",
@ -31780,28 +31494,6 @@
"is-obj": "^2.0.0"
}
},
"drivelist": {
"version": "8.0.10",
"resolved": "https://registry.npmjs.org/drivelist/-/drivelist-8.0.10.tgz",
"integrity": "sha512-2A/NCMn9jQ/9J1B8zohS8rnXQKDM6ZixLAlYS/rBeZV2NuSXJCMr/M8kKdr4vy95oOxKXi8NXk+IVrHCS3bung==",
"requires": {
"bindings": "^1.3.0",
"debug": "^3.1.0",
"mz": "^2.7.0",
"nan": "^2.14.0",
"prebuild-install": "^5.2.4"
},
"dependencies": {
"debug": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"requires": {
"ms": "^2.1.1"
}
}
}
},
"duplexer": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz",
@ -31952,14 +31644,6 @@
"integrity": "sha512-CJAN+O0/yA1CKfRn9SXOGctSpEM7DCon/r/5r2eXFMY2zCCJBasFhcM5I+1kh3Ap11FsQCX+vGHceNPvpWKhoA==",
"dev": true
},
"error": {
"version": "7.2.1",
"resolved": "https://registry.npmjs.org/error/-/error-7.2.1.tgz",
"integrity": "sha512-fo9HBvWnx3NGUKMvMwB/CBCMMrfEJgbDTVDEkPygA3Bdd3lM1OyCd+rbQ8BwnpF6GdVeOLDNmyL4N5Bg80ZvdA==",
"requires": {
"string-template": "~0.2.1"
}
},
"error-ex": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
@ -32530,59 +32214,6 @@
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
},
"etcher-image-write": {
"version": "9.1.6",
"resolved": "https://registry.npmjs.org/etcher-image-write/-/etcher-image-write-9.1.6.tgz",
"integrity": "sha512-Cm2qT342J45P2PXmBqDTNuLusy5CTkjF5IqAc6Wv57bYyYDngFMNMLWSWn74gUk38YvrdrMKYG+/2GhkWzK5qg==",
"requires": {
"bluebird": "^3.7.2",
"bluebird-retry": "^0.10.1",
"bmapflash": "^1.2.2",
"crc32-stream": "^1.0.1",
"debug": "^2.6.9",
"dev-null-stream": "0.0.1",
"drivelist": "^8.0.10",
"error": "^7.2.1",
"lodash": "^4.17.15",
"progress-stream": "^2.0.0",
"slice-stream2": "^2.0.1",
"stream-chunker": "^1.2.8",
"through2": "^2.0.5",
"tmp": "0.0.31"
},
"dependencies": {
"crc32-stream": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-1.0.1.tgz",
"integrity": "sha512-268ICyK7W4/rqhDe1LOQIVdYk8mAi5NkASgNDyu21jdadLDTa/PZlV+N2VF8x61d8m9Wa2AzCaxk/LOVRzy8sA==",
"requires": {
"crc": "^3.4.4",
"readable-stream": "^2.0.0"
}
},
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"requires": {
"ms": "2.0.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
},
"tmp": {
"version": "0.0.31",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz",
"integrity": "sha512-lfyEfOppKvWNeId5CArFLwgwef+iCnbEIy0JWYf1httIEXnx4ndL4Dr1adw7hPgeQfSlTbc/gqn6iaKcROpw5Q==",
"requires": {
"os-tmpdir": "~1.0.1"
}
}
}
},
"etcher-sdk": {
"version": "9.0.6",
"resolved": "https://registry.npmjs.org/etcher-sdk/-/etcher-sdk-9.0.6.tgz",
@ -36468,11 +36099,6 @@
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",
"integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg=="
},
"mimic-response": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz",
"integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA=="
},
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
@ -38850,28 +38476,6 @@
}
}
},
"prebuild-install": {
"version": "5.3.6",
"resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.6.tgz",
"integrity": "sha512-s8Aai8++QQGi4sSbs/M1Qku62PFK49Jm1CbgXklGz4nmHveDq0wzJkg7Na5QbnO1uNH8K7iqx2EQ/mV0MZEmOg==",
"requires": {
"detect-libc": "^1.0.3",
"expand-template": "^2.0.3",
"github-from-package": "0.0.0",
"minimist": "^1.2.3",
"mkdirp-classic": "^0.5.3",
"napi-build-utils": "^1.0.1",
"node-abi": "^2.7.0",
"noop-logger": "^0.1.1",
"npmlog": "^4.0.1",
"pump": "^3.0.0",
"rc": "^1.2.7",
"simple-get": "^3.0.3",
"tar-fs": "^2.0.0",
"tunnel-agent": "^0.6.0",
"which-pm-runs": "^1.0.0"
}
},
"preferred-pm": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/preferred-pm/-/preferred-pm-3.1.2.tgz",
@ -40276,19 +39880,6 @@
}
}
},
"resin-device-operations": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/resin-device-operations/-/resin-device-operations-1.7.0.tgz",
"integrity": "sha512-Znl7EEmXY5V/nfEi/Q+Ha998sZNPjG76dbfm/6di8l+GAhNoELY8F2JTmQo1z/XynONz1zRJ1FUJJOmw77SEiA==",
"requires": {
"balena-image-fs": "^7.0.6",
"bluebird": "^3.7.2",
"drivelist": "^8.0.10",
"etcher-image-write": "^9.1.6",
"lodash": "^4.17.15",
"rindle": "^1.3.0"
}
},
"resin-discoverable-services": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/resin-discoverable-services/-/resin-discoverable-services-2.0.4.tgz",
@ -41080,16 +40671,6 @@
"resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz",
"integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q=="
},
"simple-get": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.1.tgz",
"integrity": "sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA==",
"requires": {
"decompress-response": "^4.2.0",
"once": "^1.3.1",
"simple-concat": "^1.0.0"
}
},
"simple-git": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/simple-git/-/simple-git-3.14.1.tgz",
@ -41238,14 +40819,6 @@
}
}
},
"slice-stream2": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/slice-stream2/-/slice-stream2-2.0.1.tgz",
"integrity": "sha1-e9gO/BMjLsEVFLZlxLZBWv2mkbc=",
"requires": {
"through2": "^2.0.1"
}
},
"smart-buffer": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
@ -41467,14 +41040,6 @@
"resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz",
"integrity": "sha512-ZnWpYnYugiOVEY5GkcuJK1io5V8QmNYChG62gSit9pQVGErXtrKuPC55ITaVSukmMta5qpMU7vqLt2Lnni4f/g=="
},
"stream-chunker": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/stream-chunker/-/stream-chunker-1.2.8.tgz",
"integrity": "sha1-6zryyK7lJWzedvCh/qhjSDNtBPc=",
"requires": {
"through2": "~2.0.0"
}
},
"stream-combiner": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.2.2.tgz",
@ -41569,11 +41134,6 @@
"editor": "^1.0.0"
}
},
"string-template": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/string-template/-/string-template-0.2.1.tgz",
"integrity": "sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0="
},
"string-to-stream": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string-to-stream/-/string-to-stream-1.1.1.tgz",
@ -43320,19 +42880,11 @@
"sax": "^1.2.4"
}
},
"xml2js": {
"version": "0.4.23",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz",
"integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==",
"requires": {
"sax": ">=0.6.0",
"xmlbuilder": "~11.0.0"
}
},
"xmlbuilder": {
"version": "11.0.1",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz",
"integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA=="
"integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==",
"dev": true
},
"xok": {
"version": "1.0.0",

View File

@ -206,9 +206,8 @@
"@types/update-notifier": "^4.1.1",
"@yao-pkg/pkg": "^5.11.1",
"balena-config-json": "^4.2.0",
"balena-device-init": "^6.0.0",
"balena-errors": "^4.7.3",
"balena-image-fs": "^7.0.6",
"balena-image-fs": "^7.2.2",
"balena-image-manager": "^10.0.1",
"balena-preload": "^15.0.1",
"balena-sdk": "^19.4.0",

View File

@ -66,7 +66,6 @@ describe('detectEncoding() function', function () {
'mountutils/build/Release/MountUtils.node',
];
const sampleText = [
'node_modules/.bin/etcher-image-write',
'node_modules/.bin/mocha',
'node_modules/.bin/rimraf',
'node_modules/.bin/tsc',

View File

@ -1,102 +0,0 @@
/**
* @license
* Copyright 2019 Balena Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare module 'balena-device-init' {
import { DeviceTypeJson } from 'balena-sdk';
import * as Bluebird from 'bluebird';
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' | 'stderr', callback: (msg: string) => void): void;
on(event: 'state', callback: (state: OperationState) => void): void;
on(event: 'burn', callback: (state: BurnProgress) => void): void;
on(event: 'end', callback: () => void): void;
on(event: 'error', callback: (error: Error) => void): void;
}
export function configure(
image: string,
manifest: BalenaSdk.DeviceTypeJson.DeviceType.DeviceType,
config: object,
options?: object,
): Bluebird<InitializeEmitter>;
export function initialize(
image: string,
manifest: BalenaSdk.DeviceTypeJson.DeviceType.DeviceType,
config: object,
): Bluebird<InitializeEmitter>;
export function getImageOsVersion(
image: string,
manifest: BalenaSdk.DeviceTypeJson.DeviceType.DeviceType,
): Bluebird<string | null>;
export function getImageManifest(
image: string,
): Bluebird<BalenaSdk.DeviceTypeJson.DeviceType.DeviceType | null>;
}