feat(core): Live reload node/credential descriptions in development (no-changelog) (#4939)

This commit is contained in:
Valya
2023-02-08 18:26:07 +00:00
committed by GitHub
parent f23fb92696
commit 9c1f827dad
10 changed files with 134 additions and 155 deletions

View File

@@ -32,15 +32,17 @@ export type Types = {
};
export abstract class DirectoryLoader {
readonly loadedNodes: INodeTypeNameVersion[] = [];
isLazyLoaded = false;
readonly nodeTypes: INodeTypeData = {};
loadedNodes: INodeTypeNameVersion[] = [];
readonly credentialTypes: ICredentialTypeData = {};
nodeTypes: INodeTypeData = {};
readonly known: KnownNodesAndCredentials = { nodes: {}, credentials: {} };
credentialTypes: ICredentialTypeData = {};
readonly types: Types = { nodes: [], credentials: [] };
known: KnownNodesAndCredentials = { nodes: {}, credentials: {} };
types: Types = { nodes: [], credentials: [] };
constructor(
protected readonly directory: string,
@@ -49,8 +51,17 @@ export abstract class DirectoryLoader {
) {}
abstract packageName: string;
abstract loadAll(): Promise<void>;
reset() {
this.loadedNodes = [];
this.nodeTypes = {};
this.credentialTypes = {};
this.known = { nodes: {}, credentials: {} };
this.types = { nodes: [], credentials: [] };
}
protected resolvePath(file: string) {
return path.resolve(this.directory, file);
}
@@ -371,6 +382,8 @@ export class LazyPackageDirectoryLoader extends PackageDirectoryLoader {
nodes: this.types.nodes?.length ?? 0,
});
this.isLazyLoaded = true;
return; // We can load nodes and credentials lazily now
} catch {
Logger.debug("Can't enable lazy-loading");