Skip to content
Merged
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
1 change: 1 addition & 0 deletions .prototools
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[plugins]
# moon-test = "file://./crates/cli/tests/fixtures/moon-schema.yaml"
moon-test = "https://raw.githubusercontent.com/moonrepo/moon/master/proto-plugin.toml"
wasm-test = "file://./plugins/target/wasm32-wasi/debug/proto_wasm_test.wasm"

Expand Down
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
- [Node](https://github.com/moonrepo/tools/blob/master/tools/node/CHANGELOG.md)
- [Python](https://github.com/moonrepo/tools/blob/master/tools/python/CHANGELOG.md)
- [Rust](https://github.com/moonrepo/tools/blob/master/tools/rust/CHANGELOG.md)
- [TOML schema](https://github.com/moonrepo/tools/blob/master/tools/internal-schema/CHANGELOG.md)
- [Schema (TOML, JSON, YAML)](https://github.com/moonrepo/tools/blob/master/tools/internal-schema/CHANGELOG.md)

## Unreleased

#### 🚀 Updates

- Added support for JSON and YAML based configurations for non-WASM schema based plugins. This is an alternative to TOML, but supports all the same settings.

## 0.41.5

Expand All @@ -28,7 +34,7 @@

#### 🧩 Plugins

- Updated `internal_schema_plugin` (TOML) to v0.15.1.
- Updated `schema_tool` (TOML) to v0.15.1.
- Added `{versionMajor}`, `{versionMajorMinor}`, `{versionYear}`, `{versionYearMonth}`, `{versionPrerelease}`, and `{versionBuild}` tokens.

#### ⚙️ Internal
Expand Down
23 changes: 22 additions & 1 deletion Cargo.lock

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

2 changes: 2 additions & 0 deletions crates/cli/src/commands/plugin/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ pub async fn search(session: ProtoSession, args: SearchPluginArgs) -> AppResult
PluginAuthor::Object(author) => &author.name,
}),
Cell::new(match plugin.format {
PluginFormat::Json => "JSON",
PluginFormat::Toml => "TOML",
PluginFormat::Wasm => "WASM",
PluginFormat::Yaml => "YAML",
}),
Cell::new(&plugin.description),
Cell::new(plugin.locator.to_string())
Expand Down
23 changes: 23 additions & 0 deletions crates/cli/tests/fixtures/moon-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"bin": "moon-test",
"name": "moon-test",
"type": "cli",
"platform": {
"linux": {
"downloadFile": "moon-{arch}-unknown-linux-{libc}"
},
"macos": {
"downloadFile": "moon-{arch}-apple-darwin"
},
"windows": {
"downloadFile": "moon-{arch}-pc-windows-msvc.exe"
}
},
"install": {
"downloadUrl": "https://github.com/moonrepo/moon/releases/download/v{version}/{download_file}",
"unpack": false
},
"resolve": {
"gitUrl": "https://github.com/moonrepo/moon"
}
}
18 changes: 18 additions & 0 deletions crates/cli/tests/fixtures/moon-schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
bin: "moon-test"
name: "moon-test"
type: "cli"

platform:
linux:
downloadFile: "moon-{arch}-unknown-linux-{libc}"
macos:
downloadFile: "moon-{arch}-apple-darwin"
windows:
downloadFile: "moon-{arch}-pc-windows-msvc.exe"

install:
downloadUrl: "https://github.com/moonrepo/moon/releases/download/v{version}/{download_file}"
unpack: false

resolve:
gitUrl: "https://github.com/moonrepo/moon"
64 changes: 62 additions & 2 deletions crates/cli/tests/plugins_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ mod plugins {
use super::*;

#[tokio::test(flavor = "multi_thread")]
async fn downloads_and_installs_plugin_from_file() {
async fn downloads_and_installs_toml_plugin_from_file() {
run_tests(|env| {
let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));

Expand All @@ -73,6 +73,40 @@ mod plugins {
.await;
}

#[tokio::test(flavor = "multi_thread")]
async fn downloads_and_installs_json_plugin_from_file() {
run_tests(|env| {
let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));

load_tool_from_locator(
Id::raw("moon"),
env.to_owned(),
PluginLocator::File(Box::new(FileLocator {
file: "./tests/fixtures/moon-schema.json".into(),
path: Some(root_dir.join("./tests/fixtures/moon-schema.json")),
})),
)
})
.await;
}

#[tokio::test(flavor = "multi_thread")]
async fn downloads_and_installs_yaml_plugin_from_file() {
run_tests(|env| {
let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));

load_tool_from_locator(
Id::raw("moon"),
env.to_owned(),
PluginLocator::File(Box::new(FileLocator {
file: "./tests/fixtures/moon-schema.yaml".into(),
path: Some(root_dir.join("./tests/fixtures/moon-schema.yaml")),
})),
)
})
.await;
}

#[tokio::test]
#[should_panic(expected = "does not exist")]
async fn errors_for_missing_file() {
Expand Down Expand Up @@ -333,7 +367,33 @@ mod plugins {

#[test]
fn supports_toml_schema() {
let sandbox = create_empty_proto_sandbox_with_tools();
let sandbox = create_empty_proto_sandbox_with_tools("toml");

sandbox
.run_bin(|cmd| {
cmd.arg("install").arg("moon-test");
})
.success();

// Doesn't create shims
}

#[test]
fn supports_json_schema() {
let sandbox = create_empty_proto_sandbox_with_tools("json");

sandbox
.run_bin(|cmd| {
cmd.arg("install").arg("moon-test");
})
.success();

// Doesn't create shims
}

#[test]
fn supports_yaml_schema() {
let sandbox = create_empty_proto_sandbox_with_tools("yaml");

sandbox
.run_bin(|cmd| {
Expand Down
12 changes: 9 additions & 3 deletions crates/cli/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,23 @@ pub fn create_empty_proto_sandbox() -> ProtoSandbox {
ProtoSandbox::new(starbase_sandbox::create_empty_sandbox())
}

pub fn create_empty_proto_sandbox_with_tools() -> ProtoSandbox {
pub fn create_empty_proto_sandbox_with_tools(ext: &str) -> ProtoSandbox {
let sandbox = create_empty_proto_sandbox();
let schema_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("./tests/fixtures")
.join(format!("moon-schema.{ext}"));

sandbox.create_file(
".prototools",
r#"
format!(
r#"
moon-test = "1.0.0"

[plugins]
moon-test = "https://raw.githubusercontent.com/moonrepo/moon/master/proto-plugin.toml"
moon-test = "file://{}"
"#,
schema_path.to_string_lossy().replace("\\", "/")
),
);

sandbox
Expand Down
3 changes: 2 additions & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ warpgate = { version = "0.18.0", path = "../warpgate", features = [
"schematic",
] }
clap = { workspace = true, optional = true }
convert_case = "0.6.0"
indexmap = { workspace = true }
miette = { workspace = true }
minisign-verify = "0.2.2"
Expand All @@ -41,7 +42,7 @@ sha2 = { workspace = true }
shell-words = { workspace = true }
starbase_archive = { workspace = true }
starbase_styles = { workspace = true }
starbase_utils = { workspace = true, features = ["fs-lock"] }
starbase_utils = { workspace = true, features = ["fs-lock", "yaml"] }
thiserror = { workspace = true }
tracing = { workspace = true }
url = { version = "2.5.2", features = ["serde"] }
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/registry/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ use warpgate::{Id, PluginLocator};
#[derive(Debug, Deserialize, Serialize, Schematic)]
#[serde(rename_all = "lowercase")]
pub enum PluginFormat {
Json,
Toml,
Wasm,
Yaml,
}

/// Information about a person.
Expand Down
Loading