|
1 | | -# QuantCDN cli |
| 1 | +# QuantCDN CLI |
2 | 2 |
|
3 | | - |
| 3 | +Command line tools for QuantCDN. |
4 | 4 |
|
5 | | -Simplify deployments and interactions with the QuantCDN API by using the support cli tool. |
| 5 | +## Installation |
6 | 6 |
|
7 | | -## Install |
8 | | - |
9 | | -The preferred method for installation is via npm. |
10 | | - |
11 | | -``` |
12 | | -npm i -g @quantcdn/quant-cli |
13 | | -``` |
14 | | - |
15 | | -or locally to a project |
16 | | - |
17 | | -``` |
18 | | -npm i -D @quantcdn/quant-cli |
| 7 | +```bash |
| 8 | +npm install -g @quantcdn/quant-cli |
19 | 9 | ``` |
20 | 10 |
|
21 | 11 | ## Usage |
22 | 12 |
|
23 | | -``` |
24 | | -$ quant <command> |
25 | | -
|
26 | | -Commands: |
27 | | - quant crawl [domain] Crawl and push an entire domain |
28 | | - quant delete <path> Delete a deployed path from Quant |
29 | | - quant deploy [dir] Deploy the output of a static generator |
30 | | - quant file <file> <location> Deploy a single asset |
31 | | - quant info Give info based on current configuration |
32 | | - quant init Initialise a project in the current directory |
33 | | - quant page <file> <location> Make a local page asset available via Quant |
34 | | - quant proxy <path> <origin> [status] Create a proxy to allow traffic directly to origin |
35 | | - [basicAuthUser] [basicAuthPass] |
36 | | - quant publish <path> Publish an asset |
37 | | - quant purge <path> Purge the cache for a given url |
38 | | - quant redirect <from> <to> [status] [author] Create a redirect |
39 | | - quant search <index|unindex|clear> Perform search index operations |
40 | | - quant unpublish <path> Unpublish an asset |
41 | | -
|
42 | | -Options: |
43 | | - --version Show version number [boolean] |
44 | | - --help Show help [boolean] |
45 | | - --clientid, -c Project customer id for QuantCDN [string] |
46 | | - --project, -p Project name for QuantCDN [string] |
47 | | - --token, -t Project token for QuantCDN [string] |
48 | | - --endpoint, -e API endpoint for QuantCDN [string] [default: "https://api.quantcdn.io"] |
49 | | -``` |
50 | | - |
51 | | -## Get started |
52 | | - |
53 | | -Please refer to the ["get started" guide](https://docs.quantcdn.io/docs/cli/get-started) for more details on getting set up. |
54 | | - |
55 | | -Quant accepts options or will ready configuration values from a `quant.json` file in the current directory. |
56 | | - |
57 | | -``` |
58 | | -$ quant init |
59 | | -``` |
60 | | - |
61 | | -An interactive walk-through for configuring your API connection. |
62 | | - |
63 | | -``` |
64 | | -$ quant info |
65 | | -
|
66 | | -Endpoint: https://api.quantcdn.io/v1 |
67 | | -Customer: quant |
68 | | -Project: dev-docs |
69 | | -Token: **** |
70 | | -✅✅✅ Successfully connected to dev-docs |
71 | | -``` |
72 | | - |
73 | | -## Manage search index |
74 | | - |
75 | | -### Basic usage |
76 | | - |
77 | | -* Use `quant search status` to retrieve index size and basic configuration. |
78 | | -* Use `quant search unindex --path=/url/path` to remove an item from the index. |
79 | | -* Use `quant search clear` to clear the entire index. |
80 | | - |
81 | | -### Create and update records |
| 13 | +The CLI can be used in two modes: |
| 14 | + |
| 15 | +### Interactive Mode |
| 16 | +Simply run: |
| 17 | +```bash |
| 18 | +quant |
| 19 | +``` |
| 20 | +This will launch an interactive prompt that guides you through available commands and options. |
| 21 | + |
| 22 | +### CLI Mode |
| 23 | +```bash |
| 24 | +quant <command> [options] |
| 25 | +``` |
| 26 | + |
| 27 | +## Available Commands |
| 28 | + |
| 29 | +### Configuration |
| 30 | +- `quant init` - Initialize a project in the current directory |
| 31 | + ```bash |
| 32 | + quant init [--dir=<build-dir>] |
| 33 | + ``` |
| 34 | + |
| 35 | +- `quant info` - Show information about current configuration |
| 36 | + |
| 37 | +### Content Management |
| 38 | +- `quant deploy [dir]` - Deploy the output of a static generator |
| 39 | + ```bash |
| 40 | + quant deploy [dir] [--attachments] [--skip-unpublish] [--skip-unpublish-regex=pattern] [--enable-index-html] [--chunk-size=10] [--force] |
| 41 | + ``` |
| 42 | + |
| 43 | +- `quant file <file> <location>` - Deploy a single asset |
| 44 | + ```bash |
| 45 | + quant file path/to/file.jpg /images/file.jpg |
| 46 | + ``` |
| 47 | + |
| 48 | +- `quant page <file> <location>` - Make a local page asset available |
| 49 | + ```bash |
| 50 | + quant page path/to/page.html /about-us [--enable-index-html] |
| 51 | + ``` |
| 52 | + |
| 53 | +### Publishing Controls |
| 54 | +- `quant publish <path>` - Publish an asset |
| 55 | + ```bash |
| 56 | + quant publish /about-us [--revision=latest] |
| 57 | + ``` |
| 58 | + |
| 59 | +- `quant unpublish <path>` - Unpublish an asset |
| 60 | + ```bash |
| 61 | + quant unpublish /about-us |
| 62 | + ``` |
| 63 | + |
| 64 | +- `quant delete <path>` - Delete a deployed path |
| 65 | + ```bash |
| 66 | + quant delete /about-us [--force] |
| 67 | + ``` |
| 68 | + |
| 69 | +### Cache Management |
| 70 | +- `quant purge <path>` - Purge the cache for a given URL or cache keys |
| 71 | + ```bash |
| 72 | + quant purge /about-us # Purge by path |
| 73 | + quant purge "/*" # Purge all content |
| 74 | + quant purge --cache-keys="key1 key2" # Purge by cache keys |
| 75 | + quant purge /about-us --soft-purge # Mark as stale instead of deleting |
| 76 | + ``` |
| 77 | + |
| 78 | +### Redirects |
| 79 | +- `quant redirect <from> <to> [status]` - Create a redirect |
| 80 | + ```bash |
| 81 | + quant redirect /old-page /new-page [--status=301] |
| 82 | + ``` |
| 83 | + |
| 84 | +### Edge Functions |
| 85 | +- `quant function <file> <description> [uuid]` - Deploy an edge function |
| 86 | + ```bash |
| 87 | + quant function handler.js "My edge function" # Deploy new function |
| 88 | + quant function handler.js "Updated function" 019361ae-2516-788a-8f50-e803ff561c34 # Update existing |
| 89 | + ``` |
| 90 | + |
| 91 | +- `quant filter <file> <description> [uuid]` - Deploy an edge filter function |
| 92 | + ```bash |
| 93 | + quant filter filter.js "My edge filter" # Deploy new filter |
| 94 | + quant filter filter.js "Updated filter" 019361ae-2516-788a-8f50-e803ff561c34 # Update existing |
| 95 | + ``` |
| 96 | + |
| 97 | +- `quant auth <file> <description> [uuid]` - Deploy an edge auth function |
| 98 | + ```bash |
| 99 | + quant auth auth.js "My auth function" # Deploy new auth function |
| 100 | + quant auth auth.js "Updated auth" 019361ae-2516-788a-8f50-e803ff561c34 # Update existing |
| 101 | + ``` |
| 102 | + |
| 103 | +### Search |
| 104 | +- `quant search <operation>` - Perform search index operations |
| 105 | + ```bash |
| 106 | + quant search status # Show search index status |
| 107 | + quant search index --path=records.json # Add/update search records |
| 108 | + quant search unindex --path=/url/to/remove # Remove item from search index |
| 109 | + quant search clear # Clear entire search index |
| 110 | + ``` |
82 | 111 |
|
83 | 112 | 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: |
84 | 113 |
|
85 | | -``` |
| 114 | +```json |
86 | 115 | [ |
87 | 116 | { |
88 | 117 | "title": "This is a record", |
89 | 118 | "url": "/blog/page", |
90 | 119 | "summary": "The record is small and neat.", |
91 | | - "content": "Lots of good content here. But not too much!", |
| 120 | + "content": "Lots of good content here. But not too much!" |
92 | 121 | }, |
93 | 122 | { |
94 | 123 | "title": "Fully featured search record", |
95 | 124 | "url": "/about-us", |
96 | 125 | "summary": "The record contains all the trimmings.", |
97 | | - "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras id dolor facilisis, ornare erat et, scelerisque odio. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.", |
| 126 | + "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", |
98 | 127 | "image": "https://www.example.com/images/about.jpg", |
99 | 128 | "categories": [ "Blog", "Commerce", "Jamstack" ], |
100 | | - "tags": [ "Tailwind" , "QuantCDN" ] |
| 129 | + "tags": [ "Tailwind" , "QuantCDN" ], |
| 130 | + "author": "John Doe", |
| 131 | + "publishDate": "2024-02-22", |
| 132 | + "readTime": "5 mins", |
| 133 | + "customField": "Any value you need" |
101 | 134 | } |
102 | 135 | ] |
103 | 136 | ``` |
104 | 137 |
|
105 | | -To post these records to the search index: |
106 | | -``` |
107 | | -quant search index --path=./search-records.json |
| 138 | +Required fields for each record: |
| 139 | +- `title`: The title of the page |
| 140 | +- `url`: The URL path of the page |
| 141 | +- `content`: The searchable content |
| 142 | + |
| 143 | +Common optional fields: |
| 144 | +- `summary`: A brief description |
| 145 | +- `image`: URL to an associated image |
| 146 | +- `categories`: Array of category names |
| 147 | +- `tags`: Array of tag names |
| 148 | + |
| 149 | +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. |
| 150 | + |
| 151 | +### Validation |
| 152 | +- `quant scan` - Validate local file checksums |
| 153 | + ```bash |
| 154 | + quant scan [--diff-only] [--unpublish-only] [--skip-unpublish-regex=pattern] |
| 155 | + ``` |
| 156 | + |
| 157 | +### WAF Logs |
| 158 | +- `quant waf:logs` - Access project WAF logs |
| 159 | + ```bash |
| 160 | + quant waf:logs [--fields=field1,field2] [--output=file.csv] [--all] [--size=10] |
| 161 | + ``` |
| 162 | + |
| 163 | +## Global Options |
| 164 | +These options can be used with any command: |
| 165 | + |
| 166 | +```bash |
| 167 | +--clientid, -c Project customer id for QuantCDN |
| 168 | +--project, -p Project name for QuantCDN |
| 169 | +--token, -t Project token for QuantCDN |
| 170 | +--endpoint, -e API endpoint for QuantCDN (default: "https://api.quantcdn.io/v1") |
108 | 171 | ``` |
109 | 172 |
|
110 | | -**Note:** The path may either refer to an individual file or a path on disk containing multiple JSON files. |
| 173 | +## Configuration |
111 | 174 |
|
112 | | -## Testing |
| 175 | +The CLI can be configured using either: |
| 176 | +1. Interactive initialization: `quant init` |
| 177 | +2. Command line arguments (see Global Options) |
| 178 | +3. Environment variables: |
| 179 | + - `QUANT_CLIENT_ID` |
| 180 | + - `QUANT_PROJECT` |
| 181 | + - `QUANT_TOKEN` |
| 182 | + - `QUANT_ENDPOINT` |
| 183 | +4. Configuration file: `quant.json` in the current directory |
113 | 184 |
|
114 | | -Automated via CodeFresh for all PRs and mainline branches. |
| 185 | +Missing configuration will be handled differently depending on the context: |
| 186 | +- Running `quant` with no arguments will prompt to initialize a new project |
| 187 | +- Running specific commands without configuration will show detailed setup instructions |
115 | 188 |
|
| 189 | +## Examples |
| 190 | + |
| 191 | +```bash |
| 192 | +# Initialize a new project |
| 193 | +quant init |
| 194 | + |
| 195 | +# Deploy a directory |
| 196 | +quant deploy build --attachments |
| 197 | + |
| 198 | +# Upload a single file |
| 199 | +quant file ./logo.png /images/logo.png |
| 200 | + |
| 201 | +# Create a redirect |
| 202 | +quant redirect /old-page /new-page --status=301 |
| 203 | + |
| 204 | +# Purge cache with various options |
| 205 | +quant purge "/*" # Purge all content |
| 206 | +quant purge --cache-keys="key1 key2" # Purge specific cache keys |
| 207 | +quant purge /about --soft-purge # Soft purge a path |
| 208 | + |
| 209 | +# Deploy edge functions |
| 210 | +quant function handler.js "My edge function" # Deploy a new function |
| 211 | +quant auth auth.js "My auth function" # Deploy an auth function |
| 212 | +quant filter filter.js "My edge filter" # Deploy a filter function |
| 213 | + |
| 214 | +# Check deployment status |
| 215 | +quant scan --diff-only |
116 | 216 | ``` |
117 | | -$ npm run lint |
118 | | -$ npm run test |
| 217 | + |
| 218 | +## Testing |
| 219 | + |
| 220 | +```bash |
| 221 | +npm run lint |
| 222 | +npm run test |
119 | 223 | ``` |
120 | 224 |
|
121 | 225 | ## Contributing |
122 | 226 |
|
123 | | -Issues and feature requests are managed via Github and pull requests are welcomed. |
| 227 | +Issues and feature requests are managed via Github and pull requests are welcomed. |
0 commit comments