Skip to content

Commit b3d342d

Browse files
committed
Fix prune.
1 parent fd2960a commit b3d342d

5 files changed

Lines changed: 11 additions & 181 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
- Fixed an issue where toolchain plugins do not inherit versions from `.prototools`.
1919
- Fixed an issue where a file lock would be created for proto installation, even when it didn't need
2020
to be installed.
21+
- Fixed an issue where `moon docker prune` would force install all toolchains. If you were relying
22+
on this functionality, run `moon docker setup` instead.
2123

2224
#### 🧩 Plugins
2325

crates/app/src/commands/docker/prune.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,13 @@ pub async fn prune(session: MoonSession) -> AppResult {
340340
);
341341

342342
for project_id in &manifest.focused_projects {
343-
toolchains.extend(workspace_graph.get_project(project_id)?.toolchains.clone());
343+
toolchains.extend(
344+
workspace_graph
345+
.get_project(project_id)?
346+
.get_enabled_toolchains()
347+
.into_iter()
348+
.cloned(),
349+
);
344350
}
345351

346352
// Do this later so we only run once for each platform instead of per project

crates/app/src/commands/docker/setup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub async fn setup(session: MoonSession) -> AppResult {
1919

2020
debug!(
2121
projects = ?manifest.focused_projects.iter().map(|id| id.as_str()).collect::<Vec<_>>(),
22-
"Installing tools and dependencies for focused projects"
22+
"Installing toolchains and dependencies for focused projects"
2323
);
2424

2525
for project_id in &manifest.focused_projects {

crates/app/src/session.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::app::{Cli, Commands};
22
use crate::app_error::AppError;
3-
use crate::commands::docker::DockerCommands;
43
use crate::components::*;
54
use crate::systems::*;
65
use async_trait::async_trait;
@@ -235,15 +234,7 @@ impl MoonSession {
235234
}
236235

237236
pub fn requires_toolchain_installed(&self) -> bool {
238-
matches!(
239-
self.cli.command,
240-
Commands::Bin(_)
241-
| Commands::Docker {
242-
command: DockerCommands::Prune
243-
}
244-
| Commands::Node { .. }
245-
| Commands::Teardown
246-
)
237+
matches!(self.cli.command, Commands::Bin(_) | Commands::Node { .. })
247238
}
248239

249240
async fn load_workspace_graph(&self) -> miette::Result<()> {

crates/cli/tests/docker_test.rs

Lines changed: 0 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -397,175 +397,6 @@ mod prune {
397397
}
398398
}
399399

400-
#[cfg(not(target_os = "linux"))]
401-
mod prune_node {
402-
use super::*;
403-
404-
#[test]
405-
fn focuses_for_npm() {
406-
let (workspace_config, toolchain_config, tasks_config) =
407-
get_node_depman_fixture_configs("npm");
408-
409-
let sandbox = create_sandbox_with_config(
410-
"node-npm/workspaces",
411-
Some(workspace_config),
412-
Some(toolchain_config),
413-
Some(tasks_config),
414-
);
415-
416-
write_manifest(sandbox.path(), "other");
417-
418-
sandbox
419-
.run_moon(|cmd| {
420-
cmd.arg("docker").arg("prune");
421-
})
422-
.debug();
423-
424-
// should exist
425-
assert!(sandbox.path().join("node_modules/solid-js").exists());
426-
427-
// should not exist
428-
assert!(!sandbox.path().join("npm/node_modules").exists());
429-
assert!(
430-
!sandbox
431-
.path()
432-
.join("node_modules/babel-preset-solid")
433-
.exists()
434-
);
435-
436-
// npm installs prod deps for unfocused
437-
// assert!(!sandbox.path().join("node_modules/react").exists());
438-
}
439-
440-
#[test]
441-
fn focuses_for_pnpm() {
442-
let (workspace_config, toolchain_config, tasks_config) =
443-
get_node_depman_fixture_configs("pnpm");
444-
445-
let sandbox = create_sandbox_with_config(
446-
"node-pnpm/workspaces",
447-
Some(workspace_config),
448-
Some(toolchain_config),
449-
Some(tasks_config),
450-
);
451-
452-
write_manifest(sandbox.path(), "other");
453-
454-
sandbox.run_moon(|cmd| {
455-
cmd.arg("docker").arg("prune");
456-
});
457-
458-
// should exist
459-
assert!(sandbox.path().join("other/node_modules/solid-js").exists());
460-
461-
// should not exist
462-
assert!(!sandbox.path().join("pnpm/node_modules").exists());
463-
assert!(
464-
!sandbox
465-
.path()
466-
.join("node_modules/babel-preset-solid")
467-
.exists()
468-
);
469-
assert!(!sandbox.path().join("node_modules/react").exists());
470-
}
471-
472-
#[test]
473-
fn focuses_for_yarn() {
474-
let (workspace_config, toolchain_config, tasks_config) =
475-
get_node_depman_fixture_configs("yarn");
476-
477-
let sandbox = create_sandbox_with_config(
478-
"node-yarn/workspaces",
479-
Some(workspace_config),
480-
Some(toolchain_config),
481-
Some(tasks_config),
482-
);
483-
484-
write_manifest(sandbox.path(), "other");
485-
486-
sandbox.run_moon(|cmd| {
487-
cmd.arg("docker").arg("prune");
488-
});
489-
490-
// should exist
491-
assert!(sandbox.path().join("node_modules/solid-js").exists());
492-
493-
// should not exist
494-
assert!(!sandbox.path().join("npm/node_modules").exists());
495-
assert!(
496-
!sandbox
497-
.path()
498-
.join("node_modules/babel-preset-solid")
499-
.exists()
500-
);
501-
assert!(!sandbox.path().join("node_modules/react").exists());
502-
}
503-
504-
#[test]
505-
fn focuses_for_yarn1() {
506-
let (workspace_config, toolchain_config, tasks_config) =
507-
get_node_depman_fixture_configs("yarn1");
508-
509-
let sandbox = create_sandbox_with_config(
510-
"node-yarn1/workspaces",
511-
Some(workspace_config),
512-
Some(toolchain_config),
513-
Some(tasks_config),
514-
);
515-
516-
write_manifest(sandbox.path(), "other");
517-
518-
sandbox.run_moon(|cmd| {
519-
cmd.arg("docker").arg("prune");
520-
});
521-
522-
// should exist
523-
assert!(sandbox.path().join("node_modules/solid-js").exists());
524-
525-
// should not exist
526-
assert!(!sandbox.path().join("yarn/node_modules").exists());
527-
assert!(
528-
!sandbox
529-
.path()
530-
.join("node_modules/babel-preset-solid")
531-
.exists()
532-
);
533-
534-
// yarn 1 does not support focusing
535-
// assert!(!sandbox.path().join("node_modules/react").exists());
536-
}
537-
538-
// #[test]
539-
// fn focuses_for_node_bun() {
540-
// let (workspace_config, toolchain_config, tasks_config) =
541-
// get_node_depman_fixture_configs("bun");
542-
543-
// let sandbox = create_sandbox_with_config(
544-
// "node-bun/workspaces",
545-
// Some(workspace_config),
546-
// Some(toolchain_config),
547-
// Some(tasks_config),
548-
// );
549-
550-
// write_manifest(sandbox.path(), "other");
551-
552-
// sandbox.run_moon(|cmd| {
553-
// cmd.arg("docker").arg("prune");
554-
// });
555-
556-
// // should exist
557-
// assert!(sandbox.path().join("other/node_modules/solid-js").exists());
558-
559-
// // should not exist
560-
// assert!(!sandbox.path().join("pnpm/node_modules").exists());
561-
// assert!(!sandbox
562-
// .path()
563-
// .join("node_modules/babel-preset-solid")
564-
// .exists());
565-
// assert!(!sandbox.path().join("node_modules/react").exists());
566-
// }
567-
}
568-
569400
mod setup {
570401
use super::*;
571402

0 commit comments

Comments
 (0)