Skip to content

Commit

Permalink
🔀 Merge branch 'master' into "feature/kobotoolbox"
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoE105 committed Feb 6, 2022
2 parents 06bfac6 + 3b173b5 commit 48f8f6e
Show file tree
Hide file tree
Showing 730 changed files with 27,852 additions and 5,180 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ _START_PACKAGE
.vscode/*
!.vscode/extensions.json
.idea
vetur.config.js
nodelinter.config.json
packages/*/package-lock.json
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ npm install -g lerna

### Actual n8n setup

> **IMPORTANT**: All the steps bellow have to get executed at least once to get the development setup up and running!
> **IMPORTANT**: All the steps below have to get executed at least once to get the development setup up and running!
Now that everything n8n requires to run is installed the actual n8n code can be
checked out and set up:
Expand Down
4,075 changes: 1,944 additions & 2,131 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/cli/bin/n8n
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ if (process.argv.length === 2) {
var nodeVersion = process.versions.node.split('.');

if (parseInt(nodeVersion[0], 10) < 14) {
console.log(`\nYour Node.js version (${process.versions.node}) is too old to run n8n.\nPlease update to version 14 or later!\n`);
process.exit(0);
console.log(`\nYour Node.js version (${process.versions.node}) is too old to run n8n.\nPlease update at least to Node.js v14 or to the recommended Node.js v16!\n`);
process.exit(1);
}

require('@oclif/command').run()
Expand Down
23 changes: 17 additions & 6 deletions packages/cli/commands/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
/* eslint-disable no-console */
import { promises as fs } from 'fs';
import { Command, flags } from '@oclif/command';
import { UserSettings } from 'n8n-core';
import {
BinaryDataManager,
IBinaryDataConfig,
UserSettings,
PLACEHOLDER_EMPTY_WORKFLOW_ID,
} from 'n8n-core';
import { INode, LoggerProxy } from 'n8n-workflow';

import {
Expand All @@ -11,6 +16,7 @@ import {
CredentialTypes,
Db,
ExternalHooks,
GenericHelpers,
InternalHooksManager,
IWorkflowBase,
IWorkflowExecutionDataProcess,
Expand All @@ -21,6 +27,7 @@ import {
} from '../src';

import { getLogger } from '../src/Logger';
import config = require('../config');

export class Execute extends Command {
static description = '\nExecutes a given workflow';
Expand All @@ -44,6 +51,8 @@ export class Execute extends Command {
async run() {
const logger = getLogger();
LoggerProxy.init(logger);
const binaryDataConfig = config.get('binaryDataManager') as IBinaryDataConfig;
await BinaryDataManager.init(binaryDataConfig, true);

// eslint-disable-next-line @typescript-eslint/no-shadow
const { flags } = this.parse(Execute);
Expand Down Expand Up @@ -92,8 +101,9 @@ export class Execute extends Command {
console.info(`The file "${flags.file}" does not contain valid workflow data.`);
return;
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
workflowId = workflowData.id!.toString();

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
workflowId = workflowData.id ? workflowData.id.toString() : PLACEHOLDER_EMPTY_WORKFLOW_ID;
}

// Wait till the database is ready
Expand Down Expand Up @@ -124,15 +134,16 @@ export class Execute extends Command {
const externalHooks = ExternalHooks();
await externalHooks.init();

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

// Add the found types to an instance other parts of the application can use
const nodeTypes = NodeTypes();
await nodeTypes.init(loadNodesAndCredentials.nodeTypes);
const credentialTypes = CredentialTypes();
await credentialTypes.init(loadNodesAndCredentials.credentialTypes);

const instanceId = await UserSettings.getInstanceId();
const { cli } = await GenericHelpers.getVersions();
InternalHooksManager.init(instanceId, cli, nodeTypes);

if (!WorkflowHelpers.isWorkflowIdValid(workflowId)) {
workflowId = undefined;
}
Expand Down
13 changes: 9 additions & 4 deletions packages/cli/commands/executeBatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import * as fs from 'fs';
import { Command, flags } from '@oclif/command';

import { UserSettings } from 'n8n-core';
import { BinaryDataManager, IBinaryDataConfig, UserSettings } from 'n8n-core';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { INode, ITaskData, LoggerProxy } from 'n8n-workflow';
Expand All @@ -28,13 +28,15 @@ import {
CredentialTypes,
Db,
ExternalHooks,
GenericHelpers,
InternalHooksManager,
IWorkflowDb,
IWorkflowExecutionDataProcess,
LoadNodesAndCredentials,
NodeTypes,
WorkflowRunner,
} from '../src';
import config = require('../config');

export class ExecuteBatch extends Command {
static description = '\nExecutes multiple workflows once';
Expand Down Expand Up @@ -189,6 +191,8 @@ export class ExecuteBatch extends Command {

const logger = getLogger();
LoggerProxy.init(logger);
const binaryDataConfig = config.get('binaryDataManager') as IBinaryDataConfig;
await BinaryDataManager.init(binaryDataConfig, true);

// eslint-disable-next-line @typescript-eslint/no-shadow
const { flags } = this.parse(ExecuteBatch);
Expand Down Expand Up @@ -304,15 +308,16 @@ export class ExecuteBatch extends Command {
const externalHooks = ExternalHooks();
await externalHooks.init();

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

// Add the found types to an instance other parts of the application can use
const nodeTypes = NodeTypes();
await nodeTypes.init(loadNodesAndCredentials.nodeTypes);
const credentialTypes = CredentialTypes();
await credentialTypes.init(loadNodesAndCredentials.credentialTypes);

const instanceId = await UserSettings.getInstanceId();
const { cli } = await GenericHelpers.getVersions();
InternalHooksManager.init(instanceId, cli, nodeTypes);

// Send a shallow copy of allWorkflows so we still have all workflow data.
const results = await this.runTests([...allWorkflows]);

Expand Down
19 changes: 6 additions & 13 deletions packages/cli/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import * as localtunnel from 'localtunnel';
import { TUNNEL_SUBDOMAIN_ENV, UserSettings } from 'n8n-core';
import { BinaryDataManager, IBinaryDataConfig, TUNNEL_SUBDOMAIN_ENV, UserSettings } from 'n8n-core';
import { Command, flags } from '@oclif/command';
// eslint-disable-next-line import/no-extraneous-dependencies
import * as Redis from 'ioredis';
Expand Down Expand Up @@ -153,17 +153,6 @@ export class Start extends Command {
LoggerProxy.init(logger);
logger.info('Initializing n8n process');

logger.info(
'\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
const startDbInitPromise = Db.init().catch((error: Error) => {
logger.error(`There was an error initializing DB: "${error.message}"`);
Expand Down Expand Up @@ -313,7 +302,11 @@ export class Start extends Command {
}

const instanceId = await UserSettings.getInstanceId();
InternalHooksManager.init(instanceId);
const { cli } = await GenericHelpers.getVersions();
InternalHooksManager.init(instanceId, cli, nodeTypes);

const binaryDataConfig = config.get('binaryDataManager') as IBinaryDataConfig;
await BinaryDataManager.init(binaryDataConfig, true);

await Server.start();

Expand Down
8 changes: 6 additions & 2 deletions packages/cli/commands/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/unbound-method */
import { UserSettings } from 'n8n-core';
import { BinaryDataManager, IBinaryDataConfig, UserSettings } from 'n8n-core';
import { Command, flags } from '@oclif/command';
// eslint-disable-next-line import/no-extraneous-dependencies
import * as Redis from 'ioredis';
Expand Down Expand Up @@ -149,7 +149,11 @@ export class Webhook extends Command {
await startDbInitPromise;

const instanceId = await UserSettings.getInstanceId();
InternalHooksManager.init(instanceId);
const { cli } = await GenericHelpers.getVersions();
InternalHooksManager.init(instanceId, cli, nodeTypes);

const binaryDataConfig = config.get('binaryDataManager') as IBinaryDataConfig;
await BinaryDataManager.init(binaryDataConfig);

if (config.get('executions.mode') === 'queue') {
const redisHost = config.get('queue.bull.redis.host');
Expand Down
9 changes: 6 additions & 3 deletions packages/cli/commands/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import * as PCancelable from 'p-cancelable';

import { Command, flags } from '@oclif/command';
import { UserSettings, WorkflowExecute } from 'n8n-core';
import { BinaryDataManager, IBinaryDataConfig, UserSettings, WorkflowExecute } from 'n8n-core';

import { IExecuteResponsePromiseData, INodeTypes, IRun, Workflow, LoggerProxy } from 'n8n-workflow';

Expand Down Expand Up @@ -271,10 +271,13 @@ 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 versions = await GenericHelpers.getVersions();
const instanceId = await UserSettings.getInstanceId();
InternalHooksManager.init(instanceId);

const versions = await GenericHelpers.getVersions();
InternalHooksManager.init(instanceId, versions.cli, nodeTypes);

const binaryDataConfig = config.get('binaryDataManager') as IBinaryDataConfig;
await BinaryDataManager.init(binaryDataConfig);

console.info('\nn8n worker is now ready');
console.info(` * Version: ${versions.cli}`);
Expand Down
66 changes: 66 additions & 0 deletions packages/cli/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ const config = convict({
default: '',
env: 'DB_TABLE_PREFIX',
},
logging: {
enabled: {
doc: 'Typeorm logging enabled flag.',
format: 'Boolean',
default: false,
env: 'DB_LOGGING_ENABLED',
},
options: {
doc: 'Logging level options, default is "error". Possible values: query,error,schema,warn,info,log. To enable all logging, specify "all"',
format: String,
default: 'error',
env: 'DB_LOGGING_OPTIONS',
},
maxQueryExecutionTime: {
doc: 'Maximum number of milliseconds query should be executed before logger logs a warning. Set 0 to disable long running query warning',
format: Number,
default: 1000,
env: 'DB_LOGGING_MAX_EXECUTION_TIME',
},
},
postgresdb: {
database: {
doc: 'PostgresDB Database',
Expand Down Expand Up @@ -507,6 +527,12 @@ const config = convict({
env: 'N8N_ENDPOINT_WEBHOOK_TEST',
doc: 'Path for test-webhook endpoint',
},
disableUi: {
format: Boolean,
default: false,
env: 'N8N_DISABLE_UI',
doc: 'Disable N8N UI (Frontend).',
},
disableProductionWebhooksOnMainProcess: {
format: Boolean,
default: false,
Expand Down Expand Up @@ -650,6 +676,39 @@ const config = convict({
},
},

binaryDataManager: {
availableModes: {
format: String,
default: 'filesystem',
env: 'N8N_AVAILABLE_BINARY_DATA_MODES',
doc: 'Available modes of binary data storage, as comma separated strings',
},
mode: {
format: String,
default: 'default',
env: 'N8N_DEFAULT_BINARY_DATA_MODE',
doc: 'Storage mode for binary data, default | filesystem',
},
localStoragePath: {
format: String,
default: path.join(core.UserSettings.getUserN8nFolderPath(), 'binaryData'),
env: 'N8N_BINARY_DATA_STORAGE_PATH',
doc: 'Path for binary data storage in "filesystem" mode',
},
binaryDataTTL: {
format: Number,
default: 60,
env: 'N8N_BINARY_DATA_TTL',
doc: 'TTL for binary data of unsaved executions in minutes',
},
persistedBinaryDataTTL: {
format: Number,
default: 1440,
env: 'N8N_PERSISTED_BINARY_DATA_TTL',
doc: 'TTL for persisted binary data in minutes (binary data gets deleted if not persisted before TTL expires)',
},
},

deployment: {
type: {
format: String,
Expand Down Expand Up @@ -689,6 +748,13 @@ const config = convict({
},
},
},

defaultLocale: {
doc: 'Default locale for the UI',
format: String,
default: 'en',
env: 'N8N_DEFAULT_LOCALE',
},
});

// Overwrite default configuration with settings which got defined in
Expand Down
15 changes: 9 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.152.0",
"version": "0.162.0",
"description": "n8n Workflow Automation Tool",
"license": "SEE LICENSE IN LICENSE.md",
"homepage": "https://n8n.io",
Expand Down Expand Up @@ -66,11 +66,13 @@
"@types/jest": "^26.0.13",
"@types/localtunnel": "^1.9.0",
"@types/lodash.get": "^4.4.6",
"@types/lodash.merge": "^4.6.6",
"@types/node": "14.17.27",
"@types/open": "^6.1.0",
"@types/parseurl": "^1.3.1",
"@types/request-promise-native": "~1.0.15",
"@types/validator": "^13.7.0",
"axios": "^0.21.1",
"concurrently": "^5.1.0",
"jest": "^26.4.2",
"nodemon": "^2.0.2",
Expand Down Expand Up @@ -102,19 +104,20 @@
"dotenv": "^8.0.0",
"express": "^4.16.4",
"fast-glob": "^3.2.5",
"flatted": "^2.0.0",
"flatted": "^3.2.4",
"google-timezones-json": "^1.0.2",
"inquirer": "^7.0.1",
"json-diff": "^0.5.4",
"jsonwebtoken": "^8.5.1",
"jwks-rsa": "~1.12.1",
"localtunnel": "^2.0.0",
"lodash.get": "^4.4.2",
"lodash.merge": "^4.6.2",
"mysql2": "~2.3.0",
"n8n-core": "~0.96.0",
"n8n-editor-ui": "~0.119.0",
"n8n-nodes-base": "~0.149.0",
"n8n-workflow": "~0.79.0",
"n8n-core": "~0.104.0",
"n8n-editor-ui": "~0.129.0",
"n8n-nodes-base": "~0.160.0",
"n8n-workflow": "~0.86.0",
"oauth-1.0a": "^2.2.6",
"open": "^7.0.0",
"pg": "^8.3.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/ActiveExecutions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from 'n8n-workflow';

import { ChildProcess } from 'child_process';
import { stringify } from 'flatted';
// eslint-disable-next-line import/no-extraneous-dependencies
import * as PCancelable from 'p-cancelable';
// eslint-disable-next-line import/no-cycle
Expand Down Expand Up @@ -82,6 +83,7 @@ export class ActiveExecutions {

const execution = {
id: executionId,
data: stringify(executionData.executionData!),
waitTill: null,
};

Expand Down
Loading

0 comments on commit 48f8f6e

Please sign in to comment.