Add initial package.json scripts task autodetection (#32497)

Now, every JS/TS-related file will get their package.json script
contents added as tasks:

<img width="1020" alt="image"
src="https://github.com/user-attachments/assets/5bf80f80-fd72-4ba8-8ccf-418872895a25"
/>

To achieve that, `fn associated_tasks` from the `ContextProvider` was
made asynchronous and the related code adjusted.

Release Notes:

- Added initial `package.json` scripts task autodetection

---------

Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
This commit is contained in:
Kirill Bulatov 2025-06-11 01:16:27 +03:00 committed by GitHub
parent 0c0933d1c0
commit 9c513223c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 782 additions and 661 deletions

View file

@ -824,14 +824,14 @@ impl RunningState {
let config_is_valid = request_type.is_ok();
let build_output = if let Some(build) = build {
let (task, locator_name) = match build {
let (task_template, locator_name) = match build {
BuildTaskDefinition::Template {
task_template,
locator_name,
} => (task_template, locator_name),
BuildTaskDefinition::ByName(ref label) => {
let Some(task) = task_store.update(cx, |this, cx| {
this.task_inventory().and_then(|inventory| {
let task = task_store.update(cx, |this, cx| {
this.task_inventory().map(|inventory| {
inventory.read(cx).task_template_by_label(
buffer,
worktree_id,
@ -839,14 +839,15 @@ impl RunningState {
cx,
)
})
})?
else {
anyhow::bail!("Couldn't find task template for {:?}", build)
};
})?;
let task = match task {
Some(task) => task.await,
None => None,
}.with_context(|| format!("Couldn't find task template for {build:?}"))?;
(task, None)
}
};
let Some(task) = task.resolve_task("debug-build-task", &task_context) else {
let Some(task) = task_template.resolve_task("debug-build-task", &task_context) else {
anyhow::bail!("Could not resolve task variables within a debug scenario");
};