This library was created to facilitate the following tasks when creating a generator with Yeoman:
- Confirmation:
- Can ask for confirmation before proceeding in one line.
easily.confirmBeforeStart(message)
easily.checkForConfirmation()
simply returns the result.
- Can ask for confirmation before proceeding in one line.
- Prompting:
- Handle storing user's input from the prompts into
this.props
. Just calleasily.prompt(prompts)
instead of thethis.prompt(prompts, ...)
- Can automatically skip prompts if an option with the same name is present. It will instead copy the value of existing
this.option[field]
intothis.props[field]
. - Can register common prompts via
easily.learnPrompts(prompts)
and allow looking up prompts by name while callingeasily.prompt()
. This can save a lot of time if you create multiple generators that ask similar questions.
- Handle storing user's input from the prompts into
- Composing: with another generator, either local or external
- Simplify the syntax to
easily.composeWithLocal(name, namespace, options)
andeasily.composeWithExternal(package, namespace, options)
- Simplify the syntax to
- File handling:
- Provide functions for mass copying both static and dynamic files based on glob pattern. See
easily.copyFiles(...)
- Provide I/O functions that wraps
this.fs.xxx
and also resolve template and destination directory.
- Provide functions for mass copying both static and dynamic files based on glob pattern. See
- Method chaining: yeoman-easily was created with chaining in mind and support method chaining for fluent coding.
Installation
$ npm install --save yeoman-easily
Example Usage
'use strict'; var ye = ;var Easily = yeEasily;var commonPrompts = yeprompts;var chalk = ; moduleexports = Easily;
More resources
- See full API documentation
- An example generator that uses yeoman-easily heavily is generator-summon
- For convenience, you can use generator-easily instead of the standard generator-generator to create a new generator or subgenerator. The created generator/subgenerator will include code for using yeoman-easily by default.
License
Apache-2.0 © Krist Wongsuphasawat