Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v5.0.0 #274

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open

v5.0.0 #274

wants to merge 41 commits into from

Conversation

stooit
Copy link
Contributor

@stooit stooit commented Nov 23, 2024

Major overhaul of the CLI tool to provide a new base before adding oauth login and Dashboard API controls.

  • Adds interactive mode to CLI when running quant without other args
┌   QuantCDN CLI 
─────────────────────────────────────
Active configuration:
Organization: example-org
Project: example-project
─────────────────────────────────────
│
quant
┌   QuantCDN CLI 
─────────────────────────────────────
Active configuration:
Organization: quant
Project: quant-dashboard
Endpoint: http://localhost:8081/v1
─────────────────────────────────────
│
◆  What would you like to do?
│  ● Deploy an entire directory
│  ○ Deploy a single page
│  ○ Deploy a single file
│  ○ Create a redirect
│  ○ Purge the cache for a path
│  ○ Access WAF logs
│  ○ Perform search index operations
│  ○ Validate local file checksums
│  ○ ───────────────────────
│  ○ Deploy an edge function
│  ○ Deploy an edge filter
│  ○ Deploy an edge auth function
│  ○ ───────────────────────
│  ○ Unpublish an asset
│  ○ Delete an asset
│  ○ ───────────────────────
│  ○ Show project info
│  ○ Reinitialize project settings
  • Moves WAF logs to content API
  • Use concurrency for unpublishing to speed up deployment time
  • Write to revision log after deploy or scan commands execute
  • Batch requests to meta API for scan command for vastly increased performance
  • Prevent deploying conflicting --enable-index-html mode on/off
  • Adds functionality for add/update edge functions, edge auth, edge filters

Adds tests with reasonable coverage.


  Delete Command
    handler
      ✔ should delete a path with force flag
      ✔ should handle missing args
      ✔ should handle config fromArgs failure
      ✔ should handle already deleted paths
      ✔ should handle general errors

  Deploy Command
    handler
      ✔ should deploy files successfully
      ✔ should handle force flag
      ✔ should handle attachments flag
      ✔ should handle skip-unpublish flag
      ✔ should handle non-existent directory
      ✔ should handle empty directory
      ✔ should handle MD5 match errors
      ✔ should handle config fromArgs failure
      ✔ should handle unpublish process
      ✔ should handle skip-unpublish-regex

  File Command
    handler
      ✔ should deploy a single file
      ✔ should prompt for missing file and location
      ✔ should handle cancelled prompt
      ✔ should handle file already exists error
      ✔ should handle missing args
      ✔ should handle config fromArgs failure

  Page Command
    handler
      ✔ should deploy a single page
      ✔ should handle enable-index-html setting
      ✔ should handle MD5 match errors
      ✔ should handle errors
      ✔ should handle config fromArgs failure

  Purge Command
    handler
      ✔ should purge a single path
      ✔ should handle soft purge option
      ✔ should handle cache keys
      ✔ should handle missing args
      ✔ should handle config fromArgs failure
      ✔ should handle general errors

  Redirect Command
    handler
      ✔ should create a redirect
      ✔ should handle MD5 match errors
      ✔ should handle missing args
      ✔ should handle config fromArgs failure
      ✔ should handle general errors
      ✔ should use default status code if not provided

  Unpublish Command
    handler
      ✔ should unpublish a path
      ✔ should handle missing args
      ✔ should handle config fromArgs failure
      ✔ should handle already unpublished paths
      ✔ should handle general errors

  Config
    fromArgs
      ✔ should set defaults when no args provided
      ✔ should load from environment variables
      ✔ should load from quant.json file
      ✔ should prioritize CLI args over environment variables
      ✔ should prioritize CLI args over quant.json
      ✔ should prioritize environment variables over quant.json
      ✔ should track enableIndexHtml setting
    save
      ✔ should save config to quant.json
      ✔ should remove /v1 from endpoint when saving

  isMD5Match Helper
    ✔ should detect MD5 match in error response data
    ✔ should detect MD5 match with "Published version" message in response
    ✔ should detect MD5 match in error message
    ✔ should detect MD5 match with "Published version" in error message
    ✔ should return false for non-MD5 match errors
    ✔ should handle missing response data
    ✔ should handle null error
    ✔ should handle undefined error


  60 passing (42ms)

------------------|---------|----------|---------|---------|----------------------------------------------------------------------------------------------
File              | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                                                                            
------------------|---------|----------|---------|---------|----------------------------------------------------------------------------------------------
All files         |   36.56 |    74.64 |   44.18 |   36.56 |                                                                                              
 src              |   12.73 |    87.09 |      80 |   12.73 |                                                                                              
  config.js       |   87.12 |    86.66 |     100 |   87.12 | 79-93,109-110                                                                                
  quant-client.js |    1.48 |      100 |       0 |    1.48 | 13-872                                                                                       
 src/commands     |   53.66 |    70.46 |   28.57 |   53.66 |                                                                                              
  delete.js       |   53.12 |    66.66 |      25 |   53.12 | 18-29,33-53,68-77,98-99,105-117,119-120                                                      
  deploy.js       |   55.13 |    67.39 |      50 |   55.13 | ...9-112,117-118,121-122,129-130,156-157,183-201,216-217,229-230,242,250-251,264-265,284-285 
  file.js         |   60.46 |    70.58 |      25 |   60.46 | 15-27,31-49,78-79                                                                            
  page.js         |   55.55 |     62.5 |      25 |   55.55 | 15-31,35-53,64-69,82-83                                                                      
  purge.js        |   43.65 |     92.3 |      25 |   43.65 | 16-33,37-89                                                                                  
  redirect.js     |   49.51 |    91.66 |      25 |   49.51 | 17-33,37-71                                                                                  
  unpublish.js    |   58.33 |     62.5 |      25 |   58.33 | 17-22,26-35,61-62,74-76,78-85,89-105,107-108,112-113                                         
 src/helper       |   77.83 |    82.75 |      70 |   77.83 |                                                                                              
  array.js        |   95.65 |    66.66 |     100 |   95.65 | 18                                                                                           
  getFiles.js     |   68.29 |      100 |      50 |   68.29 | 23-35                                                                                        
  is-md5-match.js |     100 |      100 |     100 |     100 |                                                                                              
  quant-url.js    |   67.85 |      100 |       0 |   67.85 | 17-25                                                                                        
  revisions.js    |    72.3 |       60 |      80 |    72.3 | 11-13,21-23,28-30,35-41,45-46                                                                
------------------|---------|----------|---------|---------|----------------------------------------------------------------------------------------------

Allow for non-interactive mode if all required params are passed.
.. lots of other goodness.
Scan will update the local revision log.
Fixed local revision log (write to cwd).
Fixes to search and redirect commands.
Fixed output for some deploy tasks
Fixed search validation of records.
Added new mock client.
Added config + deploy test.
Cleaned up file and page functions.
Implement more of the mock client for tests.
Moved deploy test to use new mock client.
Added support for edge function/filter/auth.
Added delete test.
Fixed delete confirmation.
Fixed unpublish with args and friendlier errs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants