refactor: Accumulate loadOptions from all node versions to validate (no-changelog) (#6014)

 Accumulate loadOptions from node versions to validate
This commit is contained in:
Iván Ovejero 2023-04-20 16:21:07 +02:00 committed by GitHub
parent 723f81bab0
commit 9b651cf4f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 9 deletions

View file

@ -31,7 +31,7 @@ function findReferencedMethods(obj, refs = {}, latestName = '') {
(async () => {
const loader = new PackageDirectoryLoader(packageDir);
await loader.loadAll({ withLoadOptionsMethods: true });
await loader.loadAll();
const credentialTypes = Object.values(loader.credentialTypes).map((data) => data.type);
@ -45,7 +45,12 @@ function findReferencedMethods(obj, refs = {}, latestName = '') {
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;

View file

@ -44,8 +44,6 @@ export abstract class DirectoryLoader {
types: Types = { nodes: [], credentials: [] };
withLoadOptionsMethods = false; // only for validation during build
constructor(
readonly directory: string,
protected readonly excludeNodes: string[] = [],
@ -102,10 +100,13 @@ export abstract class DirectoryLoader {
this.fixIconPath(versionNode.description, filePath);
}
for (const version of Object.values(tempNode.nodeVersions)) {
this.addLoadOptionsMethods(version);
}
const currentVersionNode = tempNode.nodeVersions[tempNode.currentVersion];
this.addCodex({ node: currentVersionNode, filePath, isCustom });
nodeVersion = tempNode.currentVersion;
if (this.withLoadOptionsMethods) this.addLoadOptionsMethods(currentVersionNode);
if (currentVersionNode.hasOwnProperty('executeSingle')) {
Logger.warn(
@ -114,7 +115,7 @@ export abstract class DirectoryLoader {
);
}
} else {
if (this.withLoadOptionsMethods) this.addLoadOptionsMethods(tempNode);
this.addLoadOptionsMethods(tempNode);
// Short renaming to avoid type issues
nodeVersion = Array.isArray(tempNode.description.version)
@ -306,9 +307,7 @@ export class PackageDirectoryLoader extends DirectoryLoader {
this.packageName = this.packageJson.name;
}
override async loadAll(options = { withLoadOptionsMethods: false }) {
this.withLoadOptionsMethods = options.withLoadOptionsMethods;
override async loadAll() {
await this.readPackageJson();
const { n8n } = this.packageJson;