Overview
@lightnet/cli provides command-line tools for working with LightNet projects.
Install
Section titled “Install”From the root of your LightNet site project, add the CLI as a development dependency:
pnpm add -D @lightnet/cli@latestRun LightNet CLI commands with:
pnpm lightnet <command> [options]Available commands:
check-files: find broken file links and unused files.check-links: check Media Item URLs.check-translations: find missing translation strings.r2: manage files in a Cloudflare R2 bucket.
Show all available commands:
pnpm lightnet --helpShow help for a specific command:
pnpm lightnet <command> --helpRclone setup
Section titled “Rclone setup”Requirements
Section titled “Requirements”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.
Configuration
Section titled “Configuration”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 ashttps://files.your-site.exampleaccountId: your Cloudflare account IDaccessKeyId: the public access key ID from your Cloudflare tokenbucket: 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:
export LIGHTNET_R2_SECRET_ACCESS_KEY="your-r2-secret-access-key"