0.0.4 • Published 4 years ago
slax v0.0.4
Slax
Stop creating files/folders in your projects manually
Installation
- Install
slaxpackage from NPM
npm install -g slax
# or
yarn global add slax- Create a
slax.config.json:
slax init{
"templates": {}
}Creating templates
- Open
slax.config.jsonand create new template:
{
"templates": {
"feat": []
}
}- Add commands
{
"templates": {
"feat": [
{
"type": "mkdir",
"options": {
"path": "./src/features/%n%"
}
},
{
"type": "writeFile",
"options": {
"path": "./src/features/%n%/index.ts",
"content": [""]
}
}
]
}
}- Execute it by using
slax:
slax make feat -n myFeatureThis will
- Create folder
./src/features/myFeature - Create a file
./src/features/myFeature/index.tswith empty content
Custom parameters
As you have noticed, we passed -n parameter to inject it to the options
You can pass any options you can, and %optionName% in options field will be automatically injected
Commands list
mkdir - Create folder
{
"type": "mkdir",
"options": {
"path": "./src/features/%n%"
}
}writeFile - Create & Write to a File
{
"type": "writeFile",
"options": {
"path": "./src/features/%n%/atoms/%f%.ts",
"content": [
"export const %f% = () => {",
"\treturn <div>Test</div>",
"}"
]
}
}appendFile - Add extra content to your existing file
{
"type": "appendFile",
"options": {
"path": "./src/features/%n%/index.ts",
"content": [
"",
"export * from \"./atoms/%f%\""
]
}
}TODO
- More commands
- Support for
.jsconfig file - Support for custom command types