mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
refactor: update to deno_config 0.25 (#24645)
- Gets rid of WorkspaceMemberContext. It's now `Workspace` and `WorkspaceDirectory` - Uses the workspace cache in the lsp * https://github.com/denoland/deno_config/pull/95 * https://github.com/denoland/deno_config/pull/96
This commit is contained in:
parent
a4c76add56
commit
afcae364be
25 changed files with 360 additions and 332 deletions
|
@ -8,8 +8,9 @@ use crate::factory::CliFactory;
|
|||
use crate::npm::CliNpmResolver;
|
||||
use crate::task_runner;
|
||||
use crate::util::fs::canonicalize_path;
|
||||
use deno_config::deno_json::Task;
|
||||
use deno_config::workspace::TaskOrScript;
|
||||
use deno_config::workspace::Workspace;
|
||||
use deno_config::workspace::WorkspaceDirectory;
|
||||
use deno_config::workspace::WorkspaceTasksConfig;
|
||||
use deno_core::anyhow::bail;
|
||||
use deno_core::anyhow::Context;
|
||||
|
@ -30,8 +31,8 @@ pub async fn execute_script(
|
|||
) -> Result<i32, AnyError> {
|
||||
let factory = CliFactory::from_flags(flags)?;
|
||||
let cli_options = factory.cli_options();
|
||||
let start_ctx = cli_options.workspace.resolve_start_ctx();
|
||||
if !start_ctx.has_deno_or_pkg_json() {
|
||||
let start_dir = &cli_options.start_dir;
|
||||
if !start_dir.has_deno_or_pkg_json() {
|
||||
bail!("deno task couldn't find deno.json(c). See https://deno.land/manual@v{}/getting_started/configuration_file", env!("CARGO_PKG_VERSION"))
|
||||
}
|
||||
let force_use_pkg_json =
|
||||
|
@ -44,7 +45,7 @@ pub async fn execute_script(
|
|||
v == "1"
|
||||
})
|
||||
.unwrap_or(false);
|
||||
let tasks_config = start_ctx.to_tasks_config()?;
|
||||
let tasks_config = start_dir.to_tasks_config()?;
|
||||
let tasks_config = if force_use_pkg_json {
|
||||
tasks_config.with_only_pkg_json()
|
||||
} else {
|
||||
|
@ -56,7 +57,7 @@ pub async fn execute_script(
|
|||
None => {
|
||||
print_available_tasks(
|
||||
&mut std::io::stdout(),
|
||||
&cli_options.workspace,
|
||||
&cli_options.start_dir,
|
||||
&tasks_config,
|
||||
)?;
|
||||
return Ok(1);
|
||||
|
@ -143,7 +144,7 @@ pub async fn execute_script(
|
|||
if log::log_enabled!(log::Level::Error) {
|
||||
print_available_tasks(
|
||||
&mut std::io::stderr(),
|
||||
&cli_options.workspace,
|
||||
&cli_options.start_dir,
|
||||
&tasks_config,
|
||||
)?;
|
||||
}
|
||||
|
@ -204,7 +205,7 @@ fn output_task(task_name: &str, script: &str) {
|
|||
|
||||
fn print_available_tasks(
|
||||
writer: &mut dyn std::io::Write,
|
||||
workspace: &Arc<Workspace>,
|
||||
workspace_dir: &Arc<WorkspaceDirectory>,
|
||||
tasks_config: &WorkspaceTasksConfig,
|
||||
) -> Result<(), std::io::Error> {
|
||||
writeln!(writer, "{}", colors::green("Available tasks:"))?;
|
||||
|
@ -228,7 +229,8 @@ fn print_available_tasks(
|
|||
.as_ref()
|
||||
.map(|config| {
|
||||
let is_root = !is_cwd_root_dir
|
||||
&& config.folder_url == *workspace.root_folder().0.as_ref();
|
||||
&& config.folder_url
|
||||
== *workspace_dir.workspace.root_dir().as_ref();
|
||||
config
|
||||
.tasks
|
||||
.iter()
|
||||
|
@ -242,13 +244,10 @@ fn print_available_tasks(
|
|||
.as_ref()
|
||||
.map(|config| {
|
||||
let is_root = !is_cwd_root_dir
|
||||
&& config.folder_url == *workspace.root_folder().0.as_ref();
|
||||
&& config.folder_url
|
||||
== *workspace_dir.workspace.root_dir().as_ref();
|
||||
config.tasks.iter().map(move |(k, v)| {
|
||||
(
|
||||
is_root,
|
||||
false,
|
||||
(k, Cow::Owned(deno_config::Task::Definition(v.clone()))),
|
||||
)
|
||||
(is_root, false, (k, Cow::Owned(Task::Definition(v.clone()))))
|
||||
})
|
||||
})
|
||||
.into_iter()
|
||||
|
@ -275,10 +274,10 @@ fn print_available_tasks(
|
|||
}
|
||||
)?;
|
||||
let definition = match task.as_ref() {
|
||||
deno_config::Task::Definition(definition) => definition,
|
||||
deno_config::Task::Commented { definition, .. } => definition,
|
||||
Task::Definition(definition) => definition,
|
||||
Task::Commented { definition, .. } => definition,
|
||||
};
|
||||
if let deno_config::Task::Commented { comments, .. } = task.as_ref() {
|
||||
if let Task::Commented { comments, .. } = task.as_ref() {
|
||||
let slash_slash = colors::italic_gray("//");
|
||||
for comment in comments {
|
||||
writeln!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue