DEV Community

Zuygui
Zuygui

Posted on

Flow Updater JSON Creator

GitHub logo zuygui / flowupdater-json-creator

Create JSON file compatibles with Flow Updater from command line.

Flow Updater JSON Creator : Generate JSONs compatible with Flow Updater.

TODOKey FeaturesInstallationUsageContributingLicense

TODO

  • Support other mods providers (Modrinth, etc.)
  • Add custom json targets (MCP, External Files, etc.)
  • Add compatibles version getter from ModLoader's API

If you have any suggestions, feel free to open an issue or a pull request.

Key Features

  • 📁 Generate JSON files compatible with [Flow Updater].
  • 🚀 Easy-to-use interface for creating configuration files.
  • 🔧 Customize JSON settings to match your requirements.
  • 📝 Documented code for easy integration into other projects.

Installation

Download from Releases

  1. Download the latest release from the Releases page.

Build from source

Requirements:

  1. Clone the repository:
git clone https://github.com/zuygui/flow-updater-json-creator.git
Enter fullscreen mode Exit fullscreen mode
  1. Navigate to the project directory:
cd flow-updater-json-creator
Enter fullscreen mode Exit fullscreen mode
  1. Build the application:
cargo build --bin flowupdater-json-creator --release
Enter fullscreen mode Exit fullscreen mode

Usage

  1. Run the application:
/path/to/flow-updater-json-creator/flowupdater-json-creator
Enter fullscreen mode Exit fullscreen mode
  1. Follow the on-screen instructions to generate your JSON files.

  2. Once generated, you can…

Introduction

While discussing and assisting people on the Support Launcher Discord server, a discord server for helping people to make customs Minecraft launchers, I realized that creating JSON files compatible with Flow Updater was time-consuming and tedious. This led me to the idea of developing a command-line tool to replace the existing desktop application.

Flow Updater

Flow updater is a Java library to install, update and launch Minecraft (retrieved from officials servers) and mods loaded through Forge or any other mods loader. To load the mod list and other configurations, it is possible to host a JSON file and pass it into the library, ... So a JSON compatible with FlowUpdater looks like :

Note: JSON (JavaScript Object Notation) is a data file format easy to read and write for humans and machines.

{
  "curseFiles": [
    {
      "projectID": 123456, // random curseforge project id
      "fileID": 123456 // random curseforge file id
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Writing this JSON is very tedious and time-consuming because you have to find the project id and the file id for each mod. So I decided to write a CLI tool to make this task easier.

Tech Stack

To build this software, I had to utilize several tools, including:

  • Rust, a compiled functional programming language developed by Mozilla (the company behind Firefox).
  • Request TTY, a Rust crate that facilitates the creation of command-line forms.
  • Eternal API, the new Curseforge API, which allows me to retrieve the necessary information from mods for JSON generation.
  • Serde JSON, an extension of the serde crate that enables the serialization and deserialization of Rust structs.

I've only mentioned the most significant elements present in the source code.

The goal

I wanna replace the Java application (GUI) by a CLI application in Rust. I also wanna make the application more fast and accessible. Finally, I wanna add new features to the application like locals mods support and archives exports.

Development Steps

I began by developing a wrapper for the CurseForge API, which turned out to be a lengthy and challenging process but constituted the bulk of the work. Next, I coded the CLI, which was relatively straightforward. Instead of using the clap crate, a Rust tool for generating CLIs, I opted for the following line of code:

fn main() {
       let args: Vec<String> = std::env::args().collect();
}
Enter fullscreen mode Exit fullscreen mode

This code snippet captures the input to the program: the main function defines an immutable variable called args, which is a vector (a list with indefinite length, for the sake of simplicity here) of type String. Thus, we obtain a list of all the arguments given when executing the binary file (including the application's name). I concluded the development of the first version with the JSON file generation.

What's Next?

Due to my heavy workload with school, I have less time to continue making progress on the project. This does not mean that I'm abandoning it; I'm simply moving forward at a slower pace. I sincerely thank Bricklou for helping me maintain the project. We are actively working on creating new features.

The refactoring

With Bricklou, we have decided to refactor all the code of the app for a better readability and a better maintainability. The first version of code are always available at the old branch. The new version of the code is available at the master branch. I've migrated all the backend code to the backend in a rust crate called fujc_api for a better integration to the (future) GUI app and CLI. Why have two backend when we can have one ?
For install the crate, you can use the following command :

cargo add fujc_api
Enter fullscreen mode Exit fullscreen mode

or add the following line to your Cargo.toml file :

fujc_api = "0.1.0"
Enter fullscreen mode Exit fullscreen mode

The GUI

Bricklou suggested to implement a GUI app for a better accessibility. It's not already implemented but we are working on. We are using Qt for the GUI app, Qt XML, and the Qt binding for Rust. The source code isn't available yet but it will be available soon.

Credits

I wanna thank Bricklou for maintening the project with me. I also wanna thank FlowArg for creating the original project. Finally, I wanna thank Asthowen for helping me with Github CI.

Conclusion

Thank you for reading this article on my blog. I hope you enjoyed it. Please feel free to leave a comment and give the GitHub repository of this blog a star ⭐.

Top comments (0)