From e5942bfe6b2c8ec3f69878f67ae16506f84b3964 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Sun, 1 Oct 2023 21:42:32 -0700 Subject: [PATCH 1/2] Fix scaffold. --- crates/cli/src/commands/docker/scaffold.rs | 10 ++++- crates/cli/tests/docker_test.rs | 48 ++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/crates/cli/src/commands/docker/scaffold.rs b/crates/cli/src/commands/docker/scaffold.rs index f25c33035a0..20dfdb79bf9 100644 --- a/crates/cli/src/commands/docker/scaffold.rs +++ b/crates/cli/src/commands/docker/scaffold.rs @@ -132,7 +132,15 @@ fn scaffold_sources_project( manifest.focused_projects.insert(project_id.to_owned()); - copy_files(&[&project.source], &workspace.root, docker_sources_root)?; + for file in glob::walk_files( + &project.root, + ["**/*", "!**/node_modules/**", "!target/**/*"], + )? { + fs::copy_file( + &file, + docker_sources_root.join(file.strip_prefix(&workspace.root).unwrap()), + )?; + } for dep_id in project.get_dependency_ids() { scaffold_sources_project( diff --git a/crates/cli/tests/docker_test.rs b/crates/cli/tests/docker_test.rs index e4047348ce1..e654ded5d7e 100644 --- a/crates/cli/tests/docker_test.rs +++ b/crates/cli/tests/docker_test.rs @@ -293,6 +293,54 @@ mod scaffold_sources { // Check that some others DO NOT exist assert!(!docker.join("output-styles/style.js").exists()); } + + #[test] + fn doesnt_copy_node_modules() { + let (workspace_config, toolchain_config, tasks_config) = get_projects_fixture_configs(); + + let sandbox = create_sandbox_with_config( + "projects", + Some(workspace_config), + Some(toolchain_config), + Some(tasks_config), + ); + + sandbox.create_file("node_modules/root/file", ""); + sandbox.create_file("basic/node_modules/nested/file", ""); + + sandbox.run_moon(|cmd| { + cmd.arg("docker").arg("scaffold").arg("basic"); + }); + + let docker = sandbox.path().join(".moon/docker/sources"); + + assert!(!docker.join("node_modules").exists()); + assert!(!docker.join("basic/node_nodules").exists()); + } + + #[test] + fn doesnt_copy_rust_target() { + let (workspace_config, toolchain_config, tasks_config) = get_projects_fixture_configs(); + + let sandbox = create_sandbox_with_config( + "projects", + Some(workspace_config), + Some(toolchain_config), + Some(tasks_config), + ); + + sandbox.create_file("target/root/file", ""); + sandbox.create_file("basic/target/nested/file", ""); + + sandbox.run_moon(|cmd| { + cmd.arg("docker").arg("scaffold").arg("basic"); + }); + + let docker = sandbox.path().join(".moon/docker/sources"); + + assert!(!docker.join("target").exists()); + assert!(!docker.join("basic/target").exists()); + } } mod prune { From f90b87ce612212b64da791fa2c507b367d84d300 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Sun, 1 Oct 2023 23:08:25 -0700 Subject: [PATCH 2/2] Tests. --- Cargo.lock | 17 +++++++++-------- Cargo.toml | 2 +- crates/cli/src/commands/docker/scaffold.rs | 2 +- packages/cli/CHANGELOG.md | 1 + 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 72f5248ce72..6272dbf4731 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4697,9 +4697,9 @@ dependencies = [ [[package]] name = "proto_core" -version = "0.19.0" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27854ec66a980607216b7e415a2d2354aea5fceaef9fab4732d4636f92557a" +checksum = "2c68fe1824ab8c19d63392f686a9f48e03425f2e687b272b421170867de3b19b" dependencies = [ "cached", "extism", @@ -4728,9 +4728,9 @@ dependencies = [ [[package]] name = "proto_pdk_api" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbd3aa9e83629f274dba31ed08d5d6d80a2d07d81c333f298a6d2518023cd144" +checksum = "96b86ccfd83ad829a3666f84aacbd55e60cf0044608db9b1dfe890b80f0bafe9" dependencies = [ "anyhow", "semver", @@ -4743,13 +4743,14 @@ dependencies = [ [[package]] name = "proto_wasm_plugin" -version = "0.6.8" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b071ce67ba3635587bd88d82a3fd7f1fd158786509555d6aeb93cacc1edc0388" +checksum = "0ebaad7908984fc92cc4391ac5a85617b26d14cab9bca94133cb93838ea09c12" dependencies = [ "extism", "proto_pdk_api", "serde_json", + "starbase_utils", "tracing", ] @@ -5745,9 +5746,9 @@ dependencies = [ [[package]] name = "system_env" -version = "0.0.1" +version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19f0bb1e81abbd0fb277368d39b0470f4bbc01b1f4c6cede760f3e4d4b5d9bfe" +checksum = "96f6684a5639ae55e0454ad7dd9e09a1a488c9d1648fba2f4b4b1af3c93256d8" dependencies = [ "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 11c19461ebe..1c3173f1881 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ pathdiff = "0.2.1" petgraph = { version = "0.6.4", default-features = false, features = [ "serde-1", ] } -proto_core = "0.19.0" +proto_core = "0.19.2" relative-path = { version = "1.9.0", features = ["serde"] } regex = "1.9.5" reqwest = { version = "0.11.20", default-features = false, features = [ diff --git a/crates/cli/src/commands/docker/scaffold.rs b/crates/cli/src/commands/docker/scaffold.rs index 20dfdb79bf9..454cc538f2f 100644 --- a/crates/cli/src/commands/docker/scaffold.rs +++ b/crates/cli/src/commands/docker/scaffold.rs @@ -134,7 +134,7 @@ fn scaffold_sources_project( for file in glob::walk_files( &project.root, - ["**/*", "!**/node_modules/**", "!target/**/*"], + ["**/*", "!node_modules/**", "!target/**/*", "!vendor/**"], )? { fs::copy_file( &file, diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 5848091e6c8..83c3959843a 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -14,6 +14,7 @@ #### 🐞 Fixes +- Fixed an issue where `moon docker scaffold` was too greedy and would copy files it shouldn't. - Fixed some `PATH` inconsistencies when executing npm/pnpm/yarn binaries. - Fixed codegen `lower_case` and `upper_case` stripping characters.