Skip to content

quantcdn/quant-cli

Repository files navigation

QuantCDN CLI

Command line tools for QuantCDN.

Installation

npm install -g @quantcdn/quant-cli

Usage

The CLI can be used in two modes:

Interactive Mode

Simply run:

quant

This 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 directory

    quant init [--dir=<build-dir>]
  • quant info - Show information about current configuration

Content Management

  • quant deploy [dir] - Deploy the output of a static generator

    quant deploy [dir] [--attachments] [--skip-unpublish] [--skip-unpublish-regex=pattern] [--enable-index-html] [--chunk-size=10] [--force]
  • quant file <file> <location> - Deploy a single asset

    quant file path/to/file.jpg /images/file.jpg
  • quant page <file> <location> - Make a local page asset available

    quant page path/to/page.html /about-us [--enable-index-html]

Publishing Controls

  • quant publish <path> - Publish an asset

    quant publish /about-us [--revision=latest]
  • quant unpublish <path> - Unpublish an asset

    quant unpublish /about-us
  • quant delete <path> - Delete a deployed path

    quant delete /about-us [--force]

Cache Management

  • quant purge <path> - Purge the cache for a given URL or cache keys
    quant 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 redirect
    quant redirect /old-page /new-page [--status=301]

Edge Functions

  • quant function <file> <description> [uuid] - Deploy an edge function

    quant function handler.js "My edge function"                                     # Deploy new function
    quant function handler.js "Updated function" 019361ae-2516-788a-8f50-e803ff561c34  # Update existing
  • quant filter <file> <description> [uuid] - Deploy an edge filter function

    quant filter filter.js "My edge filter"                                         # Deploy new filter
    quant filter filter.js "Updated filter" 019361ae-2516-788a-8f50-e803ff561c34   # Update existing
  • quant auth <file> <description> [uuid] - Deploy an edge auth function

    quant 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 operations
    quant 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 page
  • url: The URL path of the page
  • content: The searchable content

Common optional fields:

  • summary: A brief description
  • image: URL to an associated image
  • categories: Array of category names
  • tags: 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 checksums
    quant scan [--diff-only] [--unpublish-only] [--skip-unpublish-regex=pattern]

WAF Logs

  • quant waf:logs - Access project WAF logs
    quant 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:

  1. Interactive initialization: quant init
  2. Command line arguments (see Global Options)
  3. Environment variables:
    • QUANT_CLIENT_ID
    • QUANT_PROJECT
    • QUANT_TOKEN
    • QUANT_ENDPOINT
  4. Configuration file: quant.json in the current directory

Missing configuration will be handled differently depending on the context:

  • Running quant with 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-only

Testing

npm run lint
npm run test

Contributing

Issues and feature requests are managed via Github and pull requests are welcomed.

About

CLI tools for Quant (NodeJS)

Resources

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •