Skip to content

Commit

Permalink
Merge branch 'main' into jsdocs-websockets
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisjofrank authored Feb 6, 2025
2 parents 5c862cc + 15cfa05 commit 75f7ca0
Show file tree
Hide file tree
Showing 128 changed files with 9,512 additions and 3,128 deletions.
198 changes: 170 additions & 28 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ deno_ast = { version = "=0.44.0", features = ["transpiling"] }
deno_core = { version = "0.333.0" }

deno_bench_util = { version = "0.183.0", path = "./bench_util" }
deno_config = { version = "=0.47.1", features = ["workspace"] }
deno_config = { version = "=0.48.0", features = ["workspace"] }
deno_lockfile = "=0.24.0"
deno_media_type = { version = "=0.2.5", features = ["module_specifier"] }
deno_npm = "=0.27.2"
Expand Down Expand Up @@ -123,7 +123,7 @@ cbc = { version = "=0.1.2", features = ["alloc"] }
# Instead use util::time::utc_now()
chrono = { version = "0.4", default-features = false, features = ["std", "serde"] }
color-print = "0.3.5"
console_static_text = "=0.8.1"
console_static_text = "=0.8.3"
ctr = { version = "0.9.2", features = ["alloc"] }
dashmap = "5.5.3"
data-encoding = "2.3.3"
Expand Down Expand Up @@ -155,6 +155,7 @@ hyper = { version = "1.6.0", features = ["full"] }
hyper-rustls = { version = "0.27.2", default-features = false, features = ["http1", "http2", "tls12", "ring"] }
hyper-util = { version = "0.1.10", features = ["tokio", "client", "client-legacy", "server", "server-auto"] }
hyper_v014 = { package = "hyper", version = "0.14.26", features = ["runtime", "http1"] }
import_map = { version = "0.21.0", features = ["ext"] }
indexmap = { version = "2", features = ["serde"] }
ipnet = "2.3"
jsonc-parser = { version = "=0.26.2", features = ["serde"] }
Expand Down Expand Up @@ -184,7 +185,7 @@ rand = "=0.8.5"
regex = "^1.7.0"
reqwest = { version = "=0.12.5", default-features = false, features = ["rustls-tls", "stream", "gzip", "brotli", "socks", "json", "http2"] } # pinned because of https://github.com/seanmonstar/reqwest/pull/1955
ring = "^0.17.0"
rusqlite = { version = "0.32.0", features = ["unlock_notify", "bundled"] }
rusqlite = { version = "0.32.0", features = ["unlock_notify", "bundled", "session"] }
rustls = { version = "0.23.11", default-features = false, features = ["logging", "std", "tls12", "ring"] }
rustls-pemfile = "2"
rustls-tokio-stream = "=0.3.0"
Expand Down
4 changes: 3 additions & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ deno_doc = { version = "=0.164.0", features = ["rust", "comrak"] }
deno_error.workspace = true
deno_graph = { version = "=0.87.2" }
deno_lib.workspace = true
deno_lint = { version = "0.70.0" }
deno_lint = { version = "0.71.0" }
deno_lockfile.workspace = true
deno_media_type = { workspace = true, features = ["data_url", "decoding", "module_specifier"] }
deno_npm.workspace = true
Expand Down Expand Up @@ -105,6 +105,7 @@ clap_complete = "=4.5.24"
clap_complete_fig = "=4.5.2"
color-print.workspace = true
console_static_text.workspace = true
crossterm = "0.28.1"
dashmap.workspace = true
data-encoding.workspace = true
dhat = { version = "0.3.3", optional = true }
Expand Down Expand Up @@ -169,6 +170,7 @@ tower-lsp.workspace = true
tracing = { version = "0.1", features = ["log", "default"] }
twox-hash.workspace = true
typed-arena = "=2.0.2"
unicode-width = "0.1.3"
uuid = { workspace = true, features = ["serde"] }
walkdir.workspace = true
which.workspace = true
Expand Down
54 changes: 44 additions & 10 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ pub enum DenoSubcommand {

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum OutdatedKind {
Update { latest: bool },
Update { latest: bool, interactive: bool },
PrintOutdated { compatible: bool },
}

Expand All @@ -499,6 +499,7 @@ impl DenoSubcommand {
| Self::Jupyter(_)
| Self::Repl(_)
| Self::Bench(_)
| Self::Lint(_)
| Self::Lsp
)
}
Expand Down Expand Up @@ -2660,7 +2661,7 @@ Specific version requirements to update to can be specified:
.long("latest")
.action(ArgAction::SetTrue)
.help(
"Update to the latest version, regardless of semver constraints",
"Consider the latest version, regardless of semver constraints",
)
.conflicts_with("compatible"),
)
Expand All @@ -2669,15 +2670,21 @@ Specific version requirements to update to can be specified:
.long("update")
.short('u')
.action(ArgAction::SetTrue)
.conflicts_with("compatible")
.help("Update dependency versions"),
)
.arg(
Arg::new("interactive")
.long("interactive")
.short('i')
.action(ArgAction::SetTrue)
.requires("update")
.help("Interactively select which dependencies to update")
)
.arg(
Arg::new("compatible")
.long("compatible")
.action(ArgAction::SetTrue)
.help("Only output versions that satisfy semver requirements")
.conflicts_with("update"),
.help("Only consider versions that satisfy semver requirements")
)
.arg(
Arg::new("recursive")
Expand Down Expand Up @@ -4462,7 +4469,11 @@ fn outdated_parse(
let update = matches.get_flag("update");
let kind = if update {
let latest = matches.get_flag("latest");
OutdatedKind::Update { latest }
let interactive = matches.get_flag("interactive");
OutdatedKind::Update {
latest,
interactive,
}
} else {
let compatible = matches.get_flag("compatible");
OutdatedKind::PrintOutdated { compatible }
Expand Down Expand Up @@ -11646,31 +11657,43 @@ Usage: deno repl [OPTIONS] [-- [ARGS]...]\n"
svec!["--update"],
OutdatedFlags {
filters: vec![],
kind: OutdatedKind::Update { latest: false },
kind: OutdatedKind::Update {
latest: false,
interactive: false,
},
recursive: false,
},
),
(
svec!["--update", "--latest"],
OutdatedFlags {
filters: vec![],
kind: OutdatedKind::Update { latest: true },
kind: OutdatedKind::Update {
latest: true,
interactive: false,
},
recursive: false,
},
),
(
svec!["--update", "--recursive"],
OutdatedFlags {
filters: vec![],
kind: OutdatedKind::Update { latest: false },
kind: OutdatedKind::Update {
latest: false,
interactive: false,
},
recursive: true,
},
),
(
svec!["--update", "@foo/bar"],
OutdatedFlags {
filters: svec!["@foo/bar"],
kind: OutdatedKind::Update { latest: false },
kind: OutdatedKind::Update {
latest: false,
interactive: false,
},
recursive: false,
},
),
Expand All @@ -11682,6 +11705,17 @@ Usage: deno repl [OPTIONS] [-- [ARGS]...]\n"
recursive: false,
},
),
(
svec!["--update", "--latest", "--interactive"],
OutdatedFlags {
filters: svec![],
kind: OutdatedKind::Update {
latest: true,
interactive: true,
},
recursive: false,
},
),
];
for (input, expected) in cases {
let mut args = svec!["deno", "outdated"];
Expand Down
42 changes: 32 additions & 10 deletions cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ pub struct LintOptions {
pub rules: LintRulesConfig,
pub files: FilePatterns,
pub fix: bool,
pub plugins: Vec<Url>,
}

impl Default for LintOptions {
Expand All @@ -380,20 +381,41 @@ impl LintOptions {
rules: Default::default(),
files: FilePatterns::new_with_base(base),
fix: false,
plugins: vec![],
}
}

pub fn resolve(lint_config: LintConfig, lint_flags: &LintFlags) -> Self {
Self {
pub fn resolve(
dir_path: PathBuf,
lint_config: LintConfig,
lint_flags: &LintFlags,
) -> Result<Self, AnyError> {
let rules = resolve_lint_rules_options(
lint_config.options.rules,
lint_flags.maybe_rules_tags.clone(),
lint_flags.maybe_rules_include.clone(),
lint_flags.maybe_rules_exclude.clone(),
);

let plugins = {
let plugin_specifiers = lint_config.options.plugins;
let mut plugins = Vec::with_capacity(plugin_specifiers.len());
for plugin in &plugin_specifiers {
// TODO(bartlomieju): handle import-mapped specifiers
let url = resolve_url_or_path(plugin, &dir_path)?;
plugins.push(url);
}
// ensure stability for hasher
plugins.sort_unstable();
plugins
};

Ok(Self {
files: lint_config.files,
rules: resolve_lint_rules_options(
lint_config.options.rules,
lint_flags.maybe_rules_tags.clone(),
lint_flags.maybe_rules_include.clone(),
lint_flags.maybe_rules_exclude.clone(),
),
rules,
fix: lint_flags.fix,
}
plugins,
})
}
}

Expand Down Expand Up @@ -759,7 +781,7 @@ impl CliOptions {
.resolve_lint_config_for_members(&cli_arg_patterns)?;
let mut result = Vec::with_capacity(member_configs.len());
for (ctx, config) in member_configs {
let options = LintOptions::resolve(config, lint_flags);
let options = LintOptions::resolve(ctx.dir_path(), config, lint_flags)?;
result.push((ctx, options));
}
Ok(result)
Expand Down
26 changes: 9 additions & 17 deletions cli/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::sync::Arc;
use deno_cache_dir::npm::NpmCacheDir;
use deno_config::workspace::Workspace;
use deno_config::workspace::WorkspaceDirectory;
use deno_config::workspace::WorkspaceResolver;
use deno_core::anyhow::Context;
use deno_core::error::AnyError;
use deno_core::futures::FutureExt;
Expand Down Expand Up @@ -38,6 +37,7 @@ use deno_resolver::factory::ResolverFactoryOptions;
use deno_resolver::factory::SpecifiedImportMapProvider;
use deno_resolver::npm::managed::NpmResolutionCell;
use deno_resolver::npm::DenoInNpmPackageChecker;
use deno_resolver::workspace::WorkspaceResolver;
use deno_runtime::deno_fs;
use deno_runtime::deno_fs::RealFs;
use deno_runtime::deno_permissions::Permissions;
Expand Down Expand Up @@ -97,7 +97,6 @@ use crate::resolver::CliDenoResolver;
use crate::resolver::CliNpmGraphResolver;
use crate::resolver::CliNpmReqResolver;
use crate::resolver::CliResolver;
use crate::resolver::CliSloppyImportsResolver;
use crate::resolver::FoundPackageJsonDepFlag;
use crate::standalone::binary::DenoCompileBinaryWriter;
use crate::sys::CliSys;
Expand Down Expand Up @@ -160,7 +159,8 @@ struct CliSpecifiedImportMapProvider {
impl SpecifiedImportMapProvider for CliSpecifiedImportMapProvider {
async fn get(
&self,
) -> Result<Option<deno_config::workspace::SpecifiedImportMap>, AnyError> {
) -> Result<Option<deno_resolver::workspace::SpecifiedImportMap>, AnyError>
{
async fn resolve_import_map_value_from_specifier(
specifier: &Url,
file_fetcher: &CliFileFetcher,
Expand Down Expand Up @@ -189,7 +189,7 @@ impl SpecifiedImportMapProvider for CliSpecifiedImportMapProvider {
.with_context(|| {
format!("Unable to load '{}' import map", specifier)
})?;
Ok(Some(deno_config::workspace::SpecifiedImportMap {
Ok(Some(deno_resolver::workspace::SpecifiedImportMap {
base_url: specifier,
value,
}))
Expand All @@ -199,7 +199,7 @@ impl SpecifiedImportMapProvider for CliSpecifiedImportMapProvider {
self.workspace_external_import_map_loader.get_or_load()?
{
let path_url = deno_path_util::url_from_file_path(&import_map.path)?;
Ok(Some(deno_config::workspace::SpecifiedImportMap {
Ok(Some(deno_resolver::workspace::SpecifiedImportMap {
base_url: path_url,
value: import_map.value.clone(),
}))
Expand Down Expand Up @@ -646,7 +646,6 @@ impl CliFactory {
ResolverFactoryOptions {
conditions_from_resolution_mode: Default::default(),
node_resolution_cache: Some(Arc::new(NodeResolutionThreadLocalCache)),
no_sloppy_imports_cache: false,
npm_system_info: self.flags.subcommand.npm_system_info(),
specified_import_map: Some(Box::new(CliSpecifiedImportMapProvider {
cli_options: self.cli_options()?.clone(),
Expand All @@ -663,7 +662,7 @@ impl CliFactory {
DenoSubcommand::Publish(_) => {
// the node_modules directory is not published to jsr, so resolve
// dependencies via the package.json rather than using node resolution
Some(deno_config::workspace::PackageJsonDepResolution::Enabled)
Some(deno_resolver::workspace::PackageJsonDepResolution::Enabled)
}
_ => None,
},
Expand All @@ -672,12 +671,6 @@ impl CliFactory {
})
}

pub fn sloppy_imports_resolver(
&self,
) -> Result<Option<&Arc<CliSloppyImportsResolver>>, AnyError> {
self.resolver_factory()?.sloppy_imports_resolver()
}

pub fn workspace(&self) -> Result<&Arc<Workspace>, AnyError> {
Ok(&self.workspace_directory()?.workspace)
}
Expand Down Expand Up @@ -790,10 +783,9 @@ impl CliFactory {
}

pub async fn lint_rule_provider(&self) -> Result<LintRuleProvider, AnyError> {
Ok(LintRuleProvider::new(
self.sloppy_imports_resolver()?.cloned(),
Some(self.workspace_resolver().await?.clone()),
))
Ok(LintRuleProvider::new(Some(
self.workspace_resolver().await?.clone(),
)))
}

pub async fn node_resolver(&self) -> Result<&Arc<CliNodeResolver>, AnyError> {
Expand Down
13 changes: 7 additions & 6 deletions cli/graph_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ use deno_graph::SpecifierError;
use deno_graph::WorkspaceFastCheckOption;
use deno_path_util::url_to_file_path;
use deno_resolver::npm::DenoInNpmPackageChecker;
use deno_resolver::sloppy_imports::SloppyImportsCachedFs;
use deno_resolver::sloppy_imports::SloppyImportsResolutionKind;
use deno_resolver::workspace::sloppy_imports_resolve;
use deno_runtime::deno_node;
use deno_runtime::deno_permissions::PermissionsContainer;
use deno_semver::jsr::JsrDepPackageReq;
Expand All @@ -62,7 +61,6 @@ use crate::npm::CliNpmResolver;
use crate::resolver::CliCjsTracker;
use crate::resolver::CliNpmGraphResolver;
use crate::resolver::CliResolver;
use crate::resolver::CliSloppyImportsResolver;
use crate::sys::CliSys;
use crate::tools::check;
use crate::tools::check::CheckError;
Expand Down Expand Up @@ -949,11 +947,14 @@ pub fn maybe_additional_sloppy_imports_message(
sys: &CliSys,
specifier: &ModuleSpecifier,
) -> Option<String> {
let (resolved, sloppy_reason) = sloppy_imports_resolve(
specifier,
deno_resolver::workspace::ResolutionKind::Execution,
sys.clone(),
)?;
Some(format!(
"{} {}",
CliSloppyImportsResolver::new(SloppyImportsCachedFs::new(sys.clone()))
.resolve(specifier, SloppyImportsResolutionKind::Execution)?
.as_suggestion_message(),
sloppy_reason.suggestion_message_for_specifier(&resolved),
RUN_WITH_SLOPPY_IMPORTS_MSG
))
}
Expand Down
Loading

0 comments on commit 75f7ca0

Please sign in to comment.