, // --unstabe-kv --unstable-cron
-}
-
#[derive(Clone, Debug, Eq, PartialEq, Default)]
pub struct InternalFlags {
/// Used when the language server is configured with an
@@ -1484,14 +1465,15 @@ fn handle_repl_flags(flags: &mut Flags, repl_flags: ReplFlags) {
}
pub fn clap_root() -> Command {
+ debug_assert_eq!(DENO_VERSION_INFO.typescript, deno_snapshots::TS_VERSION);
let long_version = format!(
"{} ({}, {}, {})\nv8 {}\ntypescript {}",
- crate::version::DENO_VERSION_INFO.deno,
- crate::version::DENO_VERSION_INFO.release_channel.name(),
+ DENO_VERSION_INFO.deno,
+ DENO_VERSION_INFO.release_channel.name(),
env!("PROFILE"),
env!("TARGET"),
deno_core::v8::VERSION_STRING,
- crate::version::DENO_VERSION_INFO.typescript
+ DENO_VERSION_INFO.typescript
);
run_args(Command::new("deno"), true)
@@ -1507,7 +1489,7 @@ pub fn clap_root() -> Command {
)
.color(ColorChoice::Auto)
.term_width(800)
- .version(crate::version::DENO_VERSION_INFO.deno)
+ .version(DENO_VERSION_INFO.deno)
.long_version(long_version)
.disable_version_flag(true)
.disable_help_flag(true)
@@ -4274,7 +4256,7 @@ impl CommandExt for Command {
let mut cmd = self.arg(
Arg::new("unstable")
.long("unstable")
- .help(cstr!("Enable all unstable features and APIs. Instead of using this flag, consider enabling individual unstable features
+ .help(cstr!("The `--unstable` flag has been deprecated. Use granular `--unstable-*` flags instead
To view the list of individual unstable feature flags, run this command again with --help=unstable>"))
.action(ArgAction::SetTrue)
.hide(matches!(cfg, UnstableArgsConfig::None))
diff --git a/cli/args/import_map.rs b/cli/args/import_map.rs
index ff7e42ef20..75a1611120 100644
--- a/cli/args/import_map.rs
+++ b/cli/args/import_map.rs
@@ -13,7 +13,7 @@ pub async fn resolve_import_map_value_from_specifier(
) -> Result {
if specifier.scheme() == "data" {
let data_url_text =
- deno_graph::source::RawDataUrl::parse(specifier)?.decode()?;
+ deno_media_type::data_url::RawDataUrl::parse(specifier)?.decode()?;
Ok(serde_json::from_str(&data_url_text)?)
} else {
let file = TextDecodedFile::decode(
diff --git a/cli/args/lockfile.rs b/cli/args/lockfile.rs
index 976992aac8..5fa6a49c43 100644
--- a/cli/args/lockfile.rs
+++ b/cli/args/lockfile.rs
@@ -61,11 +61,13 @@ impl<'a, T> std::ops::DerefMut for Guard<'a, T> {
}
#[derive(Debug, thiserror::Error, deno_error::JsError)]
-#[error("Failed writing lockfile")]
-#[class(inherit)]
-struct AtomicWriteFileWithRetriesError {
- #[source]
- source: std::io::Error,
+pub enum AtomicWriteFileWithRetriesError {
+ #[class(inherit)]
+ #[error(transparent)]
+ Changed(JsErrorBox),
+ #[class(inherit)]
+ #[error("Failed writing lockfile")]
+ Io(#[source] std::io::Error),
}
impl CliLockfile {
@@ -87,12 +89,16 @@ impl CliLockfile {
self.lockfile.lock().overwrite
}
- pub fn write_if_changed(&self) -> Result<(), JsErrorBox> {
+ pub fn write_if_changed(
+ &self,
+ ) -> Result<(), AtomicWriteFileWithRetriesError> {
if self.skip_write {
return Ok(());
}
- self.error_if_changed()?;
+ self
+ .error_if_changed()
+ .map_err(AtomicWriteFileWithRetriesError::Changed)?;
let mut lockfile = self.lockfile.lock();
let Some(bytes) = lockfile.resolve_write_bytes() else {
return Ok(()); // nothing to do
@@ -105,9 +111,7 @@ impl CliLockfile {
&bytes,
cache::CACHE_PERM,
)
- .map_err(|source| {
- JsErrorBox::from_err(AtomicWriteFileWithRetriesError { source })
- })?;
+ .map_err(AtomicWriteFileWithRetriesError::Io)?;
lockfile.has_content_changed = false;
Ok(())
}
diff --git a/cli/args/mod.rs b/cli/args/mod.rs
index ebd321a20a..e4f332a8bc 100644
--- a/cli/args/mod.rs
+++ b/cli/args/mod.rs
@@ -10,10 +10,6 @@ mod package_json;
use std::borrow::Cow;
use std::collections::HashMap;
use std::env;
-use std::io::BufReader;
-use std::io::Cursor;
-use std::io::Read;
-use std::io::Seek;
use std::net::SocketAddr;
use std::num::NonZeroUsize;
use std::path::Path;
@@ -56,9 +52,15 @@ use deno_core::error::AnyError;
use deno_core::resolve_url_or_path;
use deno_core::serde_json;
use deno_core::url::Url;
-use deno_error::JsErrorBox;
use deno_graph::GraphKind;
pub use deno_json::check_warn_tsconfig;
+use deno_lib::args::has_flag_env_var;
+use deno_lib::args::npm_pkg_req_ref_to_binary_command;
+use deno_lib::args::CaData;
+use deno_lib::args::NpmProcessStateKind;
+use deno_lib::args::NPM_PROCESS_STATE;
+use deno_lib::version::DENO_VERSION_INFO;
+use deno_lib::worker::StorageKeyResolver;
use deno_lint::linter::LintConfig as DenoLintConfig;
use deno_npm::npm_rc::NpmRc;
use deno_npm::npm_rc::ResolvedNpmRc;
@@ -66,27 +68,20 @@ use deno_npm::resolution::ValidSerializedNpmResolutionSnapshot;
use deno_npm::NpmSystemInfo;
use deno_path_util::normalize_path;
use deno_runtime::deno_permissions::PermissionsOptions;
-use deno_runtime::deno_tls::deno_native_certs::load_native_certs;
-use deno_runtime::deno_tls::rustls;
-use deno_runtime::deno_tls::rustls::RootCertStore;
-use deno_runtime::deno_tls::rustls_pemfile;
-use deno_runtime::deno_tls::webpki_roots;
use deno_runtime::inspector_server::InspectorServer;
use deno_semver::npm::NpmPackageReqReference;
use deno_semver::StackString;
use deno_telemetry::OtelConfig;
-use deno_telemetry::OtelRuntimeConfig;
use deno_terminal::colors;
use dotenvy::from_filename;
pub use flags::*;
use import_map::resolve_import_map_value_from_specifier;
+pub use lockfile::AtomicWriteFileWithRetriesError;
pub use lockfile::CliLockfile;
pub use lockfile::CliLockfileReadFromPathOptions;
use once_cell::sync::Lazy;
pub use package_json::NpmInstallDepsProvider;
pub use package_json::PackageJsonDepValueParseWithLocationError;
-use serde::Deserialize;
-use serde::Serialize;
use sys_traits::EnvHomeDir;
use thiserror::Error;
@@ -94,7 +89,6 @@ use crate::cache::DenoDirProvider;
use crate::file_fetcher::CliFileFetcher;
use crate::sys::CliSys;
use crate::util::fs::canonicalize_path_maybe_not_exists;
-use crate::version;
pub fn npm_registry_url() -> &'static Url {
static NPM_REGISTRY_DEFAULT_URL: Lazy = Lazy::new(|| {
@@ -606,147 +600,6 @@ pub fn create_default_npmrc() -> Arc {
})
}
-#[derive(Error, Debug, Clone, deno_error::JsError)]
-#[class(generic)]
-pub enum RootCertStoreLoadError {
- #[error(
- "Unknown certificate store \"{0}\" specified (allowed: \"system,mozilla\")"
- )]
- UnknownStore(String),
- #[error("Unable to add pem file to certificate store: {0}")]
- FailedAddPemFile(String),
- #[error("Failed opening CA file: {0}")]
- CaFileOpenError(String),
-}
-
-/// Create and populate a root cert store based on the passed options and
-/// environment.
-pub fn get_root_cert_store(
- maybe_root_path: Option,
- maybe_ca_stores: Option>,
- maybe_ca_data: Option,
-) -> Result {
- let mut root_cert_store = RootCertStore::empty();
- let ca_stores: Vec = maybe_ca_stores
- .or_else(|| {
- let env_ca_store = env::var("DENO_TLS_CA_STORE").ok()?;
- Some(
- env_ca_store
- .split(',')
- .map(|s| s.trim().to_string())
- .filter(|s| !s.is_empty())
- .collect(),
- )
- })
- .unwrap_or_else(|| vec!["mozilla".to_string()]);
-
- for store in ca_stores.iter() {
- match store.as_str() {
- "mozilla" => {
- root_cert_store.extend(webpki_roots::TLS_SERVER_ROOTS.to_vec());
- }
- "system" => {
- let roots = load_native_certs().expect("could not load platform certs");
- for root in roots {
- if let Err(err) = root_cert_store
- .add(rustls::pki_types::CertificateDer::from(root.0.clone()))
- {
- log::error!(
- "{}",
- colors::yellow(&format!(
- "Unable to add system certificate to certificate store: {:?}",
- err
- ))
- );
- let hex_encoded_root = faster_hex::hex_string(&root.0);
- log::error!("{}", colors::gray(&hex_encoded_root));
- }
- }
- }
- _ => {
- return Err(RootCertStoreLoadError::UnknownStore(store.clone()));
- }
- }
- }
-
- let ca_data =
- maybe_ca_data.or_else(|| env::var("DENO_CERT").ok().map(CaData::File));
- if let Some(ca_data) = ca_data {
- let result = match ca_data {
- CaData::File(ca_file) => {
- let ca_file = if let Some(root) = &maybe_root_path {
- root.join(&ca_file)
- } else {
- PathBuf::from(ca_file)
- };
- let certfile = std::fs::File::open(ca_file).map_err(|err| {
- RootCertStoreLoadError::CaFileOpenError(err.to_string())
- })?;
- let mut reader = BufReader::new(certfile);
- rustls_pemfile::certs(&mut reader).collect::, _>>()
- }
- CaData::Bytes(data) => {
- let mut reader = BufReader::new(Cursor::new(data));
- rustls_pemfile::certs(&mut reader).collect::, _>>()
- }
- };
-
- match result {
- Ok(certs) => {
- root_cert_store.add_parsable_certificates(certs);
- }
- Err(e) => {
- return Err(RootCertStoreLoadError::FailedAddPemFile(e.to_string()));
- }
- }
- }
-
- Ok(root_cert_store)
-}
-
-/// State provided to the process via an environment variable.
-#[derive(Clone, Debug, Serialize, Deserialize)]
-pub struct NpmProcessState {
- pub kind: NpmProcessStateKind,
- pub local_node_modules_path: Option,
-}
-
-#[derive(Clone, Debug, Serialize, Deserialize)]
-pub enum NpmProcessStateKind {
- Snapshot(deno_npm::resolution::SerializedNpmResolutionSnapshot),
- Byonm,
-}
-
-static NPM_PROCESS_STATE: Lazy