generator-fish v0.9.2
generator-fish

AKFish's generator
Installation
First, install Yeoman and generator-fish using npm (we assume you have pre-installed node.js).
npm install -g yo
npm install -g generator-fishThen generate your new project:
yo fishUsage
In your project folder, run:
yo fishThen follow the instructions.
Select tasks via CLI argument:
yo fish --coffee --mochaOr run in standalone mode:
yo fish:coffeeSupported gulp tasks:
- coffee
- mocha
- es6(babel)
- browserify
- watch
- clean
- copy
(Optional) You can override configurations with CLI arguments passed to gulp command.
Run:
yo fish:cliTo configure CLI mapping.
Getting To Know Yeoman
Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced. Feel free to learn more about him.
Development
Add New Task
Run the internal fish:fish generator in generator-fish project folder:
yo fish:fishModify the generated generators/#new#/index.js
'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var Fish = require('../../lib/base');
module.exports = Fish.buildTask('coffee', ['gulp-coffee'],
{
defaultSrc: "./coffee/**/*.coffee",
defaultDst: "./lib",
ignoreSrc: false, // toggle `src` question
ignoreDst: false, // toggle `dst` question
supportSourceMap: true, // toggle `sourceMap` question
questions: [
{
type: 'confirm',
name: 'bare',
message: '--bare',
default: true
},
]
},
{
// TODO: custom prototype methods
});When running, the prompts will generate props in its 'flatten' form:
{
src: '',
dst: '',
// other fields
}When stored to gulpconfig.json under the task's namespace, fields other than generic and private ones will be moved to opts field.
{
src: '',
dst: '',
// other fields
opts: {
// other fields
}
}The opts field will be used as gulp plugin options.
Notes:
- Generic questions will be asked before custom questions:
taskNamesrc, toggled byignoreSrcdst, toggled byignoreDstsourceMap, toggled bysupportSourceMap
- Questions with
_as prefix in their names are private. - Special custom prototype methods:
_doPrompt- called right afterthis.propsis set but before it's stored togulpconfig_doWriting- called aftergulpfile.coffee,gulpconfig.jsonand task templates are written_doInstall- called afterfish:appand task's dependencies are installed
Modify the generated generators/#new#/templates/task.coffee
A typical task.coffee should be like this:
# require dependencies
module.exports = (profile = 'default') ->
cfg = config["name:#{profile}"]
# gulp.task- It's a template file with
this.propsas its parameters - It should expose a function that takes
profilename as the only option - Following objects are exposed to global in
gulpfile.coffee:gulpheap-gulp-heapconfig- all configurations
- Task specific configurations are stored in
config[name:profile]
License
MIT © akfish