README
Onyx toolbox
Environment tools for the Onyx server
Prerequisites
Installation
npm install --global onyx-toolbox
CLI
Usage
onyx <command>
Commands
clean - Clean the environment created by the setup
help <command> - Information and available flags for the specified command
reset - Reset the environment, same as clean + setup
setup - Setup the environment
start - Start the Onyx server
status - Display the environment and processes status
stop - Stop the Onyx server
swarm <action> - Swarm commands
API
Static configuration
The values of the onyx
Object from the package.json
file are exposed in the public API.
conf: Conf
The Conf instance holding the dynamic toolbox configuration and local state.
getPath(key: string): string
Returns the path matching the provided key, if set.
Supported keys
geth.bin
: thegeth
executableserver.bin
: theonyx-server
executableswarm.bin
: theswarm
executableswarm.data
: the Swarm data folderswarm.git
: thego-ethereum
git folderswarm.pwd
: the Swarm account password fileswarm.root
: The Swarm folder, holding all the others
setPath(key: string, value: string): void
Sets the path for the specified key
. See above for the list of keys used by the toolbox.
setPaths({[key: string]: string}): void
Sets multiple paths. See above for the list of keys used by the toolbox.
resetPaths(): void
Resets the paths used by the toolbox.
isSetup(): boolean
Returns whether the environment is setup or not.
Checks if git is installed in the environment.
Checks if Go is installed in the environment.
Runs git clone
in the provided cwd
directory to download the supported go-ethereum
repository.
Runs git clone
in the provided cwd
directory to retrieve the supported go-ethereum
branch.
Runs git fetch
in the provided cwd
directory. The provided path should be the one of the go-ethereum
repository downloaded using gitFetch()
.
Builds the binary from the go-ethereum
repository provided by the cwd
argument and identified by the provided name
. Supported names are geth
and swarm
.
Creates a new BZZ account and returns its address.
Creates a password file containing the provided password or a default one.
getServerStatus(): ?{ pid: number, port: number }
If the Onyx server is running, returns an Object containing the process pid
and server port
.
getSwarmStatus(): ?{ pid: number }
If Swarm is running, returns an Object containing the process pid
.
startSwarm(options = {}): Promise<false | number>
Attempts to start the Swarm process with the provided options
. Returns the process pid or false
if it fails.
stopSwarm(): Promise<boolean | number>
Attempts to stop the Swarm process. Returns false
if the process doesn't seem to be running, true
if the process can be killed, or the process pid if it fails.
Deletes the existing local state and removes the Swarm directory with all its contents.
startServer(options = {}): Promise<false | {pid: number, port: number}>
Starts the Onyx server with the provided options
. Returns false
if it fails to start the server, or an Object containing the server pid
and port
.
stopServer(): Promise<boolean | number>
Attempts to stop the Onyx server. Returns false
if the process doesn't seem to be running, true
if the process can be killed, or the process pid if it fails.
License
MIT.
See LICENSE file.