From 260990cf6257ffa7ae8c0049dabfba01239eae11 Mon Sep 17 00:00:00 2001 From: Philipe Navarro Date: Tue, 2 Oct 2018 16:18:07 -0600 Subject: [PATCH 1/7] fix: nested plugin types --- src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 2e27a2a4..0a4e9480 100644 --- a/src/config.ts +++ b/src/config.ts @@ -433,7 +433,7 @@ export class Config implements IConfig { await instance.load() if (this.plugins.find(p => p.name === instance.name)) return this.plugins.push(instance) - await this.loadPlugins(instance.root, type, instance.pjson.oclif.plugins || []) + await this.loadPlugins(instance.root, opts.name!, instance.pjson.oclif.plugins || []) } catch (err) { this.warn(err, 'loadPlugins') } From 8b01da5373eccfdae89aaa4de072af5cb88d7df9 Mon Sep 17 00:00:00 2001 From: Philipe Navarro Date: Tue, 2 Oct 2018 16:24:06 -0600 Subject: [PATCH 2/7] fix: nested plugin types --- src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 0a4e9480..fa874f62 100644 --- a/src/config.ts +++ b/src/config.ts @@ -433,7 +433,7 @@ export class Config implements IConfig { await instance.load() if (this.plugins.find(p => p.name === instance.name)) return this.plugins.push(instance) - await this.loadPlugins(instance.root, opts.name!, instance.pjson.oclif.plugins || []) + await this.loadPlugins(instance.root, instance.name, instance.pjson.oclif.plugins || []) } catch (err) { this.warn(err, 'loadPlugins') } From 9a403a4e930ebdf1fb7fc4ca6bbd45190d965f04 Mon Sep 17 00:00:00 2001 From: Philipe Navarro Date: Tue, 2 Oct 2018 16:47:42 -0600 Subject: [PATCH 3/7] fix: nested plugin types --- src/config.ts | 6 +++--- src/plugin.ts | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/config.ts b/src/config.ts index fa874f62..36e764b7 100644 --- a/src/config.ts +++ b/src/config.ts @@ -416,12 +416,12 @@ export class Config implements IConfig { } catch {} return 0 } - protected async loadPlugins(root: string, type: string, plugins: (string | {root?: string, name?: string, tag?: string})[]) { + protected async loadPlugins(root: string, type: string, plugins: (string | {root?: string, name?: string, tag?: string})[], parent: Plugin.IPlugin | undefined) { if (!plugins || !plugins.length) return debug('loading plugins', plugins) await Promise.all((plugins || []).map(async plugin => { try { - let opts: Options = {type, root} + let opts: Options = {type, root, parent} if (typeof plugin === 'string') { opts.name = plugin } else { @@ -433,7 +433,7 @@ export class Config implements IConfig { await instance.load() if (this.plugins.find(p => p.name === instance.name)) return this.plugins.push(instance) - await this.loadPlugins(instance.root, instance.name, instance.pjson.oclif.plugins || []) + await this.loadPlugins(instance.root, type, instance.pjson.oclif.plugins || [], instance) } catch (err) { this.warn(err, 'loadPlugins') } diff --git a/src/plugin.ts b/src/plugin.ts index 30c3f949..c1f3b21f 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -18,6 +18,7 @@ export interface Options { tag?: string ignoreManifest?: boolean, errorOnManifestCreate?: boolean + parent: IPlugin | undefined } export interface IPlugin { @@ -86,6 +87,7 @@ export class Plugin implements IPlugin { hooks!: {[k: string]: string[]} valid = false alreadyLoaded = false + parent: IPlugin | undefined protected _debug = Debug() protected warned = false From 55b31c59fb68c386ef11fe5ae019c531218bd9ec Mon Sep 17 00:00:00 2001 From: Philipe Navarro Date: Tue, 2 Oct 2018 16:54:31 -0600 Subject: [PATCH 4/7] linter --- src/config.ts | 2 +- src/plugin.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config.ts b/src/config.ts index 36e764b7..4057815b 100644 --- a/src/config.ts +++ b/src/config.ts @@ -416,7 +416,7 @@ export class Config implements IConfig { } catch {} return 0 } - protected async loadPlugins(root: string, type: string, plugins: (string | {root?: string, name?: string, tag?: string})[], parent: Plugin.IPlugin | undefined) { + protected async loadPlugins(root: string, type: string, plugins: (string | {root?: string, name?: string, tag?: string})[], parent?: Plugin.IPlugin) { if (!plugins || !plugins.length) return debug('loading plugins', plugins) await Promise.all((plugins || []).map(async plugin => { diff --git a/src/plugin.ts b/src/plugin.ts index c1f3b21f..4870c49c 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -18,7 +18,7 @@ export interface Options { tag?: string ignoreManifest?: boolean, errorOnManifestCreate?: boolean - parent: IPlugin | undefined + parent?: IPlugin | undefined } export interface IPlugin { From d658c7093d7ef26aafd9838648320809600fec02 Mon Sep 17 00:00:00 2001 From: Philipe Navarro Date: Tue, 2 Oct 2018 16:57:06 -0600 Subject: [PATCH 5/7] updates --- src/plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin.ts b/src/plugin.ts index 4870c49c..e0432187 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -18,7 +18,7 @@ export interface Options { tag?: string ignoreManifest?: boolean, errorOnManifestCreate?: boolean - parent?: IPlugin | undefined + parent?: IPlugin } export interface IPlugin { From bad18b41dfb2287e87636891974e66859f1de727 Mon Sep 17 00:00:00 2001 From: Philipe Navarro Date: Thu, 4 Oct 2018 10:44:24 -0600 Subject: [PATCH 6/7] use children --- src/config.ts | 5 +++-- src/plugin.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/config.ts b/src/config.ts index 4057815b..ce7af2a1 100644 --- a/src/config.ts +++ b/src/config.ts @@ -416,12 +416,12 @@ export class Config implements IConfig { } catch {} return 0 } - protected async loadPlugins(root: string, type: string, plugins: (string | {root?: string, name?: string, tag?: string})[], parent?: Plugin.IPlugin) { + protected async loadPlugins(root: string, type: string, plugins: (string | {root?: string, name?: string, tag?: string})[], parent?: Plugin.Plugin) { if (!plugins || !plugins.length) return debug('loading plugins', plugins) await Promise.all((plugins || []).map(async plugin => { try { - let opts: Options = {type, root, parent} + let opts: Options = {type, root} if (typeof plugin === 'string') { opts.name = plugin } else { @@ -433,6 +433,7 @@ export class Config implements IConfig { await instance.load() if (this.plugins.find(p => p.name === instance.name)) return this.plugins.push(instance) + if (parent) parent.children.push(instance) await this.loadPlugins(instance.root, type, instance.pjson.oclif.plugins || [], instance) } catch (err) { this.warn(err, 'loadPlugins') diff --git a/src/plugin.ts b/src/plugin.ts index e0432187..b5c746f1 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -18,7 +18,7 @@ export interface Options { tag?: string ignoreManifest?: boolean, errorOnManifestCreate?: boolean - parent?: IPlugin + children?: Plugin[] } export interface IPlugin { @@ -87,7 +87,7 @@ export class Plugin implements IPlugin { hooks!: {[k: string]: string[]} valid = false alreadyLoaded = false - parent: IPlugin | undefined + children: Plugin[] = [] protected _debug = Debug() protected warned = false From a7ba66d44bb5177598a17799f2421a64fe599fcb Mon Sep 17 00:00:00 2001 From: Philipe Navarro Date: Tue, 9 Oct 2018 17:29:10 -0700 Subject: [PATCH 7/7] add parent --- src/config.ts | 5 ++++- src/plugin.ts | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index ce7af2a1..152ed02a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -433,7 +433,10 @@ export class Config implements IConfig { await instance.load() if (this.plugins.find(p => p.name === instance.name)) return this.plugins.push(instance) - if (parent) parent.children.push(instance) + if (parent) { + instance.parent = parent + parent.children.push(instance) + } await this.loadPlugins(instance.root, type, instance.pjson.oclif.plugins || [], instance) } catch (err) { this.warn(err, 'loadPlugins') diff --git a/src/plugin.ts b/src/plugin.ts index b5c746f1..492a9a41 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -18,6 +18,7 @@ export interface Options { tag?: string ignoreManifest?: boolean, errorOnManifestCreate?: boolean + parent?: Plugin children?: Plugin[] } @@ -87,6 +88,7 @@ export class Plugin implements IPlugin { hooks!: {[k: string]: string[]} valid = false alreadyLoaded = false + parent: Plugin | undefined children: Plugin[] = [] protected _debug = Debug() protected warned = false