27 Commits
Author SHA1 Message Date
objz a660f4a31b ci: fixed shasums again 2026-04-22 23:07:01 +02:00
objz 05f34de5ad ci: shasums 2026-04-22 22:54:09 +02:00
objz a5c38fcf6d ci: shasums 2026-04-22 22:46:52 +02:00
objz f821f2b482 ci: arch publish 2026-04-22 22:17:03 +02:00
objz e9c9db892c ci: updated runners 2026-04-22 21:56:14 +02:00
objz 1349958507 ci: fixed release build 2026-04-22 21:45:43 +02:00
objz d660f3f999 ci: fixed aur workflow 2026-04-22 20:51:08 +02:00
objz 6929496c4f ci: added aur and crates publish 2026-04-22 20:35:39 +02:00
objz b7f55bcf70 chore(release): v0.2.0 2026-04-22 20:25:07 +02:00
objz 14a5a9ca33 feat: git-cliff for better release notes and changelogs 2026-04-22 20:20:55 +02:00
objz 0b1f259cee fix: added retry logic when it fails because network instabillities 2026-04-22 20:13:57 +02:00
objz 4d055a58e9 fix: changed portablemc's client id to mcl's that now got approved 2026-04-22 20:08:17 +02:00
objz 462645f2e7 readme changes 2026-04-20 20:43:50 +02:00
objz db27b0bd0e Add Contributor Covenant Code of Conduct 2026-04-20 20:37:50 +02:00
objz a8992f6219 ci: added github issue templates 2026-04-20 20:25:47 +02:00
objz c71bc6229a theme defaults to gruvbox instead of terminal 2026-04-20 19:55:29 +02:00
objz 2bfad8b441 fix(auth): switch back to portablemc's client id, until mcl's get approved 2026-04-20 19:54:18 +02:00
objz 7ee342bfe0 added contributing guidelines 2026-04-20 19:42:47 +02:00
objz ea59e39159 added fallback icons for resource packs and worlds
resource packs and worlds without icons now show a placeholder "?"
pattern like mods already do. worlds use a larger 12x6 variant.
2026-04-20 19:25:05 +02:00
objz a29c90e86b added support for old forge versions (pre-1.13)
old forge installers don't have --installClient, so we extract the
universal jar and library info directly from install_profile.json
inside the installer jar. also tries multiple maven URL formats since
forge naming is inconsistent across versions.
2026-04-20 19:24:54 +02:00
objz 5f3f7890aa added mmc/prism modpack import and refactored import module
split import.rs into import/ module with mod.rs, mrpack.rs, mmc.rs.
auto-detects pack format from zip contents (modrinth.index.json or
mmc-pack.json). moved input parsing from net/modrinth.rs to the
import module since it handles routing for all formats now.
2026-04-20 19:24:47 +02:00
objz e1353bbcdd Merge branch 'master' of https://github.com/objz/mcl 2026-04-19 18:22:01 +02:00
objz 90caad474b fix readme 2026-04-19 18:21:55 +02:00
objz 02a40ba7be changed name to mcl-launcher 2026-04-19 17:25:09 +02:00
objz 9a85857f1d changed name to mcl-launcher 2026-04-19 17:24:46 +02:00
objz 1d30744f77 added description to Cargo.toml 2026-04-19 17:21:00 +02:00
objz 133544b500 fix readme 2026-04-19 17:16:59 +02:00
34 changed files with 2363 additions and 273 deletions

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
name: bug report
description: something isn't working right
labels: ["bug"]
body:
- type: textarea
id: description
attributes:
label: what happened
description: describe what went wrong and what you expected to happen instead.
validations:
required: true
- type: textarea
id: steps
attributes:
label: steps to reproduce
description: how can we trigger this?
placeholder: |
1. open mcl
2. do this
3. then this
4. it breaks
validations:
required: true
- type: input
id: version
attributes:
label: mcl version
description: run `mcl --version` or check the bottom of the TUI.
placeholder: 0.1.0
validations:
required: true
- type: dropdown
id: os
attributes:
label: operating system
options:
- Linux
- macOS
- Windows
validations:
required: true
- type: textarea
id: context
attributes:
label: additional context
description: anything else that might help. screenshots, config changes, etc.
validations:
required: false
+1
View File
@@ -0,0 +1 @@
blank_issues_enabled: true
+54
View File
@@ -0,0 +1,54 @@
name: crash report
description: mcl crashed or panicked
labels: ["crash"]
body:
- type: textarea
id: description
attributes:
label: what happened
description: what were you doing when mcl crashed?
validations:
required: true
- type: textarea
id: logs
attributes:
label: logs
description: |
paste relevant log output here. you can find logs at:
- **mcl logs**: `~/.cache/mcl/` (daily rolling files like `mcl.log.2026-04-20`)
- **launch logs**: `~/.local/share/mcl/instances/{instance}/.minecraft/logs/launches/`
you can also view logs in the TUI via the log overlay or use `mcl log` from the CLI.
render: text
validations:
required: false
- type: input
id: version
attributes:
label: mcl version
description: run `mcl --version` or check the bottom of the TUI.
placeholder: 0.1.0
validations:
required: true
- type: dropdown
id: os
attributes:
label: operating system
options:
- Linux
- macOS
- Windows
validations:
required: true
- type: textarea
id: context
attributes:
label: additional context
description: minecraft version, loader, instance setup, anything that might help narrow it down.
validations:
required: false
@@ -0,0 +1,27 @@
name: feature request
description: suggest something new or an improvement to something existing
labels: ["enhancement"]
body:
- type: textarea
id: description
attributes:
label: what would you like
description: describe the feature or improvement. if it's solving a problem, explain the problem too.
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: alternatives or workarounds
description: is there anything you're currently doing instead? other approaches you've considered?
validations:
required: false
- type: textarea
id: context
attributes:
label: additional context
description: anything else. mockups, links, examples from other tools, etc.
validations:
required: false
+101 -5
View File
@@ -33,7 +33,7 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: install Rust - name: install Rust
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
@@ -68,7 +68,7 @@ jobs:
Compress-Archive -Path ${{ matrix.artifact }} -DestinationPath ../../../mcl-${{ matrix.target }}.zip Compress-Archive -Path ${{ matrix.artifact }} -DestinationPath ../../../mcl-${{ matrix.target }}.zip
- name: upload artifact - name: upload artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v7
with: with:
name: mcl-${{ matrix.target }} name: mcl-${{ matrix.target }}
path: mcl-${{ matrix.target }}.* path: mcl-${{ matrix.target }}.*
@@ -77,9 +77,15 @@ jobs:
needs: build needs: build
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' && github.event_name == 'push' if: github.ref == 'refs/heads/master' && github.event_name == 'push'
outputs:
released: ${{ steps.check.outputs.exists == 'false' }}
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
with:
fetch-depth: 0
- name: get version - name: get version
id: version id: version
@@ -101,16 +107,106 @@ jobs:
- name: download artifacts - name: download artifacts
if: steps.check.outputs.exists == 'false' if: steps.check.outputs.exists == 'false'
uses: actions/download-artifact@v4 uses: actions/download-artifact@v8
with: with:
path: artifacts path: artifacts
- name: create and push tag
if: steps.check.outputs.exists == 'false'
run: |
git tag "${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"
- name: generate changelog
if: steps.check.outputs.exists == 'false'
id: changelog
uses: orhun/git-cliff-action@v4
with:
args: --latest --strip header
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: create release - name: create release
if: steps.check.outputs.exists == 'false' if: steps.check.outputs.exists == 'false'
run: | run: |
gh release create "${{ steps.version.outputs.tag }}" \ gh release create "${{ steps.version.outputs.tag }}" \
--title "${{ steps.version.outputs.tag }}" \ --title "${{ steps.version.outputs.tag }}" \
--generate-notes \ --notes "${{ steps.changelog.outputs.content }}" \
artifacts/mcl-*/* artifacts/mcl-*/*
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-crates:
needs: release
runs-on: ubuntu-latest
if: needs.release.outputs.released == 'true'
steps:
- uses: actions/checkout@v6
- name: install Rust
uses: dtolnay/rust-toolchain@stable
- name: publish to crates.io
run: cargo publish --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
publish-aur:
needs: release
runs-on: ubuntu-latest
if: needs.release.outputs.released == 'true'
steps:
- uses: actions/checkout@v6
# mcl-launcher (source package)
- name: prepare mcl-launcher
run: |
sed -i "s|^pkgver=.*|pkgver=${{ needs.release.outputs.version }}|" pkg/mcl-launcher/PKGBUILD
cp pkg/mcl-launcher/PKGBUILD PKGBUILD
- name: update checksums for mcl-launcher
uses: datakrama/archlinux-package-action@v2
with:
updpkgsums: true
srcinfo: true
flags: ""
namcap: false
- name: publish mcl-launcher to AUR
uses: KSXGitHub/github-actions-deploy-aur@v4.1.3
with:
pkgname: mcl-launcher
pkgbuild: PKGBUILD
assets: .SRCINFO
commit_username: objz
commit_email: me@objz.dev
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: "Update to ${{ needs.release.outputs.version }}"
# mcl-launcher-bin (binary package)
- name: prepare mcl-launcher-bin
run: |
sed -i "s|^pkgver=.*|pkgver=${{ needs.release.outputs.version }}|" pkg/mcl-launcher-bin/PKGBUILD
cp pkg/mcl-launcher-bin/PKGBUILD PKGBUILD
rm -f .SRCINFO
- name: update checksums for mcl-launcher-bin
uses: datakrama/archlinux-package-action@v2
with:
updpkgsums: true
srcinfo: true
flags: ""
namcap: false
- name: publish mcl-launcher-bin to AUR
uses: KSXGitHub/github-actions-deploy-aur@v4.1.3
with:
pkgname: mcl-launcher-bin
pkgbuild: PKGBUILD
assets: .SRCINFO
commit_username: objz
commit_email: me@objz.dev
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: "Update to ${{ needs.release.outputs.version }}"
+128
View File
@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
me@objz.dev.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
+55
View File
@@ -0,0 +1,55 @@
# contributing
thanks for wanting to contribute. here's how we/I do things around here.
## code style
### comments
preferred are `//` comments with a lowercase, casual tone. try to explain **why** something is done rather than restating what the code does. file-level comments are nice for describing what a file is responsible for, and function-level comments help when the behavior isn't obvious. enum variants and struct fields usually don't need comments if the names are clear enough. basically just look at how existing comments are written and match that vibe.
### visibility and naming
try to keep visibility as narrow as makes sense. `pub` when something is actually used outside the crate, `pub(crate)` across modules, `pub(super)` within a module. don't leave things `pub` just because they might be useful someday. function names should ideally be clear enough that you don't need a comment to explain what they do.
### modules and file organization
each file should have one clear responsibility. if a file starts doing two unrelated things, split it up. when a module gets big enough, convert `foo.rs` into `foo/mod.rs` with submodules. keep format-specific or protocol-specific code in its own file (e.g. `mrpack.rs` for modrinth, `mmc.rs` for multimc) and put shared types and dispatching in `mod.rs`. the general idea is that you shouldn't find multimc logic in the modrinth file or vice versa.
### tests
every test should cover a distinct code path. don't test the same branch twice with just different inputs. test names should describe the scenario, not just the function name. no need to test trivially correct code.
### general advice
- avoid "obvious" comments like `// save the profile` right above `save_profile()`
- avoid unnecessary abstractions or wrappers for things that only happen once
- avoid speculative features or "just in case" parameters
- prefer iterating directly over collecting into a vec when you only need one pass
- match existing error handling patterns, usually `map_err` with `format!`
## architecture
the codebase is split roughly like this:
- `src/cli/` handles command line interface
- `src/config/` has settings, paths, theme config
- `src/instance/` is the core. `content/` scans mods, resource packs, shaders, worlds. `import/` handles modpack importing with `mod.rs` dispatching to format-specific modules like `mrpack.rs` and `mmc.rs`. `loader/` installs mod loaders (fabric, forge, neoforge, quilt). `launch.rs` builds the java command and spawns minecraft. `manager.rs` does instance CRUD
- `src/net/` is the networking layer. http client, file downloads, and API clients per service
- `src/tui/` is the terminal UI built with ratatui
### adding a new import format
create a new file in `src/instance/import/`, add the variant to `PackFormat` in `mod.rs`, add detection logic in `detect_format()`, and add the dispatch arms in `build_summary()` and `execute_import()`.
### adding a new mod loader
create a new file in `src/instance/loader/` implementing `ModLoaderInstaller`, add the variant to `ModLoader` in `models.rs`, and register it in `get_installer()`.
## commits
start with what you did: `added`, `fixed`, `refactored`, etc. lowercase. separate logical changes into separate commits. don't bundle unrelated things into one commit.
## before submitting
make sure `cargo build`, `cargo clippy`, and `cargo test` all pass.
Generated
+1 -1
View File
@@ -1829,7 +1829,7 @@ dependencies = [
] ]
[[package]] [[package]]
name = "mcl" name = "mcl-launcher"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"async-trait", "async-trait",
+12 -2
View File
@@ -1,8 +1,18 @@
[package] [package]
name = "mcl" name = "mcl-launcher"
version = "0.1.0" version = "0.2.0"
authors = ["objz"] authors = ["objz"]
edition = "2024" edition = "2024"
description = "A fully featured Minecraft launcher TUI"
repository = "https://github.com/objz/mcl"
license = "GPL-3.0-only"
readme = "README.md"
keywords = ["minecraft", "launcher", "tui", "ratatui"]
categories = ["command-line-utilities", "games"]
[[bin]]
name = "mcl"
path = "src/main.rs"
[dependencies] [dependencies]
async-trait = "0.1" async-trait = "0.1"
+13 -5
View File
@@ -8,9 +8,9 @@
[![Issues][issues-shield]][issues-url] [![Issues][issues-shield]][issues-url]
[![GPL-3.0 License][license-shield]][license-url] [![GPL-3.0 License][license-shield]][license-url]
**MineCraft Launcher. or MineCraft cLi. pick whichever sounds better to you.** **M**ine**C**raft **L**auncher. or **M**ine**C**raft c**L**i. pick whichever sounds better to you.
<!-- ![screenshot](assets/screenshot.png) --> ![screenshot](assets/screenshot.png)
[Report Bug](https://github.com/objz/mcl/issues) · [Request Feature](https://github.com/objz/mcl/issues) [Report Bug](https://github.com/objz/mcl/issues) · [Request Feature](https://github.com/objz/mcl/issues)
@@ -20,7 +20,7 @@
## about ## about
we all love TUIs. and we all know the official Minecraft launcher is not exactly a joy to use. so here's mcl, a fully featured Minecraft launcher that lives in your terminal. written in Rust because if you're replacing something bloated you might as well go all the way. we all love TUIs. and we all know the official Minecraft launcher is not exactly a joy to use (performance wise; no hatespeech here). so here's mcl, a fully featured Minecraft launcher that lives in your terminal. written in Rust because if you're replacing something bloated you might as well go all the way.
it does everything you'd expect from a launcher. multiple instances, mod loaders, modpack imports, Microsoft auth, content management, launching. all from a TUI or from the command line. the TUI is the main thing though, the CLI is there for scripting and automation. it does everything you'd expect from a launcher. multiple instances, mod loaders, modpack imports, Microsoft auth, content management, launching. all from a TUI or from the command line. the TUI is the main thing though, the CLI is there for scripting and automation.
@@ -40,6 +40,12 @@ it does everything you'd expect from a launcher. multiple instances, mod loaders
--- ---
## authentication
mcl uses its own Microsoft client ID for Minecraft account authentication.
Authentication is performed through Microsoft’s official services.
## installation ## installation
### Arch Linux ### Arch Linux
@@ -59,9 +65,11 @@ paru -S mcl-launcher-bin
paru -S mcl-launcher-git paru -S mcl-launcher-git
``` ```
also available on [crates.io](https://crates.io/crates/mcl-launcher)
### from source ### from source
requires a Rust toolchain and OpenSSL. requires a Rust toolchain.
```sh ```sh
git clone https://github.com/objz/mcl.git git clone https://github.com/objz/mcl.git
@@ -107,7 +115,7 @@ you can create your own by dropping a TOML file in `~/.config/mcl/theme/` and re
## contributing ## contributing
contributions are welcome. fork it, branch it, PR it. make sure `cargo clippy` and `cargo test` pass before opening a PR. contributions are welcome. fork it, branch it, PR it. see [CONTRIBUTING.md](CONTRIBUTING.md) for code style and project structure.
--- ---
+1 -1
View File
@@ -5,7 +5,7 @@
# custom themes: # custom themes:
# theme = "my-theme" (loads ~/.config/mcl/theme/my-theme.toml) # theme = "my-theme" (loads ~/.config/mcl/theme/my-theme.toml)
# theme = "/path/to/file" (loads from absolute path) # theme = "/path/to/file" (loads from absolute path)
theme = "terminal" theme = "gruvbox"
# rounded, plain, double, thick # rounded, plain, double, thick
border_style = "rounded" border_style = "rounded"
+103
View File
@@ -0,0 +1,103 @@
# git-cliff ~ configuration file
# https://git-cliff.org/docs/configuration
[remote.github]
owner = "objz"
repo = "mcl"
[changelog]
# A Tera template to be rendered for each release in the changelog.
# See https://keats.github.io/tera/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | striptags | trim | upper_first }}
{% for commit in commits %}
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
{% if commit.breaking %}[**breaking**] {% endif %}\
{{ commit.message | upper_first }}\
{% if commit.github.pr_number %} ([#{{ commit.github.pr_number }}](https://github.com/objz/mcl/pull/{{ commit.github.pr_number }})){% endif %}\
{% endfor %}
{% endfor %}
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
### New Contributors
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
- @{{ contributor.username }} made their first contribution\
{% if contributor.pr_number %} in [#{{ contributor.pr_number }}](https://github.com/objz/mcl/pull/{{ contributor.pr_number }}){% endif %}\
{% endfor %}
{% endif %}
"""
# Remove leading and trailing whitespaces from the changelog's body.
trim = true
# Render body even when there are no releases to process.
render_always = true
# An array of regex based postprocessors to modify the changelog.
postprocessors = [
# Replace the placeholder <REPO> with a URL.
#{ pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" },
]
# render body even when there are no releases to process
# render_always = true
# output file path
# output = "test.md"
[git]
# Parse commits according to the conventional commits specification.
# See https://www.conventionalcommits.org
conventional_commits = true
# Exclude commits that do not match the conventional commits specification.
filter_unconventional = false
# Require all commits to be conventional.
# Takes precedence over filter_unconventional.
require_conventional = false
# Split commits on newlines, treating each line as an individual commit.
split_commits = false
# An array of regex based parsers to modify commit messages prior to further processing.
commit_preprocessors = [
# Replace issue numbers in commit messages with links.
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/objz/mcl/issues/${2}))" },
]
# Prevent commits that are breaking from being excluded by commit parsers.
protect_breaking_commits = false
# An array of regex based parsers for extracting data from the commit message.
# Assigns commits to groups.
# Optionally sets the commit's scope and can decide to exclude commits from further processing.
commit_parsers = [
{ message = "^feat", group = "<!-- 0 -->Features" },
{ message = "^fix", group = "<!-- 1 -->Bug Fixes" },
{ message = "^doc", group = "<!-- 3 -->Documentation" },
{ message = "^perf", group = "<!-- 4 -->Performance" },
{ message = "^refactor", group = "<!-- 2 -->Refactor" },
{ message = "^style", group = "<!-- 5 -->Styling" },
{ message = "^test", group = "<!-- 6 -->Testing" },
{ message = "^chore\\(release\\): prepare for", skip = true },
{ message = "^chore\\(deps.*\\)", skip = true },
{ message = "^chore\\(pr\\)", skip = true },
{ message = "^chore\\(pull\\)", skip = true },
{ message = "^chore|^ci", group = "<!-- 7 -->Miscellaneous Tasks" },
{ body = ".*security", group = "<!-- 8 -->Security" },
{ message = "^revert", group = "<!-- 9 -->Revert" },
{ message = ".*", group = "<!-- 10 -->Other" },
]
# Exclude commits that are not matched by any commit parser.
filter_commits = false
# Fail on a commit that is not matched by any commit parser.
fail_on_unmatched_commit = false
# An array of link parsers for extracting external references, and turning them into URLs, using regex.
link_parsers = []
# Include only the tags that belong to the current branch.
use_branch_tags = false
# Order releases topologically instead of chronologically.
topo_order = false
# Order commits topologically instead of chronologically.
topo_order_commits = true
# Order of commits in each group/release within the changelog.
# Allowed values: newest, oldest
sort_commits = "oldest"
# Process submodules commits
recurse_submodules = false
+674
View File
@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+5 -4
View File
@@ -1,22 +1,23 @@
# Maintainer: objz <me@objz.dev> # Maintainer: objz <me@objz.dev>
pkgname=mcl-launcher-bin pkgname=mcl-launcher-bin
pkgver=0.1.0 pkgver=0.2.0
pkgrel=1 pkgrel=1
pkgdesc="Minecraft launcher TUI" pkgdesc="Minecraft launcher TUI"
arch=('x86_64' 'aarch64') arch=('x86_64' 'aarch64')
url="https://github.com/objz/mcl" url="https://github.com/objz/mcl"
license=('GPL-3.0-only') license=('GPL-3.0-only')
depends=('openssl') depends=()
provides=('mcl-launcher') provides=('mcl-launcher')
conflicts=('mcl-launcher' 'mcl-launcher-git') conflicts=('mcl-launcher' 'mcl-launcher-git')
source=("LICENSE-${pkgver}::${url}/raw/v${pkgver}/LICENSE") source=("LICENSE-${pkgver}::${url}/raw/v${pkgver}/LICENSE" "README-${pkgver}::${url}/raw/v${pkgver}/README.md")
source_x86_64=("${url}/releases/download/v${pkgver}/mcl-x86_64-unknown-linux-gnu.tar.gz") source_x86_64=("${url}/releases/download/v${pkgver}/mcl-x86_64-unknown-linux-gnu.tar.gz")
source_aarch64=("${url}/releases/download/v${pkgver}/mcl-aarch64-unknown-linux-gnu.tar.gz") source_aarch64=("${url}/releases/download/v${pkgver}/mcl-aarch64-unknown-linux-gnu.tar.gz")
sha256sums=('SKIP') sha256sums=('SKIP' 'SKIP')
sha256sums_x86_64=('SKIP') sha256sums_x86_64=('SKIP')
sha256sums_aarch64=('SKIP') sha256sums_aarch64=('SKIP')
package() { package() {
install -Dm755 mcl "$pkgdir/usr/bin/mcl" install -Dm755 mcl "$pkgdir/usr/bin/mcl"
install -Dm644 "LICENSE-${pkgver}" "$pkgdir/usr/share/licenses/$pkgname/LICENSE" install -Dm644 "LICENSE-${pkgver}" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
install -Dm644 "README-${pkgver}" "$pkgdir/usr/share/doc/$pkgname/README.md"
} }
+129
View File
@@ -0,0 +1,129 @@
<div align="center">
# mcl
[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![GPL-3.0 License][license-shield]][license-url]
**MineCraft Launcher. or MineCraft cLi. pick whichever sounds better to you.**
<!-- ![screenshot](assets/screenshot.png) -->
[Report Bug](https://github.com/objz/mcl/issues) · [Request Feature](https://github.com/objz/mcl/issues)
</div>
---
## about
we all love TUIs. and we all know the official Minecraft launcher is not exactly a joy to use. so here's mcl, a fully featured Minecraft launcher that lives in your terminal. written in Rust because if you're replacing something bloated you might as well go all the way.
it does everything you'd expect from a launcher. multiple instances, mod loaders, modpack imports, Microsoft auth, content management, launching. all from a TUI or from the command line. the TUI is the main thing though, the CLI is there for scripting and automation.
## features
| | |
|---|---|
| **instances** | create and manage multiple instances, each with their own version, loader, mods, and settings |
| **mod loaders** | vanilla, Fabric, Quilt, Forge, NeoForge. more might show up later |
| **content** | browse and toggle mods, shaders, resource packs. view worlds, screenshots, and logs |
| **modpack import** | import from Modrinth via `.mrpack` file, URL, or slug |
| **accounts** | multiple Microsoft accounts and offline players, switch between them |
| **launching** | launch directly from the TUI or generate a desktop shortcut for any instance |
| **desktop shortcuts** | click it and Minecraft starts, no need to open mcl or type anything |
| **CLI** | every feature the TUI has is also available as a subcommand |
| **theming** | 10 built-in themes, custom themes, color overrides |
---
## installation
### Arch Linux
[![AUR version](https://img.shields.io/aur/version/mcl-launcher?style=for-the-badge&label=mcl-launcher)](https://aur.archlinux.org/packages/mcl-launcher)
[![AUR version](https://img.shields.io/aur/version/mcl-launcher-bin?style=for-the-badge&label=mcl-launcher-bin)](https://aur.archlinux.org/packages/mcl-launcher-bin)
[![AUR version](https://img.shields.io/aur/version/mcl-launcher-git?style=for-the-badge&label=mcl-launcher-git)](https://aur.archlinux.org/packages/mcl-launcher-git)
```sh
# from source (release tarball)
paru -S mcl-launcher
# prebuilt binary
paru -S mcl-launcher-bin
# latest git
paru -S mcl-launcher-git
```
### from source
requires a Rust toolchain and OpenSSL.
```sh
git clone https://github.com/objz/mcl.git
cd mcl
cargo build --release
```
### other platforms
mcl can be compiled for Linux, macOS, and Windows. right now it's only packaged for Arch Linux (AUR) but official packages for other platforms and package managers will be added continuously.
---
## where things live
| path | what |
|---|---|
| `~/.config/mcl/config.toml` | general config (paths, memory defaults, UI settings) |
| `~/.config/mcl/theme.toml` | theme, border style, color overrides |
| `~/.config/mcl/accounts.json` | accounts |
| `~/.local/share/mcl/instances/` | instances, each in its own directory |
| `~/.local/share/mcl/meta/` | cached game metadata, libraries, assets, loader profiles |
each instance has an `instance.json` for its config and a `.minecraft/` directory with the actual game files. standard layout, nothing weird.
---
## configuration
everything is configured through TOML files. `config.toml` for paths, default memory allocation, and UI behavior. `theme.toml` for theme selection and border style. you can also override individual colors without making a full custom theme.
---
## themes
mcl ships with 10 built-in themes:
`catppuccin` · `dracula` · `nord` · `gruvbox` · `one-dark` · `solarized` · `tailwind` · `tokyo-night` · `rose-pine` · `terminal`
you can create your own by dropping a TOML file in `~/.config/mcl/theme/` and referencing it by name, or point to an absolute path.
---
## contributing
contributions are welcome. fork it, branch it, PR it. make sure `cargo clippy` and `cargo test` pass before opening a PR.
---
## license
GPL-3.0. see [LICENSE](LICENSE).
---
[contributors-shield]: https://img.shields.io/github/contributors/objz/mcl.svg?style=for-the-badge
[contributors-url]: https://github.com/objz/mcl/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/objz/mcl.svg?style=for-the-badge
[forks-url]: https://github.com/objz/mcl/network/members
[stars-shield]: https://img.shields.io/github/stars/objz/mcl.svg?style=for-the-badge
[stars-url]: https://github.com/objz/mcl/stargazers
[issues-shield]: https://img.shields.io/github/issues/objz/mcl.svg?style=for-the-badge
[issues-url]: https://github.com/objz/mcl/issues
[license-shield]: https://img.shields.io/github/license/objz/mcl.svg?style=for-the-badge
[license-url]: https://github.com/objz/mcl/blob/master/LICENSE
+3 -2
View File
@@ -6,8 +6,8 @@ pkgdesc="Minecraft launcher TUI"
arch=('x86_64' 'aarch64') arch=('x86_64' 'aarch64')
url="https://github.com/objz/mcl" url="https://github.com/objz/mcl"
license=('GPL-3.0-only') license=('GPL-3.0-only')
depends=('openssl') depends=()
makedepends=('git' 'rust' 'cargo' 'openssl' 'pkgconf') makedepends=('git' 'rust' 'cargo')
provides=('mcl-launcher') provides=('mcl-launcher')
conflicts=('mcl-launcher' 'mcl-launcher-bin') conflicts=('mcl-launcher' 'mcl-launcher-bin')
source=("git+$url.git") source=("git+$url.git")
@@ -32,4 +32,5 @@ package() {
cd "$srcdir/mcl" cd "$srcdir/mcl"
install -Dm755 "target/release/mcl" "$pkgdir/usr/bin/mcl" install -Dm755 "target/release/mcl" "$pkgdir/usr/bin/mcl"
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
} }
+3 -2
View File
@@ -6,8 +6,8 @@ pkgdesc="Minecraft launcher TUI"
arch=('x86_64' 'aarch64') arch=('x86_64' 'aarch64')
url="https://github.com/objz/mcl" url="https://github.com/objz/mcl"
license=('GPL-3.0-only') license=('GPL-3.0-only')
depends=('openssl') depends=()
makedepends=('rust' 'cargo' 'openssl' 'pkgconf') makedepends=('rust' 'cargo')
provides=('mcl-launcher') provides=('mcl-launcher')
conflicts=('mcl-launcher-bin' 'mcl-launcher-git') conflicts=('mcl-launcher-bin' 'mcl-launcher-git')
source=("${url}/archive/v${pkgver}.tar.gz") source=("${url}/archive/v${pkgver}.tar.gz")
@@ -27,4 +27,5 @@ package() {
cd "$srcdir/mcl-${pkgver}" cd "$srcdir/mcl-${pkgver}"
install -Dm755 "target/release/mcl" "$pkgdir/usr/bin/mcl" install -Dm755 "target/release/mcl" "$pkgdir/usr/bin/mcl"
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
} }
+1 -1
View File
@@ -14,7 +14,7 @@ use serde::Deserialize;
use super::accounts::{Account, AccountType, AuthResult}; use super::accounts::{Account, AccountType, AuthResult};
const CLIENT_ID: &str = "708e91b5-99f8-4a1d-80ec-e746cbb24771"; const CLIENT_ID: &str = "cc1b2d89-8d8b-439f-94e6-4a7fc484f672";
const DEVICE_CODE_URL: &str = "https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode"; const DEVICE_CODE_URL: &str = "https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode";
const MSA_AUTHORIZE_URL: &str = "https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize"; const MSA_AUTHORIZE_URL: &str = "https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize";
const MSA_TOKEN_URL: &str = "https://login.microsoftonline.com/consumers/oauth2/v2.0/token"; const MSA_TOKEN_URL: &str = "https://login.microsoftonline.com/consumers/oauth2/v2.0/token";
+8 -11
View File
@@ -1,7 +1,8 @@
// modpack importing from modrinth (remote slug/url) or local .mrpack files. // modpack importing from modrinth (remote slug/url) or local files (.mrpack, mmc zips).
// resolves the input, downloads if needed, then hands off to the import engine. // resolves the input, downloads if needed, then hands off to the import engine.
use clap::ArgMatches; use clap::ArgMatches;
use crate::instance::import::{parse_import_input, ImportInput};
use crate::instance::InstanceManager; use crate::instance::InstanceManager;
use crate::net::modrinth; use crate::net::modrinth;
@@ -17,18 +18,17 @@ pub async fn handle_import(matches: &ArgMatches) -> CliResult {
let manager = InstanceManager::new(instances_dir, meta_dir); let manager = InstanceManager::new(instances_dir, meta_dir);
let client = crate::net::HttpClient::new(); let client = crate::net::HttpClient::new();
// figure out what the user gave us: a local file, a project slug, or a versioned URL let parsed = parse_import_input(input);
let parsed = modrinth::parse_input(input);
let mrpack_path = match parsed { let archive_path = match parsed {
modrinth::ModrinthInput::LocalFile(ref path) => { ImportInput::LocalFile(ref path) => {
let resolved = crate::config::settings::resolve_path(path); let resolved = crate::config::settings::resolve_path(path);
if !resolved.exists() { if !resolved.exists() {
return Err(format!("File not found: {}", resolved.display()).into()); return Err(format!("File not found: {}", resolved.display()).into());
} }
resolved resolved
} }
modrinth::ModrinthInput::ProjectSlug(ref slug) => { ImportInput::ProjectSlug(ref slug) => {
println!("Fetching project '{slug}'..."); println!("Fetching project '{slug}'...");
let project = modrinth::fetch_project(&client, slug) let project = modrinth::fetch_project(&client, slug)
.await .await
@@ -64,7 +64,7 @@ pub async fn handle_import(matches: &ArgMatches) -> CliResult {
.await .await
.map_err(|e| format!("Failed to download .mrpack: {e}"))? .map_err(|e| format!("Failed to download .mrpack: {e}"))?
} }
modrinth::ModrinthInput::VersionId { ImportInput::VersionId {
slug: _, slug: _,
ref version_id, ref version_id,
} => { } => {
@@ -87,10 +87,7 @@ pub async fn handle_import(matches: &ArgMatches) -> CliResult {
} }
}; };
let index = modrinth::parse_mrpack(&mrpack_path) let mut summary = crate::instance::import::build_summary(&archive_path)
.map_err(|e| format!("Failed to parse .mrpack: {e}"))?;
let mut summary = crate::instance::import::build_summary(&index, mrpack_path)
.map_err(|e| format!("Invalid modpack: {e}"))?; .map_err(|e| format!("Invalid modpack: {e}"))?;
if let Some(name) = override_name { if let Some(name) = override_name {
+38 -2
View File
@@ -226,8 +226,8 @@ pub(crate) fn make_icon_pixels(
Some(rows) Some(rows)
} }
/// 6x3 fallback icon showing a "?" pattern for mods without icons. // 6x3 fallback icon showing a "?" pattern for mods without icons.
fn fallback_icon() -> Vec<Vec<IconCell>> { pub(super) fn fallback_icon() -> Vec<Vec<IconCell>> {
let b = IconCell { let b = IconCell {
bg_r: 50, bg_r: 50,
bg_g: 50, bg_g: 50,
@@ -259,6 +259,42 @@ fn fallback_icon() -> Vec<Vec<IconCell>> {
] ]
} }
// 12x6 fallback icon showing a "?" pattern for worlds without icons.
pub(super) fn fallback_icon_large() -> Vec<Vec<IconCell>> {
let b = IconCell {
bg_r: 50,
bg_g: 50,
bg_b: 50,
fg_r: 50,
fg_g: 50,
fg_b: 50,
};
let tb = IconCell {
bg_r: 50,
bg_g: 50,
bg_b: 50,
fg_r: 130,
fg_g: 130,
fg_b: 130,
};
let bt = IconCell {
bg_r: 130,
bg_g: 130,
bg_b: 130,
fg_r: 50,
fg_g: 50,
fg_b: 50,
};
vec![
vec![b, b, tb, tb, tb, tb, tb, tb, tb, tb, b, b],
vec![b, b, tb, tb, tb, tb, tb, tb, tb, tb, b, b],
vec![b, b, b, b, b, b, bt, bt, bt, bt, b, b],
vec![b, b, b, b, b, b, bt, bt, bt, bt, b, b],
vec![b, b, b, b, bt, bt, bt, bt, b, b, b, b],
vec![b, b, b, b, bt, bt, bt, bt, b, b, b, b],
]
}
// enable/disable by renaming the file with/without ".disabled" suffix. // enable/disable by renaming the file with/without ".disabled" suffix.
// the minecraft way, apparently. // the minecraft way, apparently.
pub fn toggle_entry(entry: &ContentEntry) -> Result<(), std::io::Error> { pub fn toggle_entry(entry: &ContentEntry) -> Result<(), std::io::Error> {
+2 -1
View File
@@ -80,7 +80,8 @@ pub fn scan_resource_packs(instances_dir: &Path, instance_name: &str) -> Vec<Con
let icon_lines = icon_bytes let icon_lines = icon_bytes
.as_ref() .as_ref()
.and_then(|bytes| make_icon_pixels(bytes, 6, 3)); .and_then(|bytes| make_icon_pixels(bytes, 6, 3))
.or_else(|| Some(super::mods::fallback_icon()));
let display_name = if name.is_empty() { file_stem.clone() } else { name }; let display_name = if name.is_empty() { file_stem.clone() } else { name };
entries.push(ContentEntry { entries.push(ContentEntry {
+2 -1
View File
@@ -35,7 +35,8 @@ pub fn scan_worlds(instances_dir: &Path, instance_name: &str) -> Vec<ContentEntr
let icon_bytes = std::fs::read(path.join("icon.png")).ok(); let icon_bytes = std::fs::read(path.join("icon.png")).ok();
let icon_lines = icon_bytes let icon_lines = icon_bytes
.as_ref() .as_ref()
.and_then(|bytes| make_icon_pixels(bytes, 12, 6)); .and_then(|bytes| make_icon_pixels(bytes, 12, 6))
.or_else(|| Some(super::mods::fallback_icon_large()));
let description = world_description(&path); let description = world_description(&path);
+273
View File
@@ -0,0 +1,273 @@
// multimc / prism launcher instance import: mods and configs are bundled
// in the zip. we install the game + loader normally, then extract the
// archive contents over it.
use std::path::Path;
use crate::instance::manager::InstanceManager;
use crate::instance::models::ModLoader;
use crate::tui::progress;
use super::{ImportSummary, PackFormat};
use serde::Deserialize;
#[derive(Debug, Clone, Deserialize)]
struct MmcPack {
#[serde(default)]
components: Vec<MmcComponent>,
}
#[derive(Debug, Clone, Deserialize)]
struct MmcComponent {
uid: String,
#[serde(default)]
version: String,
}
impl MmcPack {
fn game_version(&self) -> Option<String> {
self.components
.iter()
.find(|c| c.uid == "net.minecraft")
.map(|c| c.version.clone())
}
fn loader(&self) -> (Option<ModLoader>, Option<String>) {
let loaders = [
("net.fabricmc.fabric-loader", ModLoader::Fabric),
("net.minecraftforge", ModLoader::Forge),
("net.neoforged", ModLoader::NeoForge),
("org.quiltmc.quilt-loader", ModLoader::Quilt),
];
for (uid, loader) in &loaders {
if let Some(component) = self.components.iter().find(|c| c.uid == *uid) {
return (Some(*loader), Some(component.version.clone()));
}
}
(None, None)
}
}
pub fn build_summary(path: &Path) -> Result<ImportSummary, String> {
let pack = parse_mmc_pack(path)?;
let game_version = pack
.game_version()
.ok_or_else(|| "mmc-pack.json missing net.minecraft component".to_string())?;
let (loader_opt, loader_version) = pack.loader();
let loader = loader_opt.unwrap_or(ModLoader::Vanilla);
let name = instance_name_from_cfg(path)
.unwrap_or_else(|| "Imported Pack".to_string());
let (mod_count, override_count) = count_content_files(path)?;
Ok(ImportSummary {
name,
pack_version: String::new(),
game_version,
loader,
loader_version,
mod_count,
override_count,
format: PackFormat::Mmc,
archive_path: path.to_path_buf(),
})
}
pub async fn execute_import(
summary: &ImportSummary,
manager: &InstanceManager,
) -> Result<crate::instance::InstanceConfig, Box<dyn std::error::Error + Send + Sync>> {
let name = super::unique_instance_name(&summary.name, &manager.instances_dir);
progress::set_action(format!("Importing '{name}'..."));
progress::set_sub_action(format!("{} {}", summary.game_version, summary.loader));
let config = manager
.create(
&name,
&summary.game_version,
summary.loader,
summary.loader_version.as_deref(),
)
.await
.map_err(|e| -> Box<dyn std::error::Error + Send + Sync> { Box::new(e) })?;
let minecraft_dir = manager.instances_dir.join(&name).join(".minecraft");
extract_mmc_archive(&summary.archive_path, &minecraft_dir)?;
progress::clear();
Ok(config)
}
// extracts everything under .minecraft/ from the archive into the instance dir
fn extract_mmc_archive(
archive_path: &Path,
minecraft_dir: &Path,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
use std::io::Read;
progress::set_action("Extracting pack contents...".to_string());
progress::set_sub_action(String::new());
let file = std::fs::File::open(archive_path)?;
let mut archive = zip::ZipArchive::new(file)?;
let prefix = find_archive_prefix(&archive);
let minecraft_prefix = format!("{prefix}.minecraft/");
let total = archive.len();
for i in 0..total {
let mut entry = archive.by_index(i)?;
let entry_name = entry.name().to_string();
let Some(relative) = entry_name.strip_prefix(&minecraft_prefix) else {
continue;
};
if relative.is_empty() || entry_name.ends_with('/') {
std::fs::create_dir_all(minecraft_dir.join(relative))?;
continue;
}
let dest = minecraft_dir.join(relative);
if let Some(parent) = dest.parent() {
std::fs::create_dir_all(parent)?;
}
let filename = relative.rsplit('/').next().unwrap_or(relative);
progress::set_sub_action(filename.to_string());
let mut buf = Vec::new();
entry.read_to_end(&mut buf)?;
std::fs::write(&dest, &buf)?;
}
Ok(())
}
fn parse_mmc_pack(path: &Path) -> Result<MmcPack, String> {
let file = std::fs::File::open(path).map_err(|e| format!("Cannot open archive: {e}"))?;
let mut archive = zip::ZipArchive::new(file).map_err(|e| format!("Invalid ZIP: {e}"))?;
let entry_name = find_entry(&archive, "mmc-pack.json")
.ok_or_else(|| "Missing mmc-pack.json in archive".to_string())?;
let entry = archive
.by_name(&entry_name)
.map_err(|e| format!("Failed to read mmc-pack.json: {e}"))?;
serde_json::from_reader(entry).map_err(|e| format!("Invalid mmc-pack.json: {e}"))
}
fn instance_name_from_cfg(path: &Path) -> Option<String> {
let file = std::fs::File::open(path).ok()?;
let mut archive = zip::ZipArchive::new(file).ok()?;
let entry_name = find_entry(&archive, "instance.cfg")?;
let entry = archive.by_name(&entry_name).ok()?;
let reader = std::io::BufRead::lines(std::io::BufReader::new(entry));
for line in reader.map_while(Result::ok) {
if let Some(value) = line.strip_prefix("name=") {
let name = value.trim().to_string();
if !name.is_empty() {
return Some(name);
}
}
}
None
}
// finds the prefix for the archive — empty for flat zips, "DirName/" for nested
fn find_archive_prefix(archive: &zip::ZipArchive<std::fs::File>) -> String {
for name in archive.file_names() {
if name.ends_with("mmc-pack.json") {
return name.strip_suffix("mmc-pack.json").unwrap_or("").to_string();
}
}
String::new()
}
// looks for a file at root or one level deep (some archives nest everything
// under a single top-level directory like "GT New Horizons 2.8.4/")
fn find_entry(archive: &zip::ZipArchive<std::fs::File>, filename: &str) -> Option<String> {
if archive.file_names().any(|n| n == filename) {
return Some(filename.to_string());
}
for name in archive.file_names() {
if name.ends_with(&format!("/{filename}")) && name.matches('/').count() == 1 {
return Some(name.to_string());
}
}
None
}
fn count_content_files(path: &Path) -> Result<(usize, usize), String> {
let file = std::fs::File::open(path).map_err(|e| e.to_string())?;
let archive = zip::ZipArchive::new(file).map_err(|e| e.to_string())?;
let prefix = find_archive_prefix(&archive);
let minecraft_prefix = format!("{prefix}.minecraft/");
let mods_prefix = format!("{prefix}.minecraft/mods/");
let mut mod_count = 0;
let mut override_count = 0;
for name in archive.file_names() {
if name.ends_with('/') {
continue;
}
if name.starts_with(&mods_prefix) {
mod_count += 1;
} else if name.starts_with(&minecraft_prefix) {
override_count += 1;
}
}
Ok((mod_count, override_count))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn parse_mmc_pack_json() {
let json = r#"{
"formatVersion": 1,
"components": [
{
"uid": "net.minecraft",
"version": "1.7.10",
"cachedName": "Minecraft"
},
{
"uid": "net.minecraftforge",
"version": "10.13.4.1614",
"cachedName": "Forge"
}
]
}"#;
let pack: MmcPack = serde_json::from_str(json).unwrap();
assert_eq!(pack.game_version(), Some("1.7.10".to_string()));
let (loader, version) = pack.loader();
assert_eq!(loader, Some(ModLoader::Forge));
assert_eq!(version, Some("10.13.4.1614".to_string()));
}
#[test]
fn parse_mmc_pack_vanilla() {
let json = r#"{
"formatVersion": 1,
"components": [
{"uid": "net.minecraft", "version": "1.21.4"}
]
}"#;
let pack: MmcPack = serde_json::from_str(json).unwrap();
assert!(pack.loader().0.is_none());
}
}
+216
View File
@@ -0,0 +1,216 @@
// modpack importing: parses user input, detects pack format from zip contents,
// builds a summary, and delegates the actual import to format-specific modules.
pub mod mmc;
pub mod mrpack;
use std::path::{Path, PathBuf};
use crate::instance::manager::InstanceManager;
use crate::instance::models::ModLoader;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PackFormat {
Mrpack,
Mmc,
}
#[derive(Debug, Clone, PartialEq)]
pub enum ImportInput {
ProjectSlug(String),
VersionId { slug: String, version_id: String },
LocalFile(String),
}
// figures out what the user gave us: a modrinth URL, a local pack file,
// or just a project slug. accepts a pretty wide range of inputs so users
// don't have to think about it.
pub fn parse_import_input(input: &str) -> ImportInput {
let input = input.trim();
if input.ends_with(".mrpack")
|| input.ends_with(".zip")
|| input.starts_with('/')
|| input.starts_with("~/")
{
return ImportInput::LocalFile(input.to_string());
}
if let Some(rest) = input
.strip_prefix("https://modrinth.com/modpack/")
.or_else(|| input.strip_prefix("http://modrinth.com/modpack/"))
{
let parts: Vec<&str> = rest.split('/').filter(|s| !s.is_empty()).collect();
return match parts.as_slice() {
[slug, "version", version_id, ..] => ImportInput::VersionId {
slug: slug.to_string(),
version_id: version_id.to_string(),
},
[slug, ..] => ImportInput::ProjectSlug(slug.to_string()),
[] => ImportInput::ProjectSlug(String::new()),
};
}
ImportInput::ProjectSlug(input.to_string())
}
#[derive(Debug, Clone)]
pub struct ImportSummary {
pub name: String,
pub pack_version: String,
pub game_version: String,
pub loader: ModLoader,
pub loader_version: Option<String>,
pub mod_count: usize,
pub override_count: usize,
pub format: PackFormat,
pub archive_path: PathBuf,
}
// peeks inside a zip to figure out what format it is.
// checks for modrinth.index.json first, then mmc-pack.json.
pub fn detect_format(path: &Path) -> Result<PackFormat, String> {
let file = std::fs::File::open(path)
.map_err(|e| format!("Cannot open '{}': {e}", path.display()))?;
let archive = zip::ZipArchive::new(file)
.map_err(|e| format!("Invalid ZIP '{}': {e}", path.display()))?;
if archive.file_names().any(|n| n == "modrinth.index.json") {
return Ok(PackFormat::Mrpack);
}
// mmc-pack.json can be at root or one directory deep
if archive.file_names().any(|n| n == "mmc-pack.json" || n.ends_with("/mmc-pack.json")) {
return Ok(PackFormat::Mmc);
}
Err("Unknown pack format: no modrinth.index.json or mmc-pack.json found".to_string())
}
pub fn build_summary(path: &Path) -> Result<ImportSummary, String> {
if !path.exists() {
return Err(format!("File not found: {}", path.display()));
}
let format = detect_format(path)?;
match format {
PackFormat::Mrpack => mrpack::build_summary(path),
PackFormat::Mmc => mmc::build_summary(path),
}
}
pub fn unique_instance_name(base: &str, instances_dir: &Path) -> String {
let candidate = base.to_string();
if !instances_dir.join(&candidate).join("instance.json").exists() {
return candidate;
}
for n in 2..100 {
let candidate = format!("{base} ({n})");
if !instances_dir.join(&candidate).join("instance.json").exists() {
return candidate;
}
}
format!("{base} (import)")
}
pub async fn execute_import(
summary: &ImportSummary,
manager: &InstanceManager,
) -> Result<crate::instance::InstanceConfig, Box<dyn std::error::Error + Send + Sync>> {
match summary.format {
PackFormat::Mrpack => mrpack::execute_import(summary, manager).await,
PackFormat::Mmc => mmc::execute_import(summary, manager).await,
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn unique_name_no_collision() {
let tmp = tempfile::tempdir().unwrap();
let name = unique_instance_name("TestPack", tmp.path());
assert_eq!(name, "TestPack");
}
#[test]
fn unique_name_with_collision() {
let tmp = tempfile::tempdir().unwrap();
let dir = tmp.path().join("TestPack");
std::fs::create_dir_all(&dir).unwrap();
std::fs::write(dir.join("instance.json"), "{}").unwrap();
let name = unique_instance_name("TestPack", tmp.path());
assert_eq!(name, "TestPack (2)");
}
#[test]
fn unique_name_multiple_collisions() {
let tmp = tempfile::tempdir().unwrap();
for suffix in ["", " (2)", " (3)"] {
let dir = tmp.path().join(format!("TestPack{suffix}"));
std::fs::create_dir_all(&dir).unwrap();
std::fs::write(dir.join("instance.json"), "{}").unwrap();
}
let name = unique_instance_name("TestPack", tmp.path());
assert_eq!(name, "TestPack (4)");
}
#[test]
fn parse_project_url() {
assert_eq!(
parse_import_input("https://modrinth.com/modpack/fabulously-optimized"),
ImportInput::ProjectSlug("fabulously-optimized".to_string())
);
}
#[test]
fn parse_version_url() {
assert_eq!(
parse_import_input("https://modrinth.com/modpack/fabulously-optimized/version/abc123"),
ImportInput::VersionId {
slug: "fabulously-optimized".to_string(),
version_id: "abc123".to_string(),
}
);
}
#[test]
fn parse_local_mrpack() {
assert_eq!(
parse_import_input("/home/user/pack.mrpack"),
ImportInput::LocalFile("/home/user/pack.mrpack".to_string())
);
}
#[test]
fn parse_local_zip() {
assert_eq!(
parse_import_input("GT_New_Horizons.zip"),
ImportInput::LocalFile("GT_New_Horizons.zip".to_string())
);
}
#[test]
fn parse_tilde_path() {
assert_eq!(
parse_import_input("~/Downloads/pack.mrpack"),
ImportInput::LocalFile("~/Downloads/pack.mrpack".to_string())
);
}
#[test]
fn parse_bare_slug() {
assert_eq!(
parse_import_input("fabulously-optimized"),
ImportInput::ProjectSlug("fabulously-optimized".to_string())
);
}
#[test]
fn parse_input_trims_whitespace() {
assert_eq!(
parse_import_input(" fabulously-optimized "),
ImportInput::ProjectSlug("fabulously-optimized".to_string())
);
}
}
@@ -1,26 +1,18 @@
// importing modrinth .mrpack modpacks: parse the manifest, create the instance, // modrinth .mrpack import: parse the manifest, download all the mods,
// download all the mods, and extract config/resource overrides from the zip // and extract config/resource overrides from the zip
use std::path::{Path, PathBuf}; use std::path::Path;
use crate::instance::manager::InstanceManager; use crate::instance::manager::InstanceManager;
use crate::instance::models::ModLoader; use crate::instance::models::ModLoader;
use crate::net::modrinth::MrpackIndex; use crate::net::modrinth::MrpackIndex;
use crate::tui::progress; use crate::tui::progress;
#[derive(Debug, Clone)] use super::{ImportSummary, PackFormat};
pub struct ImportSummary {
pub name: String, pub fn build_summary(path: &Path) -> Result<ImportSummary, String> {
pub pack_version: String, let index = crate::net::modrinth::parse_mrpack(path)?;
pub game_version: String,
pub loader: ModLoader,
pub loader_version: Option<String>,
pub mod_count: usize,
pub override_count: usize,
pub mrpack_path: PathBuf,
}
pub fn build_summary(index: &MrpackIndex, mrpack_path: PathBuf) -> Result<ImportSummary, String> {
let game_version = crate::net::modrinth::game_version_from_dependencies(&index.dependencies) let game_version = crate::net::modrinth::game_version_from_dependencies(&index.dependencies)
.ok_or_else(|| "Manifest missing minecraft dependency".to_string())?; .ok_or_else(|| "Manifest missing minecraft dependency".to_string())?;
@@ -28,7 +20,7 @@ pub fn build_summary(index: &MrpackIndex, mrpack_path: PathBuf) -> Result<Import
crate::net::modrinth::loader_from_dependencies(&index.dependencies); crate::net::modrinth::loader_from_dependencies(&index.dependencies);
let loader = loader_opt.unwrap_or(ModLoader::Vanilla); let loader = loader_opt.unwrap_or(ModLoader::Vanilla);
let override_count = count_overrides(&mrpack_path).unwrap_or(0); let override_count = count_overrides(path).unwrap_or(0);
Ok(ImportSummary { Ok(ImportSummary {
name: index.name.clone(), name: index.name.clone(),
@@ -38,7 +30,8 @@ pub fn build_summary(index: &MrpackIndex, mrpack_path: PathBuf) -> Result<Import
loader_version, loader_version,
mod_count: index.files.len(), mod_count: index.files.len(),
override_count, override_count,
mrpack_path, format: PackFormat::Mrpack,
archive_path: path.to_path_buf(),
}) })
} }
@@ -56,25 +49,11 @@ fn count_overrides(mrpack_path: &Path) -> Result<usize, String> {
Ok(count) Ok(count)
} }
pub fn unique_instance_name(base: &str, instances_dir: &Path) -> String {
let candidate = base.to_string();
if !instances_dir.join(&candidate).join("instance.json").exists() {
return candidate;
}
for n in 2..100 {
let candidate = format!("{base} ({n})");
if !instances_dir.join(&candidate).join("instance.json").exists() {
return candidate;
}
}
format!("{base} (import)")
}
pub async fn execute_import( pub async fn execute_import(
summary: &ImportSummary, summary: &ImportSummary,
manager: &InstanceManager, manager: &InstanceManager,
) -> Result<crate::instance::InstanceConfig, Box<dyn std::error::Error + Send + Sync>> { ) -> Result<crate::instance::InstanceConfig, Box<dyn std::error::Error + Send + Sync>> {
let name = unique_instance_name(&summary.name, &manager.instances_dir); let name = super::unique_instance_name(&summary.name, &manager.instances_dir);
progress::set_action(format!("Importing '{name}'...")); progress::set_action(format!("Importing '{name}'..."));
progress::set_sub_action(format!("{} {}", summary.game_version, summary.loader)); progress::set_sub_action(format!("{} {}", summary.game_version, summary.loader));
@@ -91,12 +70,12 @@ pub async fn execute_import(
let minecraft_dir = manager.instances_dir.join(&name).join(".minecraft"); let minecraft_dir = manager.instances_dir.join(&name).join(".minecraft");
let index = crate::net::modrinth::parse_mrpack(&summary.mrpack_path) let index = crate::net::modrinth::parse_mrpack(&summary.archive_path)
.map_err(|e| -> Box<dyn std::error::Error + Send + Sync> { e.into() })?; .map_err(|e| -> Box<dyn std::error::Error + Send + Sync> { e.into() })?;
download_mod_files(&index, &minecraft_dir).await?; download_mod_files(&index, &minecraft_dir).await?;
extract_overrides(&summary.mrpack_path, &minecraft_dir)?; extract_overrides(&summary.archive_path, &minecraft_dir)?;
progress::clear(); progress::clear();
Ok(config) Ok(config)
@@ -227,37 +206,3 @@ fn extract_overrides(
Ok(()) Ok(())
} }
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn unique_name_no_collision() {
let tmp = tempfile::tempdir().unwrap();
let name = unique_instance_name("TestPack", tmp.path());
assert_eq!(name, "TestPack");
}
#[test]
fn unique_name_with_collision() {
let tmp = tempfile::tempdir().unwrap();
let dir = tmp.path().join("TestPack");
std::fs::create_dir_all(&dir).unwrap();
std::fs::write(dir.join("instance.json"), "{}").unwrap();
let name = unique_instance_name("TestPack", tmp.path());
assert_eq!(name, "TestPack (2)");
}
#[test]
fn unique_name_multiple_collisions() {
let tmp = tempfile::tempdir().unwrap();
for suffix in ["", " (2)", " (3)"] {
let dir = tmp.path().join(format!("TestPack{suffix}"));
std::fs::create_dir_all(&dir).unwrap();
std::fs::write(dir.join("instance.json"), "{}").unwrap();
}
let name = unique_instance_name("TestPack", tmp.path());
assert_eq!(name, "TestPack (4)");
}
}
+125 -12
View File
@@ -67,6 +67,8 @@ struct MetaOsRule {
struct LoaderProfileJson { struct LoaderProfileJson {
main_class: String, main_class: String,
libraries: Vec<LoaderLibrary>, libraries: Vec<LoaderLibrary>,
#[serde(default)]
game_arguments: Vec<String>,
} }
#[derive(serde::Deserialize)] #[derive(serde::Deserialize)]
@@ -146,9 +148,9 @@ pub async fn launch(
ModLoader::NeoForge => Some(format!("neoforge-{}.json", lv)), ModLoader::NeoForge => Some(format!("neoforge-{}.json", lv)),
}; };
// if there's a mod loader, read its profile to get the real main class // if there's a mod loader, read its profile to get the real main class,
// and extra libraries it needs on the classpath // extra libraries, and any additional game arguments (e.g. --tweakClass)
let main_class = if let Some(filename) = profile_filename { let (main_class, loader_game_args) = if let Some(filename) = profile_filename {
let profile_path = meta_dir.join("loader-profiles").join(&filename); let profile_path = meta_dir.join("loader-profiles").join(&filename);
if !profile_path.exists() { if !profile_path.exists() {
return Err(LaunchError::MetaNotFound( return Err(LaunchError::MetaNotFound(
@@ -158,29 +160,30 @@ pub async fn launch(
let profile: LoaderProfileJson = let profile: LoaderProfileJson =
serde_json::from_slice(&tokio::fs::read(&profile_path).await?)?; serde_json::from_slice(&tokio::fs::read(&profile_path).await?)?;
// forge/neoforge install some libs locally in the instance dir, so // forge/neoforge install some libs locally in the instance dir.
// both locations need to be checked // local libs take priority so modpacks can ship patched versions
// (e.g. GTNH's launchwrapper patched for java 9+ compatibility)
let has_local_libs = matches!(config.loader, ModLoader::Forge | ModLoader::NeoForge); let has_local_libs = matches!(config.loader, ModLoader::Forge | ModLoader::NeoForge);
let local_lib_dir = minecraft_dir.join("libraries"); let local_lib_dir = minecraft_dir.join("libraries");
for lib in &profile.libraries { for lib in &profile.libraries {
if let Some(p) = crate::net::maven_coord_to_path(&lib.name) { if let Some(p) = crate::net::maven_coord_to_path(&lib.name) {
if has_local_libs { if has_local_libs {
let in_meta = lib_dir.join(&p);
let in_local = local_lib_dir.join(&p); let in_local = local_lib_dir.join(&p);
if in_meta.exists() { let in_meta = lib_dir.join(&p);
classpath.push(in_meta); if in_local.exists() {
} else if in_local.exists() {
classpath.push(in_local); classpath.push(in_local);
} else if in_meta.exists() {
classpath.push(in_meta);
} }
} else { } else {
classpath.push(lib_dir.join(p)); classpath.push(lib_dir.join(p));
} }
} }
} }
profile.main_class (profile.main_class, profile.game_arguments)
} else { } else {
meta.main_class.clone() (meta.main_class.clone(), Vec::new())
}; };
classpath.push( classpath.push(
@@ -190,6 +193,17 @@ pub async fn launch(
.join(format!("{}.jar", config.game_version)), .join(format!("{}.jar", config.game_version)),
); );
// lwjgl3ify ships a patched launchwrapper and retrofuturabootstrap for
// java 9+ compat. if present, prepend its patches to the classpath,
// override the main class to use RFB's bootstrap, and add the required
// --add-opens and system classloader flags.
let (lwjgl3ify_jvm_args, main_class) = if matches!(config.loader, ModLoader::Forge) {
let (jvm_args, override_main) = apply_lwjgl3ify_patches(&minecraft_dir, &mut classpath);
(jvm_args, override_main.unwrap_or(main_class))
} else {
(Vec::new(), main_class)
};
let sep = if cfg!(windows) { ";" } else { ":" }; let sep = if cfg!(windows) { ";" } else { ":" };
let cp_str = classpath let cp_str = classpath
.iter() .iter()
@@ -213,6 +227,7 @@ pub async fn launch(
format!("-Xms{}", config.memory_min.as_deref().unwrap_or("512M")), format!("-Xms{}", config.memory_min.as_deref().unwrap_or("512M")),
format!("-Xmx{}", config.memory_max.as_deref().unwrap_or("2G")), format!("-Xmx{}", config.memory_max.as_deref().unwrap_or("2G")),
]; ];
jvm.extend(lwjgl3ify_jvm_args);
jvm.extend(config.jvm_args.clone()); jvm.extend(config.jvm_args.clone());
// resolve auth credentials, refreshing the microsoft token if needed. // resolve auth credentials, refreshing the microsoft token if needed.
@@ -262,7 +277,7 @@ pub async fn launch(
), ),
}; };
let game_args = vec![ let mut game_args = vec![
"--username".to_string(), "--username".to_string(),
mc_username, mc_username,
"--version".to_string(), "--version".to_string(),
@@ -280,6 +295,7 @@ pub async fn launch(
"--userType".to_string(), "--userType".to_string(),
mc_user_type, mc_user_type,
]; ];
game_args.extend(loader_game_args);
let (kill_tx, kill_rx) = tokio::sync::oneshot::channel::<()>(); let (kill_tx, kill_rx) = tokio::sync::oneshot::channel::<()>();
crate::running::register_kill(&name, kill_tx); crate::running::register_kill(&name, kill_tx);
@@ -394,3 +410,100 @@ pub async fn launch(
Ok(()) Ok(())
} }
// lwjgl3ify (used by GTNH and other old forge modpacks) bundles a
// forgePatches.zip with patched launchwrapper classes that fix the
// URLClassLoader cast on java 9+. if we find it, extract the patches
// and prepend them to the classpath so they shadow the vanilla classes.
// also parses Add-Opens from the zip's manifest for the required
// --add-opens flags.
fn apply_lwjgl3ify_patches(
minecraft_dir: &Path,
classpath: &mut Vec<PathBuf>,
) -> (Vec<String>, Option<String>) {
let mods_dir = minecraft_dir.join("mods");
let lwjgl3ify_jar = match find_lwjgl3ify_jar(&mods_dir) {
Some(p) => p,
None => return (Vec::new(), None),
};
let patches_dest = minecraft_dir.join(".forge-patches.zip");
if let Err(e) = extract_forge_patches(&lwjgl3ify_jar, &patches_dest) {
tracing::warn!("Failed to extract lwjgl3ify forge patches: {e}");
return (Vec::new(), None);
}
// prepend so patched classes shadow vanilla launchwrapper
classpath.insert(0, patches_dest.clone());
let mut jvm_args = parse_add_opens(&patches_dest).unwrap_or_default();
// RFB requires its own classloader to be the system classloader, and
// its Main class handles bootstrapping into launchwrapper.
// the other flags match lwjgl3ify's java9args.txt.
jvm_args.extend([
"-Djava.system.class.loader=com.gtnewhorizons.retrofuturabootstrap.RfbSystemClassLoader".to_string(),
"-Dfile.encoding=UTF-8".to_string(),
"--enable-native-access".to_string(),
"ALL-UNNAMED".to_string(),
]);
// also prepend the lwjgl3ify jar itself so RFB can find its plugin classes
classpath.insert(1, lwjgl3ify_jar);
let main_class = "com.gtnewhorizons.retrofuturabootstrap.Main".to_string();
(jvm_args, Some(main_class))
}
fn find_lwjgl3ify_jar(mods_dir: &Path) -> Option<PathBuf> {
let entries = std::fs::read_dir(mods_dir).ok()?;
for entry in entries.flatten() {
let name = entry.file_name();
let name = name.to_string_lossy();
if name.starts_with("lwjgl3ify") && name.ends_with(".jar") {
return Some(entry.path());
}
}
None
}
fn extract_forge_patches(lwjgl3ify_jar: &Path, dest: &Path) -> Result<(), std::io::Error> {
use std::io::Read;
let file = std::fs::File::open(lwjgl3ify_jar)?;
let mut archive = zip::ZipArchive::new(file)
.map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidData, e))?;
let mut entry = archive
.by_name("me/eigenraven/lwjgl3ify/relauncher/forgePatches.zip")
.map_err(|e| std::io::Error::new(std::io::ErrorKind::NotFound, e))?;
let mut buf = Vec::new();
entry.read_to_end(&mut buf)?;
std::fs::write(dest, &buf)
}
fn parse_add_opens(patches_zip: &Path) -> Option<Vec<String>> {
use std::io::Read;
let file = std::fs::File::open(patches_zip).ok()?;
let mut archive = zip::ZipArchive::new(file).ok()?;
let mut entry = archive.by_name("META-INF/MANIFEST.MF").ok()?;
let mut manifest = String::new();
entry.read_to_string(&mut manifest).ok()?;
// manifest continuation lines start with a single space
let manifest = manifest.replace("\r\n ", "").replace("\n ", "");
let mut args = Vec::new();
for line in manifest.lines() {
if let Some(value) = line.strip_prefix("Add-Opens: ") {
for module_package in value.split_whitespace() {
args.push("--add-opens".to_string());
args.push(format!("{module_package}=ALL-UNNAMED"));
}
}
}
Some(args)
}
+24 -8
View File
@@ -1,6 +1,6 @@
// forge installation. unlike fabric/quilt, forge ships a java-based installer // forge installation. modern forge runs a java installer, old forge (pre-1.13)
// that has to be downloaded and executed. yes, a jvm is needed just to install // can't run headless so we extract the profile and libraries from the jar
// the thing that runs on a jvm. the installer jar gets cleaned up afterward. // directly. the installer jar gets cleaned up either way.
use std::path::Path; use std::path::Path;
@@ -43,7 +43,23 @@ impl ModLoaderInstaller for ForgeInstaller {
forge_api::download_forge_installer(client, game_version, loader_version, &installer_jar) forge_api::download_forge_installer(client, game_version, loader_version, &installer_jar)
.await?; .await?;
// use configured java or try to find one on PATH let profile_filename = format!("forge-{game_version}-{loader_version}.json");
if forge_api::has_legacy_install_profile(&installer_jar) {
// old forge: no --installClient support, extract directly from jar
if let Err(e) = forge_api::install_forge_from_profile(
client,
&installer_jar,
meta_dir,
&profile_filename,
)
.await
{
let _ = tokio::fs::remove_file(&installer_jar).await;
return Err(e);
}
} else {
// modern forge: run the java installer
let java_path = crate::config::SETTINGS let java_path = crate::config::SETTINGS
.paths .paths
.effective_java_path() .effective_java_path()
@@ -52,18 +68,18 @@ impl ModLoaderInstaller for ForgeInstaller {
if let Err(e) = if let Err(e) =
forge_api::run_forge_installer(&installer_jar, instance_dir, &java_path).await forge_api::run_forge_installer(&installer_jar, instance_dir, &java_path).await
{ {
// still clean up even if installation failed
let _ = tokio::fs::remove_file(&installer_jar).await; let _ = tokio::fs::remove_file(&installer_jar).await;
return Err(e); return Err(e);
} }
// extract the profile from what the installer just wrote to disk
save_forge_profile(instance_dir, meta_dir, game_version, loader_version)?;
}
if let Err(e) = tokio::fs::remove_file(&installer_jar).await { if let Err(e) = tokio::fs::remove_file(&installer_jar).await {
tracing::warn!("Failed to remove Forge installer JAR: {}", e); tracing::warn!("Failed to remove Forge installer JAR: {}", e);
} }
// extract the profile from what the installer just wrote to disk
save_forge_profile(instance_dir, meta_dir, game_version, loader_version)?;
Ok(()) Ok(())
} }
} }
+240 -15
View File
@@ -1,6 +1,6 @@
// forge mod loader: version discovery via promotions API, then download // forge mod loader: version discovery via promotions API, download and
// and run the installer jar. forge doesn't have a nice metadata API like // installation. modern forge runs a java installer, old forge (pre-1.13ish)
// fabric/quilt, so it shells out to java to run their installer. // doesn't support headless install so we extract directly from the jar.
use std::collections::HashMap; use std::collections::HashMap;
use std::path::Path; use std::path::Path;
@@ -9,7 +9,7 @@ use serde::Deserialize;
use crate::instance::loader::GameVersion; use crate::instance::loader::GameVersion;
use crate::net::{HttpClient, NetError, download_file}; use crate::net::{HttpClient, NetError, download_file};
use crate::tui::progress::set_action; use crate::tui::progress::{set_action, set_sub_action};
const FORGE_PROMOTIONS_URL: &str = const FORGE_PROMOTIONS_URL: &str =
"https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json"; "https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json";
@@ -64,28 +64,48 @@ pub async fn fetch_forge_game_versions(client: &HttpClient) -> Result<Vec<GameVe
.collect()) .collect())
} }
// forge has used at least three different maven naming conventions over the
// years with no clear cutoff. we just try each one until something works.
pub async fn download_forge_installer( pub async fn download_forge_installer(
client: &HttpClient, client: &HttpClient,
game_version: &str, game_version: &str,
forge_version: &str, forge_version: &str,
dest: &Path, dest: &Path,
) -> Result<(), NetError> { ) -> Result<(), NetError> {
let url = format!( let mc_no_dots: String = game_version.chars().filter(|c| *c != '.').collect();
"{}/{game_version}-{forge_version}/forge-{game_version}-{forge_version}-installer.jar",
FORGE_MAVEN_BASE, let slugs = [
game_version = game_version, format!("{game_version}-{forge_version}"),
forge_version = forge_version, format!("{game_version}-{forge_version}-{game_version}"),
); format!("{game_version}-{forge_version}-mc{mc_no_dots}"),
];
set_action(format!( set_action(format!(
"Downloading Forge {}-{}...", "Downloading Forge {}-{}...",
game_version, forge_version game_version, forge_version
)); ));
download_file(client, &url, dest, |downloaded, total| { let mut last_err = None;
for slug in &slugs {
let url = format!(
"{}/{slug}/forge-{slug}-installer.jar",
FORGE_MAVEN_BASE,
);
match download_file(client, &url, dest, |downloaded, total| {
crate::tui::progress::set_progress(downloaded, total); crate::tui::progress::set_progress(downloaded, total);
}) })
.await .await
{
Ok(()) => return Ok(()),
Err(e) => last_err = Some(e),
}
}
Err(last_err.unwrap_or_else(|| {
NetError::Parse(format!(
"No Forge installer found for {game_version}-{forge_version}"
))
}))
} }
pub async fn run_forge_installer( pub async fn run_forge_installer(
@@ -112,15 +132,220 @@ pub async fn run_forge_installer(
}; };
if !output.status.success() { if !output.status.success() {
return Err(NetError::InstallerFailed(format!( let stderr = String::from_utf8_lossy(&output.stderr);
"Forge installer exited with {:?}", let detail = if stderr.trim().is_empty() {
output.status.code() format!("exit code {:?}", output.status.code())
))); } else {
stderr.lines().last().unwrap_or("unknown error").to_string()
};
return Err(NetError::InstallerFailed(detail));
} }
Ok(()) Ok(())
} }
// old forge installers have an install_profile.json with a "versionInfo" key
// containing everything needed. modern ones don't have this structure.
pub(crate) fn has_legacy_install_profile(installer_path: &Path) -> bool {
let file = match std::fs::File::open(installer_path) {
Ok(f) => f,
Err(_) => return false,
};
let mut archive = match zip::ZipArchive::new(file) {
Ok(a) => a,
Err(_) => return false,
};
let entry = match archive.by_name("install_profile.json") {
Ok(e) => e,
Err(_) => return false,
};
let value: serde_json::Value = match serde_json::from_reader(entry) {
Ok(v) => v,
Err(_) => return false,
};
value.get("versionInfo").is_some()
}
// handles old-style forge installation by extracting the universal jar and
// library info directly from the installer, bypassing the GUI-only installer
pub(crate) async fn install_forge_from_profile(
client: &HttpClient,
installer_path: &Path,
meta_dir: &Path,
profile_filename: &str,
) -> Result<(), NetError> {
use std::io::Read;
set_action("Installing legacy Forge from profile...");
let file = std::fs::File::open(installer_path)?;
let mut archive = zip::ZipArchive::new(file).map_err(|e| {
NetError::Parse(format!("Failed to open installer as ZIP: {e}"))
})?;
let profile_data: serde_json::Value = {
let entry = archive.by_name("install_profile.json").map_err(|e| {
NetError::Parse(format!("install_profile.json not found in installer: {e}"))
})?;
serde_json::from_reader(entry).map_err(|e| {
NetError::Parse(format!("Failed to parse install_profile.json: {e}"))
})?
};
let version_info = profile_data.get("versionInfo").ok_or_else(|| {
NetError::Parse("install_profile.json missing versionInfo".into())
})?;
let install_info = profile_data.get("install").ok_or_else(|| {
NetError::Parse("install_profile.json missing install section".into())
})?;
let main_class = version_info
.get("mainClass")
.and_then(|v| v.as_str())
.ok_or_else(|| NetError::Parse("missing versionInfo.mainClass".into()))?
.to_string();
let libraries = version_info
.get("libraries")
.and_then(|v| v.as_array())
.ok_or_else(|| NetError::Parse("missing versionInfo.libraries".into()))?;
let file_path = install_info
.get("filePath")
.and_then(|v| v.as_str())
.ok_or_else(|| NetError::Parse("missing install.filePath".into()))?;
let install_path_coord = install_info
.get("path")
.and_then(|v| v.as_str())
.ok_or_else(|| NetError::Parse("missing install.path".into()))?;
// extract the universal jar to the correct maven location
let universal_maven_path = crate::net::maven_coord_to_path(install_path_coord)
.ok_or_else(|| {
NetError::Parse(format!("Invalid maven coord in install.path: {install_path_coord}"))
})?;
set_sub_action("Extracting universal JAR...");
let universal_dest = meta_dir.join("libraries").join(&universal_maven_path);
if let Some(parent) = universal_dest.parent() {
std::fs::create_dir_all(parent)?;
}
{
let mut entry = archive.by_name(file_path).map_err(|e| {
NetError::Parse(format!("Universal JAR '{file_path}' not found in installer: {e}"))
})?;
let mut buf = Vec::new();
entry.read_to_end(&mut buf)?;
std::fs::write(&universal_dest, &buf)?;
}
// download libraries needed by this forge version. libs with a url field
// are forge-hosted, libs without one are typically from mojang's library
// server. old forge versions reference libs like launchwrapper that aren't
// in mojang's modern version metadata, so we fetch those too.
let libraries_dir = meta_dir.join("libraries");
for lib in libraries {
let name = lib.get("name").and_then(|v| v.as_str()).unwrap_or_default();
let maven_path = match crate::net::maven_coord_to_path(name) {
Some(p) => p,
None => {
return Err(NetError::Parse(format!(
"Invalid Maven coordinate: {name}"
)));
}
};
let dest = libraries_dir.join(&maven_path);
if dest.exists() {
continue;
}
let base_url = lib
.get("url")
.and_then(|v| v.as_str())
.unwrap_or("https://libraries.minecraft.net/")
.trim_end_matches('/');
let download_url = format!("{base_url}/{maven_path}");
set_sub_action(name);
download_file(client, &download_url, &dest, |_, _| {}).await?;
}
// old forge profiles store game arguments (like --tweakClass) in
// minecraftArguments. extract non-template args to pass at launch.
let game_arguments: Vec<String> = version_info
.get("minecraftArguments")
.and_then(|v| v.as_str())
.map(extract_extra_game_args)
.unwrap_or_default();
set_action("Saving Forge profile...");
let lib_entries: Vec<serde_json::Value> = libraries
.iter()
.filter_map(|l| {
l.get("name")
.and_then(|v| v.as_str())
.map(|n| serde_json::json!({"name": n}))
})
.collect();
let profile_json = serde_json::json!({
"mainClass": main_class,
"libraries": lib_entries,
"gameArguments": game_arguments,
});
crate::instance::loader::save_profile_json(meta_dir, profile_filename, &profile_json)?;
Ok(())
}
// pulls out game arguments from old forge's minecraftArguments string that
// the launcher doesn't already handle. skips template variables (${...})
// and standard args like --username that we build ourselves.
fn extract_extra_game_args(minecraft_arguments: &str) -> Vec<String> {
let handled = [
"--username",
"--version",
"--gameDir",
"--assetsDir",
"--assetIndex",
"--uuid",
"--accessToken",
"--userProperties",
"--userType",
];
let tokens: Vec<&str> = minecraft_arguments.split_whitespace().collect();
let mut result = Vec::new();
let mut i = 0;
while i < tokens.len() {
let token = tokens[i];
if token.starts_with("--") {
if handled.contains(&token) {
// skip the flag and its value
i += 2;
continue;
}
result.push(token.to_string());
// if the next token is a value (not a flag or template), include it
if i + 1 < tokens.len() && !tokens[i + 1].starts_with("--") {
let val = tokens[i + 1];
if !val.starts_with("${") {
result.push(val.to_string());
}
i += 2;
continue;
}
}
i += 1;
}
result
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
+41 -1
View File
@@ -73,14 +73,45 @@ impl HttpClient {
} }
} }
const MAX_RETRIES: u32 = 3;
const RETRY_BASE_DELAY_MS: u64 = 500;
// streams a file to disk in chunks, calling progress_cb(downloaded, total) along the way. // streams a file to disk in chunks, calling progress_cb(downloaded, total) along the way.
// total will be 0 if the server doesn't send content-length, so callers // total will be 0 if the server doesn't send content-length, so callers
// should handle that gracefully. // should handle that gracefully. retries transient failures with exponential backoff.
pub async fn download_file( pub async fn download_file(
client: &HttpClient, client: &HttpClient,
url: &str, url: &str,
dest: &Path, dest: &Path,
progress_cb: impl Fn(u64, u64), progress_cb: impl Fn(u64, u64),
) -> Result<(), NetError> {
let mut last_error = None;
for attempt in 0..=MAX_RETRIES {
if attempt > 0 {
let delay = RETRY_BASE_DELAY_MS * 2u64.pow(attempt - 1);
tracing::warn!("retrying download (attempt {}/{}): {}", attempt + 1, MAX_RETRIES + 1, url);
tokio::time::sleep(std::time::Duration::from_millis(delay)).await;
}
match download_file_once(client, url, dest, &progress_cb).await {
Ok(()) => return Ok(()),
Err(e) if is_retryable(&e) => {
last_error = Some(e);
}
Err(e) => return Err(e),
}
}
Err(last_error.unwrap())
}
// single attempt at downloading a file to disk
async fn download_file_once(
client: &HttpClient,
url: &str,
dest: &Path,
progress_cb: &impl Fn(u64, u64),
) -> Result<(), NetError> { ) -> Result<(), NetError> {
use tokio::io::AsyncWriteExt; use tokio::io::AsyncWriteExt;
@@ -104,6 +135,15 @@ pub async fn download_file(
Ok(()) Ok(())
} }
// body decode errors and timeouts are worth retrying, but a 404 or disk error isn't
fn is_retryable(err: &NetError) -> bool {
match err {
NetError::Http(e) => e.is_timeout() || e.is_body() || e.is_connect(),
NetError::StatusError { status, .. } => *status >= 500,
_ => false,
}
}
// tries JAVA_HOME first, then PATH, then just yolos "java" and hopes for the best // tries JAVA_HOME first, then PATH, then just yolos "java" and hopes for the best
#[must_use] #[must_use]
pub fn detect_java_path() -> String { pub fn detect_java_path() -> String {
+2 -92
View File
@@ -1,5 +1,5 @@
// modrinth modpack support: parses URLs/slugs, fetches project metadata, // modrinth modpack support: fetches project metadata, downloads .mrpack files,
// downloads .mrpack files, and extracts loader info from pack manifests. // and extracts loader info from pack manifests.
use serde::Deserialize; use serde::Deserialize;
use std::collections::HashMap; use std::collections::HashMap;
@@ -51,44 +51,6 @@ pub struct MrpackFile {
pub file_size: u64, pub file_size: u64,
} }
#[derive(Debug, Clone, PartialEq)]
pub enum ModrinthInput {
ProjectSlug(String),
VersionId { slug: String, version_id: String },
LocalFile(String),
}
// figures out what the user gave us: a modrinth URL, a local .mrpack file,
// or just a project slug. accepts a pretty wide range of inputs so users
// don't have to think about it.
pub fn parse_input(input: &str) -> ModrinthInput {
let input = input.trim();
if input.ends_with(".mrpack")
|| input.starts_with('/')
|| input.starts_with("~/")
{
return ModrinthInput::LocalFile(input.to_string());
}
if let Some(rest) = input
.strip_prefix("https://modrinth.com/modpack/")
.or_else(|| input.strip_prefix("http://modrinth.com/modpack/"))
{
let parts: Vec<&str> = rest.split('/').filter(|s| !s.is_empty()).collect();
return match parts.as_slice() {
[slug, "version", version_id, ..] => ModrinthInput::VersionId {
slug: slug.to_string(),
version_id: version_id.to_string(),
},
[slug, ..] => ModrinthInput::ProjectSlug(slug.to_string()),
[] => ModrinthInput::ProjectSlug(String::new()),
};
}
ModrinthInput::ProjectSlug(input.to_string())
}
use crate::instance::models::ModLoader; use crate::instance::models::ModLoader;
// mrpack dependencies use keys like "fabric-loader", "forge", etc. // mrpack dependencies use keys like "fabric-loader", "forge", etc.
@@ -192,58 +154,6 @@ pub fn parse_mrpack(path: &std::path::Path) -> Result<MrpackIndex, String> {
mod tests { mod tests {
use super::*; use super::*;
#[test]
fn parse_project_url() {
assert_eq!(
parse_input("https://modrinth.com/modpack/fabulously-optimized"),
ModrinthInput::ProjectSlug("fabulously-optimized".to_string())
);
}
#[test]
fn parse_version_url() {
let result = parse_input("https://modrinth.com/modpack/fabulously-optimized/version/abc123");
assert_eq!(
result,
ModrinthInput::VersionId {
slug: "fabulously-optimized".to_string(),
version_id: "abc123".to_string(),
}
);
}
#[test]
fn parse_local_mrpack() {
assert_eq!(
parse_input("/home/user/pack.mrpack"),
ModrinthInput::LocalFile("/home/user/pack.mrpack".to_string())
);
}
#[test]
fn parse_tilde_path() {
assert_eq!(
parse_input("~/Downloads/pack.mrpack"),
ModrinthInput::LocalFile("~/Downloads/pack.mrpack".to_string())
);
}
#[test]
fn parse_bare_slug() {
assert_eq!(
parse_input("fabulously-optimized"),
ModrinthInput::ProjectSlug("fabulously-optimized".to_string())
);
}
#[test]
fn parse_input_trims_whitespace() {
assert_eq!(
parse_input(" fabulously-optimized "),
ModrinthInput::ProjectSlug("fabulously-optimized".to_string())
);
}
#[test] #[test]
fn loader_from_fabric_deps() { fn loader_from_fabric_deps() {
let mut deps = HashMap::new(); let mut deps = HashMap::new();
@@ -103,7 +103,7 @@ fn render_input_step(
let input_line = if state.input.is_empty() { let input_line = if state.input.is_empty() {
Line::from(vec![ Line::from(vec![
Span::styled( Span::styled(
"URL, slug, or .mrpack path...", "URL, slug, or pack file path...",
Style::default().fg(theme.text_dim()), Style::default().fg(theme.text_dim()),
), ),
Span::styled( Span::styled(
+15 -38
View File
@@ -1,11 +1,11 @@
// state machine for the modpack import wizard. // state machine for the modpack import wizard.
// accepts modrinth URLs, project slugs, version IDs, or local .mrpack paths. // accepts modrinth URLs, project slugs, version IDs, or local pack archives
// for remote packs, it fetches project info then lets the user pick a version. // (.mrpack, mmc/prism zips). remote packs go through version selection,
// local files skip straight to the confirm step. // local files skip straight to the confirm step.
use super::super::new_instance::LoadState; use super::super::new_instance::LoadState;
use crate::instance::import::ImportSummary; use crate::instance::import::{parse_import_input, ImportInput, ImportSummary};
use crate::net::modrinth::{self, ModrinthInput, VersionInfo}; use crate::net::modrinth::{self, VersionInfo};
use crate::tui::widgets::instances; use crate::tui::widgets::instances;
use crate::tui::widgets::search::SearchState; use crate::tui::widgets::search::SearchState;
use crossterm::event::{KeyCode, KeyEvent}; use crossterm::event::{KeyCode, KeyEvent};
@@ -241,19 +241,19 @@ fn start_resolve(state: &mut ImportWizardState) {
tokio::spawn(async move { tokio::spawn(async move {
let client = crate::net::HttpClient::new(); let client = crate::net::HttpClient::new();
let parsed = modrinth::parse_input(&input_text); let parsed = parse_import_input(&input_text);
match parsed { match parsed {
ModrinthInput::ProjectSlug(slug) => { ImportInput::ProjectSlug(slug) => {
resolve_project_slug(state_arc, &client, &slug).await; resolve_project_slug(state_arc, &client, &slug).await;
} }
ModrinthInput::VersionId { ImportInput::VersionId {
slug: _, slug: _,
version_id, version_id,
} => { } => {
resolve_version_id(state_arc, &client, &version_id).await; resolve_version_id(state_arc, &client, &version_id).await;
} }
ModrinthInput::LocalFile(path) => { ImportInput::LocalFile(path) => {
resolve_local_file(state_arc, &path); resolve_local_file(state_arc, &path);
} }
} }
@@ -309,9 +309,8 @@ async fn resolve_version_id(
} }
match modrinth::download_mrpack(client, &version, &tmp_dir).await { match modrinth::download_mrpack(client, &version, &tmp_dir).await {
Ok(mrpack_path) => match modrinth::parse_mrpack(&mrpack_path) { Ok(mrpack_path) => {
Ok(index) => { match crate::instance::import::build_summary(&mrpack_path) {
match crate::instance::import::build_summary(&index, mrpack_path) {
Ok(summary) => { Ok(summary) => {
if let Ok(mut s) = state_arc.lock() { if let Ok(mut s) = state_arc.lock() {
s.summary = Some(summary); s.summary = Some(summary);
@@ -325,12 +324,6 @@ async fn resolve_version_id(
), ),
} }
} }
Err(e) => set_error_and_back(
&state_arc,
format!("Failed to parse mrpack: {}", e),
ImportStep::Input,
),
},
Err(e) => set_error_and_back( Err(e) => set_error_and_back(
&state_arc, &state_arc,
format!("Failed to download mrpack: {}", e), format!("Failed to download mrpack: {}", e),
@@ -349,9 +342,7 @@ async fn resolve_version_id(
fn resolve_local_file(state_arc: Arc<Mutex<ImportWizardState>>, path: &str) { fn resolve_local_file(state_arc: Arc<Mutex<ImportWizardState>>, path: &str) {
let resolved = crate::config::settings::resolve_path(path); let resolved = crate::config::settings::resolve_path(path);
match modrinth::parse_mrpack(&resolved) { match crate::instance::import::build_summary(&resolved) {
Ok(index) => {
match crate::instance::import::build_summary(&index, resolved) {
Ok(summary) => { Ok(summary) => {
if let Ok(mut s) = state_arc.lock() { if let Ok(mut s) = state_arc.lock() {
s.summary = Some(summary); s.summary = Some(summary);
@@ -360,20 +351,13 @@ fn resolve_local_file(state_arc: Arc<Mutex<ImportWizardState>>, path: &str) {
} }
Err(e) => set_error_and_back( Err(e) => set_error_and_back(
&state_arc, &state_arc,
format!("Failed to build summary: {}", e), format!("Failed to parse pack: {}", e),
ImportStep::Input,
),
}
}
Err(e) => set_error_and_back(
&state_arc,
format!("Failed to parse mrpack: {}", e),
ImportStep::Input, ImportStep::Input,
), ),
} }
} }
// user picked a version from the list. download the .mrpack, parse it, // user picked a version from the list. download the .mrpack,
// build a summary, and move to confirm. // build a summary, and move to confirm.
fn start_version_download(state: &mut ImportWizardState) { fn start_version_download(state: &mut ImportWizardState) {
let version = match selected_version(state) { let version = match selected_version(state) {
@@ -399,9 +383,8 @@ fn start_version_download(state: &mut ImportWizardState) {
} }
match modrinth::download_mrpack(&client, &version, &tmp_dir).await { match modrinth::download_mrpack(&client, &version, &tmp_dir).await {
Ok(mrpack_path) => match modrinth::parse_mrpack(&mrpack_path) { Ok(mrpack_path) => {
Ok(index) => { match crate::instance::import::build_summary(&mrpack_path) {
match crate::instance::import::build_summary(&index, mrpack_path) {
Ok(summary) => { Ok(summary) => {
if let Ok(mut s) = state_arc.lock() { if let Ok(mut s) = state_arc.lock() {
s.summary = Some(summary); s.summary = Some(summary);
@@ -415,12 +398,6 @@ fn start_version_download(state: &mut ImportWizardState) {
), ),
} }
} }
Err(e) => set_error_and_back(
&state_arc,
format!("Failed to parse mrpack: {}", e),
ImportStep::Version,
),
},
Err(e) => set_error_and_back( Err(e) => set_error_and_back(
&state_arc, &state_arc,
format!("Failed to download mrpack: {}", e), format!("Failed to download mrpack: {}", e),