
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
JavaScript and Handlebars data templates - Producing templated configuration has never been easier!
JavaScript and Handlebars data templates - Producing templated configuration has never been easier!
Or expand JSON and YAML templates using Handlebars template syntax.
I use this to produce Kubernetes configurations from templates.
If you like this project, please star this repo and support my work
npm install -g figit
Evaluate file.js and output JSON:
figit file.js
Evaluate multiple files and output YAML:
figit file1 file2 fileN --output yaml
General use:
figit [file+] --output json | yaml [--stdin json | yaml] [--data <json-or-yaml-data-file>]
Create a template:
// myfile.js
module.exports = {
/* Whatever code you want here to produce data. */
data: {
msg: "Hello world!",
},
};
Instantiate data from the template:
figit myfile.js
JSON output:
{
"data": {
"msg": "Hello world!"
}
}
Or output YAML:
figit myfile.js --output yaml
YAML output:
data:
msg: "Hello world!"
Create a JSON template:
// myfile.json
{
"data": {
"msg": "{{MESSAGE}}",
},
};
Or create a YAML template instead:
# myfile.yaml
data:
msg: "{{MESSAGE}}"
Create a file to contain the Handlebars template data (this can be JSON or YAML as well):
// mydata.json
{
"MESSAGE": "Hello world!"
}
Note: Template variables are also populated from environment variables, so you don't necessarily need to create a template data, you could instead set a MESSAGE environment variable like this:
export MESSAGE="Hello world"
Instantiate data from the template and output as JSON:
figit myfile.json --data mydata.json --output json
JSON output:
{
"data": {
"msg": "Hello world!"
}
}
Or output YAML:
figit myfile.json --data mydata.json --output yaml
YAML output:
data:
msg: "Hello world!"
You can also combine template data from a data file, environment variables and standard input.
Load template data from a file like this:
figit myfile.json --data mydata.json
Template data is overwritten by environment variables, so in this case a MESSAGE environment variable would override the MESSAGE field from the data file.
You can read template from standard input in JSON or YAML format like this:
figit myfile.json --stdin json < mydata.json
You can use this to pipe sensitive variables from one process to another without having to save them to disk.
You can combine the methods of loading template data:
figit myfile.json --data base-data.json --stdin json < override-data.json
This allows you to have multiple levels of data. Base template data is read from the file specified by --data. Environment variables can then override the base data. Finally data read from standard input provides the final values for template data.
Here's my usecase for Figit, templating Kubernetes configurations.
// mydeployment.js
const APP_NAME = process.env.APP_NAME;
if (!APP_NAME) {
throw new Error(`Expected environment variable ${APP_NAME}`);
}
module.exports = {
apiVersion: "apps/v1",
kind: "Deployment",
metadata: {
name: ,
labels: {
app: APP_NAME,
},
},
spec: {
replicas: 3,
selector: {
matchLabels: {
app: APP_NAME,
},
},
template: {
metadata: {
labels: {
app: APP_NAME,
},
},
spec: {
containers: [
{
name: APP_NAME,
image: IMAGE_NAME,
ports: [
{
containerPort: 80,
},
],
},
],
},
},
},
};
Then in my deployment pipeline:
export APP_NAME=myapp
export IMAGE_NAME=myimage:latest
figit mydeployment.js | kubectl apply -f -
FAQs
JavaScript and Handlebars data templates - Producing templated configuration has never been easier!
The npm package figit receives a total of 130 weekly downloads. As such, figit popularity was classified as not popular.
We found that figit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.