File tree Expand file tree Collapse file tree 4 files changed +37
-8
lines changed Expand file tree Collapse file tree 4 files changed +37
-8
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " wrangler " : patch
3+ ---
4+
5+ Improve formatting of cache options for hyperdrive list command
Original file line number Diff line number Diff line change @@ -545,13 +545,13 @@ describe("hyperdrive commands", () => {
545545 await runWrangler ( "hyperdrive list" ) ;
546546 expect ( std . out ) . toMatchInlineSnapshot ( `
547547 "📋 Listing Hyperdrive configs
548- ┌──────────────────────────────────────┬─────────┬────────┬────────────────┬──────┬──────────┬─────────────────── ┐
549- │ id │ name │ user │ host │ port │ database │ caching │
550- ├──────────────────────────────────────┼─────────┼────────┼────────────────┼──────┼──────────┼─────────────────── ┤
551- │ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx │ test123 │ test │ example.com │ 5432 │ neondb │ │
552- ├──────────────────────────────────────┼─────────┼────────┼────────────────┼──────┼──────────┼─────────────────── ┤
553- │ yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy │ new-db │ dbuser │ www.google.com │ 3211 │ mydb │ {\\" disabled\\":true} │
554- └──────────────────────────────────────┴─────────┴────────┴────────────────┴──────┴──────────┴─────────────────── ┘"
548+ ┌──────────────────────────────────────┬─────────┬────────┬────────────────┬──────┬──────────┬──────────┐
549+ │ id │ name │ user │ host │ port │ database │ caching │
550+ ├──────────────────────────────────────┼─────────┼────────┼────────────────┼──────┼──────────┼──────────┤
551+ │ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx │ test123 │ test │ example.com │ 5432 │ neondb │ enabled │
552+ ├──────────────────────────────────────┼─────────┼────────┼────────────────┼──────┼──────────┼──────────┤
553+ │ yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy │ new-db │ dbuser │ www.google.com │ 3211 │ mydb │ disabled │
554+ └──────────────────────────────────────┴─────────┴────────┴────────────────┴──────┴──────────┴──────────┘"
555555 ` ) ;
556556 } ) ;
557557
Original file line number Diff line number Diff line change 11import { readConfig } from "../config" ;
22import { logger } from "../logger" ;
33import { listConfigs } from "./client" ;
4+ import { formatCachingOptions } from "./shared" ;
45import type {
56 CommonYargsArgv ,
67 StrictYargsOptionsToInterface ,
@@ -25,7 +26,7 @@ export async function handler(
2526 host : database . origin . host ?? "" ,
2627 port : database . origin . port ?. toString ( ) ?? "" ,
2728 database : database . origin . database ?? "" ,
28- caching : JSON . stringify ( database . caching ) ,
29+ caching : formatCachingOptions ( database . caching ) ,
2930 } ) )
3031 ) ;
3132}
Original file line number Diff line number Diff line change 1+ import type { CachingOptions } from "./client" ;
2+
3+ export function formatCachingOptions (
4+ cachingOptions : CachingOptions | undefined
5+ ) : string {
6+ switch ( cachingOptions ?. disabled ) {
7+ case false : {
8+ if ( cachingOptions . stale_while_revalidate === 0 ) {
9+ return `max_age: ${ cachingOptions . max_age } , stale_while_revalidate: disabled` ;
10+ } else {
11+ return `max_age: ${ cachingOptions . max_age } , stale_while_revalidate: ${ cachingOptions . stale_while_revalidate } ` ;
12+ }
13+ }
14+ case undefined : {
15+ return "enabled" ;
16+ }
17+ case true : {
18+ return "disabled" ;
19+ }
20+ default :
21+ return JSON . stringify ( cachingOptions ) ;
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments