0.0.4 • Published 3 years ago

slax v0.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Slax

Stop creating files/folders in your projects manually

Installation

  1. Install slax package from NPM
npm install -g slax
# or
yarn global add slax
  1. Create a slax.config.json:
slax init
{
  "templates": {}
}

Creating templates

  1. Open slax.config.json and create new template:
{
  "templates": {
    "feat": []
  }
}
  1. Add commands
{
  "templates": {
    "feat": [
      {
        "type": "mkdir",
        "options": {
          "path": "./src/features/%n%"
        }
      },
      {
        "type": "writeFile",
        "options": {
          "path": "./src/features/%n%/index.ts",
          "content": [""]
        }
      }
    ]
  }
}
  1. 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
0.0.4

3 years ago

0.0.3

3 years ago

0.0.1

3 years ago