Comparing version 1.0.2 to 1.0.4
{ | ||
"name": "tmpltr", | ||
"version": "1.0.2", | ||
"version": "1.0.4", | ||
"description": "Templating with mustache and YAML", | ||
@@ -11,3 +11,3 @@ "main": "bin.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Error: no test specified\"" | ||
}, | ||
@@ -14,0 +14,0 @@ "repository": { |
100
README.md
@@ -9,2 +9,100 @@ # tmpltr - templating files with mustache and YAML | ||
/_/ | ||
``` | ||
``` | ||
## Concept | ||
This tool generates a set of files based on one or more templates in combination with a set of values used as tempalte variables. | ||
For tempaltes, mustache is used. For the manifest file, YAML is used (`*.yaml` and `*.yml` are equally supported). | ||
For execution, at least one `*.mustache` template and one `*.yml` manifest file are required. | ||
## Usage | ||
``` | ||
tmpltr [workingDirectory] [--manifest <manifest yml file>] [--verbose] [--dryrun] [--console] | ||
``` | ||
### Options and switches | ||
| option | optional | default | description | | ||
|------------------|----------|---------|--------------------------------------------------------------------------------------------------------------| | ||
| workingDirectory | true | . | working directory in which to search for the templates and the manifest.yml files (if not further specified) | | ||
| --verbose | true | false | increased output on "debug" level | | ||
| --dryrun | true | false | do not write any templated files | | ||
| --console | true | false | print the templated files to the console | | ||
| --manifest | true | '' | location of the manifest.yml file. absolute or relative to the pwd | | ||
### File structure | ||
For mustache template files, please refer to [the official documentation](https://mustache.github.io/mustache.5.html) | ||
`manifest.yml` file structure: | ||
``` yaml | ||
--- | ||
# list of files to be generated | ||
files: | ||
# destination file relative to the working directory | ||
- destination: ./foo.txt | ||
# template file name. all template files must be in the working directory. | ||
# *.mustache file extension is optional. | ||
template: my-template[.mustache] | ||
# object of values to be rendered into the template | ||
values: | ||
foo: "foo" | ||
bar: "bar" | ||
fizzBuzz: 42 | ||
``` | ||
### Locating the manifest file | ||
The `--manifest` switch of the `tmpltr` command can be used to specify the manifest file. It has highest priority and is considered to be either absolute or relative to the `pwd`. | ||
``` | ||
/home/ | ||
├─ some-project/ | ||
│ ├─ templates/ | ||
│ │ ├─ manifest.yml | ||
│ │ ├─ template-a.mustache | ||
│ │ ├─ template-b.mustache | ||
│ ├─ README.md | ||
│ ├─ my-manifest.yml | ||
``` | ||
``` bash | ||
cd /home/some-project/ | ||
tmpltr --manifest ./my-manifest.yml templates | ||
# equivalent to | ||
tmpltr --manifest /home/some-project/my-manifest.yml templates | ||
``` | ||
If no `--manifest` switch is specified, the `manifest.y[a]ml` file is searched in the working directory. | ||
``` bash | ||
cd /home/some-project/ | ||
tmpltr templates # uses the manifest.yml file in the templates directory | ||
# equivalet to | ||
cd /home/some-project/templates/ | ||
tmpltr # uses the pwd (/home/some-project/templates/) as working directory and uses the manifest.yml file | ||
``` | ||
If no `manifest.y[a]ml` file is found, all `*.y[a]ml` files in the working directory are considered to be manifest files and checked against the YAML validator. | ||
``` | ||
/home/ | ||
├─ some-project/ | ||
│ ├─ templates/ | ||
│ │ ├─ manifest-a.yml | ||
│ │ ├─ manifest-b.yaml | ||
│ │ ├─ template-a.mustache | ||
│ │ ├─ template-b.mustache | ||
│ ├─ README.md | ||
│ ├─ my-manifest.yml | ||
``` | ||
``` bash | ||
cd /home/some-project/ | ||
tmpltr templates # uses manifest-a.yml AND manifest-b.yaml | ||
``` | ||
### With npm/npx | ||
``` bash | ||
npm i -g tmpltr | ||
# OR | ||
npx tmpltr | ||
``` | ||
### With docker | ||
``` bash | ||
docker run --rm -v ${PWD}:/usr/src mxcd/tmpltr | ||
``` | ||
Made with ♥, pizza and beer by MaPa |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
14699
10
107
0