AarKay — A code generator for all developers
AarKay is a code generator designed for all developers to create any type of file from data and template.
Updated for AarKay 0.0.2
The tool is designed especially for developers working on many projects at large scale. All projects have some files which are identical and only the data is what changes. These files can be converted into a template and data can be supplied to either generate or update all these files with a single command.
- All your Datafiles are located inside one folder giving you the birds eye view of your data.
- The Datafiles directory structure is directly mapped with the Generatedfiles directory structure.
Installation
Using Homebrew — brew install rahulkatariya/formulae/aarkay
Components
- Templatefiles
- Datafiles
Templatefiles
A Templatefiles consists of three components — Name, Extension and a Stencil template.
Breaking down the above Tempaltefile — Greeting.txt.stencil
- Greeting — This is a unique name of the template.
- txt — This is the extension for all Generatedfiles.
- Hello {{name}} — This is the Stencil template.
Templatefiles Directory —
~/AarKay/AarKayTemplates/AarKay/
.
All the templates should be created inside Templatefiles Directory.
Datafiles
A Datafile consists of three components — Filename, Template and Data for that template in JSON or Yml format.
Breaking down the above Datafile — Rahul.Greeting.yml
- Rahul — This is the name of Generatedfile.
- Greeting — This is the template to search for in Templatefiles Directory.
- name: Rahul — This is the data to be rendered with template Greeting.
Datafiles Directory —
~/AarKay/AarKayData/
.
All the data should be created inside Datafiles Directory.
Getting Started
Let’s create a project inside ~/{project/path}/AarKayExample
and run the command aarkay
.
This will create your Datafiles directory at AarKayFiles Directory plus the relative path of your project with base URL as ~/
— ~/AarKay/AarKayData/{project/path}/AarKayExample
.
Creating a Template
Let’s create the Greeting template inside Templates Directory
Creating the data
Instead of creating a one-to-one file, Let’s use the feature of creating one-to-many files by providing data with the Collection Datafile.
Collection Datafile is a special kind of data file which has an Array of template data and uses []
as prefix in the Datafile name.
Generating the files
The final step is to generate the files by running aarkay
.
Happy Code Generating! 😎