@unboundedsystems/jsonnet
v0.9.4-rc6
Published
jsonnet wrapper for Node.js
Downloads
168
Readme
node-jsonnet
This is an updated fork of the NPM jsonnet package.
jsonnet is a DSL for JSON. Jsonnet is created by Google.
This module is a Jsonnet wrapper for Node.js created with Emscripten.
Install
$ npm install @unboundedsystems/jsonnet
A Typescript definition file is included, so no need to install anything from @types
Usage
const jsonnet = require('@unboundedsystems/jsonnet');
const myTemplate = `
{
person1: {
name: "Alice",
welcome: "Hello " + self.name + "!",
},
person2: self.person1 { name: "Bob" },
}`;
// You only need to create one Jsonnet object and can then call eval()
// repeatedly.
const jsonnetVm = new jsonnet.Jsonnet();
const output = jsonnetVm.eval(myTemplate);
console.log(JSON.stringify(output, null, 2));
// The jsonnetVm object needs to be destroyed manually.
jsonnetVm.destroy();
Output:
{
"person1": {
"name": "Alice",
"welcome": "Hello Alice!"
},
"person2": {
"name": "Bob",
"welcome": "Hello Bob!"
}
}
References
Building & Publishing
Ensure you have the following tools installed:
- GNU make
- Docker
Build
host$ make
Publish
NOTE: This part needs better automation. Feel free to fix. :)
Run bash in the node container. Note the leading "./" and also note that your prompt in the container will have a different randomly generated hostname.
host$ ./bin/bash root@55382dc5d87f:/src#
Enter your npmjs.com credentials
root@55382dc5d87f:/src# npm login Username: someuser Password: Email: (this IS public) [email protected] Logged in as someuser on https://registry.npmjs.org/.
Actually publish
root@55382dc5d87f:/src# make publish npm publish --access=public + @unboundedsystems/[email protected]