@quantcdn/quant-cli
v5.1.1
Published
Deploy tools for QuantCDN
Readme
QuantCDN CLI
Command line tools for QuantCDN.
Installation
npm install -g @quantcdn/quant-cliUsage
The CLI can be used in two modes:
Interactive Mode
Simply run:
quantThis will launch an interactive prompt that guides you through available commands and options.
CLI Mode
quant <command> [options]Available Commands
Configuration
quant init- Initialize a project in the current directoryquant init [--dir=<build-dir>]quant info- Show information about current configuration
Content Management
quant deploy [dir]- Deploy the output of a static generatorquant deploy [dir] [--attachments] [--skip-unpublish] [--skip-unpublish-regex=pattern] [--enable-index-html] [--chunk-size=10] [--force]quant file <file> <location>- Deploy a single assetquant file path/to/file.jpg /images/file.jpgquant page <file> <location>- Make a local page asset availablequant page path/to/page.html /about-us [--enable-index-html]
Publishing Controls
quant publish <path>- Publish an assetquant publish /about-us [--revision=latest]quant unpublish <path>- Unpublish an assetquant unpublish /about-usquant delete <path>- Delete a deployed pathquant delete /about-us [--force]
Cache Management
quant purge <path>- Purge the cache for a given URL or cache keysquant purge /about-us # Purge by path quant purge "/*" # Purge all content quant purge --cache-keys="key1 key2" # Purge by cache keys quant purge /about-us --soft-purge # Mark as stale instead of deleting
Redirects
quant redirect <from> <to> [status]- Create a redirectquant redirect /old-page /new-page [--status=301]
Edge Functions
quant function <file> <description> [uuid]- Deploy an edge functionquant function handler.js "My edge function" # Deploy new function quant function handler.js "Updated function" 019361ae-2516-788a-8f50-e803ff561c34 # Update existingquant filter <file> <description> [uuid]- Deploy an edge filter functionquant filter filter.js "My edge filter" # Deploy new filter quant filter filter.js "Updated filter" 019361ae-2516-788a-8f50-e803ff561c34 # Update existingquant auth <file> <description> [uuid]- Deploy an edge auth functionquant auth auth.js "My auth function" # Deploy new auth function quant auth auth.js "Updated auth" 019361ae-2516-788a-8f50-e803ff561c34 # Update existing
Search
quant search <operation>- Perform search index operationsquant search status # Show search index status quant search index --path=records.json # Add/update search records quant search unindex --path=/url/to/remove # Remove item from search index quant search clear # Clear entire search index
You may index new content or update existing content in the search index directly. Simply provide one or multiple records in JSON files. For example, consider a search-records.json file containing the following:
[
{
"title": "This is a record",
"url": "/blog/page",
"summary": "The record is small and neat.",
"content": "Lots of good content here. But not too much!"
},
{
"title": "Fully featured search record",
"url": "/about-us",
"summary": "The record contains all the trimmings.",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"image": "https://www.example.com/images/about.jpg",
"categories": [ "Blog", "Commerce", "Jamstack" ],
"tags": [ "Tailwind" , "QuantCDN" ],
"author": "John Doe",
"publishDate": "2024-02-22",
"readTime": "5 mins",
"customField": "Any value you need"
}
]Required fields for each record:
title: The title of the pageurl: The URL path of the pagecontent: The searchable content
Common optional fields:
summary: A brief descriptionimage: URL to an associated imagecategories: Array of category namestags: Array of tag names
You can include any additional key/value pairs in your records. These custom fields will be indexed and available for filtering, faceting, or display in your search integration.
Validation
quant scan- Validate local file checksumsquant scan [--diff-only] [--unpublish-only] [--skip-unpublish-regex=pattern]
WAF Logs
quant waf:logs- Access project WAF logsquant waf:logs [--fields=field1,field2] [--output=file.csv] [--all] [--size=10]
Global Options
These options can be used with any command:
--clientid, -c Project customer id for QuantCDN
--project, -p Project name for QuantCDN
--token, -t Project token for QuantCDN
--endpoint, -e API endpoint for QuantCDN (default: "https://api.quantcdn.io/v1")Configuration
The CLI can be configured using either:
- Interactive initialization:
quant init - Command line arguments (see Global Options)
- Environment variables:
QUANT_CLIENT_IDQUANT_PROJECTQUANT_TOKENQUANT_ENDPOINT
- Configuration file:
quant.jsonin the current directory
Missing configuration will be handled differently depending on the context:
- Running
quantwith no arguments will prompt to initialize a new project - Running specific commands without configuration will show detailed setup instructions
Examples
# Initialize a new project
quant init
# Deploy a directory
quant deploy build --attachments
# Upload a single file
quant file ./logo.png /images/logo.png
# Create a redirect
quant redirect /old-page /new-page --status=301
# Purge cache with various options
quant purge "/*" # Purge all content
quant purge --cache-keys="key1 key2" # Purge specific cache keys
quant purge /about --soft-purge # Soft purge a path
# Deploy edge functions
quant function handler.js "My edge function" # Deploy a new function
quant auth auth.js "My auth function" # Deploy an auth function
quant filter filter.js "My edge filter" # Deploy a filter function
# Check deployment status
quant scan --diff-onlyTesting
npm run lint
npm run testContributing
Issues and feature requests are managed via Github and pull requests are welcomed.
