build: Upgrade some of the backend dev-tooling (no-changelog) (#4589)

* upgrade ts-node

* move tslint and typescript to a single place

* source-map-support should be loaded in the `n8n` bin script, and not in core

* upgrade jest

* Support only node.js 14, 16, or 18
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2022-11-14 15:37:32 +01:00 committed by GitHub
parent edebad1a89
commit 0148631d28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 574 additions and 435 deletions

View file

@ -1,14 +1,6 @@
const { compilerOptions } = require('./tsconfig.json');
/** @type {import('jest').Config} */
module.exports = {
verbose: true,
preset: 'ts-jest',
testEnvironment: 'node',
testRegex: '\\.(test|spec)\\.(js|ts)$',
testPathIgnorePatterns: ['/dist/', '/node_modules/'],
globals: {
'ts-jest': {
const tsJestOptions = {
isolatedModules: true,
tsconfig: {
...compilerOptions,
@ -16,7 +8,16 @@ module.exports = {
sourceMap: false,
skipLibCheck: true,
},
},
};
/** @type {import('jest').Config} */
module.exports = {
verbose: true,
testEnvironment: 'node',
testRegex: '\\.(test|spec)\\.(js|ts)$',
testPathIgnorePatterns: ['/dist/', '/node_modules/'],
transform: {
'^.+\\.ts$': ['ts-jest', tsJestOptions],
},
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',

View file

@ -39,20 +39,19 @@
"devDependencies": {
"@n8n_io/eslint-config": "*",
"@ngneat/falso": "^6.1.0",
"@types/jest": "^28.1.8",
"@types/jest": "^29.2.2",
"@types/node": "^16.11.22",
"cross-env": "^7.0.3",
"cypress": "^10.0.3",
"jest": "^28.1.3",
"jest-environment-jsdom": "^28.1.3",
"jest-mock": "^28.1.3",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"jest-mock": "^29.3.1",
"prettier": "^2.3.2",
"rimraf": "^3.0.2",
"run-script-os": "^1.0.7",
"start-server-and-test": "^1.14.0",
"supertest": "^6.2.2",
"ts-jest": "^28.0.8",
"ts-node": "^9.1.1",
"ts-jest": "^29.0.3",
"turbo": "1.5.5",
"typescript": "^4.8.4"
},

View file

@ -14,7 +14,8 @@
"eslint-plugin-import": "~2.26",
"eslint-plugin-n8n-local-rules": "~1.0",
"eslint-plugin-prettier": "~4.2",
"eslint-plugin-vue": "~7.17"
"eslint-plugin-vue": "~7.17",
"tslint": "^6.1.3"
},
"scripts": {
"clean": "rimraf .turbo",

View file

@ -1,17 +1,13 @@
#!/usr/bin/env node
var path = require('path');
const path = require('path');
// Make sure that it also find the config folder when it
// did get started from another folder that the root one.
process.env.NODE_CONFIG_DIR = process.env.NODE_CONFIG_DIR || path.join(__dirname, 'config');
// Check if version should be displayed
var versionFlags = [
'-v',
'-V',
'--version',
];
const versionFlags = ['-v', '-V', '--version'];
if (versionFlags.includes(process.argv.slice(-1)[0])) {
console.log(require('../package').version);
process.exit(0);
@ -22,13 +18,22 @@ if (process.argv.length === 2) {
process.argv.push('start');
}
var nodeVersion = process.versions.node.split('.');
const nodeVersion = process.versions.node;
const nodeVersionMajor = require('semver').major(nodeVersion);
if (parseInt(nodeVersion[0], 10) < 14) {
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`);
if (![14, 16, 18].includes(nodeVersionMajor)) {
console.log(`
Your Node.js version (${nodeVersion}) is currently not supported by n8n.
Please use Node.js v14, v16 (recommended), or v18 instead!
`);
process.exit(1);
}
require('@oclif/command').run()
.then(require('@oclif/command/flush'))
.catch(require('@oclif/errors/handle'));
try {
require('source-map-support').install();
} catch {}
require('@oclif/command')
.run()
.then(require('@oclif/command/flush'))
.catch(require('@oclif/errors/handle'));

View file

@ -96,11 +96,11 @@
"concurrently": "^5.1.0",
"nodemon": "^2.0.2",
"run-script-os": "^1.0.7",
"source-map-support": "^0.5.21",
"supertest": "^6.2.2",
"ts-node": "^8.9.1",
"ts-node": "^9.1.1",
"tsc-alias": "^1.7.0",
"tsconfig-paths": "^3.14.1",
"typescript": "~4.8.0"
"tsconfig-paths": "^3.14.1"
},
"dependencies": {
"@oclif/command": "^1.8.16",
@ -164,6 +164,7 @@
"posthog-node": "^1.3.0",
"prom-client": "^13.1.0",
"psl": "^1.8.0",
"semver": "^7.3.8",
"shelljs": "^0.8.5",
"sqlite3": "^5.1.2",
"sse-channel": "^3.1.1",

View file

@ -35,8 +35,7 @@
"@types/lodash.get": "^4.4.6",
"@types/mime-types": "^2.1.0",
"@types/request-promise-native": "~1.0.15",
"@types/uuid": "^8.3.2",
"source-map-support": "^0.5.9"
"@types/uuid": "^8.3.2"
},
"dependencies": {
"axios": "^0.21.1",

View file

@ -32,7 +32,7 @@ export interface IProcessMessage {
export interface IExecuteFunctions extends IExecuteFunctionsBase {
helpers: {
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>; // tslint:disable-line:no-any
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>;
prepareBinaryData(
binaryData: Buffer,
filePath?: string,
@ -40,7 +40,7 @@ export interface IExecuteFunctions extends IExecuteFunctionsBase {
): Promise<IBinaryData>;
getBinaryDataBuffer(itemIndex: number, propertyName: string): Promise<Buffer>;
setBinaryDataBuffer(data: IBinaryData, binaryData: Buffer): Promise<IBinaryData>;
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>; // tslint:disable-line:no-any
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>;
requestWithAuthentication(
this: IAllExecuteFunctions,
credentialsType: string,
@ -52,12 +52,12 @@ export interface IExecuteFunctions extends IExecuteFunctionsBase {
credentialsType: string,
requestOptions: OptionsWithUri | RequestPromiseOptions,
oAuth2Options?: IOAuth2Options,
): Promise<any>; // tslint:disable-line:no-any
): Promise<any>;
requestOAuth1(
this: IAllExecuteFunctions,
credentialsType: string,
requestOptions: OptionsWithUrl | RequestPromiseOptions,
): Promise<any>; // tslint:disable-line:no-any
): Promise<any>;
returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
normalizeItems(items: INodeExecutionData | INodeExecutionData[]): INodeExecutionData[];
httpRequestWithAuthentication(
@ -76,13 +76,13 @@ export interface IExecuteSingleFunctions extends IExecuteSingleFunctionsBase {
helpers: {
getBinaryDataBuffer(propertyName: string, inputIndex?: number): Promise<Buffer>;
setBinaryDataBuffer(data: IBinaryData, binaryData: Buffer): Promise<IBinaryData>;
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>; // tslint:disable-line:no-any
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>;
prepareBinaryData(
binaryData: Buffer,
filePath?: string,
mimeType?: string,
): Promise<IBinaryData>;
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>; // tslint:disable-line:no-any
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>;
requestWithAuthentication(
this: IAllExecuteFunctions,
credentialsType: string,
@ -94,12 +94,12 @@ export interface IExecuteSingleFunctions extends IExecuteSingleFunctionsBase {
credentialsType: string,
requestOptions: OptionsWithUri | RequestPromiseOptions,
oAuth2Options?: IOAuth2Options,
): Promise<any>; // tslint:disable-line:no-any
): Promise<any>;
requestOAuth1(
this: IAllExecuteFunctions,
credentialsType: string,
requestOptions: OptionsWithUrl | RequestPromiseOptions,
): Promise<any>; // tslint:disable-line:no-any
): Promise<any>;
httpRequestWithAuthentication(
this: IAllExecuteFunctions,
credentialsType: string,
@ -110,13 +110,13 @@ export interface IExecuteSingleFunctions extends IExecuteSingleFunctionsBase {
export interface IPollFunctions extends IPollFunctionsBase {
helpers: {
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>; // tslint:disable-line:no-any
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>;
prepareBinaryData(
binaryData: Buffer,
filePath?: string,
mimeType?: string,
): Promise<IBinaryData>;
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>; // tslint:disable-line:no-any
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>;
requestWithAuthentication(
this: IAllExecuteFunctions,
credentialsType: string,
@ -128,12 +128,12 @@ export interface IPollFunctions extends IPollFunctionsBase {
credentialsType: string,
requestOptions: OptionsWithUri | RequestPromiseOptions,
oAuth2Options?: IOAuth2Options,
): Promise<any>; // tslint:disable-line:no-any
): Promise<any>;
requestOAuth1(
this: IAllExecuteFunctions,
credentialsType: string,
requestOptions: OptionsWithUrl | RequestPromiseOptions,
): Promise<any>; // tslint:disable-line:no-any
): Promise<any>;
returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
httpRequestWithAuthentication(
this: IAllExecuteFunctions,
@ -149,13 +149,13 @@ export interface IResponseError extends Error {
export interface ITriggerFunctions extends ITriggerFunctionsBase {
helpers: {
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>; // tslint:disable-line:no-any
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>;
prepareBinaryData(
binaryData: Buffer,
filePath?: string,
mimeType?: string,
): Promise<IBinaryData>;
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>; // tslint:disable-line:no-any
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>;
requestWithAuthentication(
this: IAllExecuteFunctions,
credentialsType: string,
@ -167,12 +167,12 @@ export interface ITriggerFunctions extends ITriggerFunctionsBase {
credentialsType: string,
requestOptions: OptionsWithUri | RequestPromiseOptions,
oAuth2Options?: IOAuth2Options,
): Promise<any>; // tslint:disable-line:no-any
): Promise<any>;
requestOAuth1(
this: IAllExecuteFunctions,
credentialsType: string,
requestOptions: OptionsWithUrl | RequestPromiseOptions,
): Promise<any>; // tslint:disable-line:no-any
): Promise<any>;
returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
httpRequestWithAuthentication(
this: IAllExecuteFunctions,
@ -190,8 +190,8 @@ export interface IUserSettings {
export interface ILoadOptionsFunctions extends ILoadOptionsFunctionsBase {
helpers: {
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>; // tslint:disable-line:no-any
request?: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>; // tslint:disable-line:no-any
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>;
request?: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>;
requestWithAuthentication(
this: IAllExecuteFunctions,
credentialsType: string,
@ -203,12 +203,12 @@ export interface ILoadOptionsFunctions extends ILoadOptionsFunctionsBase {
credentialsType: string,
requestOptions: OptionsWithUri | RequestPromiseOptions,
oAuth2Options?: IOAuth2Options,
) => Promise<any>; // tslint:disable-line:no-any
) => Promise<any>;
requestOAuth1?(
this: IAllExecuteFunctions,
credentialsType: string,
requestOptions: OptionsWithUrl | RequestPromiseOptions,
): Promise<any>; // tslint:disable-line:no-any
): Promise<any>;
httpRequestWithAuthentication(
this: IAllExecuteFunctions,
credentialsType: string,
@ -225,8 +225,8 @@ export interface ICredentialTestFunctions extends ICredentialTestFunctionsBase {
export interface IHookFunctions extends IHookFunctionsBase {
helpers: {
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>; // tslint:disable-line:no-any
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>; // tslint:disable-line:no-any
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>;
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>;
requestWithAuthentication(
this: IAllExecuteFunctions,
credentialsType: string,
@ -238,12 +238,12 @@ export interface IHookFunctions extends IHookFunctionsBase {
credentialsType: string,
requestOptions: OptionsWithUri | RequestPromiseOptions,
oAuth2Options?: IOAuth2Options,
): Promise<any>; // tslint:disable-line:no-any
): Promise<any>;
requestOAuth1(
this: IAllExecuteFunctions,
credentialsType: string,
requestOptions: OptionsWithUrl | RequestPromiseOptions,
): Promise<any>; // tslint:disable-line:no-any
): Promise<any>;
httpRequestWithAuthentication(
this: IAllExecuteFunctions,
credentialsType: string,
@ -254,13 +254,13 @@ export interface IHookFunctions extends IHookFunctionsBase {
export interface IWebhookFunctions extends IWebhookFunctionsBase {
helpers: {
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>; // tslint:disable-line:no-any
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>;
prepareBinaryData(
binaryData: Buffer,
filePath?: string,
mimeType?: string,
): Promise<IBinaryData>;
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>; // tslint:disable-line:no-any
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>;
requestWithAuthentication(
this: IAllExecuteFunctions,
credentialsType: string,
@ -272,12 +272,12 @@ export interface IWebhookFunctions extends IWebhookFunctionsBase {
credentialsType: string,
requestOptions: OptionsWithUri | RequestPromiseOptions,
oAuth2Options?: IOAuth2Options,
): Promise<any>; // tslint:disable-line:no-any
): Promise<any>;
requestOAuth1(
this: IAllExecuteFunctions,
credentialsType: string,
requestOptions: OptionsWithUrl | RequestPromiseOptions,
): Promise<any>; // tslint:disable-line:no-any
): Promise<any>;
returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
httpRequestWithAuthentication(
this: IAllExecuteFunctions,

View file

@ -559,7 +559,6 @@ function digestAuthAxiosConfig(
async function proxyRequestToAxios(
uriOrObject: string | IDataObject,
options?: IDataObject,
// tslint:disable-next-line:no-any
): Promise<any> {
// Check if there's a better way of getting this config here
if (process.env.N8N_USE_DEPRECATED_REQUEST_LIB) {

View file

@ -292,7 +292,6 @@ export class WorkflowExecute {
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async executeHook(hookName: string, parameters: any[]): Promise<void> {
// tslint:disable-line:no-any
if (this.additionalData.hooks === undefined) {
return;
}

View file

@ -1,12 +1,6 @@
import * as NodeExecuteFunctions from './NodeExecuteFunctions';
import * as UserSettings from './UserSettings';
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, import/no-extraneous-dependencies, global-require, @typescript-eslint/no-var-requires
require('source-map-support').install();
// eslint-disable-next-line no-empty
} catch (error) {}
export * from './ActiveWorkflows';
export * from './ActiveWebhooks';
export * from './BinaryDataManager';

View file

@ -102,7 +102,6 @@
"sass": "^1.55.0",
"sass-loader": "^10.1.1",
"string-template-parser": "^1.2.6",
"tslint": "^6.1.2",
"vite": "2.9.5",
"vite-plugin-html": "^3.2.0",
"vite-plugin-monaco-editor": "^1.0.10",

View file

@ -750,9 +750,7 @@
"@types/xml2js": "^0.4.3",
"eslint-plugin-n8n-nodes-base": "^1.11.0",
"gulp": "^4.0.0",
"n8n-workflow": "~0.124.1",
"tslint": "^6.1.2",
"typescript": "~4.8.0"
"n8n-workflow": "~0.124.1"
},
"dependencies": {
"@kafkajs/confluent-schema-registry": "1.0.6",

View file

@ -583,8 +583,8 @@ export interface IExecuteFunctions {
outputIndex?: number,
): Promise<INodeExecutionData[][]>;
putExecutionToWait(waitTill: Date): Promise<void>;
sendMessageToUI(message: any): void; // tslint:disable-line:no-any
sendResponse(response: IExecuteResponsePromiseData): void; // tslint:disable-line:no-any
sendMessageToUI(message: any): void;
sendResponse(response: IExecuteResponsePromiseData): void;
helpers: {
httpRequest(
requestOptions: IHttpRequestOptions,
@ -595,7 +595,7 @@ export interface IExecuteFunctions {
requestOptions: IHttpRequestOptions,
additionalCredentialOptions?: IAdditionalCredentialOptions,
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
[key: string]: (...args: any[]) => any; // tslint:disable-line:no-any
[key: string]: (...args: any[]) => any;
};
}
@ -629,7 +629,7 @@ export interface IExecuteSingleFunctions {
requestOptions: IHttpRequestOptions,
additionalCredentialOptions?: IAdditionalCredentialOptions,
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
[key: string]: (...args: any[]) => any; // tslint:disable-line:no-any
[key: string]: (...args: any[]) => any;
};
}
@ -679,7 +679,7 @@ export interface ILoadOptionsFunctions {
requestWithAuthentication(
this: IAllExecuteFunctions,
credentialsType: string,
requestOptions: any, // tslint:disable-line:no-any
requestOptions: any,
additionalCredentialOptions?: IAdditionalCredentialOptions,
): Promise<any>;
httpRequestWithAuthentication(
@ -688,7 +688,7 @@ export interface ILoadOptionsFunctions {
requestOptions: IHttpRequestOptions,
additionalCredentialOptions?: IAdditionalCredentialOptions,
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
[key: string]: ((...args: any[]) => any) | undefined; // tslint:disable-line:no-any
[key: string]: ((...args: any[]) => any) | undefined;
};
}
@ -718,7 +718,7 @@ export interface IHookFunctions {
requestOptions: IHttpRequestOptions,
additionalCredentialOptions?: IAdditionalCredentialOptions,
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
[key: string]: (...args: any[]) => any; // tslint:disable-line:no-any
[key: string]: (...args: any[]) => any;
};
}
@ -752,7 +752,7 @@ export interface IPollFunctions {
requestOptions: IHttpRequestOptions,
additionalCredentialOptions?: IAdditionalCredentialOptions,
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
[key: string]: (...args: any[]) => any; // tslint:disable-line:no-any
[key: string]: (...args: any[]) => any;
};
}
@ -786,7 +786,7 @@ export interface ITriggerFunctions {
requestOptions: IHttpRequestOptions,
additionalCredentialOptions?: IAdditionalCredentialOptions,
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
[key: string]: (...args: any[]) => any; // tslint:disable-line:no-any
[key: string]: (...args: any[]) => any;
};
}
@ -824,7 +824,7 @@ export interface IWebhookFunctions {
requestOptions: IHttpRequestOptions,
additionalCredentialOptions?: IAdditionalCredentialOptions,
): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
[key: string]: (...args: any[]) => any; // tslint:disable-line:no-any
[key: string]: (...args: any[]) => any;
};
}

View file

@ -38,7 +38,6 @@ export class WorkflowHooks {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
async executeHookFunctions(hookName: string, parameters: any[]) {
// tslint:disable-line:no-any
if (this.hookFunctions[hookName] !== undefined && Array.isArray(this.hookFunctions[hookName])) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, no-restricted-syntax
for (const hookFunction of this.hookFunctions[hookName]!) {

File diff suppressed because it is too large Load diff