CLI Reference
The mosaic command-line interface is your primary tool for interacting with the Mosaic ecosystem.
Global Options
| Option | Description |
|---|---|
--api-url <URL> | Override the default registry URL (default: https://api.getmosaic.run). Useful for self-hosting or testing. |
-v, --verbose | Enable verbose logging. Prints detailed debug information (HTTP requests, internal errors, etc.). |
-h, --help | Print help information. |
-V, --version | Print version information. |
Commands
init
Initializes a new Mosaic project in the current directory.
mosaic initWhat it does:
- Creates a
mosaic.tomlconfiguration file. - Sets the project name based on the directory name.
- Sets the version to
0.1.0.
install
Installs dependencies into your project.
Usage:
# Install a specific package (latest version)
mosaic install <package_name>
# Install a specific version
mosaic install <package_name>@<version>
# Install all dependencies listed in mosaic.toml
mosaic installWhat it does:
- Resolves the package version from the registry.
- Checks for deprecation: If the package is deprecated, a warning is displayed with the author’s reason.
- Checks for circular dependencies.
- Downloads the package source (verified with SHA256).
- Recursively installs any dependencies.
- Injects the package as a
ModuleScriptinto your.polyfile (inScriptService). - Updates
mosaic.tomlandmosaic.lock.
Example:
mosaic install logger@1.0.0remove
Removes a package from your project.
Usage:
mosaic remove <package_name>What it does:
- Removes the dependency from
mosaic.toml. - Removes the
ModuleScriptfrom your.polyfile.
update
Updates all dependencies to their latest compatible versions.
Usage:
mosaic updateWhat it does:
- Checks the registry for newer versions of installed packages.
- Re-installs them (updating the
.polyfile andmosaic.lock).
upgrade
Upgrades the Mosaic CLI itself to the latest version available on GitHub.
Usage:
mosaic upgradeOutput: Checks for a new release, downloads the binary, and replaces the current executable in-place.
list
Lists all installed packages in the current project.
Usage:
mosaic listOutput: Displays a table of package names and their configured versions/queries.
search
Searches the registry for packages.
Usage:
mosaic search <query>Example:
mosaic search loggerOutput: Displays a table of matching packages with their latest version, author, and description.
info
Displays detailed information about a package.
Usage:
mosaic info <package_name>Example:
mosaic info loggerOutput: Shows the latest version, author, license, repository, description, and list of dependencies. Useful for vetting a package before installing it.
unpublish
Removes a specific version of a package from the registry.
Usage:
mosaic unpublish <package_name>@<version>Policy: To prevent “left-pad” style incidents and maintain registry stability, unpublishing is restricted:
- Time Limit: You can only unpublish a version within 24 hours of its initial publish.
- Dependents: You cannot unpublish a version if other packages in the registry already depend on it.
- Ownership: Only the original author can unpublish.
If you need to discourage use of an older or broken package after these limits, use mosaic deprecate (via the API) instead.
login
Authenticates you with the Mosaic registry.
Usage:
mosaic loginWhat it does:
- Prompts for your username and password.
- Retrieves an authentication token from the registry.
- Securely stores the token in your system’s keyring (Windows Credential Manager, macOS Keychain, etc.).
- Saves your username and registry URL to
~/.mosaic/auth.json(or equivalent).
logout
Logs you out of the registry.
Usage:
mosaic logoutWhat it does:
- Invalidates your token on the server.
- Removes credentials from your system keyring.
- Clears local authentication config.
signup
Creates a new account on the registry.
Usage:
mosaic signupWhat it does:
- Prompts for a new username and password.
- Creates the account.
- Automatically logs you in if successful.
publish
Publishes your package to the registry.
Usage:
# Publish with the version defined in mosaic.toml
mosaic publish
# Publish with a specific version override
mosaic publish --version <version>Prerequisites:
- You must be logged in (
mosaic login). - You must have a
mosaic.toml. - You must be the author of the package (if updating).
What it does:
- Packaging: Zips up your project files (respecting
.gitignoreand.mosaicignore). - Registration: Registers the new version with the registry API.
- Upload: Uploads the zip file to the registry’s storage.
Note: node_modules, target, and hidden files (starting with .) are automatically ignored.