@@ -46,8 +46,19 @@ pub fn cli() -> clap::Command {
46
46
. short ( 'b' )
47
47
. conflicts_with ( "project_path" )
48
48
. conflicts_with ( "build_options" )
49
+ . conflicts_with ( "js_file" )
49
50
. help ( "The system path (absolute or relative) to the compiled wasm binary we should publish, instead of building the project." ) ,
50
51
)
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
+ )
51
62
. arg (
52
63
Arg :: new ( "num_replicas" )
53
64
. value_parser ( clap:: value_parser!( u8 ) )
@@ -90,6 +101,7 @@ pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::E
90
101
let force = args. get_flag ( "force" ) ;
91
102
let anon_identity = args. get_flag ( "anon_identity" ) ;
92
103
let wasm_file = args. get_one :: < PathBuf > ( "wasm_file" ) ;
104
+ let js_file = args. get_one :: < PathBuf > ( "js_file" ) ;
93
105
let database_host = config. get_host_url ( server) ?;
94
106
let build_options = args. get_one :: < String > ( "build_options" ) . unwrap ( ) ;
95
107
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
108
120
) ) ;
109
121
}
110
122
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" )
114
131
} 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" )
116
134
} ;
117
- let program_bytes = fs:: read ( path_to_wasm ) ?;
135
+ let program_bytes = fs:: read ( path_to_program ) ?;
118
136
119
137
let server_address = {
120
138
let url = Url :: parse ( & database_host) ?;
@@ -191,6 +209,9 @@ pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::E
191
209
192
210
builder = add_auth_header_opt ( builder, & auth_header) ;
193
211
212
+ // Set the host type.
213
+ builder = builder. query ( & [ ( "host_type" , host_type) ] ) ;
214
+
194
215
let res = builder. body ( program_bytes) . send ( ) . await ?;
195
216
if res. status ( ) == StatusCode :: UNAUTHORIZED && !anon_identity {
196
217
// 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