@@ -46,8 +46,19 @@ pub fn cli() -> clap::Command {
4646 . short ( 'b' )
4747 . conflicts_with ( "project_path" )
4848 . conflicts_with ( "build_options" )
49+ . conflicts_with ( "js_file" )
4950 . help ( "The system path (absolute or relative) to the compiled wasm binary we should publish, instead of building the project." ) ,
5051 )
52+ . arg (
53+ Arg :: new ( "js_file" )
54+ . value_parser ( clap:: value_parser!( PathBuf ) )
55+ . long ( "js-path" )
56+ . short ( 'j' )
57+ . conflicts_with ( "project_path" )
58+ . conflicts_with ( "build_options" )
59+ . conflicts_with ( "wasm_file" )
60+ . help ( "UNSTABLE: The system path (absolute or relative) to the javascript file we should publish, instead of building the project." ) ,
61+ )
5162 . arg (
5263 Arg :: new ( "num_replicas" )
5364 . value_parser ( clap:: value_parser!( u8 ) )
@@ -90,6 +101,7 @@ pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::E
90101 let force = args. get_flag ( "force" ) ;
91102 let anon_identity = args. get_flag ( "anon_identity" ) ;
92103 let wasm_file = args. get_one :: < PathBuf > ( "wasm_file" ) ;
104+ let js_file = args. get_one :: < PathBuf > ( "js_file" ) ;
93105 let database_host = config. get_host_url ( server) ?;
94106 let build_options = args. get_one :: < String > ( "build_options" ) . unwrap ( ) ;
95107 let num_replicas = args. get_one :: < u8 > ( "num_replicas" ) ;
@@ -108,13 +120,19 @@ pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::E
108120 ) ) ;
109121 }
110122
111- let path_to_wasm = if let Some ( path) = wasm_file {
112- println ! ( "Skipping build. Instead we are publishing {}" , path. display( ) ) ;
113- path. clone ( )
123+ // Decide program file path and read program.
124+ // Optionally build the program.
125+ let ( path_to_program, host_type) = if let Some ( path) = wasm_file {
126+ println ! ( "(WASM) Skipping build. Instead we are publishing {}" , path. display( ) ) ;
127+ ( path. clone ( ) , "Wasm" )
128+ } else if let Some ( path) = js_file {
129+ println ! ( "(JS) Skipping build. Instead we are publishing {}" , path. display( ) ) ;
130+ ( path. clone ( ) , "Js" )
114131 } else {
115- build:: exec_with_argstring ( config. clone ( ) , path_to_project, build_options) . await ?
132+ let path = build:: exec_with_argstring ( config. clone ( ) , path_to_project, build_options) . await ?;
133+ ( path, "Wasm" )
116134 } ;
117- let program_bytes = fs:: read ( path_to_wasm ) ?;
135+ let program_bytes = fs:: read ( path_to_program ) ?;
118136
119137 let server_address = {
120138 let url = Url :: parse ( & database_host) ?;
@@ -191,6 +209,9 @@ pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::E
191209
192210 builder = add_auth_header_opt ( builder, & auth_header) ;
193211
212+ // Set the host type.
213+ builder = builder. query ( & [ ( "host_type" , host_type) ] ) ;
214+
194215 let res = builder. body ( program_bytes) . send ( ) . await ?;
195216 if res. status ( ) == StatusCode :: UNAUTHORIZED && !anon_identity {
196217 // If we're not in the `anon_identity` case, then we have already forced the user to log in above (using `get_auth_header`), so this should be safe to unwrap.
0 commit comments