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)
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
On cli, try running APM.popular()
to get a list of the most installed 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.
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?
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!
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.
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
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 ;)