mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-18 21:27:51 +00:00
Bump balena-lint to 7.2.1
Change-type: patch
This commit is contained in:
parent
1ffa8d38f1
commit
7d13946c3e
2
.eslintignore
Normal file
2
.eslintignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/completion/*
|
||||||
|
/bin/*
|
21
.eslintrc.js
Normal file
21
.eslintrc.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
module.exports = {
|
||||||
|
extends: ['./node_modules/@balena/lint/config/.eslintrc.js'],
|
||||||
|
parserOptions: {
|
||||||
|
project: 'tsconfig.dev.json',
|
||||||
|
},
|
||||||
|
root: true,
|
||||||
|
rules: {
|
||||||
|
ignoreDefinitionFiles: 0,
|
||||||
|
// to avoid the `warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion`
|
||||||
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||||
|
'@typescript-eslint/no-shadow': 'off',
|
||||||
|
'@typescript-eslint/no-var-requires': 'off',
|
||||||
|
'no-restricted-imports': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
paths: ['resin-cli-visuals', 'chalk', 'common-tags', 'resin-cli-form'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
||||||
|
},
|
||||||
|
};
|
@ -25,7 +25,6 @@ import * as filehound from 'filehound';
|
|||||||
import { Stats } from 'fs';
|
import { Stats } from 'fs';
|
||||||
import * as fs from 'fs-extra';
|
import * as fs from 'fs-extra';
|
||||||
import * as klaw from 'klaw';
|
import * as klaw from 'klaw';
|
||||||
import * as _ from 'lodash';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as rimraf from 'rimraf';
|
import * as rimraf from 'rimraf';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
|
@ -104,5 +104,5 @@ async function printMarkdown() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// tslint:disable-next-line:no-floating-promises
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
printMarkdown();
|
printMarkdown();
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// tslint:disable-next-line:import-blacklist
|
// eslint-disable-next-line no-restricted-imports
|
||||||
import { stripIndent } from 'common-tags';
|
import { stripIndent } from 'common-tags';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
@ -82,5 +82,5 @@ async function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// tslint:disable-next-line:no-floating-promises
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
run();
|
run();
|
||||||
|
@ -23,8 +23,8 @@ function parseSemver(version) {
|
|||||||
* @param {string} v2
|
* @param {string} v2
|
||||||
*/
|
*/
|
||||||
function semverGte(v1, v2) {
|
function semverGte(v1, v2) {
|
||||||
let v1Array = parseSemver(v1);
|
const v1Array = parseSemver(v1);
|
||||||
let v2Array = parseSemver(v2);
|
const v2Array = parseSemver(v2);
|
||||||
for (let i = 0; i < 3; i++) {
|
for (let i = 0; i < 3; i++) {
|
||||||
if (v1Array[i] < v2Array[i]) {
|
if (v1Array[i] < v2Array[i]) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -30,7 +30,7 @@ const { GITHUB_TOKEN } = process.env;
|
|||||||
export async function createGitHubRelease() {
|
export async function createGitHubRelease() {
|
||||||
console.log(`Publishing release ${version} to GitHub`);
|
console.log(`Publishing release ${version} to GitHub`);
|
||||||
const publishRelease = await import('publish-release');
|
const publishRelease = await import('publish-release');
|
||||||
const ghRelease = await Bluebird.fromCallback(
|
const ghRelease = (await Bluebird.fromCallback(
|
||||||
publishRelease.bind(null, {
|
publishRelease.bind(null, {
|
||||||
token: GITHUB_TOKEN || '',
|
token: GITHUB_TOKEN || '',
|
||||||
owner: 'balena-io',
|
owner: 'balena-io',
|
||||||
@ -40,7 +40,7 @@ export async function createGitHubRelease() {
|
|||||||
reuseRelease: true,
|
reuseRelease: true,
|
||||||
assets: finalReleaseAssets[process.platform],
|
assets: finalReleaseAssets[process.platform],
|
||||||
}),
|
}),
|
||||||
);
|
)) as { html_url: any };
|
||||||
console.log(`Release ${version} successful: ${ghRelease.html_url}`);
|
console.log(`Release ${version} successful: ${ghRelease.html_url}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ async function updateGitHubReleaseDescriptions(
|
|||||||
) {
|
) {
|
||||||
const perPage = 30;
|
const perPage = 30;
|
||||||
const octokit = getOctokit();
|
const octokit = getOctokit();
|
||||||
const options = await octokit.repos.listReleases.endpoint.merge({
|
const options = octokit.repos.listReleases.endpoint.merge({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
per_page: perPage,
|
per_page: perPage,
|
||||||
|
@ -60,7 +60,7 @@ async function parse(args?: string[]) {
|
|||||||
release,
|
release,
|
||||||
};
|
};
|
||||||
for (const arg of args) {
|
for (const arg of args) {
|
||||||
if (!commands.hasOwnProperty(arg)) {
|
if (!Object.hasOwn(commands, arg)) {
|
||||||
throw new Error(`command unknown: ${arg}`);
|
throw new Error(`command unknown: ${arg}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,5 +103,5 @@ export async function run(args?: string[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// tslint:disable-next-line:no-floating-promises
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
run();
|
run();
|
||||||
|
@ -136,5 +136,5 @@ async function main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// tslint:disable-next-line:no-floating-promises
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
main();
|
main();
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
import * as _ from 'lodash';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export const ROOT = path.join(__dirname, '..');
|
export const ROOT = path.join(__dirname, '..');
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
// tslint:disable:no-var-requires
|
|
||||||
|
|
||||||
// We boost the threadpool size as ext2fs can deadlock with some
|
// We boost the threadpool size as ext2fs can deadlock with some
|
||||||
// operations otherwise, if the pool runs out.
|
// operations otherwise, if the pool runs out.
|
||||||
process.env.UV_THREADPOOL_SIZE = '64';
|
process.env.UV_THREADPOOL_SIZE = '64';
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
// Before opening a PR you should build and test your changes using bin/balena
|
// Before opening a PR you should build and test your changes using bin/balena
|
||||||
// ****************************************************************************
|
// ****************************************************************************
|
||||||
|
|
||||||
// tslint:disable:no-var-requires
|
|
||||||
|
|
||||||
// We boost the threadpool size as ext2fs can deadlock with some
|
// We boost the threadpool size as ext2fs can deadlock with some
|
||||||
// operations otherwise, if the pool runs out.
|
// operations otherwise, if the pool runs out.
|
||||||
process.env.UV_THREADPOOL_SIZE = '64';
|
process.env.UV_THREADPOOL_SIZE = '64';
|
||||||
|
@ -31,8 +31,8 @@ if (fs.existsSync(commandsFilePath)) {
|
|||||||
|
|
||||||
const commandsJson = JSON.parse(fs.readFileSync(commandsFilePath, 'utf8'));
|
const commandsJson = JSON.parse(fs.readFileSync(commandsFilePath, 'utf8'));
|
||||||
|
|
||||||
var mainCommands = [];
|
const mainCommands = [];
|
||||||
var additionalCommands = [];
|
const additionalCommands = [];
|
||||||
for (const key of Object.keys(commandsJson.commands)) {
|
for (const key of Object.keys(commandsJson.commands)) {
|
||||||
const cmd = key.split(':');
|
const cmd = key.split(':');
|
||||||
if (cmd.length > 1) {
|
if (cmd.length > 1) {
|
||||||
@ -72,8 +72,8 @@ fs.readFile(bashFilePathIn, 'utf8', function (err, data) {
|
|||||||
/\$main_commands\$/g,
|
/\$main_commands\$/g,
|
||||||
'main_commands="' + mainCommandsStr + '"',
|
'main_commands="' + mainCommandsStr + '"',
|
||||||
);
|
);
|
||||||
var subCommands = [];
|
let subCommands = [];
|
||||||
var prevElement = additionalCommands[0][0];
|
let prevElement = additionalCommands[0][0];
|
||||||
additionalCommands.forEach(function (element) {
|
additionalCommands.forEach(function (element) {
|
||||||
if (element[0] === prevElement) {
|
if (element[0] === prevElement) {
|
||||||
subCommands.push(element[1]);
|
subCommands.push(element[1]);
|
||||||
@ -134,8 +134,8 @@ fs.readFile(zshFilePathIn, 'utf8', function (err, data) {
|
|||||||
/\$main_commands\$/g,
|
/\$main_commands\$/g,
|
||||||
'main_commands=( ' + mainCommandsStr + ' )',
|
'main_commands=( ' + mainCommandsStr + ' )',
|
||||||
);
|
);
|
||||||
var subCommands = [];
|
let subCommands = [];
|
||||||
var prevElement = additionalCommands[0][0];
|
let prevElement = additionalCommands[0][0];
|
||||||
additionalCommands.forEach(function (element) {
|
additionalCommands.forEach(function (element) {
|
||||||
if (element[0] === prevElement) {
|
if (element[0] === prevElement) {
|
||||||
subCommands.push(element[1]);
|
subCommands.push(element[1]);
|
||||||
|
@ -52,7 +52,6 @@ export default class RevokeCmd extends Command {
|
|||||||
public async run() {
|
public async run() {
|
||||||
const { args: params } = await this.parse(RevokeCmd);
|
const { args: params } = await this.parse(RevokeCmd);
|
||||||
|
|
||||||
try {
|
|
||||||
const apiKeyIds = params.ids.split(',');
|
const apiKeyIds = params.ids.split(',');
|
||||||
if (apiKeyIds.filter((apiKeyId) => !apiKeyId.match(/^\d+$/)).length > 0) {
|
if (apiKeyIds.filter((apiKeyId) => !apiKeyId.match(/^\d+$/)).length > 0) {
|
||||||
console.log('API key ids must be positive integers');
|
console.log('API key ids must be positive integers');
|
||||||
@ -64,8 +63,5 @@ export default class RevokeCmd extends Command {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
console.log('Successfully revoked the given API keys');
|
console.log('Successfully revoked the given API keys');
|
||||||
} catch (e) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,6 @@ export default class ApiKeysCmd extends Command {
|
|||||||
public async run() {
|
public async run() {
|
||||||
const { flags: options } = await this.parse(ApiKeysCmd);
|
const { flags: options } = await this.parse(ApiKeysCmd);
|
||||||
|
|
||||||
try {
|
|
||||||
const { getApplication } = await import('../../utils/sdk');
|
const { getApplication } = await import('../../utils/sdk');
|
||||||
const actorId = options.fleet
|
const actorId = options.fleet
|
||||||
? (
|
? (
|
||||||
@ -80,8 +79,5 @@ export default class ApiKeysCmd extends Command {
|
|||||||
fields,
|
fields,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,8 @@ export default class DeviceDeactivateCmd extends Command {
|
|||||||
public static authenticated = true;
|
public static authenticated = true;
|
||||||
|
|
||||||
public async run() {
|
public async run() {
|
||||||
const { args: params, flags: options } = await this.parse(
|
const { args: params, flags: options } =
|
||||||
DeviceDeactivateCmd,
|
await this.parse(DeviceDeactivateCmd);
|
||||||
);
|
|
||||||
|
|
||||||
const balena = getBalenaSdk();
|
const balena = getBalenaSdk();
|
||||||
const patterns = await import('../../utils/patterns');
|
const patterns = await import('../../utils/patterns');
|
||||||
|
@ -63,9 +63,8 @@ export default class DeviceLocalModeCmd extends Command {
|
|||||||
public static authenticated = true;
|
public static authenticated = true;
|
||||||
|
|
||||||
public async run() {
|
public async run() {
|
||||||
const { args: params, flags: options } = await this.parse(
|
const { args: params, flags: options } =
|
||||||
DeviceLocalModeCmd,
|
await this.parse(DeviceLocalModeCmd);
|
||||||
);
|
|
||||||
|
|
||||||
const balena = getBalenaSdk();
|
const balena = getBalenaSdk();
|
||||||
|
|
||||||
|
@ -59,9 +59,8 @@ export default class DeviceOsUpdateCmd extends Command {
|
|||||||
public static authenticated = true;
|
public static authenticated = true;
|
||||||
|
|
||||||
public async run() {
|
public async run() {
|
||||||
const { args: params, flags: options } = await this.parse(
|
const { args: params, flags: options } =
|
||||||
DeviceOsUpdateCmd,
|
await this.parse(DeviceOsUpdateCmd);
|
||||||
);
|
|
||||||
|
|
||||||
const sdk = getBalenaSdk();
|
const sdk = getBalenaSdk();
|
||||||
|
|
||||||
|
@ -65,9 +65,8 @@ export default class DevicePublicUrlCmd extends Command {
|
|||||||
public static authenticated = true;
|
public static authenticated = true;
|
||||||
|
|
||||||
public async run() {
|
public async run() {
|
||||||
const { args: params, flags: options } = await this.parse(
|
const { args: params, flags: options } =
|
||||||
DevicePublicUrlCmd,
|
await this.parse(DevicePublicUrlCmd);
|
||||||
);
|
|
||||||
|
|
||||||
const balena = getBalenaSdk();
|
const balena = getBalenaSdk();
|
||||||
|
|
||||||
|
@ -61,9 +61,8 @@ export default class DeviceRegisterCmd extends Command {
|
|||||||
public static authenticated = true;
|
public static authenticated = true;
|
||||||
|
|
||||||
public async run() {
|
public async run() {
|
||||||
const { args: params, flags: options } = await this.parse(
|
const { args: params, flags: options } =
|
||||||
DeviceRegisterCmd,
|
await this.parse(DeviceRegisterCmd);
|
||||||
);
|
|
||||||
|
|
||||||
const { getApplication } = await import('../../utils/sdk');
|
const { getApplication } = await import('../../utils/sdk');
|
||||||
|
|
||||||
|
@ -46,9 +46,8 @@ export default class DeviceShutdownCmd extends Command {
|
|||||||
public static authenticated = true;
|
public static authenticated = true;
|
||||||
|
|
||||||
public async run() {
|
public async run() {
|
||||||
const { args: params, flags: options } = await this.parse(
|
const { args: params, flags: options } =
|
||||||
DeviceShutdownCmd,
|
await this.parse(DeviceShutdownCmd);
|
||||||
);
|
|
||||||
|
|
||||||
const balena = getBalenaSdk();
|
const balena = getBalenaSdk();
|
||||||
|
|
||||||
|
@ -228,7 +228,8 @@ async function getAppVars(
|
|||||||
if (!fleetSlug) {
|
if (!fleetSlug) {
|
||||||
return appVars;
|
return appVars;
|
||||||
}
|
}
|
||||||
const vars = await sdk.models.application[
|
const vars =
|
||||||
|
await sdk.models.application[
|
||||||
options.config ? 'configVar' : 'envVar'
|
options.config ? 'configVar' : 'envVar'
|
||||||
].getAllByApplication(fleetSlug);
|
].getAllByApplication(fleetSlug);
|
||||||
fillInInfoFields(vars, fleetSlug);
|
fillInInfoFields(vars, fleetSlug);
|
||||||
@ -269,9 +270,8 @@ async function getDeviceVars(
|
|||||||
const printedUUID = options.json ? fullUUID : options.device!;
|
const printedUUID = options.json ? fullUUID : options.device!;
|
||||||
const deviceVars: EnvironmentVariableInfo[] = [];
|
const deviceVars: EnvironmentVariableInfo[] = [];
|
||||||
if (options.config) {
|
if (options.config) {
|
||||||
const deviceConfigVars = await sdk.models.device.configVar.getAllByDevice(
|
const deviceConfigVars =
|
||||||
fullUUID,
|
await sdk.models.device.configVar.getAllByDevice(fullUUID);
|
||||||
);
|
|
||||||
fillInInfoFields(deviceConfigVars, fleetSlug, printedUUID);
|
fillInInfoFields(deviceConfigVars, fleetSlug, printedUUID);
|
||||||
deviceVars.push(...deviceConfigVars);
|
deviceVars.push(...deviceConfigVars);
|
||||||
} else {
|
} else {
|
||||||
@ -296,9 +296,8 @@ async function getDeviceVars(
|
|||||||
fillInInfoFields(deviceServiceVars, fleetSlug, printedUUID);
|
fillInInfoFields(deviceServiceVars, fleetSlug, printedUUID);
|
||||||
deviceVars.push(...deviceServiceVars);
|
deviceVars.push(...deviceServiceVars);
|
||||||
|
|
||||||
const deviceEnvVars = await sdk.models.device.envVar.getAllByDevice(
|
const deviceEnvVars =
|
||||||
fullUUID,
|
await sdk.models.device.envVar.getAllByDevice(fullUUID);
|
||||||
);
|
|
||||||
fillInInfoFields(deviceEnvVars, fleetSlug, printedUUID);
|
fillInInfoFields(deviceEnvVars, fleetSlug, printedUUID);
|
||||||
deviceVars.push(...deviceEnvVars);
|
deviceVars.push(...deviceEnvVars);
|
||||||
}
|
}
|
||||||
|
@ -390,9 +390,8 @@ Can be repeated to add multiple certificates.\
|
|||||||
);
|
);
|
||||||
applicationInfoSpinner.start();
|
applicationInfoSpinner.start();
|
||||||
|
|
||||||
const applications = await this.getApplicationsWithSuccessfulBuilds(
|
const applications =
|
||||||
deviceTypeSlug,
|
await this.getApplicationsWithSuccessfulBuilds(deviceTypeSlug);
|
||||||
);
|
|
||||||
applicationInfoSpinner.stop();
|
applicationInfoSpinner.stop();
|
||||||
if (applications.length === 0) {
|
if (applications.length === 0) {
|
||||||
throw new ExpectedError(
|
throw new ExpectedError(
|
||||||
|
@ -204,12 +204,16 @@ export default class TunnelCmd extends Command {
|
|||||||
let localAddress = 'localhost';
|
let localAddress = 'localhost';
|
||||||
|
|
||||||
// First element is always remotePort
|
// First element is always remotePort
|
||||||
|
// TODO: figure out why we have explicitly passed `undefined` for the radix parameter
|
||||||
|
// eslint-disable-next-line radix
|
||||||
const remotePort = parseInt(mappingElements[0], undefined);
|
const remotePort = parseInt(mappingElements[0], undefined);
|
||||||
let localPort = remotePort;
|
let localPort = remotePort;
|
||||||
|
|
||||||
if (mappingElements.length === 2) {
|
if (mappingElements.length === 2) {
|
||||||
// [1] could be localAddress or localPort
|
// [1] could be localAddress or localPort
|
||||||
if (/^\d+$/.test(mappingElements[1])) {
|
if (/^\d+$/.test(mappingElements[1])) {
|
||||||
|
// TODO: figure out why we have explicitly passed `undefined` for the radix parameter
|
||||||
|
// eslint-disable-next-line radix
|
||||||
localPort = parseInt(mappingElements[1], undefined);
|
localPort = parseInt(mappingElements[1], undefined);
|
||||||
} else {
|
} else {
|
||||||
localAddress = mappingElements[1];
|
localAddress = mappingElements[1];
|
||||||
@ -217,6 +221,8 @@ export default class TunnelCmd extends Command {
|
|||||||
} else if (mappingElements.length === 3) {
|
} else if (mappingElements.length === 3) {
|
||||||
// [1] is localAddress, [2] is localPort
|
// [1] is localAddress, [2] is localPort
|
||||||
localAddress = mappingElements[1];
|
localAddress = mappingElements[1];
|
||||||
|
// TODO: figure out why we have explicitly passed `undefined` for the radix parameter
|
||||||
|
// eslint-disable-next-line radix
|
||||||
localPort = parseInt(mappingElements[2], undefined);
|
localPort = parseInt(mappingElements[2], undefined);
|
||||||
} else if (mappingElements.length > 3) {
|
} else if (mappingElements.length > 3) {
|
||||||
throw new InvalidPortMappingError(portMapping);
|
throw new InvalidPortMappingError(portMapping);
|
||||||
|
@ -47,7 +47,7 @@ export function outputMessage(msg: string) {
|
|||||||
* @param options Output options
|
* @param options Output options
|
||||||
*/
|
*/
|
||||||
export async function outputData(
|
export async function outputData(
|
||||||
data: any[] | {},
|
data: any[] | object,
|
||||||
fields: string[],
|
fields: string[],
|
||||||
options: DataOutputOptions | DataSetOutputOptions,
|
options: DataOutputOptions | DataSetOutputOptions,
|
||||||
) {
|
) {
|
||||||
|
@ -240,9 +240,8 @@ export async function getOsVersions(
|
|||||||
): Promise<SDK.OsVersion[]> {
|
): Promise<SDK.OsVersion[]> {
|
||||||
const sdk = getBalenaSdk();
|
const sdk = getBalenaSdk();
|
||||||
let slug = deviceType;
|
let slug = deviceType;
|
||||||
let versions: SDK.OsVersion[] = await sdk.models.os.getAvailableOsVersions(
|
let versions: SDK.OsVersion[] =
|
||||||
slug,
|
await sdk.models.os.getAvailableOsVersions(slug);
|
||||||
);
|
|
||||||
// if slug is an alias, fetch the real slug
|
// if slug is an alias, fetch the real slug
|
||||||
if (!versions.length) {
|
if (!versions.length) {
|
||||||
// unalias device type slug
|
// unalias device type slug
|
||||||
|
@ -31,7 +31,6 @@ import type * as MultiBuild from '@balena/compose/dist/multibuild';
|
|||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import type { Duplex, Readable } from 'stream';
|
import type { Duplex, Readable } from 'stream';
|
||||||
import type { Pack } from 'tar-stream';
|
import type { Pack } from 'tar-stream';
|
||||||
|
|
||||||
import { ExpectedError } from '../errors';
|
import { ExpectedError } from '../errors';
|
||||||
import {
|
import {
|
||||||
BuiltImage,
|
BuiltImage,
|
||||||
@ -1244,7 +1243,7 @@ async function pushAndUpdateServiceImages(
|
|||||||
afterEach: (
|
afterEach: (
|
||||||
serviceImage: import('@balena/compose/dist/release/models').ImageModel,
|
serviceImage: import('@balena/compose/dist/release/models').ImageModel,
|
||||||
props: object,
|
props: object,
|
||||||
) => void,
|
) => Promise<void>,
|
||||||
) {
|
) {
|
||||||
const { DockerProgress } = await import('docker-progress');
|
const { DockerProgress } = await import('docker-progress');
|
||||||
const { retry } = await import('./helpers');
|
const { retry } = await import('./helpers');
|
||||||
|
@ -194,6 +194,7 @@ export class LivepushManager {
|
|||||||
);
|
);
|
||||||
const eventQueue = this.updateEventsWaiting[$serviceName];
|
const eventQueue = this.updateEventsWaiting[$serviceName];
|
||||||
eventQueue.push(changedPath);
|
eventQueue.push(changedPath);
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
this.getDebouncedEventHandler($serviceName)();
|
this.getDebouncedEventHandler($serviceName)();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable no-restricted-imports */
|
||||||
|
/** the import blacklist is to enforce lazy loading so exempt this file */
|
||||||
/*
|
/*
|
||||||
Copyright 2020 Balena
|
Copyright 2020 Balena
|
||||||
|
|
||||||
@ -14,8 +16,6 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// tslint:disable:import-blacklist - the import blacklist is to enforce lazy loading so exempt this file
|
|
||||||
|
|
||||||
import type * as BalenaSdk from 'balena-sdk';
|
import type * as BalenaSdk from 'balena-sdk';
|
||||||
import type { Chalk } from 'chalk';
|
import type { Chalk } from 'chalk';
|
||||||
import type * as visuals from 'resin-cli-visuals';
|
import type * as visuals from 'resin-cli-visuals';
|
||||||
|
@ -29,7 +29,7 @@ import { getBalenaSdk, getVisuals, stripIndent, getCliForm } from './lazy';
|
|||||||
import validation = require('./validation');
|
import validation = require('./validation');
|
||||||
import { delay } from './helpers';
|
import { delay } from './helpers';
|
||||||
|
|
||||||
export function authenticate(options: {}): Promise<void> {
|
export function authenticate(options: object): Promise<void> {
|
||||||
const balena = getBalenaSdk();
|
const balena = getBalenaSdk();
|
||||||
return getCliForm()
|
return getCliForm()
|
||||||
.run(
|
.run(
|
||||||
|
@ -16,10 +16,11 @@ limitations under the License.
|
|||||||
|
|
||||||
import type { OptionalNavigationResource } from 'balena-sdk';
|
import type { OptionalNavigationResource } from 'balena-sdk';
|
||||||
|
|
||||||
export const getExpanded = <T extends {}>(obj: OptionalNavigationResource<T>) =>
|
export const getExpanded = <T extends object>(
|
||||||
(Array.isArray(obj) && obj[0]) || undefined;
|
obj: OptionalNavigationResource<T>,
|
||||||
|
) => (Array.isArray(obj) && obj[0]) || undefined;
|
||||||
|
|
||||||
export const getExpandedProp = <T extends {}, K extends keyof T>(
|
export const getExpandedProp = <T extends object, K extends keyof T>(
|
||||||
obj: OptionalNavigationResource<T>,
|
obj: OptionalNavigationResource<T>,
|
||||||
key: K,
|
key: K,
|
||||||
) => (Array.isArray(obj) && obj[0] && obj[0][key]) || undefined;
|
) => (Array.isArray(obj) && obj[0] && obj[0][key]) || undefined;
|
||||||
|
@ -394,7 +394,9 @@ async function createApplication(
|
|||||||
throw new sdk.errors.BalenaNotLoggedIn();
|
throw new sdk.errors.BalenaNotLoggedIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-async-promise-executor
|
||||||
const applicationName = await new Promise<string>(async (resolve, reject) => {
|
const applicationName = await new Promise<string>(async (resolve, reject) => {
|
||||||
|
// eslint-disable-next-line no-constant-condition
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
const appName = await getCliForm().ask({
|
const appName = await getCliForm().ask({
|
||||||
|
@ -194,7 +194,7 @@ async function handleHeadlessBuildStream(
|
|||||||
|
|
||||||
function handleBuilderMetadata(obj: BuilderMessage, build: RemoteBuild) {
|
function handleBuilderMetadata(obj: BuilderMessage, build: RemoteBuild) {
|
||||||
switch (obj.resource) {
|
switch (obj.resource) {
|
||||||
case 'cursor':
|
case 'cursor': {
|
||||||
if (obj.value == null) {
|
if (obj.value == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -228,6 +228,7 @@ function handleBuilderMetadata(obj: BuilderMessage, build: RemoteBuild) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'buildLogId':
|
case 'buildLogId':
|
||||||
// The name of this resource is slightly dated, but this is the release
|
// The name of this resource is slightly dated, but this is the release
|
||||||
// id from the API. We need to save this so that if the user ctrl+c's the
|
// id from the API. We need to save this so that if the user ctrl+c's the
|
||||||
@ -291,10 +292,10 @@ async function cancelBuildIfNecessary(build: RemoteBuild): Promise<void> {
|
|||||||
async function getTarStream(build: RemoteBuild): Promise<Stream.Readable> {
|
async function getTarStream(build: RemoteBuild): Promise<Stream.Readable> {
|
||||||
let tarSpinner = {
|
let tarSpinner = {
|
||||||
start: () => {
|
start: () => {
|
||||||
/*noop*/
|
/* noop*/
|
||||||
},
|
},
|
||||||
stop: () => {
|
stop: () => {
|
||||||
/*noop*/
|
/* noop*/
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
if (process.stdout.isTTY) {
|
if (process.stdout.isTTY) {
|
||||||
|
4962
npm-shrinkwrap.json
generated
4962
npm-shrinkwrap.json
generated
File diff suppressed because it is too large
Load Diff
@ -112,7 +112,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@balena/lint": "^6.2.2",
|
"@balena/lint": "^7.2.1",
|
||||||
"@electron/notarize": "^2.0.0",
|
"@electron/notarize": "^2.0.0",
|
||||||
"@octokit/plugin-throttling": "^3.5.1",
|
"@octokit/plugin-throttling": "^3.5.1",
|
||||||
"@octokit/rest": "^18.6.7",
|
"@octokit/rest": "^18.6.7",
|
||||||
@ -123,6 +123,7 @@
|
|||||||
"@types/chai-as-promised": "^7.1.4",
|
"@types/chai-as-promised": "^7.1.4",
|
||||||
"@types/cli-truncate": "^2.0.0",
|
"@types/cli-truncate": "^2.0.0",
|
||||||
"@types/common-tags": "^1.8.1",
|
"@types/common-tags": "^1.8.1",
|
||||||
|
"@types/diff": "^5.0.3",
|
||||||
"@types/dockerode": "^3.3.9",
|
"@types/dockerode": "^3.3.9",
|
||||||
"@types/ejs": "^3.1.0",
|
"@types/ejs": "^3.1.0",
|
||||||
"@types/express": "^4.17.13",
|
"@types/express": "^4.17.13",
|
||||||
@ -161,6 +162,7 @@
|
|||||||
"@types/through2": "^2.0.36",
|
"@types/through2": "^2.0.36",
|
||||||
"@types/tmp": "^0.2.3",
|
"@types/tmp": "^0.2.3",
|
||||||
"@types/which": "^2.0.1",
|
"@types/which": "^2.0.1",
|
||||||
|
"@types/window-size": "^1.1.1",
|
||||||
"archiver": "^5.3.0",
|
"archiver": "^5.3.0",
|
||||||
"catch-uncommitted": "^2.0.0",
|
"catch-uncommitted": "^2.0.0",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import mock = require('mock-require');
|
import * as mock from 'mock-require';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ describe('balena config write', function () {
|
|||||||
[{ a: 'b' }, 'a', 2, { a: 2 }],
|
[{ a: 'b' }, 'a', 2, { a: 2 }],
|
||||||
[{ a: ['b'] }, 'a', 2, { a: 2 }],
|
[{ a: ['b'] }, 'a', 2, { a: 2 }],
|
||||||
[{ a: ['b'] }, 'a.1', 'c', { a: ['b', 'c'] }],
|
[{ a: ['b'] }, 'a.1', 'c', { a: ['b', 'c'] }],
|
||||||
|
// eslint-disable-next-line no-sparse-arrays
|
||||||
[{ a: ['b'] }, 'a.2', 'c', { a: ['b', , 'c'] }],
|
[{ a: ['b'] }, 'a.2', 'c', { a: ['b', , 'c'] }],
|
||||||
[{ a: { '1': 'b' } }, 'a.1', 'c', { a: { '1': 'c' } }],
|
[{ a: { '1': 'b' } }, 'a.1', 'c', { a: { '1': 'c' } }],
|
||||||
[{ a: { '1': 'b' } }, 'a.2', 'c', { a: { '1': 'b', '2': 'c' } }],
|
[{ a: { '1': 'b' } }, 'a.2', 'c', { a: { '1': 'b', '2': 'c' } }],
|
||||||
|
@ -326,7 +326,7 @@ describe('balena deploy', function () {
|
|||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
await switchSentry(sentryStatus);
|
await switchSentry(sentryStatus);
|
||||||
// @ts-expect-error
|
// @ts-expect-error claims restore does not exist
|
||||||
process.exit.restore();
|
process.exit.restore();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -218,7 +218,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-expect-error
|
// @ts-expect-error claims the typing doesn't match
|
||||||
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-expect-error
|
// @ts-expect-error TODO: get explanation for why this ts-expect-error is necessary
|
||||||
sandbox.stub(ErrorsModule, 'getSentry').resolves({ captureException });
|
sandbox.stub(ErrorsModule, 'getSentry').resolves({ captureException });
|
||||||
processExit = sandbox.stub(process, 'exit');
|
processExit = sandbox.stub(process, 'exit');
|
||||||
|
|
||||||
|
@ -268,6 +268,7 @@ export function cleanOutput(
|
|||||||
* coded from observation of a few samples only, and may not cover all cases.
|
* coded from observation of a few samples only, and may not cover all cases.
|
||||||
*/
|
*/
|
||||||
export function monochrome(text: string): string {
|
export function monochrome(text: string): string {
|
||||||
|
// eslint-disable-next-line no-control-regex
|
||||||
return text.replace(/\u001b\[\??(\d+;)*\d+[a-zA-Z]\r?/g, '');
|
return text.replace(/\u001b\[\??(\d+;)*\d+[a-zA-Z]\r?/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,11 +38,8 @@ export class BuilderMock extends NockMock {
|
|||||||
checkURI: (uri: string) => Promise<void>;
|
checkURI: (uri: string) => Promise<void>;
|
||||||
checkBuildRequestBody: (requestBody: string | Buffer) => Promise<void>;
|
checkBuildRequestBody: (requestBody: string | Buffer) => Promise<void>;
|
||||||
}) {
|
}) {
|
||||||
this.optPost(/^\/v3\/build($|[(?])/, opts).reply(async function (
|
this.optPost(/^\/v3\/build($|[(?])/, opts).reply(
|
||||||
uri,
|
async function (uri, requestBody, callback) {
|
||||||
requestBody,
|
|
||||||
callback,
|
|
||||||
) {
|
|
||||||
let error: Error | null = null;
|
let error: Error | null = null;
|
||||||
try {
|
try {
|
||||||
await opts.checkURI(uri);
|
await opts.checkURI(uri);
|
||||||
@ -61,6 +58,7 @@ export class BuilderMock extends NockMock {
|
|||||||
error = err;
|
error = err;
|
||||||
}
|
}
|
||||||
callback(error, [opts.responseCode, opts.responseBody]);
|
callback(error, [opts.responseCode, opts.responseBody]);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { Readable } from 'stream';
|
import { Readable } from 'stream';
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as chokidar from 'chokidar';
|
import * as chokidar from 'chokidar';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import * as _ from 'lodash';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
|
|
||||||
|
@ -26,15 +26,15 @@ describe('getProxyConfig() function', function () {
|
|||||||
|
|
||||||
this.beforeEach(() => {
|
this.beforeEach(() => {
|
||||||
originalProxyConfig = [
|
originalProxyConfig = [
|
||||||
global.hasOwnProperty('PROXY_CONFIG'),
|
Object.hasOwn(global, 'PROXY_CONFIG'),
|
||||||
(global as any).PROXY_CONFIG,
|
(global as any).PROXY_CONFIG,
|
||||||
];
|
];
|
||||||
originalHttpProxy = [
|
originalHttpProxy = [
|
||||||
process.env.hasOwnProperty('HTTP_PROXY'),
|
Object.hasOwn(process.env, 'HTTP_PROXY'),
|
||||||
process.env.HTTP_PROXY,
|
process.env.HTTP_PROXY,
|
||||||
];
|
];
|
||||||
originalHttpsProxy = [
|
originalHttpsProxy = [
|
||||||
process.env.hasOwnProperty('HTTPS_PROXY'),
|
Object.hasOwn(process.env, 'HTTPS_PROXY'),
|
||||||
process.env.HTTPS_PROXY,
|
process.env.HTTPS_PROXY,
|
||||||
];
|
];
|
||||||
delete (global as any).PROXY_CONFIG;
|
delete (global as any).PROXY_CONFIG;
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as _ from 'lodash';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as tar from 'tar-stream';
|
import * as tar from 'tar-stream';
|
||||||
|
|
||||||
|
@ -13,15 +13,12 @@
|
|||||||
"removeComments": true,
|
"removeComments": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"typeRoots" : [
|
"typeRoots": [
|
||||||
"./node_modules/@types",
|
"./node_modules/@types",
|
||||||
"./node_modules/etcher-sdk/typings",
|
"./node_modules/etcher-sdk/typings",
|
||||||
"./typings"
|
"./typings"
|
||||||
],
|
],
|
||||||
"preserveSymlinks": true
|
"preserveSymlinks": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": ["./lib/**/*", "./typings/**/*"]
|
||||||
"./lib/**/*",
|
|
||||||
"./typings/**/*"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "./node_modules/@balena/lint/config/tslint-prettier.json",
|
|
||||||
"rules": {
|
|
||||||
"ignoreDefinitionFiles": false,
|
|
||||||
"import-blacklist": [true, "resin-cli-visuals", "chalk", "common-tags", "resin-cli-form"]
|
|
||||||
}
|
|
||||||
}
|
|
7
typings/balena-device-init/index.d.ts
vendored
7
typings/balena-device-init/index.d.ts
vendored
@ -18,7 +18,6 @@
|
|||||||
declare module 'balena-device-init' {
|
declare module 'balena-device-init' {
|
||||||
import { DeviceTypeJson } from 'balena-sdk';
|
import { DeviceTypeJson } from 'balena-sdk';
|
||||||
import * as Bluebird from 'bluebird';
|
import * as Bluebird from 'bluebird';
|
||||||
import { EventEmitter } from 'events';
|
|
||||||
|
|
||||||
interface OperationState {
|
interface OperationState {
|
||||||
operation:
|
operation:
|
||||||
@ -82,14 +81,14 @@ declare module 'balena-device-init' {
|
|||||||
export function configure(
|
export function configure(
|
||||||
image: string,
|
image: string,
|
||||||
manifest: BalenaSdk.DeviceTypeJson.DeviceType.DeviceType,
|
manifest: BalenaSdk.DeviceTypeJson.DeviceType.DeviceType,
|
||||||
config: {},
|
config: object,
|
||||||
options?: {},
|
options?: object,
|
||||||
): Bluebird<InitializeEmitter>;
|
): Bluebird<InitializeEmitter>;
|
||||||
|
|
||||||
export function initialize(
|
export function initialize(
|
||||||
image: string,
|
image: string,
|
||||||
manifest: BalenaSdk.DeviceTypeJson.DeviceType.DeviceType,
|
manifest: BalenaSdk.DeviceTypeJson.DeviceType.DeviceType,
|
||||||
config: {},
|
config: object,
|
||||||
): Bluebird<InitializeEmitter>;
|
): Bluebird<InitializeEmitter>;
|
||||||
|
|
||||||
export function getImageOsVersion(
|
export function getImageOsVersion(
|
||||||
|
6
typings/capitano/index.d.ts
vendored
6
typings/capitano/index.d.ts
vendored
@ -20,7 +20,7 @@ declare module 'capitano' {
|
|||||||
|
|
||||||
export interface Cli {
|
export interface Cli {
|
||||||
command: string;
|
command: string;
|
||||||
options: {};
|
options: object;
|
||||||
global: {
|
global: {
|
||||||
help?: boolean;
|
help?: boolean;
|
||||||
};
|
};
|
||||||
@ -30,12 +30,13 @@ declare module 'capitano' {
|
|||||||
signature: string;
|
signature: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
parameter?: string;
|
parameter?: string;
|
||||||
|
// eslint-disable-next-line id-denylist
|
||||||
boolean?: boolean;
|
boolean?: boolean;
|
||||||
required?: string;
|
required?: string;
|
||||||
alias?: string | string[];
|
alias?: string | string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommandDefinition<P = {}, O = {}> {
|
export interface CommandDefinition<P = object, O = object> {
|
||||||
signature: string;
|
signature: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
help?: string;
|
help?: string;
|
||||||
@ -65,6 +66,7 @@ declare module 'capitano' {
|
|||||||
export interface Option {
|
export interface Option {
|
||||||
signature: Signature;
|
signature: Signature;
|
||||||
alias: string | string[];
|
alias: string | string[];
|
||||||
|
// eslint-disable-next-line id-denylist
|
||||||
boolean: boolean;
|
boolean: boolean;
|
||||||
parameter: string;
|
parameter: string;
|
||||||
required: boolean | string;
|
required: boolean | string;
|
||||||
|
4
typings/color-hash/index.d.ts
vendored
4
typings/color-hash/index.d.ts
vendored
@ -16,10 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
declare module 'color-hash' {
|
declare module 'color-hash' {
|
||||||
interface Hasher {
|
|
||||||
hex(text: string): string;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ColorHash {
|
class ColorHash {
|
||||||
public hex(text: string): string;
|
public hex(text: string): string;
|
||||||
public rgb(text: string): [number, number, number];
|
public rgb(text: string): [number, number, number];
|
||||||
|
1
typings/common-tags/index.d.ts
vendored
1
typings/common-tags/index.d.ts
vendored
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
declare module 'common-tags/lib/stripIndent' {
|
declare module 'common-tags/lib/stripIndent' {
|
||||||
|
// eslint-disable-next-line no-restricted-imports
|
||||||
import { stripIndent } from 'common-tags';
|
import { stripIndent } from 'common-tags';
|
||||||
|
|
||||||
export = stripIndent;
|
export = stripIndent;
|
||||||
|
Loading…
Reference in New Issue
Block a user