Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Start on toolchain plugins. #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
173 changes: 170 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand Down
25 changes: 25 additions & 0 deletions toolchains/node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
44 changes: 44 additions & 0 deletions toolchains/node/src/config.rs
Original file line number Diff line number Diff line change
@@ -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<String>,

/// 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,
}
);
8 changes: 8 additions & 0 deletions toolchains/node/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mod config;
#[cfg(feature = "wasm")]
mod moon;

#[cfg(feature = "wasm")]
pub use moon::*;
#[cfg(feature = "wasm")]
pub use node_tool::*;
15 changes: 15 additions & 0 deletions toolchains/node/src/moon.rs
Original file line number Diff line number Diff line change
@@ -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<ToolchainMetadataInput>,
) -> FnResult<Json<ToolchainMetadataOutput>> {
Ok(Json(ToolchainMetadataOutput {
// config_schema: Some(SchemaBuilder::build_root::<NodeConfig>()),
plugin_version: env!("CARGO_PKG_VERSION").into(),
..ToolchainMetadataOutput::default()
}))
}
Loading
Loading