Simplify config imports in cli package (#1840)

*  Set path alias for config

*  Update config export

*  Simplify config imports

*  Update also additional imports

*  Update path in collation migration

*  Resolve aliased paths

* 👕 Fix Codacy issue

* 👕 Retry to fix Codacy issue

Co-authored-by: Jan <janober@users.noreply.github.com>
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Iván Ovejero 2021-06-22 23:18:52 +02:00 committed by GitHub
parent 07a3dbb372
commit c21c8b3369
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 107 additions and 97 deletions

View file

@ -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.

View file

@ -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,

View file

@ -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,

View file

@ -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';

View file

@ -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;

View file

@ -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"

View file

@ -16,7 +16,7 @@ import {
import { TlsOptions } from 'tls';
import * as config from '../config';
import { config } from '@config';
import { entities } from './databases/entities';

View file

@ -5,7 +5,7 @@ import {
IExternalHooksFunctions,
} from './';
import * as config from '../config';
import { config } from '@config';
class ExternalHooksClass implements IExternalHooksClass {

View file

@ -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';

View file

@ -11,7 +11,7 @@ import {
LoggerProxy,
} from 'n8n-workflow';
import * as config from '../config';
import { config } from '@config';
import {
getLogger,

View file

@ -1,4 +1,4 @@
import config = require('../config');
import { config } from '@config';
import * as winston from 'winston';
import {

View file

@ -1,5 +1,5 @@
import * as Bull from 'bull';
import * as config from '../config';
import { config } from '@config';
import { IBullJobData } from './Interfaces';
export class Queue {

View file

@ -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

View file

@ -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() {

View file

@ -43,7 +43,7 @@ import {
WorkflowHooks,
} from 'n8n-workflow';
import * as config from '../config';
import { config } from '@config';
import { LessThanOrEqual } from 'typeorm';

View file

@ -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';

View file

@ -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';

View file

@ -38,7 +38,7 @@ import {
getLogger,
} from '../src/Logger';
import * as config from '../config';
import { config } from '@config';
export class WorkflowRunnerProcess {
data: IWorkflowExecutionDataProcessWithExecution | undefined;

View file

@ -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';

View file

@ -3,7 +3,7 @@ import {
QueryRunner,
} from 'typeorm';
import * as config from '../../../../config';
import { config } from '@config';
export class WebhookModel1592447867632 implements MigrationInterface {
name = 'WebhookModel1592447867632';

View file

@ -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';

View file

@ -1,6 +1,6 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import * as config from '../../../../config';
import { config } from '@config';
export class MakeStoppedAtNullable1607431743767 implements MigrationInterface {

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -1,5 +1,5 @@
import {MigrationInterface, QueryRunner} from "typeorm";
import config = require("../../../../config");
import { config } from '@config';
export class UniqueWorkflowNames1620826335440 implements MigrationInterface {
name = 'UniqueWorkflowNames1620826335440';

View file

@ -1,5 +1,5 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import config = require('../../../../config');
import { config } from '@config';
export class CertifyCorrectCollation1623936588000 implements MigrationInterface {
name = 'CertifyCorrectCollation1623936588000';

View file

@ -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';

View file

@ -3,7 +3,7 @@ import {
QueryRunner,
} from 'typeorm';
import * as config from '../../../../config';
import { config } from '@config';
export class WebhookModel1589476000887 implements MigrationInterface {
name = 'WebhookModel1589476000887';

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -1,5 +1,5 @@
import {MigrationInterface, QueryRunner} from "typeorm";
import config = require("../../../../config");
import { config } from '@config';
export class UniqueWorkflowNames1620824779533 implements MigrationInterface {
name = 'UniqueWorkflowNames1620824779533';

View file

@ -3,7 +3,7 @@ import {
QueryRunner,
} from 'typeorm';
import * as config from '../../../../config';
import { config } from '@config';
export class InitialMigration1588102412422 implements MigrationInterface {
name = 'InitialMigration1588102412422';

View file

@ -3,7 +3,7 @@ import {
QueryRunner,
} from 'typeorm';
import * as config from '../../../../config';
import { config } from '@config';
export class WebhookModel1592445003908 implements MigrationInterface {
name = 'WebhookModel1592445003908';

View file

@ -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';

View file

@ -1,6 +1,6 @@
import {MigrationInterface, QueryRunner} from "typeorm";
import * as config from '../../../../config';
import { config } from '@config';
export class MakeStoppedAtNullable1607431743769 implements MigrationInterface {

View file

@ -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';

View file

@ -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';

View file

@ -1,5 +1,5 @@
import {MigrationInterface, QueryRunner} from "typeorm";
import config = require("../../../../config");
import { config } from '@config';
export class UniqueWorkflowNames1620821879465 implements MigrationInterface {
name = 'UniqueWorkflowNames1620821879465';

View file

@ -19,7 +19,13 @@
"target": "es2017",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true
"experimentalDecorators": true,
"baseUrl": ".",
"paths": {
"@config": [
"config/index"
]
}
},
"include": [
"**/*.d.ts",