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