@@ -6,55 +6,60 @@ import { writeFile } from 'node:fs/promises';
66import { resolve } from 'node:path' ;
77
88export async function componentizeCmd ( jsSource , opts ) {
9- const { component } = await componentize ( {
10- sourcePath : jsSource ,
11- witPath : resolve ( opts . wit ) ,
12- worldName : opts . worldName ,
13- runtimeArgs : opts . runtimeArgs ,
14- disableFeatures : opts . disable ,
15- preview2Adapter : opts . preview2Adapter ,
16- debugBindings : opts . debugBindings ,
17- debugBuild : opts . useDebugBuild ,
18- enableWizerLogging : opts . enableWizerLogging ,
19- } ) ;
20- await writeFile ( opts . out , component ) ;
9+ const { component } = await componentize ( {
10+ sourcePath : jsSource ,
11+ witPath : resolve ( opts . wit ) ,
12+ worldName : opts . worldName ,
13+ runtimeArgs : opts . runtimeArgs ,
14+ disableFeatures : opts . disable ,
15+ preview2Adapter : opts . preview2Adapter ,
16+ debugBindings : opts . debugBindings ,
17+ debugBuild : opts . useDebugBuild ,
18+ enableWizerLogging : opts . enableWizerLogging ,
19+ splicerBin : opts . splicerBin ,
20+ } ) ;
21+ await writeFile ( opts . out , component ) ;
2122}
2223
2324program
24- . version ( '0.19.1' )
25- . description ( 'Create a component from a JavaScript module' )
26- . usage ( '<js-source> --wit wit-world.wit -o <component-path>' )
27- . argument ( '<js-source>' , 'JS source file to build' )
28- . requiredOption ( '-w, --wit <path>' , 'WIT path to build with' )
29- . option ( '-n, --world-name <name>' , 'WIT world to build' )
30- . option ( '--runtime-args <string>' , 'arguments to pass to the runtime' )
31- . addOption (
32- new Option ( '-d, --disable <feature...>' , 'disable WASI features' ) . choices (
33- DEFAULT_FEATURES ,
34- ) ,
35- )
36- . option (
37- '--preview2-adapter <adapter>' ,
38- 'provide a custom preview2 adapter path' ,
39- )
40- . option ( '--use-debug-build' , 'use a debug build of StarlingMonkey' )
41- . option ( '--debug-bindings' , 'enable debug logging for bindings generation' )
42- . option (
43- '--enable-wizer-logging' ,
44- 'enable debug logging for calls in the generated component' ,
45- )
46- . requiredOption ( '-o, --out <out>' , 'output component file' )
47- . action ( asyncAction ( componentizeCmd ) ) ;
25+ . version ( '0.19.1' )
26+ . description ( 'Create a component from a JavaScript module' )
27+ . usage ( '<js-source> --wit wit-world.wit -o <component-path>' )
28+ . argument ( '<js-source>' , 'JS source file to build' )
29+ . requiredOption ( '-w, --wit <path>' , 'WIT path to build with' )
30+ . option ( '-n, --world-name <name>' , 'WIT world to build' )
31+ . option ( '--runtime-args <string>' , 'arguments to pass to the runtime' )
32+ . addOption (
33+ new Option ( '-d, --disable <feature...>' , 'disable WASI features' ) . choices (
34+ DEFAULT_FEATURES ,
35+ ) ,
36+ )
37+ . option (
38+ '--preview2-adapter <adapter>' ,
39+ 'provide a custom preview2 adapter path' ,
40+ )
41+ . option ( '--use-debug-build' , 'use a debug build of StarlingMonkey' )
42+ . option ( '--debug-bindings' , 'enable debug logging for bindings generation' )
43+ . option (
44+ '--enable-wizer-logging' ,
45+ 'enable debug logging for calls in the generated component' ,
46+ )
47+ . option (
48+ '--splicer-bin <binary_path>' ,
49+ 'use native CLI splicer for better performance' ,
50+ )
51+ . requiredOption ( '-o, --out <out>' , 'output component file' )
52+ . action ( asyncAction ( componentizeCmd ) ) ;
4853
4954program . showHelpAfterError ( ) ;
5055
5156program . parse ( ) ;
5257
5358function asyncAction ( cmd ) {
54- return function ( ) {
55- const args = [ ...arguments ] ;
56- ( async ( ) => {
57- await cmd . apply ( null , args ) ;
58- } ) ( ) ;
59- } ;
59+ return function ( ) {
60+ const args = [ ...arguments ] ;
61+ ( async ( ) => {
62+ await cmd . apply ( null , args ) ;
63+ } ) ( ) ;
64+ } ;
6065}
0 commit comments