refactor: Setup typescript project references across workflow, core, and cli (#4519)

* refactor: use consistent folder structure across workflow, core, and cli

* setup typescript project references across workflow, core, and cli
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2022-11-09 15:25:00 +01:00
committed by GitHub
parent de96def372
commit 698d96a617
251 changed files with 1284 additions and 1134 deletions

View File

@@ -1,4 +1,3 @@
/* eslint-disable import/no-cycle */
/* eslint-disable no-underscore-dangle */
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint-disable no-prototype-builtins */
@@ -34,18 +33,18 @@ import {
import glob from 'fast-glob';
import path from 'path';
import pick from 'lodash.pick';
import { IN8nNodePackageJson } from './Interfaces';
import { getLogger } from './Logger';
import config from '../config';
import { NodeTypes } from '.';
import { InstalledPackages } from './databases/entities/InstalledPackages';
import { InstalledNodes } from './databases/entities/InstalledNodes';
import { executeCommand, loadClassInIsolation } from './CommunityNodes/helpers';
import { RESPONSE_ERROR_MESSAGES } from './constants';
import { IN8nNodePackageJson } from '@/Interfaces';
import { getLogger } from '@/Logger';
import config from '@/config';
import { NodeTypes } from '@/NodeTypes';
import { InstalledPackages } from '@db/entities/InstalledPackages';
import { InstalledNodes } from '@db/entities/InstalledNodes';
import { executeCommand, loadClassInIsolation } from '@/CommunityNodes/helpers';
import { CLI_DIR, RESPONSE_ERROR_MESSAGES } from '@/constants';
import {
persistInstalledPackageData,
removePackageFromDatabase,
} from './CommunityNodes/packageModel';
} from '@/CommunityNodes/packageModel';
const CUSTOM_NODES_CATEGORY = 'Custom Nodes';
@@ -66,8 +65,6 @@ class LoadNodesAndCredentialsClass {
includeNodes: string | undefined = undefined;
nodeModulesPath = '';
logger: ILogger;
async init() {
@@ -80,13 +77,13 @@ class LoadNodesAndCredentialsClass {
// @ts-ignore
module.constructor._initPaths();
this.nodeModulesPath = await this.getNodeModulesFolderLocation();
const nodeModulesPath = await this.getNodeModulesFolderLocation();
this.excludeNodes = config.getEnv('nodes.exclude');
this.includeNodes = config.getEnv('nodes.include');
// Get all the installed packages which contain n8n nodes
const nodePackages = await this.getN8nNodePackages(this.nodeModulesPath);
const nodePackages = await this.getN8nNodePackages(nodeModulesPath);
for (const packagePath of nodePackages) {
await this.loadDataFromPackage(packagePath);
@@ -102,13 +99,13 @@ class LoadNodesAndCredentialsClass {
// to load the credentials and nodes
const checkPaths = [
// In case "n8n" package is in same node_modules folder.
path.join(__dirname, '..', '..', '..', 'n8n-workflow'),
path.join(CLI_DIR, '..', 'n8n-workflow'),
// In case "n8n" package is the root and the packages are
// in the "node_modules" folder underneath it.
path.join(__dirname, '..', '..', 'node_modules', 'n8n-workflow'),
path.join(CLI_DIR, 'node_modules', 'n8n-workflow'),
// In case "n8n" package is installed using npm/yarn workspaces
// the node_modules folder is in the root of the workspace.
path.join(__dirname, '..', '..', '..', '..', 'node_modules', 'n8n-workflow'),
path.join(CLI_DIR, '..', '..', 'node_modules', 'n8n-workflow'),
];
for (const checkPath of checkPaths) {
try {