diff --git a/Cargo.lock b/Cargo.lock index e1188fe..20cbceb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -401,6 +401,44 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "clap" +version = "4.5.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" +dependencies = [ + "anstyle", + "clap_lex", +] + +[[package]] +name = "clap_derive" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" + [[package]] name = "clean-path" version = "0.2.1" @@ -870,6 +908,12 @@ version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + [[package]] name = "either" version = "1.13.0" @@ -1229,6 +1273,7 @@ dependencies = [ "once_cell", "regex", "smallvec", + "url", ] [[package]] @@ -2104,6 +2149,81 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "moon_common" +version = "0.0.9" +dependencies = [ + "compact_str 0.8.0", + "dirs 5.0.1", + "miette 7.4.0", + "regex", + "relative-path", + "rustc-hash", + "schematic", + "serde", + "starbase_styles", + "thiserror 2.0.7", +] + +[[package]] +name = "moon_config" +version = "0.0.11" +dependencies = [ + "indexmap", + "miette 7.4.0", + "moon_common", + "moon_target", + "once_cell", + "regex", + "rpkl", + "rustc-hash", + "schematic", + "semver", + "serde", + "serde_json", + "serde_yaml", + "version_spec", + "warpgate_api", +] + +[[package]] +name = "moon_pdk" +version = "0.0.11" +dependencies = [ + "clap", + "extism-pdk", + "moon_pdk_api", + "serde", + "warpgate_pdk", +] + +[[package]] +name = "moon_pdk_api" +version = "0.0.11" +dependencies = [ + "moon_common", + "moon_config", + "rustc-hash", + "schematic", + "serde", + "warpgate_api", +] + +[[package]] +name = "moon_target" +version = "0.0.8" +dependencies = [ + "compact_str 0.8.0", + "miette 7.4.0", + "moon_common", + "once_cell", + "regex", + "schematic", + "serde", + "thiserror 2.0.7", + "tracing", +] + [[package]] name = "nix" version = "0.27.1" @@ -2156,18 +2276,29 @@ dependencies = [ "tokio", ] +[[package]] +name = "node_toolchain" +version = "0.0.1" +dependencies = [ + "extism-pdk", + "moon_pdk", + "node_tool", + "schematic", + "serde", +] + [[package]] name = "nodejs_package_json" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5b1935bec0b4fb49c42f50bd6822a3171cbf55a0d9cd1810715baa2f319a1d7" +checksum = "008b3dcf2b6ccd151efab4145717974b21588f105f2bc9004983b6cc2e00cf9e" dependencies = [ "indexmap", "rustc-hash", "semver", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.7", ] [[package]] @@ -2772,6 +2903,15 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "relative-path" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" +dependencies = [ + "serde", +] + [[package]] name = "reqwest" version = "0.12.9" @@ -2895,6 +3035,28 @@ dependencies = [ "serde", ] +[[package]] +name = "rmpv" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58450723cd9ee93273ce44a20b6ec4efe17f8ed2e3631474387bfdecf18bb2a9" +dependencies = [ + "num-traits", + "rmp", +] + +[[package]] +name = "rpkl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90d4fb97471646d778a76c8009623e1303898fdf9f4ba9f404b02a0217b7dfb1" +dependencies = [ + "dunce", + "rmp-serde", + "rmpv", + "serde", +] + [[package]] name = "rust-netrc" version = "0.1.2" @@ -3076,11 +3238,13 @@ dependencies = [ "garde", "indexmap", "miette 7.4.0", + "rpkl", "schematic_macros", "schematic_types", "serde", "serde_json", "serde_path_to_error", + "serde_yaml", "starbase_styles", "thiserror 2.0.7", "toml", @@ -3107,9 +3271,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f320deb050277c5bcc79213b01d749f8a847a63713e76d5748fdad654f47ed52" dependencies = [ "indexmap", + "rpkl", "semver", "serde", "serde_json", + "serde_yaml", "toml", "url", ] @@ -3495,6 +3661,7 @@ checksum = "81baa090153ac22b9e2666a01899a1797e88e4ae1fee84a0440862887d299219" dependencies = [ "dirs 5.0.1", "owo-colors", + "relative-path", "supports-color", ] diff --git a/Cargo.toml b/Cargo.toml index f9d0e57..69fbf6d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,22 @@ [workspace] resolver = "2" -members = ["crates/*", "tools/*"] +members = ["crates/*", "tools/*", "toolchains/*"] [workspace.dependencies] +# moon +moon_pdk = { path = "../moon/crates/pdk" } +moon_pdk_api = { path = "../moon/crates/pdk-api" } + +# proto +proto_pdk = { version = "0.25.5" } # , path = "../proto/crates/pdk" } +proto_pdk_api = { version = "0.24.5" } # , path = "../proto/crates/pdk-api" } +proto_pdk_test_utils = { version = "0.30.4" } # , path = "../proto/crates/pdk-test-utils" } + # Common extism-pdk = { version = "1.3.0" } -proto_pdk = { version = "0.25.5" } # , path = "../proto/crates/pdk" } -proto_pdk_api = { version = "0.24.5" } # , path = "../proto/crates/pdk-api" } -proto_pdk_test_utils = { version = "0.30.4" } # , path = "../proto/crates/pdk-test-utils" } regex = { version = "1.11.1", default-features = false, features = ["std"] } schematic = { version = "0.17.7", default-features = false, features = [ - "schema", + "schema", ] } serde = "1.0.216" serde_json = "1.0.132" @@ -20,7 +26,7 @@ tokio = { version = "1.42.0", features = ["full"] } toml = { version = "0.8.19", default-features = false, features = ["parse"] } # Node.js -nodejs_package_json = "0.3.0" +nodejs_package_json = "0.3.1" [profile.release] codegen-units = 1 diff --git a/toolchains/node/Cargo.toml b/toolchains/node/Cargo.toml new file mode 100644 index 0000000..9514191 --- /dev/null +++ b/toolchains/node/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "node_toolchain" +version = "0.0.1" +edition = "2021" +license = "MIT" +publish = false + +[package.metadata.release] +pre-release-replacements = [ + { file = "./CHANGELOG.md", search = "Unreleased", replace = "{{version}}" }, +] + +[lib] +crate-type = ["cdylib"] + +[dependencies] +node_tool = { path = "../../tools/node" } +extism-pdk = { workspace = true } +moon_pdk = { workspace = true } +schematic = { workspace = true } +serde = { workspace = true } + +[features] +default = ["wasm"] +wasm = ["node_tool/wasm"] diff --git a/toolchains/node/src/config.rs b/toolchains/node/src/config.rs new file mode 100644 index 0000000..100acc8 --- /dev/null +++ b/toolchains/node/src/config.rs @@ -0,0 +1,44 @@ +use moon_pdk::config_struct; +use schematic::Schematic; + +config_struct!( + /// Configures and enables the Node.js platform. + /// Docs: https://moonrepo.dev/docs/config/toolchain#node + #[derive(Default, Schematic)] + pub struct NodeConfig { + /// When `version` is defined, syncs the version as a constraint to + /// `package.json` engines. + #[schema(default = true)] + pub add_engines_constraint: bool, + + /// Arguments to automatically pass to all tasks that execute the + /// `node` binary. + pub bin_exec_args: Vec, + + /// Automatically dedupes the lockfile when dependencies have changed. + #[schema(default = true)] + pub dedupe_on_lockfile_change: bool, + + /// Automatically infer moon tasks from `package.json` scripts. + pub infer_tasks_from_scripts: bool, + + /// The relative root of the packages workspace. Defaults to moon's + /// workspace root, but should be defined when nested. + #[schema(default = ".", skip)] + pub packages_root: String, + + /// Assumes only the root `package.json` is used for dependencies. + /// Can be used to support the "one version policy" pattern. + pub root_package_only: bool, + + /// Automatically syncs the configured package manager version + /// to the root `packageManager` field in `package.json`. + #[schema(default = true)] + pub sync_package_manager_field: bool, + + /// Automatically syncs moon project-to-project relationships as + /// dependencies for each `package.json` in the workspace. + #[schema(default = true)] + pub sync_project_workspace_dependencies: bool, + } +); diff --git a/toolchains/node/src/lib.rs b/toolchains/node/src/lib.rs new file mode 100644 index 0000000..fa5a206 --- /dev/null +++ b/toolchains/node/src/lib.rs @@ -0,0 +1,8 @@ +mod config; +#[cfg(feature = "wasm")] +mod moon; + +#[cfg(feature = "wasm")] +pub use moon::*; +#[cfg(feature = "wasm")] +pub use node_tool::*; diff --git a/toolchains/node/src/moon.rs b/toolchains/node/src/moon.rs new file mode 100644 index 0000000..cc7bbc8 --- /dev/null +++ b/toolchains/node/src/moon.rs @@ -0,0 +1,15 @@ +use crate::config::NodeConfig; +use extism_pdk::*; +use moon_pdk::*; +use schematic::SchemaBuilder; + +#[plugin_fn] +pub fn register_toolchain( + Json(_): Json, +) -> FnResult> { + Ok(Json(ToolchainMetadataOutput { + // config_schema: Some(SchemaBuilder::build_root::()), + plugin_version: env!("CARGO_PKG_VERSION").into(), + ..ToolchainMetadataOutput::default() + })) +} diff --git a/tools/bun/Cargo.toml b/tools/bun/Cargo.toml index 605b71a..e6b2b56 100644 --- a/tools/bun/Cargo.toml +++ b/tools/bun/Cargo.toml @@ -11,7 +11,7 @@ pre-release-replacements = [ ] [lib] -crate-type = ['cdylib'] +crate-type = ["cdylib"] [dependencies] extism-pdk = { workspace = true } diff --git a/tools/deno/Cargo.toml b/tools/deno/Cargo.toml index e05b8dd..e72ab1f 100644 --- a/tools/deno/Cargo.toml +++ b/tools/deno/Cargo.toml @@ -11,7 +11,7 @@ pre-release-replacements = [ ] [lib] -crate-type = ['cdylib'] +crate-type = ["cdylib"] [dependencies] extism-pdk = { workspace = true } diff --git a/tools/go/Cargo.toml b/tools/go/Cargo.toml index 97cb630..29e8e92 100644 --- a/tools/go/Cargo.toml +++ b/tools/go/Cargo.toml @@ -11,7 +11,7 @@ pre-release-replacements = [ ] [lib] -crate-type = ['cdylib'] +crate-type = ["cdylib"] [dependencies] extism-pdk = { workspace = true } diff --git a/tools/internal-schema/Cargo.toml b/tools/internal-schema/Cargo.toml index 5527381..4542355 100644 --- a/tools/internal-schema/Cargo.toml +++ b/tools/internal-schema/Cargo.toml @@ -11,7 +11,7 @@ pre-release-replacements = [ ] [lib] -crate-type = ['cdylib'] +crate-type = ["cdylib"] [dependencies] extism-pdk = { workspace = true } diff --git a/tools/node-depman/Cargo.toml b/tools/node-depman/Cargo.toml index 229bc23..dd7a5f9 100644 --- a/tools/node-depman/Cargo.toml +++ b/tools/node-depman/Cargo.toml @@ -11,7 +11,7 @@ pre-release-replacements = [ ] [lib] -crate-type = ['cdylib'] +crate-type = ["cdylib"] [dependencies] node_common = { path = "../../crates/node-common" } diff --git a/tools/node/Cargo.toml b/tools/node/Cargo.toml index 810f1b7..15ec1ab 100644 --- a/tools/node/Cargo.toml +++ b/tools/node/Cargo.toml @@ -11,7 +11,7 @@ pre-release-replacements = [ ] [lib] -crate-type = ['cdylib'] +crate-type = ["cdylib", "lib"] [dependencies] node_common = { path = "../../crates/node-common" } diff --git a/tools/python/Cargo.toml b/tools/python/Cargo.toml index 729c337..77fb472 100644 --- a/tools/python/Cargo.toml +++ b/tools/python/Cargo.toml @@ -11,7 +11,7 @@ pre-release-replacements = [ ] [lib] -crate-type = ['cdylib'] +crate-type = ["cdylib"] [dependencies] extism-pdk = { workspace = true } diff --git a/tools/rust/Cargo.toml b/tools/rust/Cargo.toml index 57fb314..86ebf16 100644 --- a/tools/rust/Cargo.toml +++ b/tools/rust/Cargo.toml @@ -11,7 +11,7 @@ pre-release-replacements = [ ] [lib] -crate-type = ['cdylib'] +crate-type = ["cdylib"] [dependencies] extism-pdk = { workspace = true }