Write a template
Template is the most significant concept. the processing is follows.
Get user's answers by
prompts
.Read
root
files, filter the files byignore
.Transform file content using Loader
- Rule one(top priority): matching the text from the file's first line.
// @loader ${LOADER_NAME}?${QUERY} /* @loader ${LOADER_NAME}?${QUERY} */ # @loader ${LOADER_NAME}?${QUERY} <!-- @loader ${LOADER_NAME}?${QUERY} -->
- Rule two(normal priority): matching loader from the
test
field ofmappers
.
Adjust files struction by
move
andcopy
.Trigger
usefulHook
thenpost
hooks
Note:The order of fields in package.json
is that edam:main
is superior to main
. (>=3.1)
Config
Allows exporting config object directly, or callable.
module.exports = { /*config*/ }
module.exports = edam => ({ /*config*/ })
process
edam >= 2.0.1
Returns the object which excludes prompts
.
- type:
function
Eg:
{
process(answer) {
return {
ignore: [],
root: 'anc'
}
}
}
prompts
User's interaction definition.
type:
[]
references to inquirer.js
root
Template files' root.
- type:
string
- default:
./template
ignore
Files' filter
type:
string[]
Or
answers => []
variables
type
{}
example
{ date: new Date(), val: 'abc' } // or (answers) => ({})
hooks
hooks: {
'post': ['touch Readme.md', function () { ... }]
}
loaders 和 mappers
Check out Write a loader
move
{
"package.json.js": "package.json",
"test/**": "tests/",
// special placeholder: [path] / [name] / [ext] / [base]
// eg. root/abc.js ->
// path: `root/`
// name: `abc`
// ext: `.js`
// base: `abc.js`
// root/a.js.hbs => root/a.js
"**/*.hbs": "[path][name]"
}
or (answers) => ({})
copy
like move
usefulHook
Some useful shortcuts of post
hook.
gitInit
git init
- type:
boolean
- default:
false
- type:
installDependencies
install dependencies of
package.json
- type:
boolean
- default:
false
- type:
installDevDependencies
install devDependencies of
package.json
- type:
boolean
- default:
false
- type:
或者 (answers) => ({})