diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2024-08-15 22:47:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-15 23:47:16 +0200 |
commit | 2bb013f9baa927fc7b392766b0182b91380b9aa8 (patch) | |
tree | ca8a7ea961b50213adf0904d724974c317cefb55 /runtime | |
parent | 5ec3c5c3a46ca95f355a4520676b85ac619ca102 (diff) |
refactor: `version` module exports a single const struct (#25014)
This commit rewrites the internal `version` module that exported
various information about the current executable. Instead of exporting
several consts, we are now exporting a single const structure that
contains all the necessary information.
This is the first step towards cleaning up how we use this information
and should allow us to use SUI to be able to patch this information
in already produced binary making it easier to cut new releases.
---------
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/js/99_main.js | 53 | ||||
-rw-r--r-- | runtime/ops/bootstrap.rs | 2 | ||||
-rw-r--r-- | runtime/worker_bootstrap.rs | 5 |
3 files changed, 32 insertions, 28 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 5e25a3818..013f4996f 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -672,7 +672,6 @@ ObjectDefineProperties(finalDenoNs, { }); const { - denoVersion, tsVersion, v8Version, target, @@ -697,21 +696,22 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) { } const { - 0: location_, - 1: unstableFlag, - 2: unstableFeatures, - 3: inspectFlag, - 5: hasNodeModulesDir, - 6: argv0, - 7: nodeDebug, - 8: shouldDisableDeprecatedApiWarning, - 9: shouldUseVerboseDeprecatedApiWarning, - 10: future, - 11: mode, - 12: servePort, - 13: serveHost, - 14: serveIsMain, - 15: serveWorkerCount, + 0: denoVersion, + 1: location_, + 2: unstableFlag, + 3: unstableFeatures, + 4: inspectFlag, + 6: hasNodeModulesDir, + 7: argv0, + 8: nodeDebug, + 9: shouldDisableDeprecatedApiWarning, + 10: shouldUseVerboseDeprecatedApiWarning, + 11: future, + 12: mode, + 13: servePort, + 14: serveHost, + 15: serveIsMain, + 16: serveWorkerCount, } = runtimeOptions; if (mode === executionModes.serve) { @@ -970,16 +970,17 @@ function bootstrapWorkerRuntime( } const { - 0: location_, - 1: unstableFlag, - 2: unstableFeatures, - 4: enableTestingFeaturesFlag, - 5: hasNodeModulesDir, - 6: argv0, - 7: nodeDebug, - 8: shouldDisableDeprecatedApiWarning, - 9: shouldUseVerboseDeprecatedApiWarning, - 10: future, + 0: denoVersion, + 1: location_, + 2: unstableFlag, + 3: unstableFeatures, + 5: enableTestingFeaturesFlag, + 6: hasNodeModulesDir, + 7: argv0, + 8: nodeDebug, + 9: shouldDisableDeprecatedApiWarning, + 10: shouldUseVerboseDeprecatedApiWarning, + 11: future, } = runtimeOptions; // TODO(iuioiua): remove in Deno v2. This allows us to dynamically delete diff --git a/runtime/ops/bootstrap.rs b/runtime/ops/bootstrap.rs index 997bebd76..88475f415 100644 --- a/runtime/ops/bootstrap.rs +++ b/runtime/ops/bootstrap.rs @@ -36,7 +36,6 @@ deno_core::extension!( #[derive(Serialize)] #[serde(rename_all = "camelCase")] pub struct SnapshotOptions { - pub deno_version: String, pub ts_version: String, pub v8_version: &'static str, pub target: String, @@ -54,7 +53,6 @@ impl Default for SnapshotOptions { }; Self { - deno_version: "dev".to_owned(), ts_version: "n/a".to_owned(), v8_version: deno_core::v8_version(), target, diff --git a/runtime/worker_bootstrap.rs b/runtime/worker_bootstrap.rs index afd3242e8..b04a337a6 100644 --- a/runtime/worker_bootstrap.rs +++ b/runtime/worker_bootstrap.rs @@ -92,6 +92,7 @@ impl From<log::Level> for WorkerLogLevel { /// Common bootstrap options for MainWorker & WebWorker #[derive(Clone)] pub struct BootstrapOptions { + pub deno_version: String, /// Sets `Deno.args` in JS runtime. pub args: Vec<String>, pub cpu_count: usize, @@ -134,6 +135,7 @@ impl Default for BootstrapOptions { let user_agent = format!("Deno/{runtime_version}"); Self { + deno_version: runtime_version.to_string(), user_agent, cpu_count, no_color: !colors::use_color(), @@ -174,6 +176,8 @@ impl Default for BootstrapOptions { /// Keep this in sync with `99_main.js`. #[derive(Serialize)] struct BootstrapV8<'a>( + // deno version + &'a str, // location Option<&'a str>, // unstable @@ -219,6 +223,7 @@ impl BootstrapOptions { let (serve_is_main, serve_worker_count) = self.mode.serve_info(); let bootstrap = BootstrapV8( + &self.deno_version, self.location.as_ref().map(|l| l.as_str()), self.unstable, self.unstable_features.as_ref(), |