LIGO Package Management

By Ligo team

We are delighted to announce the capability to write, package and publish a reusable piece of code dedicated to LIGO.

While working on a project you often need to use a common, reusable piece of code. Most of the time such functions are provided by the standard library of the programming language. When it is not feasible these functions can be provided by an external library.

In version 0.35.0 of LIGO this feature is now available, thanks for Esy package manager.

LIGO libraries can be published to Npm and used with a specific LIGO CLI command which internally invokes the Esy package manager.

Library consumer

Imagine in your project you need an open source library that is already designed and published by a third party. Let’s call it ligo-list-helpers.

First, you should create an empty file named package.json. Then you can perform a local installation of the identified library using the following LIGO CLI.

touch package.json
ligo install ligo-list-helpers

Once this installation has been completed you are able to import related modules in your LIGO source code from the installed library.

#import "ligo-list-helpers/list.mligo" "XList"

...

Module imports work across all syntaxes of LIGO i.e. you can import a module written in CameLIGO in a contract written in JsLIGO.

In addition, the package.json file is updated with a new entry targeting the installed package, of course.

If required, you can also manually specify the required packages in the package.json file. If you clone a project which already has a package.json, installing all the required libraries is quite easy!

ligo install

This command installs packages to the .ligo directory in the repository where you execute the command, but this can be changed with an additional parameter named --cache-path.

Library designer

If you want to design and share a LIGO library in any language you choose (PascaLIGO, ReasonLIGO, CameLIGO or JsLIGO), this can be done using standard npm commands.

First, you should initialise a new library and setup the corresponding metadata. Once your library is completed and tested you can publish it. These initialisation and publication operations are performed via the npm command.

Want to contribute?

If you want to participate, contributions are welcome and help the growth of LIGO and its adoption.

More information can be found here.

2 Likes