Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions crates/vite_package_manager/src/package_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub struct ResolveCommandResult {
/// Then use `PackageManager::resolve_command()` to resolve the command result.
#[derive(Debug)]
pub struct PackageManager {
pub package_manager_type: PackageManagerType,
pub client: PackageManagerType,
pub package_name: Str,
pub version: Str,
pub hash: Option<Str>,
Expand All @@ -69,18 +69,18 @@ pub struct PackageManager {

#[derive(Debug)]
pub struct PackageManagerBuilder {
package_manager_type: Option<PackageManagerType>,
client_override: Option<PackageManagerType>,
cwd: AbsolutePathBuf,
}

impl PackageManagerBuilder {
pub fn new(cwd: impl AsRef<AbsolutePath>) -> Self {
Self { package_manager_type: None, cwd: cwd.as_ref().to_absolute_path_buf() }
Self { client_override: None, cwd: cwd.as_ref().to_absolute_path_buf() }
}

#[must_use]
pub const fn package_manager_type(mut self, package_manager_type: PackageManagerType) -> Self {
self.package_manager_type = Some(package_manager_type);
self.client_override = Some(package_manager_type);
self
}

Expand All @@ -89,7 +89,7 @@ impl PackageManagerBuilder {
pub async fn build(self) -> Result<PackageManager, Error> {
let workspace_root = find_workspace_root(&self.cwd)?;
let (package_manager_type, mut version, mut hash) =
get_package_manager_type_and_version(&workspace_root, self.package_manager_type)?;
get_package_manager_type_and_version(&workspace_root, self.client_override)?;

let mut package_name = package_manager_type.to_string();
let mut should_update_package_manager_field = false;
Expand Down Expand Up @@ -125,7 +125,7 @@ impl PackageManagerBuilder {
}

Ok(PackageManager {
package_manager_type,
client: package_manager_type,
package_name: package_name.into(),
version,
hash,
Expand Down
2 changes: 1 addition & 1 deletion crates/vite_task/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl ResolvedTask {
let cwd = &workspace.cwd;
let resolved_task_config =
ResolvedTaskConfig { config_dir: cwd.clone(), config: task_config };
let resolved_envs = TaskEnvs::resolve(&workspace.workspace_dir, &resolved_task_config)?;
let resolved_envs = TaskEnvs::resolve(&workspace.root_dir, &resolved_task_config)?;
let resolved_command = ResolvedTaskCommand {
fingerprint: CommandFingerprint {
cwd: cwd.clone(),
Expand Down
13 changes: 6 additions & 7 deletions crates/vite_task/src/config/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{

#[derive(Debug)]
pub struct Workspace {
pub(crate) workspace_dir: AbsolutePathBuf,
pub(crate) root_dir: AbsolutePathBuf,
pub(crate) cwd: RelativePathBuf,
/// Relative path from workspace root to current package directory.
/// Empty string ("") represents the workspace root package itself.
Expand Down Expand Up @@ -112,7 +112,7 @@ impl Workspace {

Ok(Self {
package_graph: Graph::new(),
workspace_dir: workspace_root.to_absolute_path_buf(),
root_dir: workspace_root.to_absolute_path_buf(),
cwd,
current_package_path,
task_cache,
Expand Down Expand Up @@ -189,7 +189,7 @@ impl Workspace {

Ok(Self {
package_graph,
workspace_dir: workspace_root.to_absolute_path_buf(),
root_dir: workspace_root.to_absolute_path_buf(),
cwd,
current_package_path,
task_cache,
Expand All @@ -208,7 +208,7 @@ impl Workspace {
}

pub async fn unload(self) -> Result<(), Error> {
tracing::debug!("Saving task cache {}", self.workspace_dir.as_path().display());
tracing::debug!("Saving task cache {}", self.root_dir.as_path().display());
self.task_cache.save().await?;
Ok(())
}
Expand Down Expand Up @@ -371,9 +371,8 @@ impl Workspace {
if !task_args.is_empty() {
// This is needed for constructing the task run key for caching, so that different args lead to different task runs.
updated_task.args = task_args.clone();
updated_task.resolved_command = updated_task
.resolved_config
.resolve_command(&self.workspace_dir, &task_args)?;
updated_task.resolved_command =
updated_task.resolved_config.resolve_command(&self.root_dir, &task_args)?;
}

// Add to filtered graph
Expand Down
2 changes: 1 addition & 1 deletion crates/vite_task/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ pub async fn main<
.expect("lint command requires CliOptions to be provided");

let vite_config = read_vite_config_from_workspace_root(
&workspace.workspace_dir,
&workspace.root_dir,
options.as_ref().map(|o| &o.resolve_universal_vite_config),
)
.await?;
Expand Down
2 changes: 1 addition & 1 deletion crates/vite_task/src/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl ExecutionPlan {
step.clone(),
&workspace.task_cache,
&workspace.fs,
&workspace.workspace_dir,
&workspace.root_dir,
)
.await?;

Expand Down
Loading