0.0.4 • Published 3 years ago
slax v0.0.4
Slax
Stop creating files/folders in your projects manually
Installation
- Install
slax
package from NPM
npm install -g slax
# or
yarn global add slax
- Create a
slax.config.json
:
slax init
{
"templates": {}
}
Creating templates
- Open
slax.config.json
and 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 myFeature
This will
- Create folder
./src/features/myFeature
- Create a file
./src/features/myFeature/index.ts
with 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
.js
config file - Support for custom command types