From 7aed2616863fcb6c612130493d880b2fd1305617 Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdxcode@users.noreply.github.com> Date: Tue, 6 Feb 2018 13:56:24 -0800 Subject: [PATCH] fix: add missing topics --- package.json | 8 ++++---- src/plugin.ts | 17 +++++++++++++++++ yarn.lock | 24 ++++++++++++++---------- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 70c4871c..badbfeb0 100644 --- a/package.json +++ b/package.json @@ -6,14 +6,14 @@ "bugs": "https://github.com/anycli/config/issues", "dependencies": {}, "devDependencies": { - "@anycli/errors": "^0.2.0", - "@anycli/parser": "^3.2.5", - "@anycli/tslint": "^0.2.6", + "@anycli/errors": "^0.2.1", + "@anycli/parser": "^3.2.6", + "@anycli/tslint": "^0.2.7", "@types/chai": "^4.1.2", "@types/globby": "^6.1.0", "@types/indent-string": "^3.0.0", "@types/mocha": "^2.2.48", - "@types/node": "^9.4.0", + "@types/node": "^9.4.1", "@types/wrap-ansi": "^2.0.14", "chai": "^4.1.2", "concurrently": "^3.5.1", diff --git a/src/plugin.ts b/src/plugin.ts index ccb2b300..2eed3280 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -122,6 +122,7 @@ export class Plugin implements IPlugin { this.manifest = this._manifest(!!opts.ignoreManifest) this.loadPlugins(this.root, this.pjson.anycli.plugins || []) + this.addMissingTopics() } get commandsDir() { @@ -131,6 +132,13 @@ export class Plugin implements IPlugin { get topics() { let topics = [...this._topics] for (let plugin of this.plugins) { + for (let topic of plugin.topics) { + let existing = topics.find(t => t.name === t.name) + if (existing) { + existing.description = topic.description || existing.description + existing.hidden = topic.hidden === undefined ? existing.hidden : topic.hidden + } else topics.push(topic) + } topics = [...topics, ...plugin.topics] } return topics @@ -323,6 +331,15 @@ export class Plugin implements IPlugin { err.detail = compact([err.detail, `module: ${this._base}`, scope && `task: ${scope}`, `plugin: ${this.name}`, `root: ${this.root}`]).join('\n') process.emitWarning(err) } + + protected addMissingTopics() { + for (let c of this.commands.filter(c => !c.hidden)) { + let name = c.id.split(':').slice(0, -1).join(':') + if (name && !this._topics.find(t => t.name === name)) { + this._topics.push({name}) + } + } + } } function topicsToArray(input: any, base?: string): Topic[] { diff --git a/yarn.lock b/yarn.lock index f020a7b2..8b9933e1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,9 +2,9 @@ # yarn lockfile v1 -"@anycli/errors@^0.2.0": - version "0.2.0" - resolved "https://registry.yarnpkg.com/@anycli/errors/-/errors-0.2.0.tgz#ee421115dcdb499d76de9d4853718c06e1c5d5f0" +"@anycli/errors@^0.2.1": + version "0.2.1" + resolved "https://registry.yarnpkg.com/@anycli/errors/-/errors-0.2.1.tgz#719a95cd9c23838c65929da5d625a7537dd7d035" dependencies: clean-stack "^1.3.0" fs-extra "^5.0.0" @@ -12,13 +12,13 @@ strip-ansi "^4.0.0" wrap-ansi "^3.0.1" -"@anycli/parser@^3.2.5": - version "3.2.5" - resolved "https://registry.yarnpkg.com/@anycli/parser/-/parser-3.2.5.tgz#d0e7ddb14945cb84377fa69095009ca6005e6b6d" +"@anycli/parser@^3.2.6": + version "3.2.6" + resolved "https://registry.yarnpkg.com/@anycli/parser/-/parser-3.2.6.tgz#bbd119a80709099179a9f11af0dc44b68c54575b" -"@anycli/tslint@^0.2.6": - version "0.2.6" - resolved "https://registry.yarnpkg.com/@anycli/tslint/-/tslint-0.2.6.tgz#4251f4cb3744dc577309b4351d2c2e8b65072de2" +"@anycli/tslint@^0.2.7": + version "0.2.7" + resolved "https://registry.yarnpkg.com/@anycli/tslint/-/tslint-0.2.7.tgz#68b81121f33e9aa8240bd12cfade1f6023e6820d" dependencies: tslint "^5.9.1" tslint-xo "^0.6.0" @@ -57,10 +57,14 @@ version "2.2.48" resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.48.tgz#3523b126a0b049482e1c3c11877460f76622ffab" -"@types/node@*", "@types/node@^9.4.0": +"@types/node@*": version "9.4.0" resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.0.tgz#b85a0bcf1e1cc84eb4901b7e96966aedc6f078d1" +"@types/node@^9.4.1": + version "9.4.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.1.tgz#0f636f7837e15d2d73a7f6f3ea0e322eb2a5ab65" + "@types/strip-bom@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2"