From ee888a6be0c9d57d6819c4f3d6c2bbdbb9423a66 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Wed, 29 Jan 2025 19:13:39 -0800 Subject: [PATCH] new: Improve existing toolchains. (#1807) * Add implicit relations. * Move checkpoint prints. * Add bun.lock parsing. * Update logic. * Rework deno. * Polish. * Fixes. * Add debug. * Set env var. * Fix. --- .github/workflows/moon.yml | 2 - .github/workflows/rust.yml | 6 +- .prototools | 4 +- CHANGELOG.md | 10 ++ Cargo.lock | 120 +++++++++++++++++- Cargo.toml | 2 +- crates/cli/tests/run_bun_test.rs | 75 ++++++----- crates/cli/tests/run_deno_test.rs | 6 +- ..._test__bun__handles_unhandled_promise.snap | 5 +- .../run_bun_test__bun__runs_script_task.snap | 2 +- .../run_bun_test__bun__runs_self.snap | 2 +- crates/config/src/toolchain/deno_config.rs | 3 + crates/toolchain/src/detect/languages.rs | 2 +- legacy/bun/lang/Cargo.toml | 3 + legacy/bun/lang/src/bun_lock.rs | 50 ++++++++ legacy/bun/lang/src/bun_lockb.rs | 4 +- legacy/bun/lang/src/lib.rs | 18 +++ legacy/bun/platform/src/bun_platform.rs | 15 ++- legacy/bun/tool/src/bun_tool.rs | 42 ++++-- legacy/core/test-utils/src/configs.rs | 4 +- legacy/deno/lang/Cargo.toml | 1 + legacy/deno/lang/src/deno_json.rs | 26 +++- legacy/deno/lang/src/deno_lock.rs | 38 +++--- legacy/deno/lang/src/lib.rs | 22 ++++ legacy/deno/platform/Cargo.toml | 1 + legacy/deno/platform/src/deno_platform.rs | 97 ++++++++++++-- legacy/deno/tool/src/deno_tool.rs | 25 ++-- legacy/node/platform/src/node_platform.rs | 12 +- legacy/node/tool/src/bun_tool.rs | 14 +- .../platform/src/actions/install_deps.rs | 12 +- legacy/rust/platform/src/rust_platform.rs | 113 +++++++++++++---- packages/types/src/toolchain-config.ts | 4 + tests/fixtures/bun/version-override/moon.yml | 2 +- website/docs/proto/toml-plugin.mdx | 8 -- website/docs/setup-toolchain.mdx | 2 +- website/static/schemas/toolchain.json | 9 ++ 36 files changed, 598 insertions(+), 163 deletions(-) create mode 100644 legacy/bun/lang/src/bun_lock.rs delete mode 100644 website/docs/proto/toml-plugin.mdx diff --git a/.github/workflows/moon.yml b/.github/workflows/moon.yml index 2851a81003d..ce50475a004 100644 --- a/.github/workflows/moon.yml +++ b/.github/workflows/moon.yml @@ -39,8 +39,6 @@ jobs: env: DEPOT_TOKEN: ${{ secrets.DEPOT_TOKEN }} MOON_NODE_VERSION: ${{ matrix.node-version }} - MOONBASE_SECRET_KEY: ${{ secrets.MOONBASE_SECRET_KEY }} - MOONBASE_ACCESS_KEY: ${{ secrets.MOONBASE_ACCESS_KEY }} RUST_BACKTRACE: '1' - uses: moonrepo/run-report-action@v1 if: success() || failure() diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9e44cca86d0..b2b49ca2460 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -79,7 +79,6 @@ jobs: # SCCACHE_NO_DAEMON: 1 SCCACHE_REGION: us-east-2 SCCACHE_S3_SERVER_SIDE_ENCRYPTION: true - AWS_LC_SYS_PREBUILT_NASM: 1 steps: - uses: actions/checkout@v4 - uses: moonrepo/setup-rust@v1 @@ -92,7 +91,10 @@ jobs: auto-install: true cache: ${{ runner.os == 'Linux' }} proto-version: '0.45.1' # Keep in sync - - uses: mozilla-actions/sccache-action@v0.0.5 + # Fixes issues where proto can't find a version because nothing is pinned globally + - run: cp .prototools ~/.proto/.prototools + if: ${{ runner.os == 'Linux' }} + - uses: mozilla-actions/sccache-action@v0.0.7 if: ${{ vars.ENABLE_SCCACHE == 'true' }} - uses: lukka/get-cmake@latest if: ${{ runner.os == 'Windows' }} diff --git a/.prototools b/.prototools index 5ec826a2d8f..5eca81bb9c3 100644 --- a/.prototools +++ b/.prototools @@ -1,7 +1,7 @@ # These are used by tests that require the tools # to exist in the environment! -# bun = "1.0.15" -deno = "1.40.0" +bun = "1.2.1" +deno = "2.1.7" node = "20.8.0" npm = "10.1.0" pkl = "0.27.2" diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b13413e713..146c0a4ccc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,8 +20,18 @@ - Added timeout and concurrency limit to clients. - Added a `MOON_DEBUG_REMOTE` environment variable, which can be used to debug internal errors for diagnosing connection/integration issues. +- Improved the Bun toolchain. + - Added support for the new v1.2 `bun.lock` file. We do our best to detect this, but we suggest + configuring `--save-text-lockfile`. +- Improved the Deno toolchain. + - Added support for Deno v2 and `deno install`. Will now run this command instead of `deno cache`. + - Added support for v3 and v4 lockfiles (we now use the `deno_lockfile` crate). + - Added basic support for workspaces. + - Added `deno.installArgs` setting. - Improved the Rust toolchain. - The root-level project is now properly taken into account when detecting the package workspaces. + - Project dependencies (`dependsOn`) are now automatically inferred from `Cargo.toml` + dependencies. #### 🐞 Fixes diff --git a/Cargo.lock b/Cargo.lock index f498595e910..6fda2f62594 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -834,6 +834,28 @@ dependencies = [ "winx", ] +[[package]] +name = "capacity_builder" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f2d24a6dcf0cd402a21b65d35340f3a49ff3475dc5fdac91d22d2733e6641c6" +dependencies = [ + "capacity_builder_macros", + "ecow", + "hipstr", + "itoa", +] + +[[package]] +name = "capacity_builder_macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b4a6cae9efc04cc6cbb8faf338d2c497c165c83e74509cf4dbedea948bbf6e5" +dependencies = [ + "quote", + "syn 2.0.96", +] + [[package]] name = "cargo-lock" version = "10.0.1" @@ -1025,9 +1047,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.43" +version = "4.5.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952013545c9c6dca60f491602655b795c6c062ab180c9cb0bccb83135461861" +checksum = "375f9d8255adeeedd51053574fd8d4ba875ea5fa558e86617b07f09f1680c8b6" dependencies = [ "clap", ] @@ -1453,6 +1475,56 @@ dependencies = [ "version_check 0.1.5", ] +[[package]] +name = "deno_error" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19fae9fe305307b5ef3ee4e8244c79cffcca421ab0ce8634dea0c6b1342f220f" +dependencies = [ + "deno_error_macro", + "libc", +] + +[[package]] +name = "deno_error_macro" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5abb2556e91848b66f562451fcbcdee2a3b7c88281828908dcf7cca355f5d997" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.96", +] + +[[package]] +name = "deno_lockfile" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "632e835a53ed667d62fdd766c5780fe8361c831d3e3fbf1a760a0b7896657587" +dependencies = [ + "deno_semver", + "serde", + "serde_json", + "thiserror 2.0.11", +] + +[[package]] +name = "deno_semver" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4775271f9b5602482698f76d24ea9ed8ba27af7f587a7e9a876916300c542435" +dependencies = [ + "capacity_builder", + "deno_error", + "ecow", + "hipstr", + "monch", + "once_cell", + "serde", + "thiserror 2.0.11", + "url", +] + [[package]] name = "deranged" version = "0.3.11" @@ -1646,6 +1718,15 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acf65d056c7da9c971c2847ce250fd1f0f9659d5718845c3ec0ad95f5668352c" +[[package]] +name = "ecow" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42fc0a93992b20c58b99e59d61eaf1635a25bfbe49e4275c34ba0aee98119ba" +dependencies = [ + "serde", +] + [[package]] name = "either" version = "1.13.0" @@ -2282,6 +2363,17 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hipstr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97971ffc85d4c98de12e2608e992a43f5294ebb625fdb045b27c731b64c4c6d6" +dependencies = [ + "serde", + "serde_bytes", + "sptr", +] + [[package]] name = "home" version = "0.5.11" @@ -2938,9 +3030,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "ittapi" @@ -3377,6 +3469,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "monch" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52c1b33ff98142aecea13138bd399b68aa7ab5d9546c300988c345004001eea" + [[package]] name = "moon_action" version = "0.0.1" @@ -3652,7 +3750,10 @@ dependencies = [ "cached", "miette 7.4.0", "moon_lang", + "nodejs_package_json", "rustc-hash 2.1.0", + "serde", + "starbase_utils", "tracing", "yarn-lock-parser", ] @@ -3894,6 +3995,7 @@ name = "moon_deno_lang" version = "0.0.1" dependencies = [ "cached", + "deno_lockfile", "miette 7.4.0", "moon_lang", "moon_logger", @@ -3928,6 +4030,7 @@ dependencies = [ "proto_core", "rustc-hash 2.1.0", "serde", + "starbase_utils", ] [[package]] @@ -6388,6 +6491,15 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde_bytes" +version = "0.11.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" version = "1.0.217" diff --git a/Cargo.toml b/Cargo.toml index 5df5f29320c..c143c627053 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ clap = { version = "4.5.27", default-features = false, features = [ "std", "error-context", ] } -clap_complete = "4.5.43" +clap_complete = "4.5.44" compact_str = { version = "0.8.1", default-features = false, features = [ "serde", ] } diff --git a/crates/cli/tests/run_bun_test.rs b/crates/cli/tests/run_bun_test.rs index 04e67f7a0df..75d944badc3 100644 --- a/crates/cli/tests/run_bun_test.rs +++ b/crates/cli/tests/run_bun_test.rs @@ -1,37 +1,37 @@ -// These are very flaky in CI, as they error with "Text file busy" nonstop -#[cfg(not(target_os = "linux"))] -mod bun { - use moon_config::PartialBunConfig; - use moon_test_utils::{ - assert_snapshot, create_sandbox, create_sandbox_with_config, get_bun_fixture_configs, - predicates::prelude::*, Sandbox, - }; - use std::fs; - - fn bun_sandbox() -> Sandbox { - bun_sandbox_with_config(|_| {}) - } +use moon_config::PartialBunConfig; +use moon_test_utils::{ + assert_snapshot, create_sandbox, create_sandbox_with_config, get_bun_fixture_configs, + predicates::prelude::*, Sandbox, +}; +use std::fs; + +fn bun_sandbox() -> Sandbox { + bun_sandbox_with_config(|_| {}) +} - fn bun_sandbox_with_config(callback: C) -> Sandbox - where - C: FnOnce(&mut PartialBunConfig), - { - let (workspace_config, mut toolchain_config, tasks_config) = get_bun_fixture_configs(); +fn bun_sandbox_with_config(callback: C) -> Sandbox +where + C: FnOnce(&mut PartialBunConfig), +{ + let (workspace_config, mut toolchain_config, tasks_config) = get_bun_fixture_configs(); - if let Some(bun_config) = &mut toolchain_config.bun { - callback(bun_config); - } + if let Some(bun_config) = &mut toolchain_config.bun { + callback(bun_config); + } - let sandbox = create_sandbox_with_config( - "bun", - Some(workspace_config), - Some(toolchain_config), - Some(tasks_config), - ); + let sandbox = create_sandbox_with_config( + "bun", + Some(workspace_config), + Some(toolchain_config), + Some(tasks_config), + ); - sandbox.enable_git(); - sandbox - } + sandbox.enable_git(); + sandbox +} + +mod bun { + use super::*; #[test] fn runs_self() { @@ -162,11 +162,10 @@ mod bun { cmd.arg("run").arg("bun:unhandledPromise"); }); - if cfg!(windows) { - assert.code(1); - } else { - assert_snapshot!(assert.output()); - } + let output = assert.output(); + + // Output contains os/arch stuff that we cant snapshot + assert!(predicate::str::contains("error: Oops").eval(&output)); } #[test] @@ -345,8 +344,6 @@ mod bun { } } - // Need multiple windows versions for this to work - #[cfg(not(windows))] mod workspace_overrides { use super::*; @@ -362,8 +359,8 @@ mod bun { let output = assert.output(); - assert!(predicate::str::contains("1.1.3").eval(&output)); - assert!(predicate::str::contains("0.8.0").eval(&output)); + assert!(predicate::str::contains("1.2.1").eval(&output)); + assert!(predicate::str::contains("1.1.0").eval(&output)); assert.success(); } diff --git a/crates/cli/tests/run_deno_test.rs b/crates/cli/tests/run_deno_test.rs index e633b7b9d85..6c0d90e192b 100644 --- a/crates/cli/tests/run_deno_test.rs +++ b/crates/cli/tests/run_deno_test.rs @@ -44,7 +44,7 @@ mod deno { let output = assert.output(); // Output contains arch info - assert!(predicate::str::contains("deno 1.40.0").eval(&output)); + assert!(predicate::str::contains("deno 2.1.7").eval(&output)); } #[test] @@ -230,7 +230,7 @@ mod deno { // Output includes the arch, so can't be snapshotted assert!(predicate::str::contains("deno platform").eval(&output)); - assert!(predicate::str::contains("deno 1.40.0").eval(&output)); + assert!(predicate::str::contains("deno 2.1.7").eval(&output)); } mod workspace_overrides { @@ -248,7 +248,7 @@ mod deno { let output = assert.output(); - assert!(predicate::str::contains("1.40.0").eval(&output)); + assert!(predicate::str::contains("2.1.7").eval(&output)); assert!(predicate::str::contains("1.30.0").eval(&output)); assert.success(); diff --git a/crates/cli/tests/snapshots/run_bun_test__bun__handles_unhandled_promise.snap b/crates/cli/tests/snapshots/run_bun_test__bun__handles_unhandled_promise.snap index 5e345ab6659..cbfc89fe2fa 100644 --- a/crates/cli/tests/snapshots/run_bun_test__bun__handles_unhandled_promise.snap +++ b/crates/cli/tests/snapshots/run_bun_test__bun__handles_unhandled_promise.snap @@ -1,5 +1,5 @@ --- -source: legacy/cli/tests/run_bun_test.rs +source: crates/cli/tests/run_bun_test.rs expression: assert.output() --- ▪▪▪▪ bun install @@ -8,6 +8,9 @@ stdout ▪▪▪▪ bun:unhandledPromise (100ms) stderr error: Oops +Oops + +Bun v1.2.1 (macOS arm64) Error: task_runner::run_failed × Task bun:unhandledPromise failed to run. diff --git a/crates/cli/tests/snapshots/run_bun_test__bun__runs_script_task.snap b/crates/cli/tests/snapshots/run_bun_test__bun__runs_script_task.snap index 6a2396be21a..84140322dcb 100644 --- a/crates/cli/tests/snapshots/run_bun_test__bun__runs_script_task.snap +++ b/crates/cli/tests/snapshots/run_bun_test__bun__runs_script_task.snap @@ -4,7 +4,7 @@ expression: assert.output() --- ▪▪▪▪ bun:viaScript bun platform -1.1.3 +1.2.1 ▪▪▪▪ bun:viaScript (100ms) Tasks: 1 completed diff --git a/crates/cli/tests/snapshots/run_bun_test__bun__runs_self.snap b/crates/cli/tests/snapshots/run_bun_test__bun__runs_self.snap index 0c0c6483b6e..daabdca75ba 100644 --- a/crates/cli/tests/snapshots/run_bun_test__bun__runs_self.snap +++ b/crates/cli/tests/snapshots/run_bun_test__bun__runs_self.snap @@ -4,7 +4,7 @@ expression: assert.output() --- ▪▪▪▪ bun install ▪▪▪▪ bun:version -1.1.3 +1.2.1 ▪▪▪▪ bun:version (100ms) Tasks: 1 completed diff --git a/crates/config/src/toolchain/deno_config.rs b/crates/config/src/toolchain/deno_config.rs index af5f47b38a1..1173207853f 100644 --- a/crates/config/src/toolchain/deno_config.rs +++ b/crates/config/src/toolchain/deno_config.rs @@ -15,6 +15,9 @@ pub struct DenoConfig { #[setting(default = "deps.ts")] pub deps_file: String, + /// List of arguments to append to `deno install` commands. + pub install_args: Vec, + /// Requires and forces the use of `deno.lock` files. pub lockfile: bool, diff --git a/crates/toolchain/src/detect/languages.rs b/crates/toolchain/src/detect/languages.rs index a31cab8df70..009b3aa039c 100644 --- a/crates/toolchain/src/detect/languages.rs +++ b/crates/toolchain/src/detect/languages.rs @@ -1,7 +1,7 @@ pub type StaticString = &'static str; pub type StaticStringList = &'static [StaticString]; -pub static BUN: StaticStringList = &["bunfig.toml", "bun.lockb", ".bunrc"]; +pub static BUN: StaticStringList = &["bunfig.toml", "bun.lock", "bun.lockb", ".bunrc"]; pub static DENO: StaticStringList = &["deno.json", "deno.jsonc", "deno.lock", ".dvmrc"]; diff --git a/legacy/bun/lang/Cargo.toml b/legacy/bun/lang/Cargo.toml index 10cc6e8cc3e..f2153b85f31 100644 --- a/legacy/bun/lang/Cargo.toml +++ b/legacy/bun/lang/Cargo.toml @@ -8,7 +8,10 @@ publish = false moon_lang = { path = "../../core/lang" } cached = { workspace = true } miette = { workspace = true } +nodejs_package_json = "0.3.1" rustc-hash = { workspace = true } +serde = { workspace = true } +starbase_utils = { workspace = true, features = ["json"] } tracing = { workspace = true } yarn-lock-parser = "0.10.0" diff --git a/legacy/bun/lang/src/bun_lock.rs b/legacy/bun/lang/src/bun_lock.rs new file mode 100644 index 00000000000..7c41d403db8 --- /dev/null +++ b/legacy/bun/lang/src/bun_lock.rs @@ -0,0 +1,50 @@ +use moon_lang::LockfileDependencyVersions; +use nodejs_package_json::{DependenciesMap, PackageJson}; +use rustc_hash::FxHashMap; +use serde::Deserialize; +use starbase_utils::json; +use std::sync::Arc; + +#[derive(Debug, Deserialize, Default)] +#[serde(default, rename_all = "camelCase")] +pub struct BunLockPackageDependencies { + pub dependencies: DependenciesMap, + pub dev_dependencies: DependenciesMap, + pub peer_dependencies: DependenciesMap, + pub optional_dependencies: DependenciesMap, +} + +#[derive(Debug, Deserialize, Default)] +#[serde(default)] +pub struct BunLockPackage( + String, // identifier + String, // ??? + BunLockPackageDependencies, // dependencies + String, // sha +); + +#[derive(Debug, Deserialize, Default)] +#[serde(default, rename_all = "camelCase")] +pub struct BunLock { + pub lockfile_version: u32, + pub packages: FxHashMap, + pub workspaces: Option>, +} + +pub fn load_text_lockfile_dependencies( + lockfile_text: Arc, +) -> miette::Result { + let mut deps: LockfileDependencyVersions = FxHashMap::default(); + let lockfile: BunLock = json::parse(lockfile_text.as_str())?; + + for (name, package) in lockfile.packages { + let version = package.0.replace("{name}@", ""); + let integrity = package.3; + + let dep = deps.entry(name).or_default(); + dep.push(version); + dep.push(integrity); + } + + Ok(deps) +} diff --git a/legacy/bun/lang/src/bun_lockb.rs b/legacy/bun/lang/src/bun_lockb.rs index 2ad36777b59..cd0ef38ee02 100644 --- a/legacy/bun/lang/src/bun_lockb.rs +++ b/legacy/bun/lang/src/bun_lockb.rs @@ -1,4 +1,3 @@ -use cached::proc_macro::cached; use moon_lang::LockfileDependencyVersions; use rustc_hash::FxHashMap; use std::path::PathBuf; @@ -6,8 +5,7 @@ use std::sync::Arc; use tracing::warn; use yarn_lock_parser::parse_str; -#[cached(result)] -pub fn load_lockfile_dependencies( +pub fn load_binary_lockfile_dependencies( lockfile_text: Arc, path: PathBuf, ) -> miette::Result { diff --git a/legacy/bun/lang/src/lib.rs b/legacy/bun/lang/src/lib.rs index 0dd9e04fcca..8ec3b54d120 100644 --- a/legacy/bun/lang/src/lib.rs +++ b/legacy/bun/lang/src/lib.rs @@ -1,4 +1,22 @@ +mod bun_lock; mod bun_lockb; +pub use bun_lock::*; pub use bun_lockb::*; pub use moon_lang::LockfileDependencyVersions; + +use cached::proc_macro::cached; +use std::path::PathBuf; +use std::sync::Arc; + +#[cached(result)] +pub fn load_lockfile_dependencies( + lockfile_text: Arc, + path: PathBuf, +) -> miette::Result { + if path.ends_with("bun.lock") { + load_text_lockfile_dependencies(lockfile_text) + } else { + load_binary_lockfile_dependencies(lockfile_text, path) + } +} diff --git a/legacy/bun/platform/src/bun_platform.rs b/legacy/bun/platform/src/bun_platform.rs index df2d0e60381..be8bd1c7f38 100644 --- a/legacy/bun/platform/src/bun_platform.rs +++ b/legacy/bun/platform/src/bun_platform.rs @@ -22,7 +22,9 @@ use moon_platform::{Platform, Runtime, RuntimeReq}; use moon_process::Command; use moon_project::Project; use moon_task::Task; -use moon_tool::{get_proto_version_env, prepend_path_env_var, Tool, ToolManager}; +use moon_tool::{ + get_proto_version_env, prepend_path_env_var, DependencyManager, Tool, ToolManager, +}; use moon_typescript_platform::TypeScriptTargetHash; use moon_utils::{async_trait, path}; use proto_core::ProtoEnvironment; @@ -287,7 +289,16 @@ impl Platform for BunPlatform { } fn get_dependency_configs(&self) -> miette::Result> { - Ok(Some(("bun.lockb".to_owned(), "package.json".to_owned()))) + let tool = self.toolchain.get()?; + + Ok(Some(( + if self.packages_root.join("bun.lock").exists() { + "bun.lock".into() + } else { + tool.get_lock_filename() + }, + tool.get_manifest_filename(), + ))) } async fn setup_toolchain(&mut self) -> miette::Result<()> { diff --git a/legacy/bun/tool/src/bun_tool.rs b/legacy/bun/tool/src/bun_tool.rs index 9bdfec743e9..4cef5f8d939 100644 --- a/legacy/bun/tool/src/bun_tool.rs +++ b/legacy/bun/tool/src/bun_tool.rs @@ -81,9 +81,12 @@ impl BunTool { let cache = match self.lockfile_cache.entry_async(key).await { Entry::Occupied(o) => o.get().clone(), Entry::Vacant(v) => { + let bun_lock = cwd.join("bun.lock"); let yarn_lock = cwd.join("yarn.lock"); - let content = if yarn_lock.exists() { + let content = if bun_lock.exists() { + Arc::new(fs::read_file(bun_lock)?) + } else if yarn_lock.exists() { Arc::new(fs::read_file(yarn_lock)?) } else { let mut cmd = self.create_command(&())?; @@ -195,6 +198,7 @@ impl DependencyManager<()> for BunTool { if let Some(version) = get_proto_version_env(&self.tool) { cmd.env("PROTO_BUN_VERSION", version); + cmd.env("PROTO_NODE_VERSION", "*"); } Ok(cmd) @@ -212,7 +216,18 @@ impl DependencyManager<()> for BunTool { } fn get_lock_filename(&self) -> String { - String::from("bun.lockb") + String::from( + if self + .config + .install_args + .iter() + .any(|arg| arg == "--save-text-lockfile") + { + "bun.lock" + } else { + "bun.lockb" + }, + ) } fn get_manifest_filename(&self) -> String { @@ -224,16 +239,21 @@ impl DependencyManager<()> for BunTool { &self, project_root: &Path, ) -> miette::Result { - let Some(lockfile_path) = - fs::find_upwards_until("bun.lockb", project_root, get_workspace_root()) - else { - return Ok(FxHashMap::default()); - }; + let mut lockfile_path = + fs::find_upwards_until("bun.lockb", project_root, get_workspace_root()); + + if lockfile_path.is_none() { + lockfile_path = fs::find_upwards_until("bun.lock", project_root, get_workspace_root()); + } + + if let Some(lockfile_path) = lockfile_path { + return load_lockfile_dependencies( + self.load_lockfile(lockfile_path.parent().unwrap()).await?, + lockfile_path, + ); + } - Ok(load_lockfile_dependencies( - self.load_lockfile(lockfile_path.parent().unwrap()).await?, - lockfile_path, - )?) + Ok(FxHashMap::default()) } #[instrument(skip_all)] diff --git a/legacy/core/test-utils/src/configs.rs b/legacy/core/test-utils/src/configs.rs index e06d71aa219..5336ea0bf74 100644 --- a/legacy/core/test-utils/src/configs.rs +++ b/legacy/core/test-utils/src/configs.rs @@ -348,7 +348,7 @@ pub fn get_bun_fixture_configs() -> ( toolchain_config.node = None; toolchain_config.bun = Some(PartialBunConfig { infer_tasks_from_scripts: Some(true), - version: Some(UnresolvedVersionSpec::parse("1.1.3").unwrap()), + version: Some(UnresolvedVersionSpec::parse("1.2.1").unwrap()), ..PartialBunConfig::default() }); @@ -395,7 +395,7 @@ pub fn get_deno_fixture_configs() -> ( let mut toolchain_config = get_default_toolchain(); toolchain_config.node = None; toolchain_config.deno = Some(PartialDenoConfig { - version: Some(UnresolvedVersionSpec::parse("1.40.0").unwrap()), + version: Some(UnresolvedVersionSpec::parse("2.1.7").unwrap()), ..PartialDenoConfig::default() }); diff --git a/legacy/deno/lang/Cargo.toml b/legacy/deno/lang/Cargo.toml index f3dc6981937..e2c786621e6 100644 --- a/legacy/deno/lang/Cargo.toml +++ b/legacy/deno/lang/Cargo.toml @@ -9,6 +9,7 @@ moon_lang = { path = "../../core/lang" } moon_logger = { path = "../../core/logger" } moon_typescript_lang = { path = "../../typescript/lang" } cached = { workspace = true } +deno_lockfile = "0.24.0" miette = { workspace = true } rustc-hash = { workspace = true } serde = { workspace = true } diff --git a/legacy/deno/lang/src/deno_json.rs b/legacy/deno/lang/src/deno_json.rs index 7bfb37f2a35..5a88d1cef76 100644 --- a/legacy/deno/lang/src/deno_json.rs +++ b/legacy/deno/lang/src/deno_json.rs @@ -11,8 +11,9 @@ use std::path::{Path, PathBuf}; config_cache!(DenoJson, "deno.json", read_json, write_preserved_json); // This isn't everything, just what we care about +// https://deno.land/x/deno/cli/schemas/config-file.v1.json #[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)] -#[serde(rename_all = "camelCase")] +#[serde(default, rename_all = "camelCase")] pub struct DenoJson { #[serde(skip_serializing_if = "Option::is_none")] pub compiler_options: Option, @@ -30,7 +31,7 @@ pub struct DenoJson { pub scopes: Option>>, #[serde(skip_serializing_if = "Option::is_none")] - pub tasks: Option>, + pub workspace: Option, // Non-standard #[serde(skip)] @@ -40,11 +41,32 @@ pub struct DenoJson { pub path: PathBuf, } +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] +#[serde(untagged)] +pub enum DenoJsonWorkspace { + Members(Vec), + Config { members: Vec }, +} + +impl DenoJsonWorkspace { + pub fn get_members(&self) -> &[String] { + match self { + Self::Members(members) => members, + Self::Config { members } => members, + } + } +} + #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] #[serde(untagged)] pub enum DenoJsonLock { Enabled(bool), Path(String), + Config { + path: String, + #[serde(default)] + frozen: bool, + }, } impl DenoJson { diff --git a/legacy/deno/lang/src/deno_lock.rs b/legacy/deno/lang/src/deno_lock.rs index 3650a65772f..e41bdfda7cc 100644 --- a/legacy/deno/lang/src/deno_lock.rs +++ b/legacy/deno/lang/src/deno_lock.rs @@ -1,28 +1,30 @@ use cached::proc_macro::cached; -use moon_lang::{config_cache, LockfileDependencyVersions}; +use deno_lockfile::{Lockfile, NewLockfileOptions}; +use miette::IntoDiagnostic; +use moon_lang::LockfileDependencyVersions; use rustc_hash::FxHashMap; -use serde::{Deserialize, Serialize}; -use starbase_utils::json::read_file as read_json; -use std::path::{Path, PathBuf}; - -config_cache!(DenoLock, "deno.lock", read_json); - -#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct DenoLock { - remote: FxHashMap, - - #[serde(skip)] - pub path: PathBuf, -} +use starbase_utils::fs; +use std::path::PathBuf; #[cached(result)] pub fn load_lockfile_dependencies(path: PathBuf) -> miette::Result { let mut deps: LockfileDependencyVersions = FxHashMap::default(); - if let Some(lockfile) = DenoLock::read(path)? { - for (key, value) in lockfile.remote { - deps.insert(key, vec![value]); + if path.exists() { + let lockfile_content = fs::read_file(&path)?; + let lockfile = Lockfile::new(NewLockfileOptions { + content: &lockfile_content, + file_path: path.clone(), + overwrite: false, + }) + .into_diagnostic()?; + + for (key, value) in lockfile.content.packages.jsr { + deps.insert(format!("jsr:{key}"), vec![value.integrity]); + } + + for (key, value) in lockfile.content.packages.npm { + deps.insert(format!("npm:{key}"), vec![value.integrity]); } } diff --git a/legacy/deno/lang/src/lib.rs b/legacy/deno/lang/src/lib.rs index 6490544e6f1..81612eee5f8 100644 --- a/legacy/deno/lang/src/lib.rs +++ b/legacy/deno/lang/src/lib.rs @@ -4,3 +4,25 @@ mod deno_lock; pub use deno_json::*; pub use deno_lock::*; pub use moon_lang::LockfileDependencyVersions; + +use cached::proc_macro::cached; +use std::path::PathBuf; + +#[cached(result)] +pub fn find_package_manager_workspaces_root( + starting_dir: PathBuf, +) -> miette::Result> { + let mut current_dir = Some(starting_dir.as_path()); + + while let Some(dir) = current_dir { + if let Some(deno_json) = DenoJson::read(dir)? { + if deno_json.workspace.is_some() { + return Ok(Some(dir.to_path_buf())); + } + } + + current_dir = dir.parent(); + } + + Ok(None) +} diff --git a/legacy/deno/platform/Cargo.toml b/legacy/deno/platform/Cargo.toml index 3330c7eba4b..2c004298f3e 100644 --- a/legacy/deno/platform/Cargo.toml +++ b/legacy/deno/platform/Cargo.toml @@ -25,6 +25,7 @@ miette = { workspace = true } proto_core = { workspace = true } rustc-hash = { workspace = true } serde = { workspace = true } +starbase_utils = { workspace = true, features = ["glob"] } [lints] workspace = true diff --git a/legacy/deno/platform/src/deno_platform.rs b/legacy/deno/platform/src/deno_platform.rs index 2c98601de3d..244452141c5 100644 --- a/legacy/deno/platform/src/deno_platform.rs +++ b/legacy/deno/platform/src/deno_platform.rs @@ -4,13 +4,14 @@ use crate::target_hash::DenoTargetHash; use miette::IntoDiagnostic; use moon_action::Operation; use moon_action_context::ActionContext; +use moon_common::path::{is_root_level_source, WorkspaceRelativePath, WorkspaceRelativePathBuf}; use moon_common::{color, is_ci, is_test_env, Id}; use moon_config::{ BinEntry, DenoConfig, DependencyConfig, HasherConfig, HasherOptimization, PlatformType, ProjectConfig, TypeScriptConfig, }; use moon_console::{Checkpoint, Console}; -use moon_deno_lang::{load_lockfile_dependencies, DenoJson}; +use moon_deno_lang::{find_package_manager_workspaces_root, load_lockfile_dependencies, DenoJson}; use moon_deno_tool::{get_deno_env_paths, DenoTool}; use moon_hash::ContentHasher; use moon_logger::{debug, map_list}; @@ -25,6 +26,7 @@ use moon_typescript_platform::TypeScriptTargetHash; use moon_utils::async_trait; use proto_core::{ProtoEnvironment, UnresolvedVersionSpec}; use rustc_hash::FxHashMap; +use starbase_utils::glob::GlobSet; use std::sync::Arc; use std::{ collections::BTreeMap, @@ -105,6 +107,49 @@ impl Platform for DenoPlatform { // PROJECT GRAPH + fn find_dependency_workspace_root( + &self, + starting_dir: &str, + ) -> miette::Result { + let root = find_package_manager_workspaces_root(self.workspace_root.join(starting_dir))? + .unwrap_or(self.workspace_root.clone()); + + if let Ok(root) = root.strip_prefix(&self.workspace_root) { + return WorkspaceRelativePathBuf::from_path(root).into_diagnostic(); + } + + Ok(WorkspaceRelativePathBuf::default()) + } + + fn is_project_in_dependency_workspace( + &self, + deps_root: &WorkspaceRelativePath, + project_source: &str, + ) -> miette::Result { + let deps_root_path = deps_root.to_logical_path(&self.workspace_root); + + // Root package is always considered within the workspace + if is_root_level_source(project_source) && deps_root_path == self.workspace_root { + return Ok(true); + } + + let Some(deno_json) = DenoJson::read(&deps_root_path)? else { + return Ok(false); + }; + + if let Some(workspace) = deno_json.workspace { + let members = workspace + .get_members() + .iter() + .map(|mem| mem.trim_start_matches("./")) + .collect::>(); + + return Ok(GlobSet::new(members)?.matches(project_source)); + } + + Ok(false) + } + fn load_project_implicit_dependencies( &self, _project_id: &str, @@ -203,13 +248,10 @@ impl Platform for DenoPlatform { working_dir: &Path, ) -> miette::Result> { let deno = self.toolchain.get_for_version(&runtime.requirement)?; + let is_v2 = deno.is_v2(); let mut operations = vec![]; if !self.config.bins.is_empty() { - self.console - .out - .print_checkpoint(Checkpoint::Setup, "deno install")?; - debug!( target: LOG_TARGET, "Installing Deno binaries: {}", @@ -221,11 +263,16 @@ impl Platform for DenoPlatform { "install", "--allow-net", "--allow-read", - "--no-prompt", "--lock", "deno.lock", ]; + if is_v2 { + args.push("--global"); + } else { + args.push("--no-prompt"); + } + match bin { BinEntry::Name(name) => args.push(name), BinEntry::Config(cfg) => { @@ -249,6 +296,10 @@ impl Platform for DenoPlatform { operations.push( Operation::task_execution(format!("deno {}", args.join(" "))) .track_async(|| async { + self.console + .out + .print_checkpoint(Checkpoint::Setup, "deno install --global")?; + deno.create_command(&())? .args(args) .cwd(working_dir) @@ -264,15 +315,33 @@ impl Platform for DenoPlatform { if self.config.lockfile { debug!(target: LOG_TARGET, "Installing dependencies"); - self.console - .out - .print_checkpoint(Checkpoint::Setup, "deno cache")?; + if is_v2 { + operations.push( + Operation::task_execution("deno install") + .track_async(|| async { + self.console + .out + .print_checkpoint(Checkpoint::Setup, "deno install")?; - operations.push( - Operation::task_execution("deno cache --lock deno.lock --lock-write") - .track_async(|| deno.install_dependencies(&(), working_dir, !is_test_env())) - .await?, - ); + deno.install_dependencies(&(), working_dir, !is_test_env()) + .await + }) + .await?, + ); + } else { + operations.push( + Operation::task_execution("deno cache --lock-write") + .track_async(|| async { + self.console + .out + .print_checkpoint(Checkpoint::Setup, "deno cache")?; + + deno.install_dependencies(&(), working_dir, !is_test_env()) + .await + }) + .await?, + ); + } } Ok(operations) diff --git a/legacy/deno/tool/src/deno_tool.rs b/legacy/deno/tool/src/deno_tool.rs index 39fb6759740..9caa9f98aed 100644 --- a/legacy/deno/tool/src/deno_tool.rs +++ b/legacy/deno/tool/src/deno_tool.rs @@ -72,6 +72,14 @@ impl DenoTool { Ok(deno) } + + pub fn is_v2(&self) -> bool { + self.config.version.as_ref().is_some_and(|spec| match spec { + UnresolvedVersionSpec::Req(req) => req.comparators.iter().any(|c| c.major >= 2), + UnresolvedVersionSpec::Semantic(version) => version.major >= 2, + _ => false, + }) + } } #[async_trait] @@ -207,15 +215,14 @@ impl DependencyManager<()> for DenoTool { ) -> miette::Result<()> { let mut cmd = self.create_command(parent)?; - cmd.args([ - "cache", - "--lock", - "deno.lock", - "--lock-write", - &self.config.deps_file, - ]) - .cwd(working_dir) - .set_print_command(log); + if self.is_v2() { + cmd.args(["install", "--no-check"]); + cmd.args(&self.config.install_args); + } else { + cmd.args(["cache", "--lock-write", &self.config.deps_file]); + } + + cmd.cwd(working_dir).set_print_command(log); let mut cmd = cmd.create_async(); diff --git a/legacy/node/platform/src/node_platform.rs b/legacy/node/platform/src/node_platform.rs index 6bb20cb7957..1fe69d72967 100644 --- a/legacy/node/platform/src/node_platform.rs +++ b/legacy/node/platform/src/node_platform.rs @@ -142,6 +142,7 @@ impl Platform for NodePlatform { project_source: &str, ) -> miette::Result { let mut in_workspace = false; + let deps_root_path = deps_root.to_logical_path(&self.workspace_root); // Single version policy / only a root package.json if self.config.root_package_only { @@ -149,12 +150,12 @@ impl Platform for NodePlatform { } // Root package is always considered within the workspace - if is_root_level_source(project_source) && self.packages_root == self.workspace_root { + if is_root_level_source(project_source) && deps_root_path == self.workspace_root { return Ok(true); } if let Some(globs) = get_package_manager_workspaces( - deps_root.to_logical_path(&self.workspace_root), + deps_root_path, matches!(self.config.package_manager, NodePackageManager::Pnpm), )? { in_workspace = GlobSet::new(&globs)?.matches(project_source); @@ -180,6 +181,13 @@ impl Platform for NodePlatform { PackageJsonCache::read(project_source.to_path(&self.workspace_root))? { if let Some(package_name) = package_json.data.name { + debug!( + target: LOG_TARGET, + "Inheriting alias {} for project {}", + color::label(&package_name), + color::id(project_id) + ); + self.package_names .insert(package_name.clone(), project_id.to_owned()); diff --git a/legacy/node/tool/src/bun_tool.rs b/legacy/node/tool/src/bun_tool.rs index 6b6f8226045..2d1c8c79cf0 100644 --- a/legacy/node/tool/src/bun_tool.rs +++ b/legacy/node/tool/src/bun_tool.rs @@ -192,6 +192,7 @@ impl DependencyManager for BunTool { if let Some(version) = get_proto_version_env(&self.tool) { cmd.env("PROTO_BUN_VERSION", version); + cmd.env("PROTO_NODE_VERSION", "*"); } if let Some(version) = get_proto_version_env(&node.tool) { @@ -213,7 +214,18 @@ impl DependencyManager for BunTool { } fn get_lock_filename(&self) -> String { - String::from("bun.lockb") + String::from( + if self + .config + .install_args + .iter() + .any(|arg| arg == "--save-text-lockfile") + { + "bun.lock" + } else { + "bun.lockb" + }, + ) } fn get_manifest_filename(&self) -> String { diff --git a/legacy/python/platform/src/actions/install_deps.rs b/legacy/python/platform/src/actions/install_deps.rs index fd29aadceee..cfcb4ebd8cf 100644 --- a/legacy/python/platform/src/actions/install_deps.rs +++ b/legacy/python/platform/src/actions/install_deps.rs @@ -24,15 +24,17 @@ pub async fn install_deps( }; if !venv_root.exists() && requirements_path.is_some() { - console - .out - .print_checkpoint(Checkpoint::Setup, "python venv")?; - let args = vec!["-m", "venv", venv_root.to_str().unwrap_or_default()]; operations.push( Operation::task_execution(format!("python {}", args.join(" "))) - .track_async(|| python.exec_python(args, working_dir, workspace_root)) + .track_async(|| async { + console + .out + .print_checkpoint(Checkpoint::Setup, "python venv")?; + + python.exec_python(args, working_dir, workspace_root).await + }) .await?, ); } diff --git a/legacy/rust/platform/src/rust_platform.rs b/legacy/rust/platform/src/rust_platform.rs index 09a57a82836..c91c2635b80 100644 --- a/legacy/rust/platform/src/rust_platform.rs +++ b/legacy/rust/platform/src/rust_platform.rs @@ -10,8 +10,8 @@ use moon_common::{ Id, }; use moon_config::{ - BinEntry, HasherConfig, PlatformType, ProjectConfig, ProjectsAliasesList, ProjectsSourcesList, - RustConfig, UnresolvedVersionSpec, + BinEntry, DependencyConfig, DependencyScope, DependencySource, HasherConfig, PlatformType, + ProjectConfig, ProjectsAliasesList, ProjectsSourcesList, RustConfig, UnresolvedVersionSpec, }; use moon_console::{Checkpoint, Console}; use moon_hash::ContentHasher; @@ -21,7 +21,7 @@ use moon_process::Command; use moon_project::Project; use moon_rust_lang::{ cargo_lock::load_lockfile_dependencies, - cargo_toml::CargoTomlCache, + cargo_toml::{CargoTomlCache, DepsSet}, toolchain_toml::{ToolchainToml, ToolchainTomlCache}, }; use moon_rust_tool::{get_rust_env_paths, RustTool}; @@ -46,6 +46,8 @@ pub struct RustPlatform { console: Arc, + package_names: FxHashMap, + proto_env: Arc, toolchain: ToolManager, @@ -63,6 +65,7 @@ impl RustPlatform { ) -> Self { RustPlatform { config: config.to_owned(), + package_names: FxHashMap::default(), proto_env, toolchain: ToolManager::new(Runtime::new(Id::raw("rust"), RuntimeReq::Global)), workspace_root: workspace_root.to_path_buf(), @@ -151,16 +154,16 @@ impl Platform for RustPlatform { ) -> miette::Result { let deps_root_path = deps_root.to_logical_path(&self.workspace_root); - let Some(cargo_toml) = CargoTomlCache::read(&deps_root_path)? else { - return Ok(false); - }; - if is_root_level_source(project_source) && deps_root_path == self.workspace_root || deps_root.as_str() == project_source { return Ok(true); } + let Some(cargo_toml) = CargoTomlCache::read(&deps_root_path)? else { + return Ok(false); + }; + if let Some(workspace) = cargo_toml.workspace { return Ok( GlobSet::new_split(&workspace.members, &workspace.exclude)?.matches(project_source) @@ -176,6 +179,12 @@ impl Platform for RustPlatform { projects_list: &ProjectsSourcesList, aliases_list: &mut ProjectsAliasesList, ) -> miette::Result<()> { + debug!( + target: LOG_TARGET, + "Loading names (aliases) from project {}'s", + color::file("Cargo.toml") + ); + // Extract the alias from the Cargo project relative to the lockfile for (id, source) in projects_list { let project_root = source.to_path(&self.workspace_root); @@ -190,6 +199,9 @@ impl Platform for RustPlatform { color::id(id) ); + self.package_names + .insert(package.name.clone(), id.to_owned()); + aliases_list.push((id.to_owned(), package.name)); } } @@ -199,6 +211,45 @@ impl Platform for RustPlatform { Ok(()) } + #[instrument(skip(self))] + fn load_project_implicit_dependencies( + &self, + project_id: &str, + project_source: &str, + ) -> miette::Result> { + let mut implicit_deps = vec![]; + + debug!( + target: LOG_TARGET, + "Scanning {} for implicit dependency relations", + color::id(project_id), + ); + + if let Some(cargo_toml) = CargoTomlCache::read(self.workspace_root.join(project_source))? { + let mut find_implicit_relations = |package_deps: &DepsSet, scope: &DependencyScope| { + for (dep_name, dep) in package_deps { + // Only inherit if the dependency is using the local `path = "..."` syntax + if dep.detail().is_some_and(|d| d.path.is_some()) { + if let Some(dep_project_id) = self.package_names.get(dep_name) { + implicit_deps.push(DependencyConfig { + id: dep_project_id.to_owned(), + scope: *scope, + source: DependencySource::Implicit, + via: Some(dep_name.clone()), + }); + } + } + } + }; + + find_implicit_relations(&cargo_toml.dependencies, &DependencyScope::Production); + find_implicit_relations(&cargo_toml.dev_dependencies, &DependencyScope::Development); + find_implicit_relations(&cargo_toml.build_dependencies, &DependencyScope::Build); + } + + Ok(implicit_deps) + } + // TOOLCHAIN fn is_toolchain_enabled(&self) -> miette::Result { @@ -291,10 +342,6 @@ impl Platform for RustPlatform { let mut operations = vec![]; if !self.config.components.is_empty() { - self.console - .out - .print_checkpoint(Checkpoint::Setup, "rustup component")?; - debug!( target: LOG_TARGET, "Installing rustup components: {}", @@ -306,16 +353,18 @@ impl Platform for RustPlatform { operations.push( Operation::task_execution(format!("rustup {}", args.join(" "))) - .track_async(|| tool.exec_rustup(args, working_dir)) + .track_async(|| async { + self.console + .out + .print_checkpoint(Checkpoint::Setup, "rustup component")?; + + tool.exec_rustup(args, working_dir).await + }) .await?, ); } if !self.config.targets.is_empty() { - self.console - .out - .print_checkpoint(Checkpoint::Setup, "rustup target")?; - debug!( target: LOG_TARGET, "Installing rustup targets: {}", @@ -327,28 +376,32 @@ impl Platform for RustPlatform { operations.push( Operation::task_execution(format!("rustup {}", args.join(" "))) - .track_async(|| tool.exec_rustup(args, working_dir)) + .track_async(|| async { + self.console + .out + .print_checkpoint(Checkpoint::Setup, "rustup target")?; + + tool.exec_rustup(args, working_dir).await + }) .await?, ); } if find_cargo_lock(working_dir, &self.workspace_root).is_none() { - self.console - .out - .print_checkpoint(Checkpoint::Setup, "cargo generate-lockfile")?; - operations.push( Operation::task_execution("cargo generate-lockfile") - .track_async(|| tool.exec_cargo(["generate-lockfile"], working_dir)) + .track_async(|| async { + self.console + .out + .print_checkpoint(Checkpoint::Setup, "cargo generate-lockfile")?; + + tool.exec_cargo(["generate-lockfile"], working_dir).await + }) .await?, ); } if !self.config.bins.is_empty() { - self.console - .out - .print_checkpoint(Checkpoint::Setup, "cargo binstall")?; - let globals_dir = self.get_globals_dir(Some(tool)); // Install cargo-binstall if it does not exist @@ -401,7 +454,13 @@ impl Platform for RustPlatform { operations.push( Operation::task_execution(format!("cargo {}", args.join(" "))) - .track_async(|| tool.exec_cargo(args, working_dir)) + .track_async(|| async { + self.console + .out + .print_checkpoint(Checkpoint::Setup, "cargo binstall")?; + + tool.exec_cargo(args, working_dir).await + }) .await?, ); } diff --git a/packages/types/src/toolchain-config.ts b/packages/types/src/toolchain-config.ts index 3ec84cfb937..0382fd43ae4 100644 --- a/packages/types/src/toolchain-config.ts +++ b/packages/types/src/toolchain-config.ts @@ -86,6 +86,8 @@ export interface DenoConfig { * @default 'deps.ts' */ depsFile?: string; + /** List of arguments to append to `deno install` commands. */ + installArgs: string[]; /** Requires and forces the use of `deno.lock` files. */ lockfile: boolean; /** Location of the WASM plugin to use for Deno support. */ @@ -485,6 +487,8 @@ export interface PartialDenoConfig { * @default 'deps.ts' */ depsFile?: string | null; + /** List of arguments to append to `deno install` commands. */ + installArgs?: string[] | null; /** Requires and forces the use of `deno.lock` files. */ lockfile?: boolean | null; /** Location of the WASM plugin to use for Deno support. */ diff --git a/tests/fixtures/bun/version-override/moon.yml b/tests/fixtures/bun/version-override/moon.yml index f9725d7f3bd..101cf4d7582 100644 --- a/tests/fixtures/bun/version-override/moon.yml +++ b/tests/fixtures/bun/version-override/moon.yml @@ -2,4 +2,4 @@ language: javascript toolchain: bun: - version: '0.8.0' + version: '1.1.0' diff --git a/website/docs/proto/toml-plugin.mdx b/website/docs/proto/toml-plugin.mdx deleted file mode 100644 index adf2d7952b8..00000000000 --- a/website/docs/proto/toml-plugin.mdx +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: TOML plugin -sidebar_label: TOML -toc_max_heading_level: 5 ---- - -The TOML plugin documentation has moved to: -[https://moonrepo.dev/docs/proto/non-wasm-plugin](/docs/proto/non-wasm-plugin) diff --git a/website/docs/setup-toolchain.mdx b/website/docs/setup-toolchain.mdx index 8faf9c7f72b..3925f8eca45 100644 --- a/website/docs/setup-toolchain.mdx +++ b/website/docs/setup-toolchain.mdx @@ -37,7 +37,7 @@ day-to-day. ## Enabling a platform By default all tasks run through the -[system platform](./how-it-works/languages#system-language-and-platform) and inherit _no_ special +[system platform](./how-it-works/languages#system-language-and-toolchain) and inherit _no_ special functionality. If you want to take advantage of this functionality, like dependency hashing, package shorthand execution, and lockfile management, you'll need to enable the platform in [`.moon/toolchain.yml`](./config/toolchain). Otherwise, you can skip to the diff --git a/website/static/schemas/toolchain.json b/website/static/schemas/toolchain.json index beba9ba5392..d521a525a90 100644 --- a/website/static/schemas/toolchain.json +++ b/website/static/schemas/toolchain.json @@ -293,6 +293,15 @@ "default": "deps.ts", "type": "string" }, + "installArgs": { + "title": "installArgs", + "description": "List of arguments to append to deno install commands.", + "type": "array", + "items": { + "type": "string" + }, + "markdownDescription": "List of arguments to append to `deno install` commands." + }, "lockfile": { "title": "lockfile", "description": "Requires and forces the use of deno.lock files.",