From c21c8b33691c4c5b010e741abd78ca5ff2e56526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Tue, 22 Jun 2021 23:18:52 +0200 Subject: [PATCH] :zap: Simplify config imports in cli package (#1840) * :zap: Set path alias for config * :zap: Update config export * :zap: Simplify config imports * :zap: Update also additional imports * :zap: Update path in collation migration * :zap: Resolve aliased paths * :shirt: Fix Codacy issue * :shirt: Retry to fix Codacy issue Co-authored-by: Jan Co-authored-by: Jan Oberhauser --- packages/cli/bin/n8n | 3 +- packages/cli/commands/start.ts | 4 +- packages/cli/commands/webhook.ts | 4 +- packages/cli/commands/worker.ts | 4 +- packages/cli/config/index.ts | 3 +- packages/cli/package.json | 4 + packages/cli/src/Db.ts | 2 +- packages/cli/src/ExternalHooks.ts | 2 +- packages/cli/src/GenericHelpers.ts | 2 +- packages/cli/src/LoadNodesAndCredentials.ts | 2 +- packages/cli/src/Logger.ts | 2 +- packages/cli/src/Queue.ts | 18 ++-- packages/cli/src/Server.ts | 2 +- packages/cli/src/WebhookServer.ts | 88 +++++++++---------- .../cli/src/WorkflowExecuteAdditionalData.ts | 2 +- packages/cli/src/WorkflowHelpers.ts | 2 +- packages/cli/src/WorkflowRunner.ts | 2 +- packages/cli/src/WorkflowRunnerProcess.ts | 2 +- .../1588157391238-InitialMigration.ts | 2 +- .../migrations/1592447867632-WebhookModel.ts | 2 +- .../1594902918301-CreateIndexStoppedAt.ts | 2 +- .../1607431743767-MakeStoppedAtNullable.ts | 2 +- .../migrations/1611149998770-AddWebhookId.ts | 2 +- .../1615306975123-ChangeDataSize.ts | 2 +- .../1617268711084-CreateTagEntity.ts | 2 +- .../1620729500000-ChangeCredentialDataSize.ts | 2 +- .../1620826335440-UniqueWorkflowNames.ts | 2 +- .../1623936588000-CertifyCorrectCollation.ts | 2 +- .../1587669153312-InitialMigration.ts | 2 +- .../migrations/1589476000887-WebhookModel.ts | 2 +- .../1594828256133-CreateIndexStoppedAt.ts | 2 +- .../1607431743768-MakeStoppedAtNullable.ts | 2 +- .../migrations/1611144599516-AddWebhookId.ts | 2 +- .../1617270242566-CreateTagEntity.ts | 2 +- .../1620824779533-UniqueWorkflowNames.ts | 2 +- .../1588102412422-InitialMigration.ts | 2 +- .../migrations/1592445003908-WebhookModel.ts | 2 +- .../1594825041918-CreateIndexStoppedAt.ts | 2 +- .../1607431743769-MakeStoppedAtNullable.ts | 2 +- .../migrations/1611071044839-AddWebhookId.ts | 2 +- .../1617213344594-CreateTagEntity.ts | 2 +- .../1620821879465-UniqueWorkflowNames.ts | 2 +- packages/cli/tsconfig.json | 8 +- 43 files changed, 107 insertions(+), 97 deletions(-) diff --git a/packages/cli/bin/n8n b/packages/cli/bin/n8n index b72c643fb3..3cc5be4f6c 100755 --- a/packages/cli/bin/n8n +++ b/packages/cli/bin/n8n @@ -1,6 +1,7 @@ #!/usr/bin/env node - +var alias = require('module-alias'); var path = require('path'); // tslint:disable-line:no-var-keyword +alias(path.resolve(__dirname, "../")); // Make sure that it also find the config folder when it // did get started from another folder that the root one. diff --git a/packages/cli/commands/start.ts b/packages/cli/commands/start.ts index 023e3e827f..69b71ca483 100644 --- a/packages/cli/commands/start.ts +++ b/packages/cli/commands/start.ts @@ -7,7 +7,7 @@ import { Command, flags } from '@oclif/command'; const open = require('open'); import * as Redis from 'ioredis'; -import * as config from '../config'; +import { config } from '@config'; import { ActiveExecutions, ActiveWorkflowRunner, @@ -25,7 +25,7 @@ import { } from '../src'; import { IDataObject } from 'n8n-workflow'; -import { +import { getLogger, } from '../src/Logger'; diff --git a/packages/cli/commands/webhook.ts b/packages/cli/commands/webhook.ts index e1acc94874..7f3019575e 100644 --- a/packages/cli/commands/webhook.ts +++ b/packages/cli/commands/webhook.ts @@ -4,7 +4,7 @@ import { import { Command, flags } from '@oclif/command'; import * as Redis from 'ioredis'; -import * as config from '../config'; +import { config } from '@config'; import { ActiveExecutions, ActiveWorkflowRunner, @@ -20,7 +20,7 @@ import { } from '../src'; import { IDataObject } from 'n8n-workflow'; -import { +import { getLogger, } from '../src/Logger'; diff --git a/packages/cli/commands/worker.ts b/packages/cli/commands/worker.ts index 56da5d9c98..5974934718 100644 --- a/packages/cli/commands/worker.ts +++ b/packages/cli/commands/worker.ts @@ -37,7 +37,7 @@ import { WorkflowExecuteAdditionalData, } from '../src'; -import { +import { getLogger, } from '../src/Logger'; @@ -45,7 +45,7 @@ import { LoggerProxy, } from 'n8n-workflow'; -import * as config from '../config'; +import { config } from '@config'; import * as Bull from 'bull'; import * as Queue from '../src/Queue'; diff --git a/packages/cli/config/index.ts b/packages/cli/config/index.ts index 0da11e786a..8aef25f0fe 100644 --- a/packages/cli/config/index.ts +++ b/packages/cli/config/index.ts @@ -5,7 +5,7 @@ import * as core from 'n8n-core'; dotenv.config(); -const config = convict({ +export const config = convict({ database: { type: { @@ -633,4 +633,3 @@ config.validate({ allowed: 'strict', }); -export = config; diff --git a/packages/cli/package.json b/packages/cli/package.json index e4a23302ad..13523c82c9 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -105,6 +105,7 @@ "jwks-rsa": "~1.12.1", "localtunnel": "^2.0.0", "lodash.get": "^4.4.2", + "module-alias": "^2.2.2", "mysql2": "~2.2.0", "n8n-core": "~0.75.0", "n8n-editor-ui": "~0.95.0", @@ -121,6 +122,9 @@ "typeorm": "^0.2.30", "winston": "^3.3.3" }, + "_moduleAliases": { + "@config": "./dist/config/index.js" + }, "jest": { "transform": { "^.+\\.tsx?$": "ts-jest" diff --git a/packages/cli/src/Db.ts b/packages/cli/src/Db.ts index c91c872693..5d548c63d5 100644 --- a/packages/cli/src/Db.ts +++ b/packages/cli/src/Db.ts @@ -16,7 +16,7 @@ import { import { TlsOptions } from 'tls'; -import * as config from '../config'; +import { config } from '@config'; import { entities } from './databases/entities'; diff --git a/packages/cli/src/ExternalHooks.ts b/packages/cli/src/ExternalHooks.ts index aa14662a60..39f2201686 100644 --- a/packages/cli/src/ExternalHooks.ts +++ b/packages/cli/src/ExternalHooks.ts @@ -5,7 +5,7 @@ import { IExternalHooksFunctions, } from './'; -import * as config from '../config'; +import { config } from '@config'; class ExternalHooksClass implements IExternalHooksClass { diff --git a/packages/cli/src/GenericHelpers.ts b/packages/cli/src/GenericHelpers.ts index d6da9e87da..89e5cdaa0f 100644 --- a/packages/cli/src/GenericHelpers.ts +++ b/packages/cli/src/GenericHelpers.ts @@ -1,4 +1,4 @@ -import * as config from '../config'; +import { config } from '@config'; import * as express from 'express'; import { join as pathJoin } from 'path'; import { readFile as fsReadFile } from 'fs/promises'; diff --git a/packages/cli/src/LoadNodesAndCredentials.ts b/packages/cli/src/LoadNodesAndCredentials.ts index 777fa0bb00..637f016f1c 100644 --- a/packages/cli/src/LoadNodesAndCredentials.ts +++ b/packages/cli/src/LoadNodesAndCredentials.ts @@ -11,7 +11,7 @@ import { LoggerProxy, } from 'n8n-workflow'; -import * as config from '../config'; +import { config } from '@config'; import { getLogger, diff --git a/packages/cli/src/Logger.ts b/packages/cli/src/Logger.ts index 3bbc61e6a9..b70be03596 100644 --- a/packages/cli/src/Logger.ts +++ b/packages/cli/src/Logger.ts @@ -1,4 +1,4 @@ -import config = require('../config'); +import { config } from '@config'; import * as winston from 'winston'; import { diff --git a/packages/cli/src/Queue.ts b/packages/cli/src/Queue.ts index 1b85fe4bc4..b2d7cf4788 100644 --- a/packages/cli/src/Queue.ts +++ b/packages/cli/src/Queue.ts @@ -1,14 +1,14 @@ import * as Bull from 'bull'; -import * as config from '../config'; +import { config } from '@config'; import { IBullJobData } from './Interfaces'; export class Queue { private jobQueue: Bull.Queue; - + constructor() { const prefix = config.get('queue.bull.prefix') as string; const redisOptions = config.get('queue.bull.redis') as object; - // Disabling ready check is necessary as it allows worker to + // Disabling ready check is necessary as it allows worker to // quickly reconnect to Redis if Redis crashes or is unreachable // for some time. With it enabled, worker might take minutes to realize // redis is back up and resume working. @@ -16,25 +16,25 @@ export class Queue { // @ts-ignore this.jobQueue = new Bull('jobs', { prefix, redis: redisOptions, enableReadyCheck: false }); } - + async add(jobData: IBullJobData, jobOptions: object): Promise { return await this.jobQueue.add(jobData,jobOptions); } - + async getJob(jobId: Bull.JobId): Promise { return await this.jobQueue.getJob(jobId); } - + async getJobs(jobTypes: Bull.JobStatus[]): Promise { return await this.jobQueue.getJobs(jobTypes); } - + getBullObjectInstance(): Bull.Queue { return this.jobQueue; } /** - * + * * @param job A Bull.Job instance * @returns boolean true if we were able to securely stop the job */ @@ -62,6 +62,6 @@ export function getInstance(): Queue { if (activeQueueInstance === undefined) { activeQueueInstance = new Queue(); } - + return activeQueueInstance; } diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 0a31144999..5566dd8657 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -101,7 +101,7 @@ import { import * as basicAuth from 'basic-auth'; import * as compression from 'compression'; -import * as config from '../config'; +import { config } from '@config'; import * as jwt from 'jsonwebtoken'; import * as jwks from 'jwks-rsa'; // @ts-ignore diff --git a/packages/cli/src/WebhookServer.ts b/packages/cli/src/WebhookServer.ts index becfb71af7..c49e1803a8 100644 --- a/packages/cli/src/WebhookServer.ts +++ b/packages/cli/src/WebhookServer.ts @@ -22,7 +22,7 @@ import { } from './'; import * as compression from 'compression'; -import * as config from '../config'; +import { config } from '@config'; import * as parseUrl from 'parseurl'; export function registerProductionWebhooks() { @@ -111,7 +111,7 @@ export function registerProductionWebhooks() { } class App { - + app: express.Application; activeWorkflowRunner: ActiveWorkflowRunner.ActiveWorkflowRunner; endpointWebhook: string; @@ -129,12 +129,12 @@ class App { protocol: string; sslKey: string; sslCert: string; - + presetCredentialsLoaded: boolean; - + constructor() { this.app = express(); - + this.endpointWebhook = config.get('endpoints.webhook') as string; this.saveDataErrorExecution = config.get('executions.saveDataOnError') as string; this.saveDataSuccessExecution = config.get('executions.saveDataOnSuccess') as string; @@ -143,22 +143,22 @@ class App { this.maxExecutionTimeout = config.get('executions.maxTimeout') as number; this.timezone = config.get('generic.timezone') as string; this.restEndpoint = config.get('endpoints.rest') as string; - + this.activeWorkflowRunner = ActiveWorkflowRunner.getInstance(); - + this.activeExecutionsInstance = ActiveExecutions.getInstance(); - + this.protocol = config.get('protocol'); this.sslKey = config.get('ssl_key'); this.sslCert = config.get('ssl_cert'); - + this.externalHooks = ExternalHooks(); - + this.presetCredentialsLoaded = false; this.endpointPresetCredentials = config.get('credentials.overwrite.endpoint') as string; } - - + + /** * Returns the current epoch time * @@ -168,15 +168,15 @@ class App { getCurrentDate(): Date { return new Date(); } - - + + async config(): Promise { - + this.versions = await GenericHelpers.getVersions(); - + // Compress the response data this.app.use(compression()); - + // Make sure that each request has the "parsedUrl" parameter this.app.use((req: express.Request, res: express.Response, next: express.NextFunction) => { (req as ICustomRequest).parsedUrl = parseUrl(req); @@ -184,7 +184,7 @@ class App { req.rawBody = Buffer.from('', 'base64'); next(); }); - + // Support application/json type post data this.app.use(bodyParser.json({ limit: '16mb', verify: (req, res, buf) => { @@ -192,7 +192,7 @@ class App { req.rawBody = buf; }, })); - + // Support application/xml type post data // @ts-ignore this.app.use(bodyParser.xml({ @@ -202,14 +202,14 @@ class App { explicitArray: false, // Only put properties in array if length > 1 }, })); - + this.app.use(bodyParser.text({ limit: '16mb', verify: (req, res, buf) => { // @ts-ignore req.rawBody = buf; }, })); - + //support application/x-www-form-urlencoded post data this.app.use(bodyParser.urlencoded({ extended: false, verify: (req, res, buf) => { @@ -217,7 +217,7 @@ class App { req.rawBody = buf; }, })); - + if (process.env['NODE_ENV'] !== 'production') { this.app.use((req: express.Request, res: express.Response, next: express.NextFunction) => { // Allow access also from frontend when developing @@ -227,64 +227,64 @@ class App { next(); }); } - - + + this.app.use((req: express.Request, res: express.Response, next: express.NextFunction) => { if (Db.collections.Workflow === null) { const error = new ResponseHelper.ResponseError('Database is not ready!', undefined, 503); return ResponseHelper.sendErrorResponse(res, error); } - + next(); }); - - - + + + // ---------------------------------------- // Healthcheck // ---------------------------------------- - - + + // Does very basic health check this.app.get('/healthz', async (req: express.Request, res: express.Response) => { - + const connectionManager = getConnectionManager(); - + if (connectionManager.connections.length === 0) { const error = new ResponseHelper.ResponseError('No Database connection found!', undefined, 503); return ResponseHelper.sendErrorResponse(res, error); } - + if (connectionManager.connections[0].isConnected === false) { // Connection is not active const error = new ResponseHelper.ResponseError('Database connection not active!', undefined, 503); return ResponseHelper.sendErrorResponse(res, error); } - + // Everything fine const responseData = { status: 'ok', }; - + ResponseHelper.sendSuccessResponse(res, responseData, true, 200); }); - + registerProductionWebhooks.apply(this); - + } - + } export async function start(): Promise { const PORT = config.get('port'); const ADDRESS = config.get('listen_address'); - + const app = new App(); - + await app.config(); - + let server; - + if (app.protocol === 'https' && app.sslKey && app.sslCert) { const https = require('https'); const privateKey = readFileSync(app.sslKey, 'utf8'); @@ -295,12 +295,12 @@ export async function start(): Promise { const http = require('http'); server = http.createServer(app.app); } - + server.listen(PORT, ADDRESS, async () => { const versions = await GenericHelpers.getVersions(); console.log(`n8n ready on ${ADDRESS}, port ${PORT}`); console.log(`Version: ${versions.cli}`); - + await app.externalHooks.run('n8n.ready', [app]); }); } diff --git a/packages/cli/src/WorkflowExecuteAdditionalData.ts b/packages/cli/src/WorkflowExecuteAdditionalData.ts index 9d0478d997..e6eafd4c2c 100644 --- a/packages/cli/src/WorkflowExecuteAdditionalData.ts +++ b/packages/cli/src/WorkflowExecuteAdditionalData.ts @@ -43,7 +43,7 @@ import { WorkflowHooks, } from 'n8n-workflow'; -import * as config from '../config'; +import { config } from '@config'; import { LessThanOrEqual } from 'typeorm'; diff --git a/packages/cli/src/WorkflowHelpers.ts b/packages/cli/src/WorkflowHelpers.ts index 68718dc4cf..61be6d744c 100644 --- a/packages/cli/src/WorkflowHelpers.ts +++ b/packages/cli/src/WorkflowHelpers.ts @@ -22,7 +22,7 @@ import { LoggerProxy as Logger, Workflow,} from 'n8n-workflow'; -import * as config from '../config'; +import { config } from '@config'; import { WorkflowEntity } from './databases/entities/WorkflowEntity'; import { validate } from 'class-validator'; diff --git a/packages/cli/src/WorkflowRunner.ts b/packages/cli/src/WorkflowRunner.ts index 56031d5a77..352cf9a209 100644 --- a/packages/cli/src/WorkflowRunner.ts +++ b/packages/cli/src/WorkflowRunner.ts @@ -36,7 +36,7 @@ import { WorkflowOperationError, } from 'n8n-workflow'; -import * as config from '../config'; +import { config } from '@config'; import * as PCancelable from 'p-cancelable'; import { join as pathJoin } from 'path'; import { fork } from 'child_process'; diff --git a/packages/cli/src/WorkflowRunnerProcess.ts b/packages/cli/src/WorkflowRunnerProcess.ts index 3dbc77cf6c..7f03fe221d 100644 --- a/packages/cli/src/WorkflowRunnerProcess.ts +++ b/packages/cli/src/WorkflowRunnerProcess.ts @@ -38,7 +38,7 @@ import { getLogger, } from '../src/Logger'; -import * as config from '../config'; +import { config } from '@config'; export class WorkflowRunnerProcess { data: IWorkflowExecutionDataProcessWithExecution | undefined; diff --git a/packages/cli/src/databases/mysqldb/migrations/1588157391238-InitialMigration.ts b/packages/cli/src/databases/mysqldb/migrations/1588157391238-InitialMigration.ts index 1d1d4d8cc5..8125fb43d5 100644 --- a/packages/cli/src/databases/mysqldb/migrations/1588157391238-InitialMigration.ts +++ b/packages/cli/src/databases/mysqldb/migrations/1588157391238-InitialMigration.ts @@ -1,6 +1,6 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import * as config from '../../../../config'; +import { config } from '@config'; export class InitialMigration1588157391238 implements MigrationInterface { name = 'InitialMigration1588157391238'; diff --git a/packages/cli/src/databases/mysqldb/migrations/1592447867632-WebhookModel.ts b/packages/cli/src/databases/mysqldb/migrations/1592447867632-WebhookModel.ts index 13969d72ef..0054ece048 100644 --- a/packages/cli/src/databases/mysqldb/migrations/1592447867632-WebhookModel.ts +++ b/packages/cli/src/databases/mysqldb/migrations/1592447867632-WebhookModel.ts @@ -3,7 +3,7 @@ import { QueryRunner, } from 'typeorm'; -import * as config from '../../../../config'; +import { config } from '@config'; export class WebhookModel1592447867632 implements MigrationInterface { name = 'WebhookModel1592447867632'; diff --git a/packages/cli/src/databases/mysqldb/migrations/1594902918301-CreateIndexStoppedAt.ts b/packages/cli/src/databases/mysqldb/migrations/1594902918301-CreateIndexStoppedAt.ts index 24556ea6bd..2527374eb2 100644 --- a/packages/cli/src/databases/mysqldb/migrations/1594902918301-CreateIndexStoppedAt.ts +++ b/packages/cli/src/databases/mysqldb/migrations/1594902918301-CreateIndexStoppedAt.ts @@ -1,6 +1,6 @@ import { MigrationInterface, QueryRunner } from "typeorm"; -import * as config from '../../../../config'; +import { config } from '@config'; export class CreateIndexStoppedAt1594902918301 implements MigrationInterface { name = 'CreateIndexStoppedAt1594902918301'; diff --git a/packages/cli/src/databases/mysqldb/migrations/1607431743767-MakeStoppedAtNullable.ts b/packages/cli/src/databases/mysqldb/migrations/1607431743767-MakeStoppedAtNullable.ts index dd261b6620..d6d3e5d710 100644 --- a/packages/cli/src/databases/mysqldb/migrations/1607431743767-MakeStoppedAtNullable.ts +++ b/packages/cli/src/databases/mysqldb/migrations/1607431743767-MakeStoppedAtNullable.ts @@ -1,6 +1,6 @@ import { MigrationInterface, QueryRunner } from "typeorm"; -import * as config from '../../../../config'; +import { config } from '@config'; export class MakeStoppedAtNullable1607431743767 implements MigrationInterface { diff --git a/packages/cli/src/databases/mysqldb/migrations/1611149998770-AddWebhookId.ts b/packages/cli/src/databases/mysqldb/migrations/1611149998770-AddWebhookId.ts index 7eb1e7aee7..4df194a8ed 100644 --- a/packages/cli/src/databases/mysqldb/migrations/1611149998770-AddWebhookId.ts +++ b/packages/cli/src/databases/mysqldb/migrations/1611149998770-AddWebhookId.ts @@ -1,5 +1,5 @@ import {MigrationInterface, QueryRunner} from "typeorm"; -import * as config from '../../../../config'; +import { config } from '@config'; export class AddWebhookId1611149998770 implements MigrationInterface { name = 'AddWebhookId1611149998770'; diff --git a/packages/cli/src/databases/mysqldb/migrations/1615306975123-ChangeDataSize.ts b/packages/cli/src/databases/mysqldb/migrations/1615306975123-ChangeDataSize.ts index 793b178ef3..a8bb2a54f6 100644 --- a/packages/cli/src/databases/mysqldb/migrations/1615306975123-ChangeDataSize.ts +++ b/packages/cli/src/databases/mysqldb/migrations/1615306975123-ChangeDataSize.ts @@ -1,5 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import * as config from '../../../../config'; +import { config } from '@config'; export class ChangeDataSize1615306975123 implements MigrationInterface { name = 'ChangeDataSize1615306975123'; diff --git a/packages/cli/src/databases/mysqldb/migrations/1617268711084-CreateTagEntity.ts b/packages/cli/src/databases/mysqldb/migrations/1617268711084-CreateTagEntity.ts index cd2ec52c5b..615100fcbe 100644 --- a/packages/cli/src/databases/mysqldb/migrations/1617268711084-CreateTagEntity.ts +++ b/packages/cli/src/databases/mysqldb/migrations/1617268711084-CreateTagEntity.ts @@ -1,5 +1,5 @@ import {MigrationInterface, QueryRunner} from "typeorm"; -import * as config from '../../../../config'; +import { config } from '@config'; export class CreateTagEntity1617268711084 implements MigrationInterface { name = 'CreateTagEntity1617268711084'; diff --git a/packages/cli/src/databases/mysqldb/migrations/1620729500000-ChangeCredentialDataSize.ts b/packages/cli/src/databases/mysqldb/migrations/1620729500000-ChangeCredentialDataSize.ts index ea1bd42049..1ecfc0a2ca 100644 --- a/packages/cli/src/databases/mysqldb/migrations/1620729500000-ChangeCredentialDataSize.ts +++ b/packages/cli/src/databases/mysqldb/migrations/1620729500000-ChangeCredentialDataSize.ts @@ -1,5 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import * as config from '../../../../config'; +import { config } from '@config'; export class ChangeCredentialDataSize1620729500000 implements MigrationInterface { name = 'ChangeCredentialDataSize1620729500000'; diff --git a/packages/cli/src/databases/mysqldb/migrations/1620826335440-UniqueWorkflowNames.ts b/packages/cli/src/databases/mysqldb/migrations/1620826335440-UniqueWorkflowNames.ts index 3dcf379028..d05dfef3d2 100644 --- a/packages/cli/src/databases/mysqldb/migrations/1620826335440-UniqueWorkflowNames.ts +++ b/packages/cli/src/databases/mysqldb/migrations/1620826335440-UniqueWorkflowNames.ts @@ -1,5 +1,5 @@ import {MigrationInterface, QueryRunner} from "typeorm"; -import config = require("../../../../config"); +import { config } from '@config'; export class UniqueWorkflowNames1620826335440 implements MigrationInterface { name = 'UniqueWorkflowNames1620826335440'; diff --git a/packages/cli/src/databases/mysqldb/migrations/1623936588000-CertifyCorrectCollation.ts b/packages/cli/src/databases/mysqldb/migrations/1623936588000-CertifyCorrectCollation.ts index 079cd9cc70..08961e92c1 100644 --- a/packages/cli/src/databases/mysqldb/migrations/1623936588000-CertifyCorrectCollation.ts +++ b/packages/cli/src/databases/mysqldb/migrations/1623936588000-CertifyCorrectCollation.ts @@ -1,5 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import config = require('../../../../config'); +import { config } from '@config'; export class CertifyCorrectCollation1623936588000 implements MigrationInterface { name = 'CertifyCorrectCollation1623936588000'; diff --git a/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts b/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts index eace7a92fb..eb337a36cc 100644 --- a/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts +++ b/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts @@ -1,7 +1,7 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import * as config from '../../../../config'; +import { config } from '@config'; export class InitialMigration1587669153312 implements MigrationInterface { name = 'InitialMigration1587669153312'; diff --git a/packages/cli/src/databases/postgresdb/migrations/1589476000887-WebhookModel.ts b/packages/cli/src/databases/postgresdb/migrations/1589476000887-WebhookModel.ts index cbc0de279d..b38dbc876e 100644 --- a/packages/cli/src/databases/postgresdb/migrations/1589476000887-WebhookModel.ts +++ b/packages/cli/src/databases/postgresdb/migrations/1589476000887-WebhookModel.ts @@ -3,7 +3,7 @@ import { QueryRunner, } from 'typeorm'; -import * as config from '../../../../config'; +import { config } from '@config'; export class WebhookModel1589476000887 implements MigrationInterface { name = 'WebhookModel1589476000887'; diff --git a/packages/cli/src/databases/postgresdb/migrations/1594828256133-CreateIndexStoppedAt.ts b/packages/cli/src/databases/postgresdb/migrations/1594828256133-CreateIndexStoppedAt.ts index 664834082e..c560e0e326 100644 --- a/packages/cli/src/databases/postgresdb/migrations/1594828256133-CreateIndexStoppedAt.ts +++ b/packages/cli/src/databases/postgresdb/migrations/1594828256133-CreateIndexStoppedAt.ts @@ -1,6 +1,6 @@ import { MigrationInterface, QueryRunner } from "typeorm"; -import * as config from '../../../../config'; +import { config } from '@config'; export class CreateIndexStoppedAt1594828256133 implements MigrationInterface { name = 'CreateIndexStoppedAt1594828256133'; diff --git a/packages/cli/src/databases/postgresdb/migrations/1607431743768-MakeStoppedAtNullable.ts b/packages/cli/src/databases/postgresdb/migrations/1607431743768-MakeStoppedAtNullable.ts index 5f0a05c02c..8dc4c78dba 100644 --- a/packages/cli/src/databases/postgresdb/migrations/1607431743768-MakeStoppedAtNullable.ts +++ b/packages/cli/src/databases/postgresdb/migrations/1607431743768-MakeStoppedAtNullable.ts @@ -1,6 +1,6 @@ import {MigrationInterface, QueryRunner} from "typeorm"; -import * as config from '../../../../config'; +import { config } from '@config'; export class MakeStoppedAtNullable1607431743768 implements MigrationInterface { name = 'MakeStoppedAtNullable1607431743768'; diff --git a/packages/cli/src/databases/postgresdb/migrations/1611144599516-AddWebhookId.ts b/packages/cli/src/databases/postgresdb/migrations/1611144599516-AddWebhookId.ts index b6f4d1a684..8bf811a9a4 100644 --- a/packages/cli/src/databases/postgresdb/migrations/1611144599516-AddWebhookId.ts +++ b/packages/cli/src/databases/postgresdb/migrations/1611144599516-AddWebhookId.ts @@ -1,5 +1,5 @@ import {MigrationInterface, QueryRunner} from "typeorm"; -import * as config from '../../../../config'; +import { config } from '@config'; export class AddWebhookId1611144599516 implements MigrationInterface { name = 'AddWebhookId1611144599516'; diff --git a/packages/cli/src/databases/postgresdb/migrations/1617270242566-CreateTagEntity.ts b/packages/cli/src/databases/postgresdb/migrations/1617270242566-CreateTagEntity.ts index 7ccdcd3181..3fc8216fb6 100644 --- a/packages/cli/src/databases/postgresdb/migrations/1617270242566-CreateTagEntity.ts +++ b/packages/cli/src/databases/postgresdb/migrations/1617270242566-CreateTagEntity.ts @@ -1,5 +1,5 @@ import {MigrationInterface, QueryRunner} from "typeorm"; -import * as config from '../../../../config'; +import { config } from '@config'; export class CreateTagEntity1617270242566 implements MigrationInterface { name = 'CreateTagEntity1617270242566'; diff --git a/packages/cli/src/databases/postgresdb/migrations/1620824779533-UniqueWorkflowNames.ts b/packages/cli/src/databases/postgresdb/migrations/1620824779533-UniqueWorkflowNames.ts index ab6adb2995..bfd2ea324f 100644 --- a/packages/cli/src/databases/postgresdb/migrations/1620824779533-UniqueWorkflowNames.ts +++ b/packages/cli/src/databases/postgresdb/migrations/1620824779533-UniqueWorkflowNames.ts @@ -1,5 +1,5 @@ import {MigrationInterface, QueryRunner} from "typeorm"; -import config = require("../../../../config"); +import { config } from '@config'; export class UniqueWorkflowNames1620824779533 implements MigrationInterface { name = 'UniqueWorkflowNames1620824779533'; diff --git a/packages/cli/src/databases/sqlite/migrations/1588102412422-InitialMigration.ts b/packages/cli/src/databases/sqlite/migrations/1588102412422-InitialMigration.ts index 09a0da911a..fd5f51239a 100644 --- a/packages/cli/src/databases/sqlite/migrations/1588102412422-InitialMigration.ts +++ b/packages/cli/src/databases/sqlite/migrations/1588102412422-InitialMigration.ts @@ -3,7 +3,7 @@ import { QueryRunner, } from 'typeorm'; -import * as config from '../../../../config'; +import { config } from '@config'; export class InitialMigration1588102412422 implements MigrationInterface { name = 'InitialMigration1588102412422'; diff --git a/packages/cli/src/databases/sqlite/migrations/1592445003908-WebhookModel.ts b/packages/cli/src/databases/sqlite/migrations/1592445003908-WebhookModel.ts index b011061e28..b956751834 100644 --- a/packages/cli/src/databases/sqlite/migrations/1592445003908-WebhookModel.ts +++ b/packages/cli/src/databases/sqlite/migrations/1592445003908-WebhookModel.ts @@ -3,7 +3,7 @@ import { QueryRunner, } from 'typeorm'; -import * as config from '../../../../config'; +import { config } from '@config'; export class WebhookModel1592445003908 implements MigrationInterface { name = 'WebhookModel1592445003908'; diff --git a/packages/cli/src/databases/sqlite/migrations/1594825041918-CreateIndexStoppedAt.ts b/packages/cli/src/databases/sqlite/migrations/1594825041918-CreateIndexStoppedAt.ts index 7c8104f06a..3d5c7860d5 100644 --- a/packages/cli/src/databases/sqlite/migrations/1594825041918-CreateIndexStoppedAt.ts +++ b/packages/cli/src/databases/sqlite/migrations/1594825041918-CreateIndexStoppedAt.ts @@ -1,6 +1,6 @@ import { MigrationInterface, QueryRunner } from "typeorm"; -import * as config from '../../../../config'; +import { config } from '@config'; export class CreateIndexStoppedAt1594825041918 implements MigrationInterface { name = 'CreateIndexStoppedAt1594825041918'; diff --git a/packages/cli/src/databases/sqlite/migrations/1607431743769-MakeStoppedAtNullable.ts b/packages/cli/src/databases/sqlite/migrations/1607431743769-MakeStoppedAtNullable.ts index 29285c9192..50cbe8d74d 100644 --- a/packages/cli/src/databases/sqlite/migrations/1607431743769-MakeStoppedAtNullable.ts +++ b/packages/cli/src/databases/sqlite/migrations/1607431743769-MakeStoppedAtNullable.ts @@ -1,6 +1,6 @@ import {MigrationInterface, QueryRunner} from "typeorm"; -import * as config from '../../../../config'; +import { config } from '@config'; export class MakeStoppedAtNullable1607431743769 implements MigrationInterface { diff --git a/packages/cli/src/databases/sqlite/migrations/1611071044839-AddWebhookId.ts b/packages/cli/src/databases/sqlite/migrations/1611071044839-AddWebhookId.ts index c4489ad6a6..bcb0afc49a 100644 --- a/packages/cli/src/databases/sqlite/migrations/1611071044839-AddWebhookId.ts +++ b/packages/cli/src/databases/sqlite/migrations/1611071044839-AddWebhookId.ts @@ -1,5 +1,5 @@ import {MigrationInterface, QueryRunner} from "typeorm"; -import * as config from '../../../../config'; +import { config } from '@config'; export class AddWebhookId1611071044839 implements MigrationInterface { name = 'AddWebhookId1611071044839'; diff --git a/packages/cli/src/databases/sqlite/migrations/1617213344594-CreateTagEntity.ts b/packages/cli/src/databases/sqlite/migrations/1617213344594-CreateTagEntity.ts index 3f52eed827..db00d17152 100644 --- a/packages/cli/src/databases/sqlite/migrations/1617213344594-CreateTagEntity.ts +++ b/packages/cli/src/databases/sqlite/migrations/1617213344594-CreateTagEntity.ts @@ -1,5 +1,5 @@ import {MigrationInterface, QueryRunner} from "typeorm"; -import * as config from '../../../../config'; +import { config } from '@config'; export class CreateTagEntity1617213344594 implements MigrationInterface { name = 'CreateTagEntity1617213344594'; diff --git a/packages/cli/src/databases/sqlite/migrations/1620821879465-UniqueWorkflowNames.ts b/packages/cli/src/databases/sqlite/migrations/1620821879465-UniqueWorkflowNames.ts index 732b080ed0..2e18b35889 100644 --- a/packages/cli/src/databases/sqlite/migrations/1620821879465-UniqueWorkflowNames.ts +++ b/packages/cli/src/databases/sqlite/migrations/1620821879465-UniqueWorkflowNames.ts @@ -1,5 +1,5 @@ import {MigrationInterface, QueryRunner} from "typeorm"; -import config = require("../../../../config"); +import { config } from '@config'; export class UniqueWorkflowNames1620821879465 implements MigrationInterface { name = 'UniqueWorkflowNames1620821879465'; diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index 4aaf4747fc..a4288ebfaa 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -19,7 +19,13 @@ "target": "es2017", "sourceMap": true, "emitDecoratorMetadata": true, - "experimentalDecorators": true + "experimentalDecorators": true, + "baseUrl": ".", + "paths": { + "@config": [ + "config/index" + ] + } }, "include": [ "**/*.d.ts",