File tree Expand file tree Collapse file tree 3 files changed +70
-0
lines changed 
content/docs/style-guide/components Expand file tree Collapse file tree 3 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 1+ --- 
2+ import  { z  } from  " astro:schema"  ;
3+ import  { experimental_getWranglerCommands  } from  " wrangler"  ;
4+ import  WranglerCommand  from  " ./WranglerCommand.astro"  ;
5+ 
6+ const   props =  z .object ({
7+ 	namespace: z .string (), 
8+ }); 
9+ 
10+ const   { namespace } =  props .parse (Astro .props );
11+ 
12+ const   defs =  experimental_getWranglerCommands ();
13+ 
14+ const   node =  defs .subtree .get (namespace );
15+ 
16+ if  (! node  ||  node .subtree .size  ===  0 ) {
17+ 	throw  new  Error (` [WranglerNamespace] Namespace "${namespace }" not found ` ); 
18+ } 
19+ 
20+ const   definitions:  NonNullable <(typeof  node )[" definition"  ]>[] =  [];
21+ 
22+ function  flattenSubtree(node :  (typeof  defs )[" subtree"  ]) {
23+ 	for  (const   value of  node .values ()) { 
24+ 		if  (value .definition ?.type  ===  " command"  ) { 
25+ 			definitions .push (value .definition ); 
26+ 		} else  { 
27+ 			flattenSubtree (value .subtree ); 
28+ 		} 
29+ 	} 
30+ } 
31+ 
32+ flattenSubtree (node .subtree );
33+ --- 
34+ 
35+ { 
36+ 	definitions .map ((definition ) =>  {
37+ 		if  (definition .type  !==  " command"  ) {
38+ 			throw  new  Error (
39+ 				` [WranglerNamespace] Expected "command" but got "${definition .type }" for "${definition .command }" ` ,
40+ 			);
41+ 		}
42+ 		return  (
43+ 			<WranglerCommand   command = { definition .command .replace (" wrangler "  , " "  )}  />
44+ 		);
45+ 	})
46+ } 
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ export { default as TunnelCalculator } from "./TunnelCalculator.astro";
5858export  {  default  as  Type  }  from  "./Type.astro" ; 
5959export  {  default  as  TypeScriptExample  }  from  "./TypeScriptExample.astro" ; 
6060export  {  default  as  WranglerCommand  }  from  "./WranglerCommand.astro" ; 
61+ export  {  default  as  WranglerNamespace  }  from  "./WranglerNamespace.astro" ; 
6162export  {  default  as  WranglerConfig  }  from  "./WranglerConfig.astro" ; 
6263export  {  default  as  WARPReleases  }  from  "./WARPReleases.astro" ; 
6364export  {  default  as  Width  }  from  "./Width.astro" ; 
Original file line number Diff line number Diff line change 1+ --- 
2+ title : WranglerNamespace 
3+ styleGuide :
4+   component : WranglerNamespace 
5+ --- 
6+ 
7+ The ` WranglerNamespace `  component documents the available commands for a given namespace.
8+ 
9+ This is generated using the Wrangler version in the [ ` cloudflare-docs `  repository] ( https://github.com/cloudflare/cloudflare-docs/blob/production/package.json ) .
10+ 
11+ ## Import  
12+ 
13+ ``` mdx 
14+ import  { WranglerNamespace  } from  " ~/components"  ;
15+ ``` 
16+ 
17+ ## Usage  
18+ 
19+ ``` mdx  live
20+ import  { WranglerNamespace  } from  " ~/components"  ;
21+ 
22+ <WranglerNamespace  namespace = " d1"   />
23+ ``` 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments