moon-install

MoonBit CLI installer

moonbit
cli
installer
moon add mizchi/moon-install@0.1.1
Download zip
Author
Version
0.1.1
License
Apache-2.0
Last updated
6 months ago
Downloads
22

Dependencies

README

#moon-install

MoonBit CLI installer.

#Installation

curl -fsSL https://raw.githubusercontent.com/mizchi/moon-install/main/install.sh | sh

Environment variables:

  • MOON_INSTALL_VERSION: e.g. v0.1.0
  • MOON_INSTALL_DIR: e.g. $HOME/.local/bin

#Usage

moon-install <user>/<repo>[@<version>]/<pkg/path> --name <cmd> --target <js|native>

Examples:

moon-install mizchi/starlint/cli --name starlint moon-install mizchi/starlint@0.1.0/cli --target native moon-install uninstall mycmd

If @<version> is omitted, the latest version is used.

#PATH setup

Installed commands are placed in ~/.mooninstall/bin. Add it to PATH if needed.

export PATH="$HOME/.mooninstall/bin:$PATH"

#How it works

  • Extract source to ~/.mooninstall/src/<user>/<repo>/
  • Run moon build --target <target> --release
  • Alias the generated artifact to ~/.mooninstall/bin/<name>
    • js: create a wrapper script to run with node
    • native: link the generated *.exe with ln -sf
  • Same name is overwritten

#Requirements

  • moon must be installed
  • unzip, ln, chmod must be available

#mizchi/moon-install

MoonBit CLI installer.

moon-install mizchi/starlint/cli --name starlint moon-install mizchi/starlint@0.1.0/cli --target native

PATH setup:

export PATH="$HOME/.mooninstall/bin:$PATH"

#
CliError

pub(all) suberror CliError {
HelpRequested
MissingSpec
MissingUninstallName
UnknownFlag(String)
MissingFlagValue(String)
InvalidTarget(String)
UnexpectedArg(String)
}

impl Eq for CliError
impl Show for CliError

#
ExecError

pub(all) suberror ExecError {
CommandFailed(String, Int)
}

impl Eq for ExecError
impl Show for ExecError

#
InstallError

pub(all) suberror InstallError {
MissingHome
InvalidSpec(String)
InvalidArgs(String)
IoError(String)
CommandFailed(String, Int)
ArtifactNotFound(String)
RegistryIndexNotFound(String)
RegistryIndexInvalid(String)
UnsupportedTarget(String)
}

impl Eq for InstallError

#
RegistryIndexError

pub(all) suberror RegistryIndexError {
InvalidJson
MissingVersion
}

#
SpecError

pub(all) suberror SpecError {
MissingOwner
MissingRepo
MissingVersion
MissingPackagePath
InvalidFormat(String)
}

impl Eq for SpecError
impl Show for SpecError

#
VersionSelectError

pub(all) suberror VersionSelectError {
InvalidLatest(String)
InvalidRequested(String)
}

#
Command

pub enum Command {
Install(InstallArgs)
Uninstall(String)
}

impl Eq for Command
impl Show for Command

#
InstallArgs

pub struct InstallArgs {
spec : String
name : String?
target : Target
}

impl Eq for InstallArgs
impl Show for InstallArgs

#
Spec

pub struct Spec {
owner : String
repo : String
version : String?
package_path : String
package_name : String
}

impl Eq for Spec
impl Show for Spec

#
Target

pub enum Target {
Native
Js
}

impl Eq for Target
impl Show for Target

#
Target::artifact_ext

fn Target::artifact_ext(target : Target) -> String

#
Target::from_string

fn Target::from_string(s : String) -> Target?

#
Target::to_moon_arg

fn Target::to_moon_arg(target : Target) -> String

#
artifact_path

fn artifact_path(repo_dir : String, package_path : String, target : Target) -> String

#
ensure_dir_recursive

fn ensure_dir_recursive(path : String) -> Unit raise
IOError

#
install

fn install(spec : Spec, name : String, target : Target) -> Result[Unit, InstallError]

#
join_path

fn join_path(lhs : String, rhs : String) -> String

#
parse_cli_args

fn parse_cli_args(args : Array[String]) -> Result[Command, CliError]

#
parse_registry_latest_version

fn parse_registry_latest_version(content : String) -> Result[String, RegistryIndexError]

#
parse_spec

fn parse_spec(input : String) -> Result[Spec, SpecError]

#
remove_dir_recursive

fn remove_dir_recursive(path : String) -> Unit raise
IOError

#
run_cli

fn run_cli() -> Unit

#
run_shell

fn run_shell(cmd : String) -> Result[Unit, ExecError]

#
run_shell_in_dir

fn run_shell_in_dir(dir : String, args : Array[String]) -> Result[Unit, ExecError]

#
select_version

fn select_version(requested : String?, latest : String) -> Result[String, VersionSelectError]

#
shell_escape

fn shell_escape(s : String) -> String

#
shell_join

fn shell_join(args : Array[String]) -> String

#
uninstall

fn uninstall(name : String) -> Result[Unit, InstallError]

#
usage

fn usage() -> String

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io