From b129bfcfe73f7966c52db0b5d3057db265e9933b Mon Sep 17 00:00:00 2001 From: EGOIST <0x142857@gmail.com> Date: Thu, 10 Jan 2019 00:41:36 +0800 Subject: [PATCH] feat: display generator description --- docs/config.md | 6 ++++++ lib/Generator.js | 4 ++++ lib/validateConfig.js | 1 + 3 files changed, 11 insertions(+) diff --git a/docs/config.md b/docs/config.md index c7924ca..c7bfe9c 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1,5 +1,11 @@ # Config +## config.description + +- Type: `string` + +Generator description. + ## config.prompts - Type: `Array | (this: Generator) => Array` diff --git a/lib/Generator.js b/lib/Generator.js index c45ec1c..c7d2bf2 100644 --- a/lib/Generator.js +++ b/lib/Generator.js @@ -156,6 +156,10 @@ module.exports = class Generator { const config = validateConfig(this.config, opts.extendConfigSchema) + if (config.description) { + logger.status('green', 'Generator', config.description) + } + if (config.prepare) { await config.prepare.call(this, this) } diff --git a/lib/validateConfig.js b/lib/validateConfig.js index f9ab0b4..8462284 100644 --- a/lib/validateConfig.js +++ b/lib/validateConfig.js @@ -4,6 +4,7 @@ const KopyError = require('./KopyError') module.exports = (config, extendConfigSchema) => { // TODO: improve prompts and actions validation const schema = { + description: struct.optional('string'), prepare: struct.optional('function'), prompts: struct.optional(struct.union(['array', 'function'])), actions: struct.optional(struct.union(['array', 'function'])),