Skip to content

Commit

Permalink
Merge branch 'master' into painter-example
Browse files Browse the repository at this point in the history
  • Loading branch information
aksiome committed Mar 6, 2025
2 parents d03aeaa + 3c3bd03 commit 9a612bd
Show file tree
Hide file tree
Showing 1,053 changed files with 3,194 additions and 2,353 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

/.github export-ignore
/.vscode export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.readthedocs.yml export-ignore
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: ❓ Question
url: https://github.com/mcbookshelf/Bookshelf/discussions
url: https://github.com/mcbookshelf/bookshelf/discussions
about: Please ask questions here.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

- [ ] I agree to release my contribution under the [MPL v2 License](http://mozilla.org/MPL/2.0/).
- [ ] My pull request is associated with an existing issue.
- [ ] I have updated the [changelog](https://github.com/mcbookshelf/Bookshelf/blob/master/docs/CHANGELOG.md) to reflect my contribution.
- [ ] I have updated the [changelog](https://github.com/mcbookshelf/bookshelf/blob/master/docs/CHANGELOG.md) to reflect my contribution.
- [ ] If this pull request adds or modifies a feature:
- [ ] I have documented my changes in the `/docs` folder.
- [ ] I have thoroughly tested my changes. See [testing guidelines](https://docs.mcbookshelf.dev/en/latest/contribute/debug.html#unit-tests).
19 changes: 19 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 🚀 Publish Release

on:
release:
types: [published]

jobs:
publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
environment: release
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: pdm-project/setup-pdm@v4
- name: Publish package distributions to PyPI
run: pdm publish
10 changes: 6 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
name: 🔍 Check Release Necessity
needs: update-metadata
runs-on: ubuntu-latest
environment: release
if: github.ref == 'refs/heads/master'
outputs:
release_tag: ${{ steps.check-versions.outputs.release_tag }}
Expand All @@ -48,12 +49,12 @@ jobs:
- name: Check Versions
id: check-versions
run: |
VERSION=$(python core/definitions.py VERSION)
MINECRAFT_VERSIONS=$(python core/definitions.py MINECRAFT_VERSIONS)
VERSION=$(python -m bookshelf version)
MC_VERSIONS=$(python -m bookshelf mc_versions)
game_versions=$(echo $MINECRAFT_VERSIONS | sed 's/ /,/g')
mc_versions=$(echo $MC_VERSIONS | sed 's/ /,/g')
echo "release_tag=v$VERSION" >> $GITHUB_OUTPUT
echo "release_name=v$VERSION - MC $game_versions" >> $GITHUB_OUTPUT
echo "release_name=v$VERSION - MC $mc_versions" >> $GITHUB_OUTPUT
if [ -n "$(git tag -l "v$VERSION")" ]; then
echo "version_exists=true" >> $GITHUB_OUTPUT
Expand All @@ -70,6 +71,7 @@ jobs:
name: 📦 Create Release
needs: check-versions
runs-on: ubuntu-latest
environment: release
if: ${{ needs.check-versions.outputs.version_exists == 'false' }}
steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ __pycache__/
.beet_cache/
.DS_Store
.env
.idea/
.ipynb_checkpoints
.LSOverride
.mypy_cache/
Expand All @@ -14,8 +15,11 @@ __pycache__/
*.egg
*.egg-info/
*.py[cod]
*.swp
*~
*$py.class
build/
dist/
docs/_build/
env.bak/
env/
Expand Down
11 changes: 6 additions & 5 deletions .spyglassrc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"env": {
"exclude": [
".github/",
".vscode/",
"docs/",
"scripts/",
"@gitignore"
".*/**",
"bookshelf/**",
"data/**",
"docs/**",
"build/**",
"release/**"
],
"mcmetaSummaryOverrides": {
"commands": {
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</div>

<div align="center">
<a href="https://github.com/mcbookshelf/Bookshelf/stargazers"><img src="https://img.shields.io/github/stars/mcbookshelf/Bookshelf?colorA=363a4f&colorB=b7bdf8&style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2Ij4KPHBhdGggZD0iTTIzNS4yNCw4NC4zOGwtMjguMDYsMjMuNjgsOC41NiwzNS4zOWExMy4zNCwxMy4zNCwwLDAsMS01LjA5LDEzLjkxLDEzLjU0LDEzLjU0LDAsMCwxLTE1LC42OUwxNjQsMTM5bC0zMS42NSwxOS4wNmExMy41MSwxMy41MSwwLDAsMS0xNS0uNjksMTMuMzIsMTMuMzIsMCwwLDEtNS4xLTEzLjkxbDguNTYtMzUuMzlMOTIuNzYsODQuMzhhMTMuMzksMTMuMzksMCwwLDEsNy42Ni0yMy41OGwzNi45NC0yLjkyLDE0LjIxLTMzLjY2YTEzLjUxLDEzLjUxLDAsMCwxLDI0Ljg2LDBsMTQuMjEsMzMuNjYsMzYuOTQsMi45MmExMy4zOSwxMy4zOSwwLDAsMSw3LjY2LDIzLjU4Wk04OC4xMSwxMTEuODlhOCw4LDAsMCwwLTExLjMyLDBMMTguMzQsMTcwLjM0YTgsOCwwLDAsMCwxMS4zMiwxMS4zMmw1OC40NS01OC40NUE4LDgsMCwwLDAsODguMTEsMTExLjg5Wm0tLjUsNjEuMTlMMzQuMzQsMjI2LjM0YTgsOCwwLDAsMCwxMS4zMiwxMS4zMmw1My4yNi01My4yN2E4LDgsMCwwLDAtMTEuMzEtMTEuMzFabTczLTEtNTQuMjksNTQuMjhhOCw4LDAsMCwwLDExLjMyLDExLjMybDU0LjI4LTU0LjI4YTgsOCwwLDAsMC0xMS4zMS0xMS4zMloiIHN0eWxlPSJmaWxsOiAjQ0FEM0Y1OyIvPgo8L3N2Zz4="></a>
<a href="https://github.com/mcbookshelf/bookshelf/stargazers"><img src="https://img.shields.io/github/stars/mcbookshelf/bookshelf?colorA=363a4f&colorB=b7bdf8&style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2Ij4KPHBhdGggZD0iTTIzNS4yNCw4NC4zOGwtMjguMDYsMjMuNjgsOC41NiwzNS4zOWExMy4zNCwxMy4zNCwwLDAsMS01LjA5LDEzLjkxLDEzLjU0LDEzLjU0LDAsMCwxLTE1LC42OUwxNjQsMTM5bC0zMS42NSwxOS4wNmExMy41MSwxMy41MSwwLDAsMS0xNS0uNjksMTMuMzIsMTMuMzIsMCwwLDEtNS4xLTEzLjkxbDguNTYtMzUuMzlMOTIuNzYsODQuMzhhMTMuMzksMTMuMzksMCwwLDEsNy42Ni0yMy41OGwzNi45NC0yLjkyLDE0LjIxLTMzLjY2YTEzLjUxLDEzLjUxLDAsMCwxLDI0Ljg2LDBsMTQuMjEsMzMuNjYsMzYuOTQsMi45MmExMy4zOSwxMy4zOSwwLDAsMSw3LjY2LDIzLjU4Wk04OC4xMSwxMTEuODlhOCw4LDAsMCwwLTExLjMyLDBMMTguMzQsMTcwLjM0YTgsOCwwLDAsMCwxMS4zMiwxMS4zMmw1OC40NS01OC40NUE4LDgsMCwwLDAsODguMTEsMTExLjg5Wm0tLjUsNjEuMTlMMzQuMzQsMjI2LjM0YTgsOCwwLDAsMCwxMS4zMiwxMS4zMmw1My4yNi01My4yN2E4LDgsMCwwLDAtMTEuMzEtMTEuMzFabTczLTEtNTQuMjksNTQuMjhhOCw4LDAsMCwwLDExLjMyLDExLjMybDU0LjI4LTU0LjI4YTgsOCwwLDAsMC0xMS4zMS0xMS4zMloiIHN0eWxlPSJmaWxsOiAjQ0FEM0Y1OyIvPgo8L3N2Zz4="></a>
&nbsp;
<a href="https://github.com/mcbookshelf/Bookshelf/releases/latest"><img src="https://img.shields.io/github/v/release/mcbookshelf/Bookshelf?colorA=363a4f&colorB=a6da95&style=for-the-badge&logo=github&logoColor=cad3f5"></a>
<a href="https://github.com/mcbookshelf/bookshelf/releases/latest"><img src="https://img.shields.io/github/v/release/mcbookshelf/bookshelf?colorA=363a4f&colorB=a6da95&style=for-the-badge&logo=github&logoColor=cad3f5"></a>
&nbsp;
<a href="https://discord.gg/MkXytNjmBt"><img src="https://img.shields.io/discord/1247513995376726116?style=for-the-badge&color=%237289DA&labelColor=363a4f&logo=discord&logoColor=cad3f5"></a>
</div>
Expand Down Expand Up @@ -57,8 +57,8 @@ Bookshelf (formerly known as Gunivers Libs) is a modular library datapack design
</picture>
&nbsp;
<picture>
<source media="(prefers-color-scheme: dark)" alt="generate" srcset="docs/_imgs/readme/generate-dark.svg">
<img alt="generate" src="docs/_imgs/readme/generate.svg">
<source media="(prefers-color-scheme: dark)" alt="generation" srcset="docs/_imgs/readme/generation-dark.svg">
<img alt="generation" src="docs/_imgs/readme/generation.svg">
</picture>
&nbsp;
<picture>
Expand Down Expand Up @@ -86,7 +86,7 @@ That’s why we started this project, to provide a variety of reusable tools and
While we strive to keep our modules as optimized as possible, our top priority is accessibility. We focus on creating features that are easy to use and simple to install, ensuring they’re practical for everyone.

> “I have seen further than others because I have stood on the shoulders of giants.”
>
>
> -- Isaac Newton

Expand Down
16 changes: 16 additions & 0 deletions bookshelf/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""Bookshelf is a modular library for building Minecraft datapacks.
It provides a wide range of modules that can be used individually,
giving developers the flexibility to pick only the features they need.
"""

from bookshelf.definitions import MC_VERSIONS, VERSION


def version() -> str:
"""Get the current version of Bookshelf."""
return VERSION

def mc_versions() -> list[str]:
"""Get Minecraft versions compatible with the current Bookshelf version."""
return MC_VERSIONS
13 changes: 13 additions & 0 deletions bookshelf/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import sys

from . import mc_versions, version

if __name__ == "__main__":
if len(sys.argv) > 1:
command = sys.argv[1]
if command == "version":
print(str(version())) # noqa: T201
elif command == "mc_versions":
print(str(mc_versions())) # noqa: T201
else:
print(f"Unknown command: {command}") # noqa: T201
16 changes: 16 additions & 0 deletions bookshelf/bundle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from collections.abc import Callable
from functools import cache

from beet import Context, subproject

from bookshelf.definitions import MODULES_DIR

__path__ = ""

@cache
def __getattr__(name: str) -> Callable[[Context], None]:
def plugin(ctx: Context) -> None:
"""Require a bundle of modules."""
config = {"directory": f"{MODULES_DIR}/@{name}", "extend": "module.json"}
ctx.require(subproject(config))
return plugin
1 change: 1 addition & 0 deletions bookshelf/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Commands for the Bookshelf Library."""
2 changes: 1 addition & 1 deletion core/cli/docs.py → bookshelf/cli/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import click

from core.definitions import DOC_DIR
from bookshelf.definitions import DOC_DIR


@click.group()
Expand Down
28 changes: 15 additions & 13 deletions core/cli/meta.py → bookshelf/cli/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@

import click

from core.common.logger import log_step
from core.common.metadata import build_manifest, get_feature_meta, get_module_meta
from core.definitions import (
DOC_SWITCHER,
from bookshelf.definitions import (
DOC_DIR,
DOC_URL,
GITHUB_REPO,
META_MANIFEST,
META_VERSIONS,
MINECRAFT_VERSIONS,
MC_VERSIONS,
MODULES,
MODULES_DIR,
ROOT_DIR,
VERSION,
)
from bookshelf.logger import log_step
from bookshelf.meta import build_manifest, get_feature_meta, get_module_meta

MANIFEST_FILE = "data/manifest.json"
VERSIONS_FILE = "data/versions.json"


@click.group()
Expand Down Expand Up @@ -64,7 +66,7 @@ def update_manifest() -> bool:
"""Generate and update the manifest file."""
with log_step("⚙️ Generating manifest file…") as logger:
if manifest := build_manifest(logger):
with Path(ROOT_DIR / META_MANIFEST).open("w", newline="\n") as file:
with Path(ROOT_DIR / MANIFEST_FILE).open("w", newline="\n") as file:
json.dump(manifest, file, indent=2)

return not logger.errors
Expand All @@ -73,7 +75,7 @@ def update_manifest() -> bool:
def update_switcher() -> None:
"""Generate and update the switcher file."""
with log_step("⚙️ Generating switcher file…") as logger:
switcher_path = ROOT_DIR / DOC_SWITCHER
switcher_path = DOC_DIR / "_static/switcher.json"
switcher: list[dict] = json.loads(switcher_path.read_text("utf-8"))

if any(entry["version"][1:] == VERSION for entry in switcher):
Expand All @@ -83,7 +85,7 @@ def update_switcher() -> None:
entry = {
"name": VERSION,
"version": f"v{VERSION}",
"url": f"https://docs.mcbookshelf.dev/en/v{VERSION}/",
"url": f"{DOC_URL}/en/v{VERSION}/",
}

for i in range(len(switcher)):
Expand All @@ -99,7 +101,7 @@ def update_switcher() -> None:
def update_versions() -> None:
"""Generate and update the versions file."""
with log_step("⚙️ Generating versions file…") as logger:
versions_path = ROOT_DIR / META_VERSIONS
versions_path = ROOT_DIR / VERSIONS_FILE
versions: list[dict] = json.loads(versions_path.read_text("utf-8"))

if any(entry["version"] == VERSION for entry in versions):
Expand All @@ -108,8 +110,8 @@ def update_versions() -> None:

versions.insert(0, {
"version": VERSION,
"minecraft_versions": MINECRAFT_VERSIONS,
"manifest": f"https://raw.githubusercontent.com/{GITHUB_REPO}/refs/tags/v{VERSION}/{META_MANIFEST}",
"minecraft_versions": MC_VERSIONS,
"manifest": f"https://raw.githubusercontent.com/{GITHUB_REPO}/refs/tags/v{VERSION}/{MANIFEST_FILE}",
})

versions_path.write_text(json.dumps(versions, indent=2), "utf-8")
Loading

0 comments on commit 9a612bd

Please sign in to comment.