The name of lubjs comes from Lu Ban, a Chinese structural engineer, inventor, and carpenter during the Zhou Dynasty, also revered as the Chinese god (patron) of builders and contractors.
- simple config , out of the box - by creating
.lubrc,.lubrc.jsonor.lubrc.jsin your project and declare plugins, you can use others' cli command as well as boilerplate - OO Design, develop your own plugin quickly - Define your command class by appointment and export it, you just make it.
- abundant async/async function utils -
lubjsprovides you with many useful utils which you can use when developing your plugins. - integratable and extendable - by declare multiple plugins you just integrate these commands if these plugins alse requires other plugins in config file, the project also own them.
- support promise (async/await) and generator
npm install lub --save
# use:
npx lub <subcommand>or
npm install lub -g
# use:
lub <subcommand>The order lubjs read from your project is: .lubrc.js > .lubrc.json > .lubrc
A typical lubrc config looks like this:
// .lubrc or .lubrc.json
{
"plugins": [
"lub-plugin-publish" // plugin - npm package name
],
"lub-plugin-publish":{ // config will passed to plugin
"foo": "bar"
},
// it will change lub-plugin-publish plugin's subcommand `dev` to `bar-dev`
// in case of two plugins have the same subcommand name
// after set alias just use `lub bar-dev`
"alias": {
"lub-plugin-bar": {
"dev": "bar-dev"
}
},
// if you want do some tasks before or after some subcommand, you can define your tasks
"task": {
// `publish` subcommand from `lub-plugin-publish` plugin,
"publish": [
{
"command": "sh ./scripts/deploy.sh", // the command to exec
"order": "after", // exec the command after `lub publish`
"async": true // exec the command asyncly
}
]
}
}You can also export your config in .lubrc.js.
// .lubrc.js
module.exports = {
"plugins": [
"lub-plugin-publish" // plugin - npm package name
],
"lub-plugin-publish":{ // config will passed to plugin
"foo": "bar"
},
// it will change lub-plugin-publish plugin's subcommand `dev` to `bar-dev`
// in case of two plugins have the same subcommand name
// after set alias just use `lub bar-dev`
"alias": {
"lub-plugin-bar": {
"dev": "bar-dev"
}
},
// if you want do some tasks before or after some subcommand, you can define your tasks
"task": {
// `publish` subcommand from `lub-plugin-publish` plugin,
"publish": [
{
"command": "sh ./scripts/deploy.sh", // the command to exec
"order": "after", // exec the command after `lub publish`
"async": true // exec the command asyncly
}
]
}
}When in a empty project, it's quit useful to exec lub init <pluginName>.
It will:
- run
npm install <pluginName> --save-devinstall the plugin - exec the init command of that plugin
Also supports extra optional argvs
- --client, -c: replace npm client with yours like: tnpm, yarn, cnpm
- default: 'npm'
- --registry, -r: replace the npm registry
- default: 'https://registry.npmjs.org'
Want to know the version of lubjs? lub -v
0.1.3Want to know plugin subcommand's version like publish? lub publish -v
Notice: If subcommand doesn't set its version , lub will use
lub-coreversion.
Want to know current project supports what subcomands? just use lub -h lub --help.
Usage: lub <subCommand>
Commands:
lub publish Generate changelog, publish to npm and push to git
Global Options:
-h, --help Show help [boolean]
-v, --version Show version number [boolean]Want to know the usage of lub publish? try lub publish -h.
Usage: lub publish [major | minor | patch | version]
Global Options:
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Options:
--registry, -r set npm's registry [string] [default: "https://registry.npmjs.org"]
--filename, -f changelog file name [string] [default: "CHANGELOG"]
--client, -c npm client [string] [default: "npm"]
--npm, -n whether to publish to npm [boolean] [default: true]After list subcommands by lub -h, use lub <subCommand> to exec subcommands
Notice: If tasks are defined in config file, they will also be executed.
Benefit from lub-command package's OO Design Pattern, it's quite simple and quick to develop your own plugin and subcommands, see here.
And a real world example: lub-plugin-publish
If your have some wondeful plugins and utils, pull requests are welcomed in this github group.