-
Notifications
You must be signed in to change notification settings - Fork 1
Create implementation #1
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
Open
RedstoneWizard08
wants to merge
9
commits into
gorilla-devs:main
Choose a base branch
from
RedstoneWizard08:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dbe6562
Cargo init
RedstoneWizard08 32a62a1
Add code
RedstoneWizard08 1c59bd0
Fix HTTP requests
RedstoneWizard08 ac1cca3
Update tests
RedstoneWizard08 72555dc
Switch to Libic
RedstoneWizard08 e9dc169
Converters
RedstoneWizard08 64ae6fc
Published!
RedstoneWizard08 66d98f1
Fixes and async!
RedstoneWizard08 5e5ed84
Updates
RedstoneWizard08 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| /target | ||
| /Cargo.lock | ||
| /node_modules | ||
| index.node |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "cSpell.words": [ | ||
| "Devs", | ||
| "faber", | ||
| "forgic", | ||
| "libic", | ||
| "minecraft", | ||
| "minreq", | ||
| "vanel", | ||
| "xmltojson" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| [package] | ||
| description = "Blank Description" | ||
| edition = "2021" | ||
| license = "GPL-3.0" | ||
| name = "ludic" | ||
| version = "0.1.0" | ||
|
|
||
| [dependencies] | ||
| either = {version = "1.6.1", features = ["serde"]} | ||
| faber = {version = "0.1.0", path = "../faber"} | ||
| forgic = {version = "0.1.0", path = "../forgic"} | ||
| futures = "0.3" | ||
| libic = {version = "0.1.0", path = "../libic"} | ||
| quantum-mc = {version = "0.1.0", path = "../quantum"} | ||
| serde = {version = "1.0", features = ["derive"]} | ||
| serde_json = "1.0" | ||
| vanel = {version = "0.1.0", path = "../vanel"} | ||
| neon = {version = "0.10.1", default-features = false, features = ["napi-6", "channel-api", "promise-api"]} | ||
| tokio = {version = "1", features = ["rt-multi-thread"]} | ||
| once_cell = "1" | ||
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| use neon::{prelude::{FunctionContext, JsResult, Context, JsPromise}, result::NeonResult}; | ||
| use once_cell::sync::OnceCell; | ||
| use tokio::runtime::Runtime; | ||
| use crate::util::convert_array; | ||
|
|
||
| fn runtime<'a, C: Context<'a>>(cx: &mut C) -> NeonResult<&'static Runtime> { | ||
| static RUNTIME: OnceCell<Runtime> = OnceCell::new(); | ||
|
|
||
| return RUNTIME.get_or_try_init(|| Runtime::new().or_else(|err| cx.throw_error(err.to_string()))); | ||
| } | ||
|
|
||
| pub fn get_fabric_versions(mut ctx: FunctionContext) -> JsResult<JsPromise> { | ||
| let rt = runtime(&mut ctx)?; | ||
| let channel = ctx.channel(); | ||
| let (def, pro) = ctx.promise(); | ||
|
|
||
| rt.spawn(async move { | ||
| let raw = faber::get_fabric_versions().await; | ||
|
|
||
| def.settle_with(&channel, move |mut ctx| { | ||
| let conv = convert_array(&mut ctx, raw); | ||
| let res = conv.or_else(|err| ctx.throw_error(err.to_string()))?; | ||
|
|
||
| match Option::from(res) { | ||
| Some(res) => Ok(res), | ||
| None => ctx.throw_error("Could not get fabric releases!"), | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| return Ok(pro); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| pub mod faber; | ||
| pub mod vanel; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| pub use faber::*; | ||
| pub use forgic::*; | ||
| pub use quantum_mc::*; | ||
| pub use vanel::*; | ||
|
|
||
| pub mod converters; | ||
| pub mod util; | ||
|
|
||
| pub mod tests { | ||
| #[test] | ||
| fn test_faber() { | ||
| let run = faber::get_fabric_versions(); | ||
| let out = futures::executor::block_on(run); | ||
| println!("{:?}", out); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_forgic() { | ||
| let run = forgic::get_forge_versions(); | ||
| let out = futures::executor::block_on(run); | ||
| println!("{:?}", out); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_quantum() { | ||
| let run = quantum_mc::get_quilt_versions(); | ||
| let out = futures::executor::block_on(run); | ||
| println!("{:?}", out); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_vanel() { | ||
| let run = vanel::get_minecraft_versions(); | ||
| let out = futures::executor::block_on(run); | ||
| println!("{:?}", out); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| pub struct ModLoader { | ||
| /// The mod loader's name. Will be "vanilla," "forge," "quilt," or "fabric". | ||
| pub name: String, | ||
|
|
||
| /// The mod loader's version. | ||
| pub version: String, | ||
|
|
||
| /// The mod loader's download URL. | ||
| pub url: String, | ||
|
|
||
| /// The mod loader's download file name. | ||
| pub file_name: String, | ||
|
|
||
| /// The mod loader's download file size. | ||
| pub file_size: String, | ||
|
|
||
| /// The mod loader's launch command. | ||
| pub launch_command: Vec<String>, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| use neon::prelude::{Context, JsArray, JsResult, Object}; | ||
|
|
||
| pub fn convert_array<'a, C: Context<'a>>(ctx: &mut C, vec: Vec<String>) -> JsResult<'a, JsArray> { | ||
| let arr = JsArray::new(ctx, vec.len() as u32); | ||
|
|
||
| for (i, s) in vec.iter().enumerate() { | ||
| let val = ctx.string(s); | ||
| arr.set(ctx, i as u32, val)?; | ||
| } | ||
|
|
||
| return Ok(arr); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our API wrappers will be MIT+Apache2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, we can change the license.