Install packages on ao processes using AO Package Manager

gm! If you have ever heard about package managers, you might think it’s to manage installed packages… well that’s exactly what ao package manager (APM) does for your ao processes, and today we will have a look at how you can use the apm blueprint to install packages on both the aos cli and the betteridea web IDE

First things first, you can visit apm.betteridea.dev to browse through and search for packages and even publish your own (will explain publishing in another article)

APM homepage
APM homepage

Get the APM blueprint

For web IDE users, you don’t need to install anything since apm is already integrated in the ui :)

However, If you are using the aos cli repl, you will have to load the apm blueprint by running

.load-blueprint apm

This will add helper functions like searching, getting info, publishing, installing and uninstalling packages

loading apm blueprint
loading apm blueprint

Browse & Install packages

On cli, try running APM.popular() to get a list of the most installed packages

popular packages
popular packages

-- You can ignore the UpdateNotice for now, this will be be fixed when apm client 1.0.2 pr is merged with the aos repository

To install a package, you need to run the command

APM.install('pacakge_name')

and replace ‘package_name‘ with the name of the package as it appears in the APM registry.

installing a package
installing a package

NOTE: the install command will download the latest version of the package available, in case you want to install another specific version, you can pass in the version number along with the package name, for example:

APM.install("sample@1.0.1") -- will install the 1.0.1 version of sample

On the web IDE, you can open any project and click on the ‘packages’ button at the top right, this will open up a popup where you can checkout packages and install them. easy much?

IDE ui to manage packages
IDE ui to manage packages

Use your installed package

After a successful installation, you can simple use lua’s require function to load up the code in the installed package and use it however you want to.

local sample = require("sample")
return sample.hello() --prints hello ao!
using the package on the cli
using the package on the cli
using the package on the IDE
using the package on the IDE

Checking installed packages

To get a list of installed packages, simply run the command

APM.installed

This will present you with a table, consisting of the names of installed packages and their versions.

installed packages
installed packages

Uninstalling packages

Once a package is no longer required, it can be removed from your process by simply running the uninstall command

APM.uninstall('package_name')

and replace ‘package_name‘ with the name of the package as it appears in the installed list or the APM registry

uninstalling the package
uninstalling the package

Stay tuned for a how to publish guide :)

If you have an idea for a package that would be useful to developing on ao or just a fun package to add humour to applications, reach out to us on our discord and we’ll help you with the publishing process

Thanks for reading ;)

Subscribe to BetterIDEa
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.