Skip to content

Commit 35c48c9

Browse files
authored
Merge pull request #274 from quantcdn/feat/v5.0.0
v5.0.0
2 parents 7219c84 + 7d6689a commit 35c48c9

70 files changed

Lines changed: 5890 additions & 4695 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
files: ['**/*.js'],
3+
languageOptions: {
4+
ecmaVersion: 2022,
5+
sourceType: 'module',
6+
globals: {
7+
process: 'readonly',
8+
require: 'readonly',
9+
module: 'readonly',
10+
__dirname: 'readonly',
11+
__filename: 'readonly',
12+
Buffer: 'readonly',
13+
console: 'readonly'
14+
}
15+
},
16+
rules: {
17+
'no-console': 'off',
18+
'no-unused-vars': ['error', {
19+
'argsIgnorePattern': '^_',
20+
'varsIgnorePattern': '^_'
21+
}]
22+
}
23+
};

.github/workflows/ci.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
33

4-
name: Run unit tests
4+
name: CI
55

66
on:
77
push:
@@ -11,22 +11,26 @@ on:
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
1615

1716
strategy:
1817
matrix:
1918
node-version: [18.x, 20.x]
20-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2119

2220
steps:
23-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v4
22+
2423
- name: Use Node.js ${{ matrix.node-version }}
25-
uses: actions/setup-node@v2
24+
uses: actions/setup-node@v4
2625
with:
2726
node-version: ${{ matrix.node-version }}
28-
- run: npm install
29-
- run: npm run lint:cli
30-
- run: npm run lint:src
31-
- run: npm run build --if-present
32-
- run: npm test
27+
cache: 'npm'
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Run linting
33+
run: npm run lint:cli
34+
35+
- name: Run tests
36+
run: npm test

.mocharc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"loader": "esm",
3+
"experimental-modules": true,
4+
"node-option": [
5+
"experimental-vm-modules",
6+
"no-warnings"
7+
]
8+
}

README.md

Lines changed: 191 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,227 @@
1-
# QuantCDN cli
1+
# QuantCDN CLI
22

3-
![Unit tests](https://github.com/quantcdn/quant-cli/actions/workflows/ci.yml/badge.svg)
3+
Command line tools for QuantCDN.
44

5-
Simplify deployments and interactions with the QuantCDN API by using the support cli tool.
5+
## Installation
66

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
199
```
2010

2111
## Usage
2212

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+
```
82111

83112
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:
84113

85-
```
114+
```json
86115
[
87116
{
88117
"title": "This is a record",
89118
"url": "/blog/page",
90119
"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!"
92121
},
93122
{
94123
"title": "Fully featured search record",
95124
"url": "/about-us",
96125
"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.",
98127
"image": "https://www.example.com/images/about.jpg",
99128
"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"
101134
}
102135
]
103136
```
104137

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")
108171
```
109172

110-
**Note:** The path may either refer to an individual file or a path on disk containing multiple JSON files.
173+
## Configuration
111174

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
113184

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
115188

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
116216
```
117-
$ npm run lint
118-
$ npm run test
217+
218+
## Testing
219+
220+
```bash
221+
npm run lint
222+
npm run test
119223
```
120224

121225
## Contributing
122226

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

Comments
 (0)