• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / edge-runtime / 14876524117

07 May 2025 06:18AM UTC coverage: 51.423% (-0.05%) from 51.468%
14876524117

Pull #538

github

web-flow
Merge 1ef60f38d into 0acdf1b78
Pull Request #538: fix: bring back decorator flag in bundle command

0 of 21 new or added lines in 2 files covered. (0.0%)

5 existing lines in 5 files now uncovered.

17853 of 34718 relevant lines covered (51.42%)

5593.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/cli/src/flags.rs
1
use std::net::SocketAddr;
2
use std::path::PathBuf;
3

4
use clap::arg;
5
use clap::builder::BoolishValueParser;
6
use clap::builder::FalseyValueParser;
7
use clap::builder::TypedValueParser;
8
use clap::crate_version;
9
use clap::value_parser;
10
use clap::ArgAction;
11
use clap::ArgGroup;
12
use clap::Command;
13
use clap::ValueEnum;
14
use deno_facade::Checksum;
15

16
#[derive(ValueEnum, Default, Clone, Copy)]
17
#[repr(u8)]
18
pub(super) enum EszipV2ChecksumKind {
19
  #[default]
20
  NoChecksum = 0,
21
  Sha256 = 1,
22
  XxHash3 = 2,
23
}
24

25
impl From<EszipV2ChecksumKind> for Option<Checksum> {
26
  fn from(value: EszipV2ChecksumKind) -> Self {
×
27
    Checksum::from_u8(value as u8)
×
28
  }
×
29
}
30

31
pub(super) fn get_cli() -> Command {
×
32
  Command::new(env!("CARGO_BIN_NAME"))
×
33
    .about(env!("CARGO_PKG_DESCRIPTION"))
×
34
    .version(format!(
×
35
      "{}\ndeno {} ({}, {})",
×
36
      crate_version!(),
×
37
      deno::version(),
×
38
      env!("PROFILE"),
×
39
      env!("TARGET")
×
40
    ))
×
41
    .arg_required_else_help(true)
×
42
    .arg(
×
43
      arg!(-v --verbose "Use verbose output")
×
44
        .conflicts_with("quiet")
×
45
        .global(true)
×
46
        .action(ArgAction::SetTrue),
×
47
    )
×
48
    .arg(
×
49
      arg!(-q --quiet "Do not print any log messages")
×
50
        .conflicts_with("verbose")
×
51
        .global(true)
×
52
        .action(ArgAction::SetTrue),
×
53
    )
×
54
    .arg(
×
55
      arg!(--"log-source")
×
56
        .help("Include source file and line in log messages")
×
57
        .global(true)
×
58
        .action(ArgAction::SetTrue),
×
59
    )
×
60
    .subcommand(get_start_command())
×
61
    .subcommand(get_bundle_command())
×
62
    .subcommand(get_unbundle_command())
×
63
}
×
64

65
fn get_start_command() -> Command {
×
66
  Command::new("start")
×
67
    .about("Start the server")
×
68
    .arg(
×
69
      arg!(-i --ip <HOST>)
×
70
        .help("Host IP address to listen on")
×
71
        .default_value("0.0.0.0"),
×
72
    )
×
73
    .arg(
×
74
      arg!(-p --port <PORT>)
×
75
        .help("Port to listen on")
×
76
        .env("EDGE_RUNTIME_PORT")
×
77
        .default_value("9000")
×
78
        .value_parser(value_parser!(u16)),
×
79
    )
×
80
    .arg(
×
81
      arg!(--tls[PORT])
×
82
        .env("EDGE_RUNTIME_TLS")
×
83
        .num_args(0..=1)
×
84
        .default_missing_value("443")
×
85
        .value_parser(value_parser!(u16))
×
86
        .requires("key")
×
87
        .requires("cert"),
×
88
    )
×
89
    .arg(
×
90
      arg!(--key <Path>)
×
91
        .help("Path to PEM-encoded key to be used to TLS")
×
92
        .env("EDGE_RUNTIME_TLS_KEY_PATH")
×
93
        .value_parser(value_parser!(PathBuf)),
×
94
    )
×
95
    .arg(
×
96
      arg!(--cert <Path>)
×
97
        .help("Path to PEM-encoded X.509 certificate to be used to TLS")
×
98
        .env("EDGE_RUNTIME_TLS_CERT_PATH")
×
99
        .value_parser(value_parser!(PathBuf)),
×
100
    )
×
101
    .arg(
×
102
      arg!(--"main-service" <DIR>)
×
103
        .help("Path to main service directory or eszip")
×
104
        .default_value("examples/main"),
×
105
    )
×
106
    .arg(
×
107
      arg!(--"disable-module-cache")
×
108
        .help("Disable using module cache")
×
109
        .default_value("false")
×
110
        .value_parser(FalseyValueParser::new()),
×
111
    )
×
112
    .arg(arg!(--"event-worker" <Path>).help("Path to event worker directory"))
×
113
    .arg(
×
114
      arg!(--"main-entrypoint" <Path>)
×
115
        .help("Path to entrypoint in main service (only for eszips)"),
×
116
    )
×
117
    .arg(
×
118
      arg!(--"events-entrypoint" <Path>)
×
119
        .help("Path to entrypoint in events worker (only for eszips)"),
×
120
    )
×
121
    .arg(
×
122
      arg!(--"policy" <POLICY>)
×
123
        .help("Policy to enforce in the worker pool")
×
124
        .default_value("per_worker")
×
125
        .value_parser(["per_worker", "per_request", "oneshot"]),
×
126
    )
×
127
    .arg(
×
128
      arg!(--"graceful-exit-timeout"[SECONDS])
×
129
        .help(concat!(
×
130
          "Maximum time in seconds that can wait for workers before ",
×
131
          "terminating forcibly. If providing zero value, the runtime will ",
×
132
          "not try a graceful exit."
×
133
        ))
×
134
        // NOTE(Nyannyacha): Default timeout value follows the
×
135
        // value[1] defined in moby.
×
136
        //
×
137
        // [1]: https://github.com/moby/moby/blob/master/daemon/config/config.go#L45-L47
×
138
        .default_value("15")
×
139
        .value_parser(value_parser!(u64).range(..u64::MAX)),
×
140
    )
×
141
    .arg(
×
142
      arg!(--"event-worker-exit-timeout"[SECONDS])
×
143
        .help(concat!(
×
144
          "Maximum time in seconds that can wait for the event worker before ",
×
145
          "terminating forcibly. (graceful exit)"
×
146
        ))
×
147
        .default_value("10")
×
148
        .value_parser(value_parser!(u64).range(..u64::MAX)),
×
149
    )
×
150
    .arg(
×
151
      arg!(
×
152
        --"experimental-graceful-exit-keepalive-deadline-ratio"
×
153
        <PERCENTAGE>
154
      )
155
      .help(concat!(
×
156
        "(Experimental) Maximum period of time that incoming requests ",
×
157
        "can be processed over a pre-established keep-alive HTTP connection. ",
×
158
        "This is specified as a percentage of the `--graceful-exit-timeout` ",
×
159
        "value. The percentage cannot be greater than 95."
×
160
      ))
×
161
      .value_parser(value_parser!(u64).range(..=95)),
×
162
    )
×
163
    .arg(
×
164
      arg!(--"max-parallelism" <COUNT>)
×
165
        .help(concat!(
×
166
          "Maximum count of workers that can exist in the worker pool ",
×
167
          "simultaneously"
×
168
        ))
×
169
        .value_parser(
×
170
          // NOTE: Acceptable bounds were chosen arbitrarily.
×
171
          value_parser!(u32)
×
172
            .range(1..9999)
×
173
            .map(|it| -> usize { it as usize }),
×
174
        ),
×
175
    )
×
176
    .arg(
×
177
      arg!(--"request-wait-timeout" <MILLISECONDS>)
×
178
        .help(concat!(
×
179
          "Maximum time in milliseconds that can wait to establish a ",
×
180
          "connection with a worker"
×
181
        ))
×
182
        .default_value("10000")
×
183
        .value_parser(value_parser!(u64)),
×
184
    )
×
185
    .arg(
×
186
      arg!(--"request-idle-timeout" <MILLISECONDS>)
×
187
        .help(concat!(
×
188
          "Maximum time in milliseconds that can be waited from when a ",
×
189
          "worker takes over the request (disabled by default)"
×
190
        ))
×
191
        .value_parser(value_parser!(u64)),
×
192
    )
×
193
    .arg(
×
194
      arg!(--"request-read-timeout" <MILLISECONDS>)
×
195
        .help(concat!(
×
196
          "Maximum time in milliseconds that can be waited from when the ",
×
197
          "connection is accepted until the request body is fully read ",
×
198
          "(disabled by default)"
×
199
        ))
×
200
        .value_parser(value_parser!(u64)),
×
201
    )
×
202
    .arg(
×
203
      arg!(--"inspect"[HOST_AND_PORT])
×
204
        .help("Activate inspector on host:port")
×
205
        .num_args(0..=1)
×
206
        .value_parser(value_parser!(SocketAddr))
×
207
        .require_equals(true)
×
208
        .default_missing_value("127.0.0.1:9229"),
×
209
    )
×
210
    .arg(
×
211
      arg!(--"inspect-brk"[HOST_AND_PORT])
×
212
        .help(concat!(
×
213
          "Activate inspector on host:port, wait for debugger to connect ",
×
214
          "and break at the start of user script"
×
215
        ))
×
216
        .num_args(0..=1)
×
217
        .value_parser(value_parser!(SocketAddr))
×
218
        .require_equals(true)
×
219
        .default_missing_value("127.0.0.1:9229"),
×
220
    )
×
221
    .arg(
×
222
      arg!(--"inspect-wait"[HOST_AND_PORT])
×
223
        .help(concat!(
×
224
          "Activate inspector on host:port and wait for debugger to ",
×
225
          "connect before running user code"
×
226
        ))
×
227
        .num_args(0..=1)
×
228
        .value_parser(value_parser!(SocketAddr))
×
229
        .require_equals(true)
×
230
        .default_missing_value("127.0.0.1:9229"),
×
231
    )
×
232
    .group(ArgGroup::new("inspector").args([
×
233
      "inspect",
×
234
      "inspect-brk",
×
235
      "inspect-wait",
×
236
    ]))
×
237
    .arg(
×
238
      arg!(--"inspect-main")
×
239
        .help("Allow creating inspector for main worker")
×
240
        .requires("inspector")
×
241
        .action(ArgAction::SetTrue),
×
242
    )
×
243
    .arg(
×
244
      arg!(--"static" <Path>)
×
245
        .help("Glob pattern for static files to be included")
×
246
        .action(ArgAction::Append),
×
247
    )
×
248
    .arg(
×
249
      arg!(--"tcp-nodelay"[BOOL])
×
250
        .help("Disables Nagle's algorithm")
×
251
        .num_args(0..=1)
×
252
        .value_parser(BoolishValueParser::new())
×
253
        .require_equals(true)
×
254
        .default_value("true")
×
255
        .default_missing_value("true"),
×
256
    )
×
257
    .arg(
×
258
      arg!(--"request-buffer-size" <BYTES>)
×
259
        .help(concat!(
×
260
          "The buffer size of the stream that is used to forward a request ",
×
261
          "to the worker"
×
262
        ))
×
263
        .value_parser(value_parser!(u64))
×
264
        .default_value("16384"),
×
265
    )
×
266
    .arg(
×
267
      arg!(--"dispatch-beforeunload-wall-clock-ratio" <PERCENTAGE>)
×
268
        .value_parser(value_parser!(u8).range(..=99))
×
269
        .default_value("90"),
×
270
    )
×
271
    .arg(
×
272
      arg!(--"dispatch-beforeunload-cpu-ratio" <PERCENTAGE>)
×
273
        .value_parser(value_parser!(u8).range(..=99))
×
274
        .default_value("90"),
×
275
    )
×
276
    .arg(
×
277
      arg!(--"dispatch-beforeunload-memory-ratio" <PERCENTAGE>)
×
278
        .value_parser(value_parser!(u8).range(..=99))
×
279
        .default_value("90"),
×
280
    )
×
281
}
×
282

283
fn get_bundle_command() -> Command {
×
284
  Command::new("bundle")
×
285
    .about(concat!(
×
286
      "Creates an 'eszip' file that can be executed by the EdgeRuntime. ",
×
287
      "Such file contains all the modules in contained in a single binary."
×
288
    ))
×
289
    .arg(
×
290
      arg!(--"output" <DIR>)
×
291
        .help("Path to output eszip file")
×
292
        .default_value("bin.eszip"),
×
293
    )
×
294
    .arg(
×
295
      arg!(--"entrypoint" <Path>)
×
296
        .help("Path to entrypoint to bundle as an eszip")
×
297
        .required(true),
×
298
    )
×
299
    .arg(
×
300
      arg!(--"static" <Path>)
×
301
        .help("Glob pattern for static files to be included")
×
302
        .action(ArgAction::Append),
×
303
    )
×
304
    .arg(
×
305
      arg!(--"import-map" <Path>).help("(DEPRECATED) Path to import map file"),
×
306
    )
×
NEW
307
    .arg(
×
NEW
308
      arg!(--"decorator" <TYPE>)
×
NEW
309
        .help(concat!(
×
NEW
310
          "(DEPRECATED) Type of decorator to use on the main worker and event worker. ",
×
NEW
311
          "If not specified, the decorator feature is disabled."
×
NEW
312
        ))
×
NEW
313
        .value_parser(["tc39", "typescript", "typescript_with_metadata"]),
×
NEW
314
    )
×
315
    .arg(
×
316
      arg!(--"checksum" <KIND>)
×
317
        .env("EDGE_RUNTIME_BUNDLE_CHECKSUM")
×
318
        .help("Hash function to use when checksum the contents")
×
319
        .value_parser(value_parser!(EszipV2ChecksumKind)),
×
320
    )
×
321
    .arg(
×
322
      arg!(--"disable-module-cache")
×
323
        .help("Disable using module cache")
×
324
        .default_value("false")
×
325
        .value_parser(FalseyValueParser::new()),
×
326
    )
×
327
}
×
328

329
fn get_unbundle_command() -> Command {
×
330
  Command::new("unbundle")
×
331
    .about("Unbundles an .eszip file into the specified directory")
×
332
    .arg(
×
333
      arg!(--"output" <DIR>)
×
334
        .help("Path to extract the ESZIP content")
×
335
        .default_value("./"),
×
336
    )
×
337
    .arg(
×
338
      arg!(--"eszip" <DIR>)
×
339
        .help("Path of eszip to extract")
×
340
        .required(true),
×
341
    )
×
342
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc