Riot component generator
tori - Opinionatedtori CLI tool, inspired by hpal
!!! BREAKING CHANGE WITH V2 !!!
With version 2, the package was moved to a different organization (@graundsco -> @riot-tools
). Please check the updated installation instruction below to use the latest version. There are no other new changes to the functionalities whatsoever.
Installation and usage
Note: tori was developed with nodejs v12+, it hasn't been tested in earlier versions
Recommended way:
npm i @riot-tools/tori -D
npx tori path/to/component
How it works
By default tori
will take in the whole path structure where you want to create the component. It will use the last part of the path as the name of the component.
Running npx tori src/components/my-component
will generate my-component
directory under src/components/
with all the files defined in the templates. Note that you don't have to create the parent directories as tori will recursively create them for you if they don't exist.
Tori assumes that alongside using riot, you will use Jest as the testing framework.
Some of the code has been commented out in the template files to make it more convenient for you to enable them.
Customization
You can extend tori's component generation by defining paths to your desired directories in package.json
.
package.json example
"tori": {
"basePath": "src", // The root of your source code. Note that the key MUST BE "basePath"
"components": "components" // Key defines the command you can use with tori and the value is the path based on "basePath" value
"common": "components/common"
},
Now, if you want to create a component under src/components/common
, you can run npx tori common my-component
.
Note: the keys don't have to match the directory names: they can be anything! Just remember that they will be the commands you will use with tori, e.g. key named
x
will becomenpx tori x component-name
.
Dependencies
TODO
-
[ ] Support defining your own templates in your work directory
-
[ ] More command line options for the tool?
- e.g.
help
- e.g.
-
Something else? Let us know!