Skip to content

Overview

@lightnet/cli provides command-line tools for working with LightNet projects.

From the root of your LightNet site project, add the CLI as a development dependency:

Terminal window
pnpm add -D @lightnet/cli@latest

Run LightNet CLI commands with:

Terminal window
pnpm lightnet <command> [options]

Available commands:

Show all available commands:

Terminal window
pnpm lightnet --help

Show help for a specific command:

Terminal window
pnpm lightnet <command> --help

If you have set up large file storage with Cloudflare R2, install rclone to use R2 commands and R2 file checks. You can download rclone from rclone.org.

The first time you run a command that needs R2 access, LightNet CLI prompts for any missing bucket settings and saves them in lightnet-cli.json at the root of your LightNet site project. You can also create or edit that file manually.

LightNet reads R2 connection settings from lightnet-cli.json:

{
"r2": {
"publicUrl": "https://files.your-site.example",
"accountId": "your-cloudflare-account-id",
"accessKeyId": "your-r2-access-key-id",
"bucket": "your-bucket-name"
}
}

The same file can also contain the siteUrl used by check-links.

Add lightnet-cli.json to your git repository so every developer and CI job uses the same non-secret bucket settings.

These settings match the fields from Configure file storage:

  • publicUrl: the public URL for your files, such as https://files.your-site.example
  • accountId: your Cloudflare account ID
  • accessKeyId: the public access key ID from your Cloudflare token
  • bucket: the R2 bucket for your site

LightNet passes these settings to rclone automatically. You do not need to create an rclone remote manually.

The secret access key is intentionally not saved in lightnet-cli.json.

For local interactive use, you can let the CLI prompt for the secret access key. The prompt stores the key only for the current command session.

For CI, scripts, or repeated local commands, set the secret access key in your shell before running the command:

Terminal window
export LIGHTNET_R2_SECRET_ACCESS_KEY="your-r2-secret-access-key"