Skip to content

Commit

Permalink
Merge remote-tracking branch 'other/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mjquinlan2000 committed Nov 3, 2021
2 parents 9409511 + 85f6c84 commit a9436a6
Show file tree
Hide file tree
Showing 270 changed files with 6,731 additions and 2,110 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ module.exports = {
'undefined',
],

'no-void': ['error', { 'allowAsStatement': true }],

// ----------------------------------
// @typescript-eslint
// ----------------------------------
Expand Down Expand Up @@ -250,6 +252,11 @@ module.exports = {
*/
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }],

/**
* https://github.com/typescript-eslint/typescript-eslint/blob/v4.30.0/packages/eslint-plugin/docs/rules/no-floating-promises.md
*/
'@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],

/**
* https://eslint.org/docs/1.0.0/rules/no-throw-literal
*/
Expand Down
2 changes: 0 additions & 2 deletions packages/cli/commands/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import {
IWorkflowExecutionDataProcess,
LoadNodesAndCredentials,
NodeTypes,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
WorkflowCredentials,
WorkflowHelpers,
WorkflowRunner,
} from '../src';
Expand Down
6 changes: 1 addition & 5 deletions packages/cli/commands/executeBatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Command, flags } from '@oclif/command';
import { UserSettings } from 'n8n-core';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { INode, INodeExecutionData, ITaskData, LoggerProxy } from 'n8n-workflow';
import { INode, ITaskData, LoggerProxy } from 'n8n-workflow';

import { sep } from 'path';

Expand All @@ -28,14 +28,10 @@ import {
CredentialTypes,
Db,
ExternalHooks,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
IExecutionsCurrentSummary,
IWorkflowDb,
IWorkflowExecutionDataProcess,
LoadNodesAndCredentials,
NodeTypes,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
WorkflowCredentials,
WorkflowRunner,
} from '../src';

Expand Down
30 changes: 20 additions & 10 deletions packages/cli/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import {
Db,
ExternalHooks,
GenericHelpers,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
IExecutionsCurrentSummary,
InternalHooksManager,
LoadNodesAndCredentials,
NodeTypes,
Server,
Expand Down Expand Up @@ -92,9 +91,12 @@ export class Start extends Command {
setTimeout(() => {
// In case that something goes wrong with shutdown we
// kill after max. 30 seconds no matter what
console.log(`process exited after 30s`);
process.exit(processExitCode);
}, 30000);

await InternalHooksManager.getInstance().onN8nStop();

const skipWebhookDeregistration = config.get(
'endpoints.skipWebhoooksDeregistrationOnShutdown',
) as boolean;
Expand Down Expand Up @@ -151,9 +153,15 @@ export class Start extends Command {
LoggerProxy.init(logger);
logger.info('Initializing n8n process');

// todo remove a few versions after release
logger.info(
'\nn8n now checks for new versions and security updates. You can turn this off using the environment variable N8N_VERSION_NOTIFICATIONS_ENABLED to "false"\nFor more information, please refer to https://docs.n8n.io/getting-started/installation/advanced/configuration.html\n',
'\n' +
'****************************************************\n' +
'* *\n' +
'* n8n now sends selected, anonymous telemetry. *\n' +
'* For more details (and how to opt out): *\n' +
'* https://docs.n8n.io/reference/telemetry.html *\n' +
'* *\n' +
'****************************************************\n',
);

// Start directly with the init of the database to improve startup time
Expand All @@ -173,10 +181,6 @@ export class Start extends Command {
const loadNodesAndCredentials = LoadNodesAndCredentials();
await loadNodesAndCredentials.init();

// Load the credentials overwrites if any exist
const credentialsOverwrites = CredentialsOverwrites();
await credentialsOverwrites.init();

// Load all external hooks
const externalHooks = ExternalHooks();
await externalHooks.init();
Expand All @@ -187,6 +191,10 @@ export class Start extends Command {
const credentialTypes = CredentialTypes();
await credentialTypes.init(loadNodesAndCredentials.credentialTypes);

// Load the credentials overwrites if any exist
const credentialsOverwrites = CredentialsOverwrites();
await credentialsOverwrites.init();

// Wait till the database is ready
await startDbInitPromise;

Expand Down Expand Up @@ -304,14 +312,16 @@ export class Start extends Command {
);
}

const instanceId = await UserSettings.getInstanceId();
InternalHooksManager.init(instanceId);

await Server.start();

// Start to get active workflows and run their triggers
activeWorkflowRunner = ActiveWorkflowRunner.getInstance();
await activeWorkflowRunner.init();

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const waitTracker = WaitTracker();
WaitTracker();

const editorUrl = GenericHelpers.getBaseUrl();
this.log(`\nEditor is now accessible via:\n${editorUrl}`);
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/commands/update/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { Command, flags } from '@oclif/command';

import { IDataObject, LoggerProxy } from 'n8n-workflow';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Db, GenericHelpers } from '../../src';
import { Db } from '../../src';

import { getLogger } from '../../src/Logger';

Expand Down
6 changes: 4 additions & 2 deletions packages/cli/commands/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ import {
Db,
ExternalHooks,
GenericHelpers,
InternalHooksManager,
LoadNodesAndCredentials,
NodeTypes,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
TestWebhooks,
WebhookServer,
} from '../src';

Expand Down Expand Up @@ -149,6 +148,9 @@ export class Webhook extends Command {
// Wait till the database is ready
await startDbInitPromise;

const instanceId = await UserSettings.getInstanceId();
InternalHooksManager.init(instanceId);

if (config.get('executions.mode') === 'queue') {
const redisHost = config.get('queue.bull.redis.host');
const redisPassword = config.get('queue.bull.redis.password');
Expand Down
19 changes: 6 additions & 13 deletions packages/cli/commands/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,12 @@ import * as PCancelable from 'p-cancelable';
import { Command, flags } from '@oclif/command';
import { UserSettings, WorkflowExecute } from 'n8n-core';

import {
IDataObject,
INodeTypes,
IRun,
IWorkflowExecuteHooks,
Workflow,
WorkflowHooks,
LoggerProxy,
} from 'n8n-workflow';
import { INodeTypes, IRun, Workflow, LoggerProxy } from 'n8n-workflow';

import { FindOneOptions } from 'typeorm';

import * as Bull from 'bull';
import {
ActiveExecutions,
CredentialsOverwrites,
CredentialTypes,
Db,
Expand All @@ -35,11 +26,10 @@ import {
IBullJobData,
IBullJobResponse,
IExecutionFlattedDb,
IExecutionResponse,
InternalHooksManager,
LoadNodesAndCredentials,
NodeTypes,
ResponseHelper,
WorkflowCredentials,
WorkflowExecuteAdditionalData,
} from '../src';

Expand Down Expand Up @@ -203,7 +193,7 @@ export class Worker extends Command {
Worker.runningJobs[job.id] = workflowRun;

// Wait till the execution is finished
const runData = await workflowRun;
await workflowRun;

delete Worker.runningJobs[job.id];

Expand Down Expand Up @@ -269,6 +259,9 @@ export class Worker extends Command {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
Worker.jobQueue.process(flags.concurrency, async (job) => this.runJob(job, nodeTypes));

const instanceId = await UserSettings.getInstanceId();
InternalHooksManager.init(instanceId);

const versions = await GenericHelpers.getVersions();

console.info('\nn8n worker is now ready');
Expand Down
40 changes: 40 additions & 0 deletions packages/cli/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,46 @@ const config = convict({
env: 'N8N_VERSION_NOTIFICATIONS_INFO_URL',
},
},

deployment: {
type: {
format: String,
default: 'default',
env: 'N8N_DEPLOYMENT_TYPE',
},
},

personalization: {
enabled: {
doc: 'Whether personalization is enabled.',
format: Boolean,
default: true,
env: 'N8N_PERSONALIZATION_ENABLED',
},
},

diagnostics: {
enabled: {
doc: 'Whether diagnostic mode is enabled.',
format: Boolean,
default: true,
env: 'N8N_DIAGNOSTICS_ENABLED',
},
config: {
frontend: {
doc: 'Diagnostics config for frontend.',
format: String,
default: '1zPn9bgWPzlQc0p8Gj1uiK6DOTn;https://telemetry.n8n.io',
env: 'N8N_DIAGNOSTICS_CONFIG_FRONTEND',
},
backend: {
doc: 'Diagnostics config for backend.',
format: String,
default: '1zPn7YoGC3ZXE9zLeTKLuQCB4F6;https://telemetry.n8n.io/v1/batch',
env: 'N8N_DIAGNOSTICS_CONFIG_BACKEND',
},
},
},
});

// Overwrite default configuration with settings which got defined in
Expand Down
13 changes: 7 additions & 6 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "n8n",
"version": "0.144.0",
"version": "0.147.0",
"description": "n8n Workflow Automation Tool",
"license": "SEE LICENSE IN LICENSE.md",
"homepage": "https://n8n.io",
Expand Down Expand Up @@ -66,7 +66,7 @@
"@types/jest": "^26.0.13",
"@types/localtunnel": "^1.9.0",
"@types/lodash.get": "^4.4.6",
"@types/node": "^14.14.40",
"@types/node": "14.17.27",
"@types/open": "^6.1.0",
"@types/parseurl": "^1.3.1",
"@types/request-promise-native": "~1.0.15",
Expand All @@ -83,6 +83,7 @@
"dependencies": {
"@oclif/command": "^1.5.18",
"@oclif/errors": "^1.2.2",
"@rudderstack/rudder-sdk-node": "^1.0.2",
"@types/json-diff": "^0.5.1",
"@types/jsonwebtoken": "^8.5.2",
"basic-auth": "^2.0.1",
Expand All @@ -109,10 +110,10 @@
"localtunnel": "^2.0.0",
"lodash.get": "^4.4.2",
"mysql2": "~2.3.0",
"n8n-core": "~0.89.0",
"n8n-editor-ui": "~0.112.0",
"n8n-nodes-base": "~0.141.0",
"n8n-workflow": "~0.72.0",
"n8n-core": "~0.91.0",
"n8n-editor-ui": "~0.114.0",
"n8n-nodes-base": "~0.144.0",
"n8n-workflow": "~0.74.0",
"oauth-1.0a": "^2.2.6",
"open": "^7.0.0",
"pg": "^8.3.0",
Expand Down
20 changes: 1 addition & 19 deletions packages/cli/src/CredentialTypes.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
import { ICredentialType, ICredentialTypes as ICredentialTypesInterface } from 'n8n-workflow';

// eslint-disable-next-line import/no-cycle
import { CredentialsOverwrites, ICredentialsTypeData } from '.';
import { ICredentialsTypeData } from '.';

class CredentialTypesClass implements ICredentialTypesInterface {
credentialTypes: ICredentialsTypeData = {};

async init(credentialTypes: ICredentialsTypeData): Promise<void> {
this.credentialTypes = credentialTypes;

// Load the credentials overwrites if any exist
const credentialsOverwrites = CredentialsOverwrites().getAll();

// eslint-disable-next-line no-restricted-syntax
for (const credentialType of Object.keys(credentialsOverwrites)) {
if (credentialTypes[credentialType] === undefined) {
// eslint-disable-next-line no-continue
continue;
}

// Add which properties got overwritten that the Editor-UI knows
// which properties it should hide
// eslint-disable-next-line no-underscore-dangle, no-param-reassign
credentialTypes[credentialType].__overwrittenProperties = Object.keys(
credentialsOverwrites[credentialType],
);
}
}

getAll(): ICredentialType[] {
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/CredentialsOverwrites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class CredentialsOverwritesClass {
private resolvedTypes: string[] = [];

async init(overwriteData?: ICredentialsOverwrite) {
// If data gets reinitialized reset the resolved types cache
this.resolvedTypes.length = 0;

if (overwriteData !== undefined) {
// If data is already given it can directly be set instead of
// loaded from environment
Expand Down Expand Up @@ -41,6 +44,7 @@ class CredentialsOverwritesClass {

if (overwrites && Object.keys(overwrites).length) {
this.overwriteData[type] = overwrites;
credentialTypeData.__overwrittenProperties = Object.keys(overwrites);
}
}
}
Expand Down
Loading

0 comments on commit a9436a6

Please sign in to comment.