mirror of
https://github.com/denoland/deno.git
synced 2025-07-24 05:35:33 +00:00
fix(publish): properly display graph validation errors (#22775)
The graph validation errors were displaying cryptically during publish. This fixes that.
This commit is contained in:
parent
87a08fc3b2
commit
594d8397ad
9 changed files with 70 additions and 73 deletions
|
@ -58,27 +58,6 @@ pub struct GraphValidOptions {
|
|||
pub is_vendoring: bool,
|
||||
}
|
||||
|
||||
/// Check if `roots` and their deps are available. Returns `Ok(())` if
|
||||
/// so. Returns `Err(_)` if there is a known module graph or resolution
|
||||
/// error statically reachable from `roots` and not a dynamic import.
|
||||
pub fn graph_valid_with_cli_options(
|
||||
graph: &ModuleGraph,
|
||||
fs: &dyn FileSystem,
|
||||
roots: &[ModuleSpecifier],
|
||||
options: &CliOptions,
|
||||
) -> Result<(), AnyError> {
|
||||
graph_valid(
|
||||
graph,
|
||||
fs,
|
||||
roots,
|
||||
GraphValidOptions {
|
||||
is_vendoring: false,
|
||||
follow_type_only: options.type_check_mode().is_true(),
|
||||
check_js: options.check_js(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/// Check if `roots` and their deps are available. Returns `Ok(())` if
|
||||
/// so. Returns `Err(_)` if there is a known module graph or resolution
|
||||
/// error statically reachable from `roots`.
|
||||
|
@ -214,7 +193,6 @@ pub struct CreateGraphOptions<'a> {
|
|||
|
||||
pub struct ModuleGraphCreator {
|
||||
options: Arc<CliOptions>,
|
||||
fs: Arc<dyn FileSystem>,
|
||||
npm_resolver: Arc<dyn CliNpmResolver>,
|
||||
module_graph_builder: Arc<ModuleGraphBuilder>,
|
||||
lockfile: Option<Arc<Mutex<Lockfile>>>,
|
||||
|
@ -224,7 +202,6 @@ pub struct ModuleGraphCreator {
|
|||
impl ModuleGraphCreator {
|
||||
pub fn new(
|
||||
options: Arc<CliOptions>,
|
||||
fs: Arc<dyn FileSystem>,
|
||||
npm_resolver: Arc<dyn CliNpmResolver>,
|
||||
module_graph_builder: Arc<ModuleGraphBuilder>,
|
||||
lockfile: Option<Arc<Mutex<Lockfile>>>,
|
||||
|
@ -232,7 +209,6 @@ impl ModuleGraphCreator {
|
|||
) -> Self {
|
||||
Self {
|
||||
options,
|
||||
fs,
|
||||
npm_resolver,
|
||||
lockfile,
|
||||
module_graph_builder,
|
||||
|
@ -267,9 +243,10 @@ impl ModuleGraphCreator {
|
|||
.await
|
||||
}
|
||||
|
||||
pub async fn create_publish_graph(
|
||||
pub async fn create_and_validate_publish_graph(
|
||||
&self,
|
||||
packages: &[WorkspaceMemberConfig],
|
||||
build_fast_check_graph: bool,
|
||||
) -> Result<ModuleGraph, AnyError> {
|
||||
let mut roots = Vec::new();
|
||||
for package in packages {
|
||||
|
@ -283,15 +260,18 @@ impl ModuleGraphCreator {
|
|||
loader: None,
|
||||
})
|
||||
.await?;
|
||||
self.graph_valid(&graph)?;
|
||||
if self.options.type_check_mode().is_true() {
|
||||
self.type_check_graph(graph.clone()).await?;
|
||||
}
|
||||
self.module_graph_builder.build_fast_check_graph(
|
||||
&mut graph,
|
||||
BuildFastCheckGraphOptions {
|
||||
workspace_fast_check: true,
|
||||
},
|
||||
)?;
|
||||
if build_fast_check_graph {
|
||||
self.module_graph_builder.build_fast_check_graph(
|
||||
&mut graph,
|
||||
BuildFastCheckGraphOptions {
|
||||
workspace_fast_check: true,
|
||||
},
|
||||
)?;
|
||||
}
|
||||
Ok(graph)
|
||||
}
|
||||
|
||||
|
@ -330,12 +310,7 @@ impl ModuleGraphCreator {
|
|||
})
|
||||
.await?;
|
||||
|
||||
graph_valid_with_cli_options(
|
||||
&graph,
|
||||
self.fs.as_ref(),
|
||||
&graph.roots,
|
||||
&self.options,
|
||||
)?;
|
||||
self.graph_valid(&graph)?;
|
||||
if let Some(lockfile) = &self.lockfile {
|
||||
graph_lock_or_exit(&graph, &mut lockfile.lock());
|
||||
}
|
||||
|
@ -349,6 +324,10 @@ impl ModuleGraphCreator {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn graph_valid(&self, graph: &ModuleGraph) -> Result<(), AnyError> {
|
||||
self.module_graph_builder.graph_valid(graph)
|
||||
}
|
||||
|
||||
async fn type_check_graph(
|
||||
&self,
|
||||
graph: ModuleGraph,
|
||||
|
@ -658,6 +637,30 @@ impl ModuleGraphBuilder {
|
|||
permissions,
|
||||
)
|
||||
}
|
||||
|
||||
/// Check if `roots` and their deps are available. Returns `Ok(())` if
|
||||
/// so. Returns `Err(_)` if there is a known module graph or resolution
|
||||
/// error statically reachable from `roots` and not a dynamic import.
|
||||
pub fn graph_valid(&self, graph: &ModuleGraph) -> Result<(), AnyError> {
|
||||
self.graph_roots_valid(graph, &graph.roots)
|
||||
}
|
||||
|
||||
pub fn graph_roots_valid(
|
||||
&self,
|
||||
graph: &ModuleGraph,
|
||||
roots: &[ModuleSpecifier],
|
||||
) -> Result<(), AnyError> {
|
||||
graph_valid(
|
||||
graph,
|
||||
self.fs.as_ref(),
|
||||
roots,
|
||||
GraphValidOptions {
|
||||
is_vendoring: false,
|
||||
follow_type_only: self.options.type_check_mode().is_true(),
|
||||
check_js: self.options.check_js(),
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn error_for_any_npm_specifier(
|
||||
|
@ -697,7 +700,8 @@ pub fn enhanced_module_error_message(
|
|||
error: &ModuleError,
|
||||
) -> String {
|
||||
let additional_message = match error {
|
||||
ModuleError::Missing(specifier, _) => {
|
||||
ModuleError::LoadingErr(specifier, _, _) // ex. "Is a directory" error
|
||||
| ModuleError::Missing(specifier, _) => {
|
||||
SloppyImportsResolver::resolve_with_fs(
|
||||
fs,
|
||||
specifier,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue