"Fossies" - the Fresh Open Source Software Archive

Member "cli-1.1280.1/release-scripts/hcl-to-json-parser-generator-v2/README.md" (20 Feb 2024, 3960 Bytes) of package /linux/misc/snyk-cli-1.1280.1.tar.gz:

As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

HCL to JSON v2

This package uses GopherJS[1] to convert the snyk/snyk-iac-parsers Golang package into JavaScript and provide it as a CommonJS module. It is suffixed with v2 as we already have an existing hcl2json implementation, which we will deprecate when we fully switch to this implementation.


The current path of this folder has to be added into the $GOPATH environment variable for the build to work (this is currently a requirement of GopherJS). e.g:

export GOPATH=$HOME/dev/snyk/release-scripts/hcl-to-json-parser-generator-v2

Make sure that your $GOROOT environment variable is set to where go is installed, for example:


Then, from this working directory run:

% make build

This will generate two files a hcltojson-v2.js and an hcltojson-v2.js.map with source maps for the minified file. You can find these files under /release-scripts/hcl-to-json-parser-generator-v2/src/hcltojson-v2/dist/

The output file is ~4.0M minified and ~716K gzipped.


The module exposes one function:


A simple assertion that the compiled file works can be run via:

% make test

Local development

To point to a different version of the snyk/snyk-iac-parsers locally, you will need to follow these steps:

 go get github.com/snyk/snyk-iac-parsers@commithash
make build

Updating the snyk/snyk-iac-parsers package for production use

The generated GopherJS artefact is used in src/cli/commands/test/iac/local-execution/parsers/hcl-to-json-v2/

There are two ways to do this:

Automatic release process

To check that the new version still works and is ready to be released:

 make release version=${version_or_sha}


make release version=v0.2.0

This will get the required version, check for errors, run the tests against the new versions and copy the artefact to the iac/local-execution directory. In a case of a failure, it will revert the changes and fail gracefully.

Manual release process

This is a similar process to the local development, but you also need a couple of extra steps:

 go get github.com/snyk/snyk-iac-parsers@tag
make build