Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
jatg is a low configuration tool to generate files based on templates.
Most template generation tools require elaborate configurations, lack intuitive usage, are tied to a specific framework or do not support variable transformations. The objective of this tool is to be as intuitive as possible while providing a flexible feature set.
Simply create a template, add it to the configuration file and then run the CLI to generate files.
templates.json
You can create the file by running npx jatg --init
, or just start by copying the example below:
templates.json
{
"$schema": "https://unpkg.com/jatg/templates.schema.json",
"templates": [
{
"name": "my-awesome-template",
"sourcePaths": ["./templates"],
"outputPath": "./src/modules",
"variables": [
{
"variable": "name",
"name": "Module Name"
}
]
}
]
}
The format of this file is documented through the TemplateConfiguration TypeScript interface and the JSON Schema. Refer them for a list of all possible properties.
The file names don't need to follow any specific extension.
If you prefer, you can end them with .template
.
The .template
extension will be removed for the final file.
You can have as many files as needed for a single template.
templates/%name%.ts
export class %name.pascalCase% {
// ...
}
The template can have variables they can be transformed through functions. Read more about them in the variables section.
Just run the CLI to generate files based on the templates created.
You'll be prompted which template you want to generate, and the variable values.
npx jatg
Pretty straightforward, isn't it?
A template can have multiple variables. Those can be defined in the configuration and can be used to make template contents and file names dynamic.
The syntax is the variable name surrounded by percentages (%variable_name%
) and the value can be formatted through special functions, separated by dots (%variable_name.upper%
).
For the variable named entity
and the value user-post
, here are a few examples:
Template | Result | What is hapenning? |
---|---|---|
%entity% | user-post | prints the variable value as is |
%entity.upper% | USER-POST | prints the variable formatted value in uppercase |
%entity.plural.upper% | USER-POSTS | prints the variable value formatted in plural and in uppercase |
%entity.plural.dotCase.upper% | USER.POSTS | prints the variable value formatted in plural, in dot case and in uppercase |
Variables can be used in template file contents, the template file name and the configuration outputPath
.
These are based on the basic string functions included in JavaScript.
Function | Before | After |
---|---|---|
upper | "TwoWords" | "TWOWORDS" |
lower | "TwoWords" | "twowords" |
trim | " TwoWords " | "TwoWords" |
unaccent | "maçã" | "maca" |
These functions use change-case under the hood.
Function | Result |
---|---|
camelCase | twoWords |
capitalCase | Two Words |
constantCase | TWO_WORDS |
dotCase | two.words |
kebabCase | two-words |
noCase | two words |
pascalCase | TwoWords |
pascalSnakeCase | Two_Words |
pathCase | two/words |
sentenceCase | Two words |
snakeCase | two_words |
trainCase | Two-Words |
initials | TW |
These functions use pluralize under the hood.
Function | Result |
---|---|
plural | twoWords |
singular | twoWord |
You can run the generation through npx by simply running the command: npx jatg
.
You can also install globally through npm install --global jatg
and run it directly through jatg
.
You can also install it as a dev dependency to your project through npm install -D jatg
and add a script in your package.json
:
{
// ...
"scripts": {
"generate": "jatg"
}
// ...
}
Then you can run it through npm run generate
.
You can also specify options, such as picking a specific template:
npx jatg --template my-awesome-template
For a list of options, run jatg --help
.
FAQs
Just Another Template Generator
The npm package jatg receives a total of 8 weekly downloads. As such, jatg popularity was classified as not popular.
We found that jatg demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.