feat(core): Upgrade oclif (no-changelog) (#8381)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-01-22 18:25:36 +01:00
committed by GitHub
parent 2c146cca62
commit 913c8c6b0c
29 changed files with 234 additions and 677 deletions

View File

@@ -1,7 +1,7 @@
import 'reflect-metadata';
import { Command } from '@oclif/command';
import { ExitError } from '@oclif/errors';
import { Container } from 'typedi';
import { Command } from '@oclif/core';
import { ExitError } from '@oclif/core/lib/errors';
import { ApplicationError, ErrorReporterProxy as ErrorReporter, sleep } from 'n8n-workflow';
import { BinaryDataService, InstanceSettings, ObjectStoreService } from 'n8n-core';
import type { AbstractServer } from '@/AbstractServer';

View File

@@ -1,12 +1,13 @@
import { flags } from '@oclif/command';
import { Container } from 'typedi';
import { Flags } from '@oclif/core';
import { ApplicationError } from 'n8n-workflow';
import { SecurityAuditService } from '@/security-audit/SecurityAudit.service';
import { RISK_CATEGORIES } from '@/security-audit/constants';
import config from '@/config';
import type { Risk } from '@/security-audit/types';
import { BaseCommand } from './BaseCommand';
import { Container } from 'typedi';
import { InternalHooks } from '@/InternalHooks';
import { ApplicationError } from 'n8n-workflow';
export class SecurityAudit extends BaseCommand {
static description = 'Generate a security audit report for this n8n instance';
@@ -18,20 +19,20 @@ export class SecurityAudit extends BaseCommand {
];
static flags = {
help: flags.help({ char: 'h' }),
categories: flags.string({
help: Flags.help({ char: 'h' }),
categories: Flags.string({
default: RISK_CATEGORIES.join(','),
description: 'Comma-separated list of categories to include in the audit',
}),
// eslint-disable-next-line @typescript-eslint/naming-convention
'days-abandoned-workflow': flags.integer({
'days-abandoned-workflow': Flags.integer({
default: config.getEnv('security.audit.daysAbandonedWorkflow'),
description: 'Days for a workflow to be considered abandoned if not executed',
}),
};
async run() {
const { flags: auditFlags } = this.parse(SecurityAudit);
const { flags: auditFlags } = await this.parse(SecurityAudit);
const categories =
auditFlags.categories?.split(',').filter((c): c is Risk.Category => c !== '') ??

View File

@@ -1,4 +1,4 @@
import { Command, flags } from '@oclif/command';
import { Command, Flags } from '@oclif/core';
import type { DataSourceOptions as ConnectionOptions } from 'typeorm';
import { DataSource as Connection } from 'typeorm';
import { Container } from 'typedi';
@@ -14,7 +14,7 @@ export class DbRevertMigrationCommand extends Command {
static examples = ['$ n8n db:revert'];
static flags = {
help: flags.help({ char: 'h' }),
help: Flags.help({ char: 'h' }),
};
protected logger = Container.get(Logger);
@@ -22,7 +22,7 @@ export class DbRevertMigrationCommand extends Command {
private connection: Connection;
async init() {
this.parse(DbRevertMigrationCommand);
await this.parse(DbRevertMigrationCommand);
}
async run() {

View File

@@ -1,5 +1,6 @@
import { Container } from 'typedi';
import { Flags } from '@oclif/core';
import { promises as fs } from 'fs';
import { flags } from '@oclif/command';
import { PLACEHOLDER_EMPTY_WORKFLOW_ID } from 'n8n-core';
import type { IWorkflowBase } from 'n8n-workflow';
import { ApplicationError, ExecutionBaseError } from 'n8n-workflow';
@@ -9,7 +10,7 @@ import { WorkflowRunner } from '@/WorkflowRunner';
import type { IWorkflowExecutionDataProcess } from '@/Interfaces';
import { findCliWorkflowStart, isWorkflowIdValid } from '@/utils';
import { BaseCommand } from './BaseCommand';
import { Container } from 'typedi';
import { WorkflowRepository } from '@db/repositories/workflow.repository';
import { OwnershipService } from '@/services/ownership.service';
@@ -19,14 +20,14 @@ export class Execute extends BaseCommand {
static examples = ['$ n8n execute --id=5', '$ n8n execute --file=workflow.json'];
static flags = {
help: flags.help({ char: 'h' }),
file: flags.string({
help: Flags.help({ char: 'h' }),
file: Flags.string({
description: 'path to a workflow file to execute',
}),
id: flags.string({
id: Flags.string({
description: 'id of the workflow to execute',
}),
rawOutput: flags.boolean({
rawOutput: Flags.boolean({
description: 'Outputs only JSON data, with no other text',
}),
};
@@ -38,8 +39,7 @@ export class Execute extends BaseCommand {
}
async run() {
// eslint-disable-next-line @typescript-eslint/no-shadow
const { flags } = this.parse(Execute);
const { flags } = await this.parse(Execute);
if (!flags.id && !flags.file) {
this.logger.info('Either option "--id" or "--file" have to be set!');

View File

@@ -1,7 +1,8 @@
/* eslint-disable @typescript-eslint/no-loop-func */
import { Container } from 'typedi';
import { Flags } from '@oclif/core';
import fs from 'fs';
import os from 'os';
import { flags } from '@oclif/command';
import type { IRun, ITaskData } from 'n8n-workflow';
import { ApplicationError, jsonParse, sleep } from 'n8n-workflow';
import { sep } from 'path';
@@ -12,9 +13,11 @@ import { ActiveExecutions } from '@/ActiveExecutions';
import { WorkflowRunner } from '@/WorkflowRunner';
import type { IWorkflowDb, IWorkflowExecutionDataProcess } from '@/Interfaces';
import type { User } from '@db/entities/User';
import { WorkflowRepository } from '@db/repositories/workflow.repository';
import { OwnershipService } from '@/services/ownership.service';
import { findCliWorkflowStart } from '@/utils';
import { BaseCommand } from './BaseCommand';
import { Container } from 'typedi';
import type {
IExecutionResult,
INodeSpecialCase,
@@ -22,8 +25,6 @@ import type {
IResult,
IWorkflowExecutionProgress,
} from '../types/commands.types';
import { WorkflowRepository } from '@db/repositories/workflow.repository';
import { OwnershipService } from '@/services/ownership.service';
const re = /\d+/;
@@ -60,49 +61,49 @@ export class ExecuteBatch extends BaseCommand {
];
static flags = {
help: flags.help({ char: 'h' }),
debug: flags.boolean({
help: Flags.help({ char: 'h' }),
debug: Flags.boolean({
description: 'Toggles on displaying all errors and debug messages.',
}),
ids: flags.string({
ids: Flags.string({
description:
'Specifies workflow IDs to get executed, separated by a comma or a file containing the ids',
}),
concurrency: flags.integer({
concurrency: Flags.integer({
default: 1,
description:
'How many workflows can run in parallel. Defaults to 1 which means no concurrency.',
}),
output: flags.string({
output: Flags.string({
description:
'Enable execution saving, You must inform an existing folder to save execution via this param',
}),
snapshot: flags.string({
snapshot: Flags.string({
description:
'Enables snapshot saving. You must inform an existing folder to save snapshots via this param.',
}),
compare: flags.string({
compare: Flags.string({
description:
'Compares current execution with an existing snapshot. You must inform an existing folder where the snapshots are saved.',
}),
shallow: flags.boolean({
shallow: Flags.boolean({
description:
'Compares only if attributes output from node are the same, with no regards to nested JSON objects.',
}),
githubWorkflow: flags.boolean({
githubWorkflow: Flags.boolean({
description:
'Enables more lenient comparison for GitHub workflows. This is useful for reducing false positives when comparing Test workflows.',
}),
skipList: flags.string({
skipList: Flags.string({
description: 'File containing a comma separated list of workflow IDs to skip.',
}),
retries: flags.integer({
retries: Flags.integer({
description: 'Retries failed workflows up to N tries. Default is 1. Set 0 to disable.',
default: 1,
}),
shortOutput: flags.boolean({
shortOutput: Flags.boolean({
description: 'Omits the full execution information from output, displaying only summary.',
}),
};
@@ -185,8 +186,7 @@ export class ExecuteBatch extends BaseCommand {
}
async run() {
// eslint-disable-next-line @typescript-eslint/no-shadow
const { flags } = this.parse(ExecuteBatch);
const { flags } = await this.parse(ExecuteBatch);
ExecuteBatch.debug = flags.debug;
ExecuteBatch.concurrency = flags.concurrency || 1;

View File

@@ -1,4 +1,4 @@
import { flags } from '@oclif/command';
import { Flags } from '@oclif/core';
import fs from 'fs';
import path from 'path';
import { Credentials } from 'n8n-core';
@@ -20,37 +20,36 @@ export class ExportCredentialsCommand extends BaseCommand {
];
static flags = {
help: flags.help({ char: 'h' }),
all: flags.boolean({
help: Flags.help({ char: 'h' }),
all: Flags.boolean({
description: 'Export all credentials',
}),
backup: flags.boolean({
backup: Flags.boolean({
description:
'Sets --all --pretty --separate for simple backups. Only --output has to be set additionally.',
}),
id: flags.string({
id: Flags.string({
description: 'The ID of the credential to export',
}),
output: flags.string({
output: Flags.string({
char: 'o',
description: 'Output file name or directory if using separate files',
}),
pretty: flags.boolean({
pretty: Flags.boolean({
description: 'Format the output in an easier to read fashion',
}),
separate: flags.boolean({
separate: Flags.boolean({
description:
'Exports one file per credential (useful for versioning). Must inform a directory via --output.',
}),
decrypted: flags.boolean({
decrypted: Flags.boolean({
description:
'Exports data decrypted / in plain text. ALL SENSITIVE INFORMATION WILL BE VISIBLE IN THE FILES. Use to migrate from a installation to another that have a different secret key (in the config file).',
}),
};
async run() {
// eslint-disable-next-line @typescript-eslint/no-shadow
const { flags } = this.parse(ExportCredentialsCommand);
const { flags } = await this.parse(ExportCredentialsCommand);
if (flags.backup) {
flags.all = true;

View File

@@ -1,4 +1,4 @@
import { flags } from '@oclif/command';
import { Flags } from '@oclif/core';
import fs from 'fs';
import path from 'path';
import { BaseCommand } from '../BaseCommand';
@@ -17,33 +17,32 @@ export class ExportWorkflowsCommand extends BaseCommand {
];
static flags = {
help: flags.help({ char: 'h' }),
all: flags.boolean({
help: Flags.help({ char: 'h' }),
all: Flags.boolean({
description: 'Export all workflows',
}),
backup: flags.boolean({
backup: Flags.boolean({
description:
'Sets --all --pretty --separate for simple backups. Only --output has to be set additionally.',
}),
id: flags.string({
id: Flags.string({
description: 'The ID of the workflow to export',
}),
output: flags.string({
output: Flags.string({
char: 'o',
description: 'Output file name or directory if using separate files',
}),
pretty: flags.boolean({
pretty: Flags.boolean({
description: 'Format the output in an easier to read fashion',
}),
separate: flags.boolean({
separate: Flags.boolean({
description:
'Exports one file per workflow (useful for versioning). Must inform a directory via --output.',
}),
};
async run() {
// eslint-disable-next-line @typescript-eslint/no-shadow
const { flags } = this.parse(ExportWorkflowsCommand);
const { flags } = await this.parse(ExportWorkflowsCommand);
if (flags.backup) {
flags.all = true;

View File

@@ -1,9 +1,10 @@
import { flags } from '@oclif/command';
import { Container } from 'typedi';
import { Flags } from '@oclif/core';
import { Cipher } from 'n8n-core';
import fs from 'fs';
import glob from 'fast-glob';
import { Container } from 'typedi';
import type { EntityManager } from 'typeorm';
import * as Db from '@/Db';
import type { User } from '@db/entities/User';
import { SharedCredentials } from '@db/entities/SharedCredentials';
@@ -28,15 +29,15 @@ export class ImportCredentialsCommand extends BaseCommand {
];
static flags = {
help: flags.help({ char: 'h' }),
input: flags.string({
help: Flags.help({ char: 'h' }),
input: Flags.string({
char: 'i',
description: 'Input file name or directory if --separate is used',
}),
separate: flags.boolean({
separate: Flags.boolean({
description: 'Imports *.json files from directory provided by --input',
}),
userId: flags.string({
userId: Flags.string({
description: 'The ID of the user to assign the imported credentials to',
}),
};
@@ -51,8 +52,7 @@ export class ImportCredentialsCommand extends BaseCommand {
}
async run(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-shadow
const { flags } = this.parse(ImportCredentialsCommand);
const { flags } = await this.parse(ImportCredentialsCommand);
if (!flags.input) {
this.logger.info('An input file or directory with --input must be provided');

View File

@@ -1,18 +1,19 @@
import { flags } from '@oclif/command';
import { Container } from 'typedi';
import { Flags } from '@oclif/core';
import { ApplicationError, jsonParse } from 'n8n-workflow';
import fs from 'fs';
import glob from 'fast-glob';
import { Container } from 'typedi';
import { UM_FIX_INSTRUCTION } from '@/constants';
import { WorkflowEntity } from '@db/entities/WorkflowEntity';
import { disableAutoGeneratedIds } from '@db/utils/commandHelpers';
import type { IWorkflowToImport } from '@/Interfaces';
import { BaseCommand } from '../BaseCommand';
import { generateNanoId } from '@db/utils/generators';
import { RoleService } from '@/services/role.service';
import { UM_FIX_INSTRUCTION } from '@/constants';
import { UserRepository } from '@db/repositories/user.repository';
import { WorkflowRepository } from '@db/repositories/workflow.repository';
import type { IWorkflowToImport } from '@/Interfaces';
import { RoleService } from '@/services/role.service';
import { ImportService } from '@/services/import.service';
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
import { BaseCommand } from '../BaseCommand';
function assertHasWorkflowsToImport(workflows: unknown): asserts workflows is IWorkflowToImport[] {
if (!Array.isArray(workflows)) {
@@ -43,15 +44,15 @@ export class ImportWorkflowsCommand extends BaseCommand {
];
static flags = {
help: flags.help({ char: 'h' }),
input: flags.string({
help: Flags.help({ char: 'h' }),
input: Flags.string({
char: 'i',
description: 'Input file name or directory if --separate is used',
}),
separate: flags.boolean({
separate: Flags.boolean({
description: 'Imports *.json files from directory provided by --input',
}),
userId: flags.string({
userId: Flags.string({
description: 'The ID of the user to assign the imported workflows to',
}),
};
@@ -62,8 +63,7 @@ export class ImportWorkflowsCommand extends BaseCommand {
}
async run(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-shadow
const { flags } = this.parse(ImportWorkflowsCommand);
const { flags } = await this.parse(ImportWorkflowsCommand);
if (!flags.input) {
this.logger.info('An input file or directory with --input must be provided');

View File

@@ -1,7 +1,7 @@
import { Container } from 'typedi';
import { SETTINGS_LICENSE_CERT_KEY } from '@/constants';
import { BaseCommand } from '../BaseCommand';
import { SettingsRepository } from '@db/repositories/settings.repository';
import Container from 'typedi';
export class ClearLicenseCommand extends BaseCommand {
static description = 'Clear license';

View File

@@ -1,5 +1,5 @@
import { License } from '@/License';
import { Container } from 'typedi';
import { License } from '@/License';
import { BaseCommand } from '../BaseCommand';
export class LicenseInfoCommand extends BaseCommand {

View File

@@ -1,7 +1,7 @@
import { flags } from '@oclif/command';
import { BaseCommand } from '../BaseCommand';
import { WorkflowRepository } from '@db/repositories/workflow.repository';
import Container from 'typedi';
import { Flags } from '@oclif/core';
import { WorkflowRepository } from '@db/repositories/workflow.repository';
import { BaseCommand } from '../BaseCommand';
export class ListWorkflowCommand extends BaseCommand {
static description = '\nList workflows';
@@ -13,18 +13,17 @@ export class ListWorkflowCommand extends BaseCommand {
];
static flags = {
help: flags.help({ char: 'h' }),
active: flags.string({
help: Flags.help({ char: 'h' }),
active: Flags.string({
description: 'Filters workflows by active status. Can be true or false',
}),
onlyId: flags.boolean({
onlyId: Flags.boolean({
description: 'Outputs workflow IDs only, one per line.',
}),
};
async run() {
// eslint-disable-next-line @typescript-eslint/no-shadow
const { flags } = this.parse(ListWorkflowCommand);
const { flags } = await this.parse(ListWorkflowCommand);
if (flags.active !== undefined && !['true', 'false'].includes(flags.active)) {
this.error('The --active flag has to be passed using true or false');

View File

@@ -1,7 +1,7 @@
import { flags } from '@oclif/command';
import { BaseCommand } from '../BaseCommand';
import Container from 'typedi';
import { Flags } from '@oclif/core';
import { UserRepository } from '@db/repositories/user.repository';
import { BaseCommand } from '../BaseCommand';
export class DisableMFACommand extends BaseCommand {
static description = 'Disable MFA authentication for a user';
@@ -9,8 +9,8 @@ export class DisableMFACommand extends BaseCommand {
static examples = ['$ n8n mfa:disable --email=johndoe@example.com'];
static flags = {
help: flags.help({ char: 'h' }),
email: flags.string({
help: Flags.help({ char: 'h' }),
email: Flags.string({
description: 'The email of the user to disable the MFA authentication',
}),
};
@@ -20,8 +20,7 @@ export class DisableMFACommand extends BaseCommand {
}
async run(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-shadow
const { flags } = this.parse(DisableMFACommand);
const { flags } = await this.parse(DisableMFACommand);
if (!flags.email) {
this.logger.info('An email with --email must be provided');

View File

@@ -1,27 +1,24 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { Container } from 'typedi';
import { Flags, type Config } from '@oclif/core';
import path from 'path';
import { mkdir } from 'fs/promises';
import { createReadStream, createWriteStream, existsSync } from 'fs';
import { flags } from '@oclif/command';
import stream from 'stream';
import replaceStream from 'replacestream';
import { promisify } from 'util';
import glob from 'fast-glob';
import { sleep, jsonParse } from 'n8n-workflow';
import config from '@/config';
import config from '@/config';
import { ActiveExecutions } from '@/ActiveExecutions';
import { ActiveWorkflowRunner } from '@/ActiveWorkflowRunner';
import { Server } from '@/Server';
import { EDITOR_UI_DIST_DIR, LICENSE_FEATURES } from '@/constants';
import { eventBus } from '@/eventbus';
import { BaseCommand } from './BaseCommand';
import { InternalHooks } from '@/InternalHooks';
import { License } from '@/License';
import type { IConfig } from '@oclif/config';
import { OrchestrationService } from '@/services/orchestration.service';
import { OrchestrationHandlerMainService } from '@/services/orchestration/main/orchestration.handler.main.service';
import { PruningService } from '@/services/pruning.service';
@@ -30,6 +27,7 @@ import { SettingsRepository } from '@db/repositories/settings.repository';
import { ExecutionRepository } from '@db/repositories/execution.repository';
import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error';
import { WaitTracker } from '@/WaitTracker';
import { BaseCommand } from './BaseCommand';
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
const open = require('open');
@@ -46,16 +44,16 @@ export class Start extends BaseCommand {
];
static flags = {
help: flags.help({ char: 'h' }),
open: flags.boolean({
help: Flags.help({ char: 'h' }),
open: Flags.boolean({
char: 'o',
description: 'opens the UI automatically in browser',
}),
tunnel: flags.boolean({
tunnel: Flags.boolean({
description:
'runs the webhooks via a hooks.n8n.cloud tunnel server. Use only for testing and development!',
}),
reinstallMissingPackages: flags.boolean({
reinstallMissingPackages: Flags.boolean({
description:
'Attempts to self heal n8n if packages with nodes are missing. Might drastically increase startup times.',
}),
@@ -67,7 +65,7 @@ export class Start extends BaseCommand {
private pruningService: PruningService;
constructor(argv: string[], cmdConfig: IConfig) {
constructor(argv: string[], cmdConfig: Config) {
super(argv, cmdConfig);
this.setInstanceType('main');
this.setInstanceQueueModeId();
@@ -260,8 +258,7 @@ export class Start extends BaseCommand {
}
async run() {
// eslint-disable-next-line @typescript-eslint/no-shadow
const { flags } = this.parse(Start);
const { flags } = await this.parse(Start);
// Load settings from database and set them to config.
const databaseSettings = await Container.get(SettingsRepository).findBy({

View File

@@ -1,7 +1,7 @@
import { flags } from '@oclif/command';
import { BaseCommand } from '../BaseCommand';
import { Container } from 'typedi';
import { Flags } from '@oclif/core';
import { WorkflowRepository } from '@db/repositories/workflow.repository';
import Container from 'typedi';
import { BaseCommand } from '../BaseCommand';
export class UpdateWorkflowCommand extends BaseCommand {
static description = 'Update workflows';
@@ -12,21 +12,20 @@ export class UpdateWorkflowCommand extends BaseCommand {
];
static flags = {
help: flags.help({ char: 'h' }),
active: flags.string({
help: Flags.help({ char: 'h' }),
active: Flags.string({
description: 'Active state the workflow/s should be set to',
}),
all: flags.boolean({
all: Flags.boolean({
description: 'Operate on all workflows',
}),
id: flags.string({
id: Flags.string({
description: 'The ID of the workflow to operate on',
}),
};
async run() {
// eslint-disable-next-line @typescript-eslint/no-shadow
const { flags } = this.parse(UpdateWorkflowCommand);
const { flags } = await this.parse(UpdateWorkflowCommand);
if (!flags.all && !flags.id) {
console.info('Either option "--all" or "--id" have to be set!');

View File

@@ -1,12 +1,13 @@
import { flags } from '@oclif/command';
import { Container } from 'typedi';
import { Flags, type Config } from '@oclif/core';
import { sleep } from 'n8n-workflow';
import config from '@/config';
import { ActiveExecutions } from '@/ActiveExecutions';
import { WebhookServer } from '@/WebhookServer';
import { Queue } from '@/Queue';
import { BaseCommand } from './BaseCommand';
import { Container } from 'typedi';
import type { IConfig } from '@oclif/config';
import { OrchestrationWebhookService } from '@/services/orchestration/webhook/orchestration.webhook.service';
import { OrchestrationHandlerWebhookService } from '@/services/orchestration/webhook/orchestration.handler.webhook.service';
@@ -16,12 +17,12 @@ export class Webhook extends BaseCommand {
static examples = ['$ n8n webhook'];
static flags = {
help: flags.help({ char: 'h' }),
help: Flags.help({ char: 'h' }),
};
protected server = Container.get(WebhookServer);
constructor(argv: string[], cmdConfig: IConfig) {
constructor(argv: string[], cmdConfig: Config) {
super(argv, cmdConfig);
this.setInstanceType('webhook');
if (this.queueModeId) {

View File

@@ -1,11 +1,9 @@
import { Container } from 'typedi';
import { Flags, type Config } from '@oclif/core';
import express from 'express';
import http from 'http';
import type PCancelable from 'p-cancelable';
import { Container } from 'typedi';
import { flags } from '@oclif/command';
import { WorkflowExecute } from 'n8n-core';
import type {
ExecutionError,
ExecutionStatus,
@@ -20,13 +18,11 @@ import * as ResponseHelper from '@/ResponseHelper';
import * as WebhookHelpers from '@/WebhookHelpers';
import * as WorkflowExecuteAdditionalData from '@/WorkflowExecuteAdditionalData';
import { PermissionChecker } from '@/UserManagement/PermissionChecker';
import config from '@/config';
import type { Job, JobId, JobResponse, WebhookResponse } from '@/Queue';
import { Queue } from '@/Queue';
import { generateFailedExecutionFromError } from '@/WorkflowHelpers';
import { N8N_VERSION } from '@/constants';
import { BaseCommand } from './BaseCommand';
import { ExecutionRepository } from '@db/repositories/execution.repository';
import { WorkflowRepository } from '@db/repositories/workflow.repository';
import { OwnershipService } from '@/services/ownership.service';
@@ -36,11 +32,11 @@ import { rawBodyReader, bodyParser } from '@/middlewares';
import { eventBus } from '@/eventbus';
import type { RedisServicePubSubSubscriber } from '@/services/redis/RedisServicePubSubSubscriber';
import { EventMessageGeneric } from '@/eventbus/EventMessageClasses/EventMessageGeneric';
import type { IConfig } from '@oclif/config';
import { OrchestrationHandlerWorkerService } from '@/services/orchestration/worker/orchestration.handler.worker.service';
import { OrchestrationWorkerService } from '@/services/orchestration/worker/orchestration.worker.service';
import type { WorkerJobStatusSummary } from '../services/orchestration/worker/types';
import type { WorkerJobStatusSummary } from '@/services/orchestration/worker/types';
import { ServiceUnavailableError } from '@/errors/response-errors/service-unavailable.error';
import { BaseCommand } from './BaseCommand';
export class Worker extends BaseCommand {
static description = '\nStarts a n8n worker';
@@ -48,8 +44,8 @@ export class Worker extends BaseCommand {
static examples = ['$ n8n worker --concurrency=5'];
static flags = {
help: flags.help({ char: 'h' }),
concurrency: flags.integer({
help: Flags.help({ char: 'h' }),
concurrency: Flags.integer({
default: 10,
description: 'How many jobs can run in parallel.',
}),
@@ -257,7 +253,7 @@ export class Worker extends BaseCommand {
};
}
constructor(argv: string[], cmdConfig: IConfig) {
constructor(argv: string[], cmdConfig: Config) {
super(argv, cmdConfig);
if (!process.env.N8N_ENCRYPTION_KEY) {
@@ -333,8 +329,7 @@ export class Worker extends BaseCommand {
}
async initQueue() {
// eslint-disable-next-line @typescript-eslint/no-shadow
const { flags } = this.parse(Worker);
const { flags } = await this.parse(Worker);
const redisConnectionTimeoutLimit = config.getEnv('queue.bull.redis.timeoutThreshold');
@@ -495,8 +490,7 @@ export class Worker extends BaseCommand {
}
async run() {
// eslint-disable-next-line @typescript-eslint/no-shadow
const { flags } = this.parse(Worker);
const { flags } = await this.parse(Worker);
this.logger.info('\nn8n worker is now ready');
this.logger.info(` * Version: ${N8N_VERSION}`);