Zx cli scripting with dfx

If you haven’t see the project zx, it might be worth checking out.

While certainly bash scripting is the most direct for cli, and if you’re going to use Javascript there’s of course agent-js, there’s likely a niche for simplifying dfx devops management using the tool.

Here’s a gist containing two files:

./zx-scripts/generate_icrc1_deployment_literal.mjs:
./initReplicaScript.mjs

Where the second restarts dfx clean in the background, checks if the system wide networks.json file is configured correctly for dfx nns to deploy its canisters and runs that if so, and then deploys an icrc1 ledger using an imported factory builder utility to generate the full command line literal based on the configurable inputs.

It’s not production quality by any means, but hopefully shows enough of the initial steps for using zx in your own projects.

One use in particular might be setting up a sequence of dfx commands that would demonstrate how to use whatever’s in the project to be included with the readme or documentation.

1 Like