mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor: Migrate nodes build system to tsup (no-changelog) (#14192)
This commit is contained in:
@@ -5,14 +5,15 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"clean": "rimraf dist .turbo",
|
||||
"copy-nodes-json": "node scripts/copy-nodes-json.js .",
|
||||
"dev": "pnpm watch",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && pnpm n8n-copy-static-files && pnpm n8n-generate-translations && pnpm n8n-generate-metadata",
|
||||
"build": "tsup --tsconfig tsconfig.build.json && pnpm copy-nodes-json && tsc-alias -p tsconfig.build.json && pnpm n8n-copy-static-files && pnpm n8n-generate-translations && pnpm n8n-generate-metadata",
|
||||
"format": "biome format --write .",
|
||||
"format:check": "biome ci .",
|
||||
"lint": "eslint nodes credentials utils test --quiet && node ./scripts/validate-load-options-methods.js",
|
||||
"lintfix": "eslint nodes credentials utils test --fix",
|
||||
"watch": "tsc-watch -p tsconfig.build.json --onCompilationComplete \"tsc-alias -p tsconfig.build.json\" --onSuccess \"pnpm n8n-generate-metadata\"",
|
||||
"watch": "tsup --watch --tsconfig tsconfig.build.json --onSuccess \"pnpm copy-nodes-json && tsc-alias -p tsconfig.build.json && pnpm n8n-generate-metadata\"",
|
||||
"test": "jest"
|
||||
},
|
||||
"files": [
|
||||
|
||||
12
packages/nodes-base/scripts/copy-nodes-json.js
Normal file
12
packages/nodes-base/scripts/copy-nodes-json.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const glob = require('fast-glob');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function copyJsonFiles(baseDir) {
|
||||
const files = glob.sync('nodes/**/*.node.json', { cwd: baseDir });
|
||||
for (const file of files) {
|
||||
fs.copyFileSync(path.resolve(baseDir, file), path.resolve(baseDir, 'dist', file));
|
||||
}
|
||||
}
|
||||
|
||||
copyJsonFiles(process.argv[2]);
|
||||
@@ -6,10 +6,11 @@
|
||||
},
|
||||
"include": [
|
||||
"credentials/**/*.ts",
|
||||
"credentials/translations/**/*.json",
|
||||
"nodes/**/*.ts",
|
||||
"nodes/**/*.json",
|
||||
"credentials/translations/**/*.json",
|
||||
"types/**/*.ts"
|
||||
"types/**/*.ts",
|
||||
"utils/**/*.ts"
|
||||
],
|
||||
"exclude": ["nodes/**/*.test.ts", "credentials/**/*.test.ts", "test/**"]
|
||||
"exclude": ["nodes/**/*.test.ts", "credentials/**/*.test.ts", "utils/**/*.test.ts", "test/**"]
|
||||
}
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
"include": [
|
||||
"credentials/**/*.ts",
|
||||
"nodes/**/*.ts",
|
||||
"nodes/**/*.json",
|
||||
"test/**/*.ts",
|
||||
"utils/**/*.ts",
|
||||
"types/**/*.ts"
|
||||
"types/**/*.ts",
|
||||
"utils/**/*.ts"
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../@n8n/imap/tsconfig.build.json" },
|
||||
|
||||
53
packages/nodes-base/tsup.config.ts
Normal file
53
packages/nodes-base/tsup.config.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { defineConfig } from 'tsup';
|
||||
import glob from 'fast-glob';
|
||||
import { resolve } from 'path';
|
||||
import { readFile } from 'fs/promises';
|
||||
|
||||
const packagesDir = resolve(__dirname, '..');
|
||||
const aiNodesDir = resolve(packagesDir, '@n8n', 'nodes-langchain');
|
||||
|
||||
const aiNodesFiles = await glob('nodes/**/*.ts', { cwd: aiNodesDir });
|
||||
const aiNodesFilesContents = aiNodesFiles.map((filePath) =>
|
||||
readFile(resolve(aiNodesDir, filePath), 'utf-8'),
|
||||
);
|
||||
|
||||
// Files used in @n8n/nodes-langchain package
|
||||
const aiNodesPackageImports = (await Promise.all(aiNodesFilesContents)).reduce(
|
||||
(acc, fileContents) => {
|
||||
const regex = /from\s+['"](n8n-nodes-base[^'"]+)['"]/g;
|
||||
let match;
|
||||
while ((match = regex.exec(fileContents)) !== null) {
|
||||
acc.add(match[1]);
|
||||
}
|
||||
|
||||
return acc;
|
||||
},
|
||||
new Set<string>(),
|
||||
);
|
||||
|
||||
const aiNodesPackageDependencies = Array.from(aiNodesPackageImports).map(
|
||||
(i) => i.replace('n8n-nodes-base/dist/', '') + '.ts',
|
||||
);
|
||||
|
||||
const commonIgnoredFiles = ['!**/*.d.ts', '!**/*.test.ts'];
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default defineConfig([
|
||||
{
|
||||
entry: [
|
||||
'{credentials,nodes,test,types,utils}/**/*.ts',
|
||||
...commonIgnoredFiles,
|
||||
...aiNodesPackageDependencies.map((path) => `!${path}`),
|
||||
],
|
||||
format: ['cjs'],
|
||||
dts: false,
|
||||
bundle: false,
|
||||
},
|
||||
{
|
||||
entry: [...aiNodesPackageDependencies, ...commonIgnoredFiles],
|
||||
format: ['cjs'],
|
||||
dts: true,
|
||||
bundle: false,
|
||||
},
|
||||
]);
|
||||
Reference in New Issue
Block a user