File tree 4 files changed +37
-8
lines changed
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", () => {
545
545
await runWrangler ( "hyperdrive list" ) ;
546
546
expect ( std . out ) . toMatchInlineSnapshot ( `
547
547
"📋 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
+ └──────────────────────────────────────┴─────────┴────────┴────────────────┴──────┴──────────┴──────────┘"
555
555
` ) ;
556
556
} ) ;
557
557
Original file line number Diff line number Diff line change 1
1
import { readConfig } from "../config" ;
2
2
import { logger } from "../logger" ;
3
3
import { listConfigs } from "./client" ;
4
+ import { formatCachingOptions } from "./shared" ;
4
5
import type {
5
6
CommonYargsArgv ,
6
7
StrictYargsOptionsToInterface ,
@@ -25,7 +26,7 @@ export async function handler(
25
26
host : database . origin . host ?? "" ,
26
27
port : database . origin . port ?. toString ( ) ?? "" ,
27
28
database : database . origin . database ?? "" ,
28
- caching : JSON . stringify ( database . caching ) ,
29
+ caching : formatCachingOptions ( database . caching ) ,
29
30
} ) )
30
31
) ;
31
32
}
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