inix
v1.4.2
Published
init whatever you want
Downloads
5
Maintainers
Readme
inix
initilize your project with someone boilerplate(X). X means anyone boilerplate, becuase x normally means a varibale in mathematics.
About
Everytime when you start a new project, firstly you will intilize the project by scaffold tool or some boilerplate. Now you just need to create your own boilerplate repo, then inix
will help you finish the rest things.
Installation
$ npm i -g inix
Getting Started
createilize your project with someone local template or remote git repo
$ inix create ~/demo/template
API
import { createApp } from "inix/dist/lib/commands/create";
createApp({
templatePath: "/Users/xxx/xxx/template",
data: { //data for template to render if any in terms of meta.js
},
});
Commands
inix create
You can create your project from local template.
$ inix create <target>
The directory structure of template should be like:
- root
- template
- meta.js
For example, if the path of your template is ~/inix/root, then you can run:
$ inix create ~/inix/root
By default, it will show all existing boilerplates that you can use when you run:
$ inix create
inix config
Config the template records which could be used to create new project by inix create
use local path to setup template records
$ inix config ~/demo/template.json
or use a remote config file by url
$ inix config http://xxx.xxx.com/path/template.json
inix add
Add new boilerplate into your template list, then you can use it when you run inix create
$ inix add
It will let you input some properties about the new boilerplate, like name, description and boilerplate location(local path or git repo). If it is a git repo, you could input the branch name as well.
inix del
Delete some boilerplate from the existing selections. After you run the command, it will show all existing selections which you can delete.
$ inix del
inix ls
Display all boilerplates you already have.
Boilerplate Definition
directory structure of boilerplate. See example.
- template
- mata.js (optional)
In meta.js, you can setup questions wrote by inquirer. Then you can use these answers in your template files rendered by handlebars. As well, if you want to do something after project initilization, you can use endCallback
in your meta.js to do whatever you want.
Here is example about meta.js
//meta.js
module.exports = {
questions: [{
{
type: 'input',
name: 'description'
},
{
type: 'input',
name: 'serviceName',
message: 'need service name',
validate: function (val) {
if (!val) {
return "service name required"
} else {
return true;
}
}
},
}],
endCallback: function(metaData, {chalk, logger, files}) {
//you can visit all answers from metaData.answers
//files are that all in your boilerplate
//do sth
}
}