mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-06-18 07:48:09 +00:00
chore: Update balena-lint
Change-type: patch
This commit is contained in:
@ -86,7 +86,7 @@ function importOclifCommands(jsFilename: string): OclifCommand[] {
|
|||||||
|
|
||||||
const command: OclifCommand =
|
const command: OclifCommand =
|
||||||
jsFilename === 'help'
|
jsFilename === 'help'
|
||||||
? ((new FakeHelpCommand() as unknown) as OclifCommand)
|
? (new FakeHelpCommand() as unknown as OclifCommand)
|
||||||
: (require(path.join(process.cwd(), jsFilename)).default as OclifCommand);
|
: (require(path.join(process.cwd(), jsFilename)).default as OclifCommand);
|
||||||
|
|
||||||
return [command];
|
return [command];
|
||||||
|
@ -62,9 +62,12 @@ export async function release() {
|
|||||||
|
|
||||||
/** Return a cached Octokit instance, creating a new one as needed. */
|
/** Return a cached Octokit instance, creating a new one as needed. */
|
||||||
const getOctokit = _.once(function () {
|
const getOctokit = _.once(function () {
|
||||||
const Octokit = (require('@octokit/rest') as typeof import('@octokit/rest')).Octokit.plugin(
|
const Octokit = (
|
||||||
(require('@octokit/plugin-throttling') as typeof import('@octokit/plugin-throttling'))
|
require('@octokit/rest') as typeof import('@octokit/rest')
|
||||||
.throttling,
|
).Octokit.plugin(
|
||||||
|
(
|
||||||
|
require('@octokit/plugin-throttling') as typeof import('@octokit/plugin-throttling')
|
||||||
|
).throttling,
|
||||||
);
|
);
|
||||||
return new Octokit({
|
return new Octokit({
|
||||||
auth: GITHUB_TOKEN,
|
auth: GITHUB_TOKEN,
|
||||||
@ -110,7 +113,8 @@ function getPageNumbers(
|
|||||||
if (!response.headers.link) {
|
if (!response.headers.link) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
const parse = require('parse-link-header') as typeof import('parse-link-header');
|
const parse =
|
||||||
|
require('parse-link-header') as typeof import('parse-link-header');
|
||||||
const parsed = parse(response.headers.link);
|
const parsed = parse(response.headers.link);
|
||||||
if (parsed == null) {
|
if (parsed == null) {
|
||||||
throw new Error(`Failed to parse link header: '${response.headers.link}'`);
|
throw new Error(`Failed to parse link header: '${response.headers.link}'`);
|
||||||
@ -158,12 +162,14 @@ async function updateGitHubReleaseDescriptions(
|
|||||||
per_page: perPage,
|
per_page: perPage,
|
||||||
});
|
});
|
||||||
let errCount = 0;
|
let errCount = 0;
|
||||||
type Release = import('@octokit/rest').RestEndpointMethodTypes['repos']['listReleases']['response']['data'][0];
|
type Release =
|
||||||
|
import('@octokit/rest').RestEndpointMethodTypes['repos']['listReleases']['response']['data'][0];
|
||||||
for await (const response of octokit.paginate.iterator<Release>(options)) {
|
for await (const response of octokit.paginate.iterator<Release>(options)) {
|
||||||
const { page: thisPage, pages: totalPages, ordinal } = getPageNumbers(
|
const {
|
||||||
response,
|
page: thisPage,
|
||||||
perPage,
|
pages: totalPages,
|
||||||
);
|
ordinal,
|
||||||
|
} = getPageNumbers(response, perPage);
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (const cliRelease of response.data) {
|
for (const cliRelease of response.data) {
|
||||||
const prefix = `[#${ordinal + i++} pg ${thisPage}/${totalPages}]`;
|
const prefix = `[#${ordinal + i++} pg ${thisPage}/${totalPages}]`;
|
||||||
|
@ -111,8 +111,6 @@ ${dockerignoreHelp}
|
|||||||
|
|
||||||
await Command.checkLoggedInIf(!!options.application);
|
await Command.checkLoggedInIf(!!options.application);
|
||||||
|
|
||||||
// compositions with many services trigger misleading warnings
|
|
||||||
// @ts-ignore editing property that isn't typed but does exist
|
|
||||||
(await import('events')).defaultMaxListeners = 1000;
|
(await import('events')).defaultMaxListeners = 1000;
|
||||||
|
|
||||||
const sdk = getBalenaSdk();
|
const sdk = getBalenaSdk();
|
||||||
|
@ -155,8 +155,6 @@ ${dockerignoreHelp}
|
|||||||
DeployCmd,
|
DeployCmd,
|
||||||
);
|
);
|
||||||
|
|
||||||
// compositions with many services trigger misleading warnings
|
|
||||||
// @ts-ignore editing property that isn't typed but does exist
|
|
||||||
(await import('events')).defaultMaxListeners = 1000;
|
(await import('events')).defaultMaxListeners = 1000;
|
||||||
|
|
||||||
const logger = await Command.getLogger();
|
const logger = await Command.getLogger();
|
||||||
@ -190,10 +188,8 @@ ${dockerignoreHelp}
|
|||||||
options['registry-secrets'],
|
options['registry-secrets'],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const {
|
const { dockerfilePath, registrySecrets } =
|
||||||
dockerfilePath,
|
await validateProjectDirectory(sdk, {
|
||||||
registrySecrets,
|
|
||||||
} = await validateProjectDirectory(sdk, {
|
|
||||||
dockerfilePath: options.dockerfile,
|
dockerfilePath: options.dockerfile,
|
||||||
noParentCheck: options['noparent-check'] || false,
|
noParentCheck: options['noparent-check'] || false,
|
||||||
projectPath: options.source || '.',
|
projectPath: options.source || '.',
|
||||||
|
@ -111,7 +111,8 @@ export default class DeviceCmd extends Command {
|
|||||||
|
|
||||||
device.dashboard_url = balena.models.device.getDashboardUrl(device.uuid);
|
device.dashboard_url = balena.models.device.getDashboardUrl(device.uuid);
|
||||||
|
|
||||||
const belongsToApplication = device.belongs_to__application as Application[];
|
const belongsToApplication =
|
||||||
|
device.belongs_to__application as Application[];
|
||||||
device.application_name = belongsToApplication?.[0]
|
device.application_name = belongsToApplication?.[0]
|
||||||
? belongsToApplication[0].app_name
|
? belongsToApplication[0].app_name
|
||||||
: 'N/a';
|
: 'N/a';
|
||||||
|
@ -103,7 +103,9 @@ export default class DeviceInitCmd extends Command {
|
|||||||
const application = (await getApplication(
|
const application = (await getApplication(
|
||||||
balena,
|
balena,
|
||||||
options['application'] ||
|
options['application'] ||
|
||||||
(await (await import('../../utils/patterns')).selectApplication()).id,
|
(
|
||||||
|
await (await import('../../utils/patterns')).selectApplication()
|
||||||
|
).id,
|
||||||
{
|
{
|
||||||
$expand: {
|
$expand: {
|
||||||
is_for__device_type: {
|
is_for__device_type: {
|
||||||
|
@ -98,15 +98,17 @@ export default class DeviceMoveCmd extends Command {
|
|||||||
const devices = await Promise.all(
|
const devices = await Promise.all(
|
||||||
deviceIds.map(
|
deviceIds.map(
|
||||||
(uuid) =>
|
(uuid) =>
|
||||||
balena.models.device.get(uuid, expandForAppName) as Promise<
|
balena.models.device.get(
|
||||||
ExtendedDevice
|
uuid,
|
||||||
>,
|
expandForAppName,
|
||||||
|
) as Promise<ExtendedDevice>,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Map application name for each device
|
// Map application name for each device
|
||||||
for (const device of devices) {
|
for (const device of devices) {
|
||||||
const belongsToApplication = device.belongs_to__application as Application[];
|
const belongsToApplication =
|
||||||
|
device.belongs_to__application as Application[];
|
||||||
device.application_name = belongsToApplication?.[0]
|
device.application_name = belongsToApplication?.[0]
|
||||||
? belongsToApplication[0].app_name
|
? belongsToApplication[0].app_name
|
||||||
: 'N/a';
|
: 'N/a';
|
||||||
@ -168,7 +170,6 @@ export default class DeviceMoveCmd extends Command {
|
|||||||
compatibleDeviceTypes.some(
|
compatibleDeviceTypes.some(
|
||||||
(dt) => dt.slug === app.is_for__device_type[0].slug,
|
(dt) => dt.slug === app.is_for__device_type[0].slug,
|
||||||
) &&
|
) &&
|
||||||
// @ts-ignore using the extended device object prop
|
|
||||||
devices.some((device) => device.application_name !== app.app_name),
|
devices.some((device) => device.application_name !== app.app_name),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
@ -79,12 +79,8 @@ export default class DeviceOsUpdateCmd extends Command {
|
|||||||
const sdk = getBalenaSdk();
|
const sdk = getBalenaSdk();
|
||||||
|
|
||||||
// Get device info
|
// Get device info
|
||||||
const {
|
const { uuid, is_of__device_type, os_version, os_variant } =
|
||||||
uuid,
|
(await sdk.models.device.get(params.uuid, {
|
||||||
is_of__device_type,
|
|
||||||
os_version,
|
|
||||||
os_variant,
|
|
||||||
} = (await sdk.models.device.get(params.uuid, {
|
|
||||||
$select: ['uuid', 'os_version', 'os_variant'],
|
$select: ['uuid', 'os_version', 'os_variant'],
|
||||||
$expand: {
|
$expand: {
|
||||||
is_of__device_type: {
|
is_of__device_type: {
|
||||||
|
@ -96,7 +96,8 @@ export default class DevicesCmd extends Command {
|
|||||||
devices = devices.map(function (device) {
|
devices = devices.map(function (device) {
|
||||||
device.dashboard_url = balena.models.device.getDashboardUrl(device.uuid);
|
device.dashboard_url = balena.models.device.getDashboardUrl(device.uuid);
|
||||||
|
|
||||||
const belongsToApplication = device.belongs_to__application as Application[];
|
const belongsToApplication =
|
||||||
|
device.belongs_to__application as Application[];
|
||||||
device.application_name = belongsToApplication?.[0]?.app_name || null;
|
device.application_name = belongsToApplication?.[0]?.app_name || null;
|
||||||
|
|
||||||
device.uuid = options.json ? device.uuid : device.uuid.slice(0, 7);
|
device.uuid = options.json ? device.uuid : device.uuid.slice(0, 7);
|
||||||
|
@ -344,8 +344,10 @@ function fillInInfoFields(
|
|||||||
envVar.serviceName = (envVar.service as SDK.Service[])[0]?.service_name;
|
envVar.serviceName = (envVar.service as SDK.Service[])[0]?.service_name;
|
||||||
} else if ('service_install' in envVar) {
|
} else if ('service_install' in envVar) {
|
||||||
// envVar is of type DeviceServiceEnvironmentVariableInfo
|
// envVar is of type DeviceServiceEnvironmentVariableInfo
|
||||||
envVar.serviceName = ((envVar.service_install as SDK.ServiceInstall[])[0]
|
envVar.serviceName = (
|
||||||
?.installs__service as SDK.Service[])[0]?.service_name;
|
(envVar.service_install as SDK.ServiceInstall[])[0]
|
||||||
|
?.installs__service as SDK.Service[]
|
||||||
|
)[0]?.service_name;
|
||||||
}
|
}
|
||||||
envVar.appName = appNameOrSlug;
|
envVar.appName = appNameOrSlug;
|
||||||
envVar.serviceName = envVar.serviceName || '*';
|
envVar.serviceName = envVar.serviceName || '*';
|
||||||
|
@ -83,8 +83,9 @@ export default class LocalFlashCmd extends Command {
|
|||||||
try {
|
try {
|
||||||
const info = await execAsync('cat /proc/version');
|
const info = await execAsync('cat /proc/version');
|
||||||
distroVersion = info.stdout.toLowerCase();
|
distroVersion = info.stdout.toLowerCase();
|
||||||
// tslint:disable-next-line: no-empty
|
} catch {
|
||||||
} catch {}
|
// pass
|
||||||
|
}
|
||||||
if (distroVersion.includes('microsoft')) {
|
if (distroVersion.includes('microsoft')) {
|
||||||
throw new ExpectedError(stripIndent`
|
throw new ExpectedError(stripIndent`
|
||||||
This command is known not to work on WSL. Please use a CLI release
|
This command is known not to work on WSL. Please use a CLI release
|
||||||
|
@ -55,10 +55,8 @@ export default class OsVersionsCmd extends Command {
|
|||||||
public async run() {
|
public async run() {
|
||||||
const { args: params } = this.parse<FlagsDef, ArgsDef>(OsVersionsCmd);
|
const { args: params } = this.parse<FlagsDef, ArgsDef>(OsVersionsCmd);
|
||||||
|
|
||||||
const {
|
const { versions: vs, recommended } =
|
||||||
versions: vs,
|
await getBalenaSdk().models.os.getSupportedVersions(params.type);
|
||||||
recommended,
|
|
||||||
} = await getBalenaSdk().models.os.getSupportedVersions(params.type);
|
|
||||||
|
|
||||||
vs.forEach((v) => {
|
vs.forEach((v) => {
|
||||||
console.log(`v${v}` + (v === recommended ? ' (recommended)' : ''));
|
console.log(`v${v}` + (v === recommended ? ' (recommended)' : ''));
|
||||||
|
@ -87,9 +87,8 @@ export default class ScanCmd extends Command {
|
|||||||
const ux = getCliUx();
|
const ux = getCliUx();
|
||||||
ux.action.start('Scanning for local balenaOS devices');
|
ux.action.start('Scanning for local balenaOS devices');
|
||||||
|
|
||||||
const localDevices: LocalBalenaOsDevice[] = await discover.discoverLocalBalenaOsDevices(
|
const localDevices: LocalBalenaOsDevice[] =
|
||||||
discoverTimeout,
|
await discover.discoverLocalBalenaOsDevices(discoverTimeout);
|
||||||
);
|
|
||||||
const engineReachableDevices: boolean[] = await Promise.all(
|
const engineReachableDevices: boolean[] = await Promise.all(
|
||||||
localDevices.map(async ({ address }: { address: string }) => {
|
localDevices.map(async ({ address }: { address: string }) => {
|
||||||
const docker = await dockerUtils.createClient({
|
const docker = await dockerUtils.createClient({
|
||||||
|
10
lib/help.ts
10
lib/help.ts
@ -112,9 +112,8 @@ export default class BalenaHelp extends Help {
|
|||||||
typeof additionalCommands[0]?.usage === 'string'
|
typeof additionalCommands[0]?.usage === 'string'
|
||||||
) {
|
) {
|
||||||
primaryCommands[0].usage = primaryCommands[0].usage.padEnd(usageLength);
|
primaryCommands[0].usage = primaryCommands[0].usage.padEnd(usageLength);
|
||||||
additionalCommands[0].usage = additionalCommands[0].usage.padEnd(
|
additionalCommands[0].usage =
|
||||||
usageLength,
|
additionalCommands[0].usage.padEnd(usageLength);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output help
|
// Output help
|
||||||
@ -139,9 +138,8 @@ export default class BalenaHelp extends Help {
|
|||||||
console.log(' --help, -h');
|
console.log(' --help, -h');
|
||||||
console.log(' --debug\n');
|
console.log(' --debug\n');
|
||||||
|
|
||||||
const {
|
const { reachingOut } =
|
||||||
reachingOut,
|
require('./utils/messages') as typeof import('./utils/messages');
|
||||||
} = require('./utils/messages') as typeof import('./utils/messages');
|
|
||||||
console.log(reachingOut);
|
console.log(reachingOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
export class CliSettings {
|
export class CliSettings {
|
||||||
public readonly settings: any;
|
public readonly settings: any;
|
||||||
constructor() {
|
constructor() {
|
||||||
this.settings = require('balena-settings-client') as typeof import('balena-settings-client');
|
this.settings =
|
||||||
|
require('balena-settings-client') as typeof import('balena-settings-client');
|
||||||
}
|
}
|
||||||
|
|
||||||
public get<T>(name: string): T {
|
public get<T>(name: string): T {
|
||||||
|
@ -188,10 +188,8 @@ async function resolveOSVersion(deviceType: string, version: string) {
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const { versions: vs, recommended } =
|
||||||
versions: vs,
|
await getBalenaSdk().models.os.getSupportedVersions(deviceType);
|
||||||
recommended,
|
|
||||||
} = await getBalenaSdk().models.os.getSupportedVersions(deviceType);
|
|
||||||
|
|
||||||
const choices = vs.map((v) => ({
|
const choices = vs.map((v) => ({
|
||||||
value: v,
|
value: v,
|
||||||
|
@ -48,9 +48,10 @@ import Logger = require('./logger');
|
|||||||
* push commands, parse it into separate arrays of release tag keys and values.
|
* push commands, parse it into separate arrays of release tag keys and values.
|
||||||
* The returned keys and values arrays are guaranteed to be of the same length.
|
* The returned keys and values arrays are guaranteed to be of the same length.
|
||||||
*/
|
*/
|
||||||
export function parseReleaseTagKeysAndValues(
|
export function parseReleaseTagKeysAndValues(releaseTags: string[]): {
|
||||||
releaseTags: string[],
|
releaseTagKeys: string[];
|
||||||
): { releaseTagKeys: string[]; releaseTagValues: string[] } {
|
releaseTagValues: string[];
|
||||||
|
} {
|
||||||
if (releaseTags.length === 0) {
|
if (releaseTags.length === 0) {
|
||||||
return { releaseTagKeys: [], releaseTagValues: [] };
|
return { releaseTagKeys: [], releaseTagValues: [] };
|
||||||
}
|
}
|
||||||
@ -285,9 +286,8 @@ export async function buildProject(opts: {
|
|||||||
|
|
||||||
setTaskAttributes({ tasks, imageDescriptorsByServiceName, ...opts });
|
setTaskAttributes({ tasks, imageDescriptorsByServiceName, ...opts });
|
||||||
|
|
||||||
const transposeOptArray: Array<
|
const transposeOptArray: Array<TransposeOptions | undefined> =
|
||||||
TransposeOptions | undefined
|
await Promise.all(
|
||||||
> = await Promise.all(
|
|
||||||
tasks.map((task) => {
|
tasks.map((task) => {
|
||||||
// Setup emulation if needed
|
// Setup emulation if needed
|
||||||
if (needsQemu && !task.external) {
|
if (needsQemu && !task.external) {
|
||||||
@ -498,9 +498,8 @@ async function setTaskProgressHooks({
|
|||||||
let rawStream;
|
let rawStream;
|
||||||
stream = createLogStream(stream);
|
stream = createLogStream(stream);
|
||||||
if (transposeOptions) {
|
if (transposeOptions) {
|
||||||
const buildThroughStream = transpose.getBuildThroughStream(
|
const buildThroughStream =
|
||||||
transposeOptions,
|
transpose.getBuildThroughStream(transposeOptions);
|
||||||
);
|
|
||||||
rawStream = stream.pipe(buildThroughStream);
|
rawStream = stream.pipe(buildThroughStream);
|
||||||
} else {
|
} else {
|
||||||
rawStream = stream;
|
rawStream = stream;
|
||||||
@ -766,10 +765,8 @@ async function newTarDirectory(
|
|||||||
const tar = await import('tar-stream');
|
const tar = await import('tar-stream');
|
||||||
const pack = tar.pack();
|
const pack = tar.pack();
|
||||||
const serviceDirs = await getServiceDirsFromComposition(dir, composition);
|
const serviceDirs = await getServiceDirsFromComposition(dir, composition);
|
||||||
const {
|
const { filteredFileList, dockerignoreFiles } =
|
||||||
filteredFileList,
|
await filterFilesWithDockerignore(dir, multiDockerignore, serviceDirs);
|
||||||
dockerignoreFiles,
|
|
||||||
} = await filterFilesWithDockerignore(dir, multiDockerignore, serviceDirs);
|
|
||||||
printDockerignoreWarn(dockerignoreFiles, serviceDirs, multiDockerignore);
|
printDockerignoreWarn(dockerignoreFiles, serviceDirs, multiDockerignore);
|
||||||
for (const fileStats of filteredFileList) {
|
for (const fileStats of filteredFileList) {
|
||||||
pack.entry(
|
pack.entry(
|
||||||
@ -975,7 +972,8 @@ async function parseRegistrySecrets(
|
|||||||
}
|
}
|
||||||
const raw = (await fs.readFile(secretsFilename)).toString();
|
const raw = (await fs.readFile(secretsFilename)).toString();
|
||||||
const multiBuild = await import('resin-multibuild');
|
const multiBuild = await import('resin-multibuild');
|
||||||
const registrySecrets = new multiBuild.RegistrySecretValidator().validateRegistrySecrets(
|
const registrySecrets =
|
||||||
|
new multiBuild.RegistrySecretValidator().validateRegistrySecrets(
|
||||||
isYaml ? require('js-yaml').load(raw) : JSON.parse(raw),
|
isYaml ? require('js-yaml').load(raw) : JSON.parse(raw),
|
||||||
);
|
);
|
||||||
multiBuild.addCanonicalDockerHubEntry(registrySecrets);
|
multiBuild.addCanonicalDockerHubEntry(registrySecrets);
|
||||||
@ -1279,9 +1277,11 @@ async function pushServiceImages(
|
|||||||
const { pushAndUpdateServiceImages } = await import('./compose');
|
const { pushAndUpdateServiceImages } = await import('./compose');
|
||||||
const releaseMod = await import('balena-release');
|
const releaseMod = await import('balena-release');
|
||||||
logger.logInfo('Pushing images to registry...');
|
logger.logInfo('Pushing images to registry...');
|
||||||
await pushAndUpdateServiceImages(docker, token, taggedImages, async function (
|
await pushAndUpdateServiceImages(
|
||||||
serviceImage,
|
docker,
|
||||||
) {
|
token,
|
||||||
|
taggedImages,
|
||||||
|
async function (serviceImage) {
|
||||||
logger.logDebug(
|
logger.logDebug(
|
||||||
`Saving image ${serviceImage.is_stored_at__image_location}`,
|
`Saving image ${serviceImage.is_stored_at__image_location}`,
|
||||||
);
|
);
|
||||||
@ -1289,7 +1289,8 @@ async function pushServiceImages(
|
|||||||
delete serviceImage.build_log;
|
delete serviceImage.build_log;
|
||||||
}
|
}
|
||||||
await releaseMod.updateImage(pineClient, serviceImage.id, serviceImage);
|
await releaseMod.updateImage(pineClient, serviceImage.id, serviceImage);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deployProject(
|
export async function deployProject(
|
||||||
|
@ -216,7 +216,7 @@ export class DeviceAPI {
|
|||||||
const NetKeepalive = await import('net-keepalive');
|
const NetKeepalive = await import('net-keepalive');
|
||||||
// Certain versions of typescript won't convert
|
// Certain versions of typescript won't convert
|
||||||
// this automatically
|
// this automatically
|
||||||
const sock = (res.socket as any) as NodeJSSocketWithFileDescriptor;
|
const sock = res.socket as any as NodeJSSocketWithFileDescriptor;
|
||||||
// We send a tcp keepalive probe once every 5 seconds
|
// We send a tcp keepalive probe once every 5 seconds
|
||||||
NetKeepalive.setKeepAliveInterval(sock, 5000);
|
NetKeepalive.setKeepAliveInterval(sock, 5000);
|
||||||
// After 5 failed probes, the connection is marked as
|
// After 5 failed probes, the connection is marked as
|
||||||
@ -235,7 +235,7 @@ export class DeviceAPI {
|
|||||||
// A helper method for promisifying general (non-streaming) requests. Streaming
|
// A helper method for promisifying general (non-streaming) requests. Streaming
|
||||||
// requests should use a seperate setup
|
// requests should use a seperate setup
|
||||||
private static async promisifiedRequest<
|
private static async promisifiedRequest<
|
||||||
T extends Parameters<typeof request>[0]
|
T extends Parameters<typeof request>[0],
|
||||||
>(opts: T, logger?: Logger): Promise<any> {
|
>(opts: T, logger?: Logger): Promise<any> {
|
||||||
interface ObjectWithUrl {
|
interface ObjectWithUrl {
|
||||||
url?: string;
|
url?: string;
|
||||||
|
@ -151,9 +151,8 @@ export class LivepushManager {
|
|||||||
// only happens when the dockerfile path is
|
// only happens when the dockerfile path is
|
||||||
// specified differently - this should be patched
|
// specified differently - this should be patched
|
||||||
// in resin-bundle-resolve
|
// in resin-bundle-resolve
|
||||||
this.dockerfilePaths[
|
this.dockerfilePaths[buildTask.serviceName] =
|
||||||
buildTask.serviceName
|
this.getDockerfilePathFromTask(buildTask);
|
||||||
] = this.getDockerfilePathFromTask(buildTask);
|
|
||||||
} else {
|
} else {
|
||||||
this.dockerfilePaths[buildTask.serviceName] = [
|
this.dockerfilePaths[buildTask.serviceName] = [
|
||||||
buildTask.dockerfilePath,
|
buildTask.dockerfilePath,
|
||||||
|
@ -90,9 +90,8 @@ export async function sudo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function runCommand<T>(commandArgs: string[]): Promise<T> {
|
export function runCommand<T>(commandArgs: string[]): Promise<T> {
|
||||||
const {
|
const { isSubcommand } =
|
||||||
isSubcommand,
|
require('../preparser') as typeof import('../preparser');
|
||||||
} = require('../preparser') as typeof import('../preparser');
|
|
||||||
if (isSubcommand(commandArgs)) {
|
if (isSubcommand(commandArgs)) {
|
||||||
commandArgs = [
|
commandArgs = [
|
||||||
commandArgs[0] + ':' + commandArgs[1],
|
commandArgs[0] + ':' + commandArgs[1],
|
||||||
@ -598,14 +597,13 @@ export function addSIGINTHandler(sigintHandler: () => void, once = true) {
|
|||||||
* @param theArgs Arguments to be passed to the task function
|
* @param theArgs Arguments to be passed to the task function
|
||||||
*/
|
*/
|
||||||
export async function awaitInterruptibleTask<
|
export async function awaitInterruptibleTask<
|
||||||
T extends (...args: any[]) => Promise<any>
|
T extends (...args: any[]) => Promise<any>,
|
||||||
>(task: T, ...theArgs: Parameters<T>): Promise<ReturnType<T>> {
|
>(task: T, ...theArgs: Parameters<T>): Promise<ReturnType<T>> {
|
||||||
let sigintHandler: () => void = () => undefined;
|
let sigintHandler: () => void = () => undefined;
|
||||||
const sigintPromise = new Promise<T>((_resolve, reject) => {
|
const sigintPromise = new Promise<T>((_resolve, reject) => {
|
||||||
sigintHandler = () => {
|
sigintHandler = () => {
|
||||||
const {
|
const { SIGINTError } =
|
||||||
SIGINTError,
|
require('../errors') as typeof import('../errors');
|
||||||
} = require('../errors') as typeof import('../errors');
|
|
||||||
reject(new SIGINTError('Task aborted on SIGINT signal'));
|
reject(new SIGINTError('Task aborted on SIGINT signal'));
|
||||||
};
|
};
|
||||||
addSIGINTHandler(sigintHandler);
|
addSIGINTHandler(sigintHandler);
|
||||||
|
@ -61,5 +61,6 @@ export const getCliForm = once(
|
|||||||
export const getCliUx = once(() => require('cli-ux').ux as typeof ux);
|
export const getCliUx = once(() => require('cli-ux').ux as typeof ux);
|
||||||
|
|
||||||
// Directly export stripIndent as we always use it immediately, but importing just `stripIndent` reduces startup time
|
// Directly export stripIndent as we always use it immediately, but importing just `stripIndent` reduces startup time
|
||||||
// tslint:disable-next-line:no-var-requires
|
export const stripIndent =
|
||||||
export const stripIndent = require('common-tags/lib/stripIndent') as typeof StripIndent;
|
// tslint:disable-next-line:no-var-requires
|
||||||
|
require('common-tags/lib/stripIndent') as typeof StripIndent;
|
||||||
|
@ -268,10 +268,8 @@ export async function awaitDeviceOsUpdate(
|
|||||||
progressBar.update({ percentage: 0 });
|
progressBar.update({ percentage: 0 });
|
||||||
|
|
||||||
const poll = async (): Promise<void> => {
|
const poll = async (): Promise<void> => {
|
||||||
const [
|
const [osUpdateStatus, { overall_progress: osUpdateProgress }] =
|
||||||
osUpdateStatus,
|
await Promise.all([
|
||||||
{ overall_progress: osUpdateProgress },
|
|
||||||
] = await Promise.all([
|
|
||||||
balena.models.device.getOsUpdateStatus(uuid),
|
balena.models.device.getOsUpdateStatus(uuid),
|
||||||
balena.models.device.get(uuid, { $select: 'overall_progress' }),
|
balena.models.device.get(uuid, { $select: 'overall_progress' }),
|
||||||
]);
|
]);
|
||||||
|
1082
npm-shrinkwrap.json
generated
1082
npm-shrinkwrap.json
generated
File diff suppressed because it is too large
Load Diff
@ -69,7 +69,7 @@
|
|||||||
"catch-uncommitted": "ts-node --transpile-only automation/run.ts catch-uncommitted",
|
"catch-uncommitted": "ts-node --transpile-only automation/run.ts catch-uncommitted",
|
||||||
"ci": "npm run test && npm run catch-uncommitted",
|
"ci": "npm run test && npm run catch-uncommitted",
|
||||||
"watch": "gulp watch",
|
"watch": "gulp watch",
|
||||||
"lint": "balena-lint -e ts -e js --typescript --fix automation/ completion/ lib/ typings/ tests/ bin/balena bin/balena-dev gulpfile.js .mocharc.js .mocharc-standalone.js",
|
"lint": "balena-lint -e ts -e js --fix automation/ completion/ lib/ typings/ tests/ bin/balena bin/balena-dev gulpfile.js .mocharc.js .mocharc-standalone.js",
|
||||||
"update": "ts-node --transpile-only ./automation/update-module.ts",
|
"update": "ts-node --transpile-only ./automation/update-module.ts",
|
||||||
"prepare": "echo {} > bin/.fast-boot.json",
|
"prepare": "echo {} > bin/.fast-boot.json",
|
||||||
"prepublishOnly": "npm run build"
|
"prepublishOnly": "npm run build"
|
||||||
@ -111,7 +111,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@balena/lint": "^5.2.0",
|
"@balena/lint": "^6.1.1",
|
||||||
"@oclif/config": "^1.17.0",
|
"@oclif/config": "^1.17.0",
|
||||||
"@oclif/dev-cli": "^1.26.0",
|
"@oclif/dev-cli": "^1.26.0",
|
||||||
"@oclif/parser": "^3.8.5",
|
"@oclif/parser": "^3.8.5",
|
||||||
|
@ -223,7 +223,7 @@ describe('balena deploy', function () {
|
|||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
await switchSentry(sentryStatus);
|
await switchSentry(sentryStatus);
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
process.exit.restore();
|
process.exit.restore();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -100,9 +100,8 @@ export async function inspectTarStream(
|
|||||||
try {
|
try {
|
||||||
expect($expected).to.deep.equal(found);
|
expect($expected).to.deep.equal(found);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const {
|
const { diff } =
|
||||||
diff,
|
require('deep-object-diff') as typeof import('deep-object-diff');
|
||||||
} = require('deep-object-diff') as typeof import('deep-object-diff');
|
|
||||||
const diffStr = JSON.stringify(
|
const diffStr = JSON.stringify(
|
||||||
diff($expected, found),
|
diff($expected, found),
|
||||||
(_k, v) => (v === undefined ? 'undefined' : v),
|
(_k, v) => (v === undefined ? 'undefined' : v),
|
||||||
@ -216,7 +215,7 @@ export async function testDockerBuildStream(o: {
|
|||||||
}
|
}
|
||||||
if (o.expectedExitCode != null) {
|
if (o.expectedExitCode != null) {
|
||||||
if (process.env.BALENA_CLI_TEST_TYPE !== 'standalone') {
|
if (process.env.BALENA_CLI_TEST_TYPE !== 'standalone') {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
sinon.assert.calledWith(process.exit);
|
sinon.assert.calledWith(process.exit);
|
||||||
}
|
}
|
||||||
expect(o.expectedExitCode).to.equal(exitCode);
|
expect(o.expectedExitCode).to.equal(exitCode);
|
||||||
|
@ -48,7 +48,7 @@ describe('handleError() function', () => {
|
|||||||
'printExpectedErrorMessage',
|
'printExpectedErrorMessage',
|
||||||
);
|
);
|
||||||
captureException = sinon.stub();
|
captureException = sinon.stub();
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
sandbox.stub(ErrorsModule, 'getSentry').resolves({ captureException });
|
sandbox.stub(ErrorsModule, 'getSentry').resolves({ captureException });
|
||||||
processExit = sandbox.stub(process, 'exit');
|
processExit = sandbox.stub(process, 'exit');
|
||||||
|
|
||||||
|
@ -39,9 +39,8 @@ interface TestOutput {
|
|||||||
* @param testOutput
|
* @param testOutput
|
||||||
*/
|
*/
|
||||||
function filterCliOutputForTests(testOutput: TestOutput): TestOutput {
|
function filterCliOutputForTests(testOutput: TestOutput): TestOutput {
|
||||||
const {
|
const { matchesNodeEngineVersionWarn } =
|
||||||
matchesNodeEngineVersionWarn,
|
require('../automation/utils') as typeof import('../automation/utils');
|
||||||
} = require('../automation/utils') as typeof import('../automation/utils');
|
|
||||||
return {
|
return {
|
||||||
exitCode: testOutput.exitCode,
|
exitCode: testOutput.exitCode,
|
||||||
err: testOutput.err.filter(
|
err: testOutput.err.filter(
|
||||||
|
@ -130,9 +130,8 @@ export class NockMock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected handleUnexpectedRequest(req: any) {
|
protected handleUnexpectedRequest(req: any) {
|
||||||
const {
|
const { interceptorServerPort } =
|
||||||
interceptorServerPort,
|
require('./proxy-server') as typeof import('./proxy-server');
|
||||||
} = require('./proxy-server') as typeof import('./proxy-server');
|
|
||||||
const o = req.options || {};
|
const o = req.options || {};
|
||||||
const u = o.uri || {};
|
const u = o.uri || {};
|
||||||
const method = req.method;
|
const method = req.method;
|
||||||
|
@ -86,7 +86,9 @@ async function createProxyServer(): Promise<[number, number]> {
|
|||||||
const interceptorPort = await createInterceptorServer();
|
const interceptorPort = await createInterceptorServer();
|
||||||
|
|
||||||
const proxy = httpProxy.createProxyServer();
|
const proxy = httpProxy.createProxyServer();
|
||||||
proxy.on('error', function (
|
proxy.on(
|
||||||
|
'error',
|
||||||
|
function (
|
||||||
err: Error,
|
err: Error,
|
||||||
_req: http.IncomingMessage,
|
_req: http.IncomingMessage,
|
||||||
res: http.ServerResponse,
|
res: http.ServerResponse,
|
||||||
@ -95,7 +97,8 @@ async function createProxyServer(): Promise<[number, number]> {
|
|||||||
const msg = `Proxy server error: ${err}`;
|
const msg = `Proxy server error: ${err}`;
|
||||||
console.error(msg);
|
console.error(msg);
|
||||||
res.end(msg);
|
res.end(msg);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const server = http.createServer(function (
|
const server = http.createServer(function (
|
||||||
req: http.IncomingMessage,
|
req: http.IncomingMessage,
|
||||||
@ -150,10 +153,9 @@ async function createInterceptorServer(): Promise<number> {
|
|||||||
if (process.env.DEBUG) {
|
if (process.env.DEBUG) {
|
||||||
console.error(`[debug] Interceptor forwarding for ${proxiedFor}`);
|
console.error(`[debug] Interceptor forwarding for ${proxiedFor}`);
|
||||||
}
|
}
|
||||||
// tslint:disable-next-line:prefer-const
|
const parsed = url.parse(proxiedFor);
|
||||||
let { protocol, hostname, port, path: urlPath, hash } = url.parse(
|
const { hash, hostname, path: urlPath } = parsed;
|
||||||
proxiedFor,
|
let { port, protocol } = parsed;
|
||||||
);
|
|
||||||
protocol = (protocol || 'http:').toLowerCase();
|
protocol = (protocol || 'http:').toLowerCase();
|
||||||
port = port || (protocol === 'https:' ? '443' : '80');
|
port = port || (protocol === 'https:' ? '443' : '80');
|
||||||
const reqOpts = {
|
const reqOpts = {
|
||||||
|
@ -46,7 +46,8 @@ class MockLivepushManager extends LivepushManager {
|
|||||||
api: {} as import('../../../lib/utils/device/api').DeviceAPI,
|
api: {} as import('../../../lib/utils/device/api').DeviceAPI,
|
||||||
logger: {} as import('../../../lib/utils/logger'),
|
logger: {} as import('../../../lib/utils/logger'),
|
||||||
buildLogs: {},
|
buildLogs: {},
|
||||||
deployOpts: {} as import('../../../lib/utils/device/deploy').DeviceDeployOptions,
|
deployOpts:
|
||||||
|
{} as import('../../../lib/utils/device/deploy').DeviceDeployOptions,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,6 @@ describe('detectEncoding() function', function () {
|
|||||||
'node_modules/.bin/mocha',
|
'node_modules/.bin/mocha',
|
||||||
'node_modules/.bin/rimraf',
|
'node_modules/.bin/rimraf',
|
||||||
'node_modules/.bin/gulp',
|
'node_modules/.bin/gulp',
|
||||||
'node_modules/.bin/coffeelint',
|
|
||||||
'node_modules/.bin/tsc',
|
'node_modules/.bin/tsc',
|
||||||
'node_modules/.bin/balena-lint',
|
'node_modules/.bin/balena-lint',
|
||||||
'node_modules/.bin/balena-preload',
|
'node_modules/.bin/balena-preload',
|
||||||
|
Reference in New Issue
Block a user