mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 05:17:28 -08:00
refactor: Accumulate loadOptions
from all node versions to validate (no-changelog) (#6014)
⚡ Accumulate loadOptions from node versions to validate
This commit is contained in:
parent
723f81bab0
commit
9b651cf4f8
|
@ -31,7 +31,7 @@ function findReferencedMethods(obj, refs = {}, latestName = '') {
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const loader = new PackageDirectoryLoader(packageDir);
|
const loader = new PackageDirectoryLoader(packageDir);
|
||||||
await loader.loadAll({ withLoadOptionsMethods: true });
|
await loader.loadAll();
|
||||||
|
|
||||||
const credentialTypes = Object.values(loader.credentialTypes).map((data) => data.type);
|
const credentialTypes = Object.values(loader.credentialTypes).map((data) => data.type);
|
||||||
|
|
||||||
|
@ -45,7 +45,12 @@ function findReferencedMethods(obj, refs = {}, latestName = '') {
|
||||||
|
|
||||||
const { name } = type.description;
|
const { name } = type.description;
|
||||||
|
|
||||||
acc[name] = acc[name] ? acc[name].push(methods) : methods;
|
if (acc[name]) {
|
||||||
|
acc[name] = [...new Set([...acc[name], ...methods])];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
acc[name] = methods;
|
||||||
});
|
});
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
|
|
|
@ -44,8 +44,6 @@ export abstract class DirectoryLoader {
|
||||||
|
|
||||||
types: Types = { nodes: [], credentials: [] };
|
types: Types = { nodes: [], credentials: [] };
|
||||||
|
|
||||||
withLoadOptionsMethods = false; // only for validation during build
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
readonly directory: string,
|
readonly directory: string,
|
||||||
protected readonly excludeNodes: string[] = [],
|
protected readonly excludeNodes: string[] = [],
|
||||||
|
@ -102,10 +100,13 @@ export abstract class DirectoryLoader {
|
||||||
this.fixIconPath(versionNode.description, filePath);
|
this.fixIconPath(versionNode.description, filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const version of Object.values(tempNode.nodeVersions)) {
|
||||||
|
this.addLoadOptionsMethods(version);
|
||||||
|
}
|
||||||
|
|
||||||
const currentVersionNode = tempNode.nodeVersions[tempNode.currentVersion];
|
const currentVersionNode = tempNode.nodeVersions[tempNode.currentVersion];
|
||||||
this.addCodex({ node: currentVersionNode, filePath, isCustom });
|
this.addCodex({ node: currentVersionNode, filePath, isCustom });
|
||||||
nodeVersion = tempNode.currentVersion;
|
nodeVersion = tempNode.currentVersion;
|
||||||
if (this.withLoadOptionsMethods) this.addLoadOptionsMethods(currentVersionNode);
|
|
||||||
|
|
||||||
if (currentVersionNode.hasOwnProperty('executeSingle')) {
|
if (currentVersionNode.hasOwnProperty('executeSingle')) {
|
||||||
Logger.warn(
|
Logger.warn(
|
||||||
|
@ -114,7 +115,7 @@ export abstract class DirectoryLoader {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.withLoadOptionsMethods) this.addLoadOptionsMethods(tempNode);
|
this.addLoadOptionsMethods(tempNode);
|
||||||
// Short renaming to avoid type issues
|
// Short renaming to avoid type issues
|
||||||
|
|
||||||
nodeVersion = Array.isArray(tempNode.description.version)
|
nodeVersion = Array.isArray(tempNode.description.version)
|
||||||
|
@ -306,9 +307,7 @@ export class PackageDirectoryLoader extends DirectoryLoader {
|
||||||
this.packageName = this.packageJson.name;
|
this.packageName = this.packageJson.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
override async loadAll(options = { withLoadOptionsMethods: false }) {
|
override async loadAll() {
|
||||||
this.withLoadOptionsMethods = options.withLoadOptionsMethods;
|
|
||||||
|
|
||||||
await this.readPackageJson();
|
await this.readPackageJson();
|
||||||
|
|
||||||
const { n8n } = this.packageJson;
|
const { n8n } = this.packageJson;
|
||||||
|
|
Loading…
Reference in a new issue