Giter VIP home page Giter VIP logo

regolith's Introduction

Regolith

• Regolith is an Add-on Compiler for the Bedrock Edition of Minecraft.

Visit the Website! ⇗

  • Much like bridge. v2, Regolith introduces the concept of a "project folder", where your addons are written, including the RP, the BP, and any models, textures or configuration files. This single-folder-structure is great for version control, and allows you to keep your "source-of-truth" outside of com.mojang.

  • In the simplest case, Regolith allows you to "compile" (copy) your RP and BP from the project folder, into the com.mojang folder. During the copy, Regolith will run a series of "filters" on the files, allowing you to programmatically transform them as they are copied into com.mojang. This allows you to transform your addon non-destructively, and to introduce new syntax into addons.

🎫 Value Preposition

  • Fundamentally, Regolith is nothing new. Many tools like this exist, such as the bridge v2 plugin system, or even something like Gulp or SASS.

  • The value preposition for Regolith is that it allows many tools, in many languages and pay-structures to work together in a single, unified compilation flow.

  • Hobbiests can use the Standard Library ⇗, or write their own filters. Marketplace teams can write proprietary filters, or internal filters.

💻 Regolith Development

🎚 Setup:

This setup is for developers. If you're a normal user, you can find simpler instructions here.

1. Install Golang

2. Install Dependencies

  • go get -u ./... to recursively install all dependencies.

3. Test / Run

Since Regolith is a console application which requires very specific project setup and arguments, go run .\main.go doesn't really do anything.

You can build and install Regolith from source using go install and test test the application in the same way as user would do, by using it on a separate Regolith project.

You can also write your own tests in the test directory. Here are some examples of useful test commands:

  • go test ./test - runs all of the tests from the test folder (we keep all of the test there)
  • go test ./test -v -run "TestRecycledCopy" - run only the "TestRecycledCopy" with verbose output.
  • dlv test ./test -- "-test.run" TestInstallAllAndRun - debug the "TestInstallAllAndRun" test using delve

🏗 Building as a .exe:

  • You can build either with GoReleaser, or natively

1. Install GoReleaser

  • go install github.com/goreleaser/goreleaser@latest

2. Build

There are a few ways to build:

  • go install (installs to gopath)
  • go build (creates a .exe file)
  • ./scripts/build-local.sh (¯_(ツ)_/¯)

regolith's People

Contributors

arexon avatar daanv2 avatar echelon101 avatar evilguy50 avatar hatchibombotar avatar ink0rr avatar juneezee avatar laurhinch avatar luminoso-256 avatar majestikbutter avatar medicaljewel105 avatar nusiq avatar retr0cube avatar simon-losier avatar sirlich avatar stirante avatar thijshankelmc avatar unkn0wncat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

regolith's Issues

Create system that minifies json, and passes it in as an argument

As per the title. This would be completely optional, and of course not all filters would even HAVE settings, but I think its really nice:

{
    "run_with": "python",
    "location": "./credit_creator.py",
    "name": "Credit Creator",
    "settings": {
        "identifier": "sirlich"
    }
}

Gets called like:
python -u credit_creator.py '{"identifier":"sirlich"}'

Write run-target for online-filters.

More details in #5 and #7.

This filter-type will allow the user to specify an arbitrary URL (or do we confine to github?), that will install the folder into .regolith/cache, with some name-spacing.

Relies on the use of regolith install. Please see #5

Rewrite readme.md

Consider moving existing readme into running.md or something.

We need to explain what Regolith is, whats completed (broadly), and whats still left to do (broadly). We can provide links to the example project (say its private), and then also to the public filters.

Add default `data` path

As Regolith becomes more complex, its clear that the data folder needs to be made required, or at least default.

I suggest packs/data but does anyone have another preferred path?

Should be created with regolith init and also set into the default config.json

Improve error messaging: no more tracebacks for Regolith-handled errors.

Related to #22.

We need to provide a traceback of course, if requested, but many of our errors are currently producing a tracback, even when they really shouldn't.

For example, running regolith run without regolith init will cause a very yucky error, that is difficult to interpret. In these cases, we should write a clear, concise error, with instructions on what to do next:

image

Merge filter definition with remote filter, when calling

This will allow properties set inside of the config.json to be read and understood by the downloaded filter, when running.

Code for this currently exists for the settings key, but we should expand this solution for all keys inside of filters.

Optional filter argument for ordering the input arguments.

Right now, there is an opinionated ordering:

  1. script
  2. settings (merged)
  3. external arguments (in remote filter)
  4. internal arguments (set inside of the config.json locally)

This is "fine", but we may need extra power sometimes.

We can create a new field called "argumentOrder" like this:

"argumentOrder": "${script} ${settings} ${localArguments} ${remoteArguments}"

If argument order exists, the command should be built by find-and-replacing the values into the argument order.

Rework project system to use project-config-standard

https://github.com/bridge-core/project-config-standard

Example config:

{
    "type": "minecraftBedrock",
    "name": "Test",
    "namespace": "sirlich",
    "author": "sirlich",
    "targetVersion": "1.16.0",
    "description": "",
    "regolith": {
        "profiles": {
            "dev": {
                "export": {
                    "target": "development"
                },
                "filters": [
                    {
                        "run_with": "python",
                        "location": "./filters/kra_convert.py"
                    },
                    {
                        "run_with": "python",
                        "location": "./filters/flat_features.py"
                    },
                    {
                        "run_with": "python",
                        "location": "./filters/languages.py"
                    },
                    {
                        "run_with": "python",
                        "location": "./filters/debug_molang/debug_molang.py",
                        "settings": {
                            "places": 5
                        }
                    }
                ],
                "unsafe": false
            }
        }
    },
    "packs": {
        "behaviorPack": "./BP",
        "resourcePack": "./RP"
    }
}

Things to discuss about "world" export target

I implemented the "world" export target (for issue #14) but we haven't decide how to handle some cases. Current implementation is very simple.

The "world" export target requires exactly one of the two properties "worldPath" or "worldName". Providing both of them will result in an error.

Problems

  1. In current implementation "worldPath" can lead anywhere. It just creates the some additional folders in that path and exports files there. The folders are "<worldPath>/behavior_packs/<project_name>_bp" and "<worldPath>/resource_packs/<project_name>_rp". I'm not sure if that's ok. Maybe the export path should be relative to .../com.mojang/minecraftWorlds folder?
  2. The exporter doesn't create the behavior_packs.json and resource_packs.json in the world. Maybe it should?
  3. If there is behavior_packs.json and/or resource_packs.json file in the world and it has a reference to an existing BP/RP should the exporter export files to the path of that reference? What if the file points at a pack inside development_behavior_packs/development_resource_packs.

Design format + write logic for export locations

Can build upon the base in minecraft_utils.go.

I guess we want these targets:

  • exact (filepath)
  • dev packs (requires a definition for the name of the RP and the BP, after exporting)
  • world (same req as above)
  • none (just leave in build)

Add data folder for custom data of the filters

It would be nice to have "data" path for regolith which should be copied to the working directory with RP and BP.

  • The folder will be copied inot .tmp/data during runtime.
  • The profile will have a new dataPath property with a path relative to the root of the project that points at the data folder

[Design decision] Handling virtual environments for Python

This issue will be used as a thread to discuss the possible changes to venvPath setting.

Current implementation

Regolith config.json file has currently 4 depth levels.

  1. Root - defined by the Bedrock-OSS/project-config-standard
  2. "regolith" - the root of the regolith configuration
  3. "profiles" - a list of profiles. A profile is a single task that you can trigger with regolith run command
  4. "filters" - a filter is a single action within the profile (it can be a python, js or shell script)

Currently the venvPath is a property of a profile. Adding that configuration to the file will cause creation of a single python environment for all filters in the profile. Skipping that property will (the default behavior) creates separate venv for every filter in .regolith/cache/<filter path>/venv.

venvPath can be either relative or absolute path. If user choose to put relative path in there it will create the virtual environment in a path relative to .regolith/venvs/.

Problems

1. Where in the config.json should we put the venvPath property

1.1. It should be the property for entire project (inside "regolith")
1.2 It should be the property of a profile (regolith -> profiles -> [profile name]). This is the current solution.
1.3 It should be the proprety of a filter (regolith -> profiles -> -> filters -> [filter name]).

2. If the path is relative, what should be the root

2.1. .regolith/venvs/<user path> - This is the current solution
2.2. .regolith/cache/<user path> - The problem of this solution is that we already use .regolith/cache/<filter name> for caching filters. If someone choose to name the venv the same as the filter it could create some collisions.
2.3 .regolith/cache/venvs/<user path> - with this solution i suggest moving the filter cache from .regolith/cache/<filter name> to .regolith/cache/filters/<filter name>.

3. What should be the default behavior

3.1. Separate venv for every filter - This is the current solution
3.2. Separate venv for every profile
3.3. Everything should use single venv

4. Should we allow absolute paths

4.1. Yes
4.2. No

Investigate installing regolith

What does it look like to download and use regolith for the random user?

Can they rely on regolith gopath thing, or do they need to include an .exe in every project.

What can we do to make this process awesome and easy?

Remove `build` folder as a default export

Right now, the build folder is created for all export targets, which doesn't make much sense.

  • Rename none to local
  • Remove build directory for all export targets that are not local
  • Improve efficiency of export by using a MOVE not a COPY (doesn't apply to local)

Build regolith test bed

This means setting up a proper testing suite, which will test Regolith. We can trigger this as part of CI.

Regolith cannot be used without git

What do we want to do here?

Could not install dependency github.com/Bedrock-OSS/regolith-filters//texture_list: error downloading 'https://github.com/Bedrock-OSS/regolith-filters.git': git must be available and on the PATH

Write security system, for protecting users from RCE.

We need to fully define the different security levels. Currently the possible run-types are: (in order of safety)

  • Standard Library
  • Local Filters
  • Online Filters

Local is dangerous cause somebody can say "please put this here, and then run X". Its safer than online filters though, because the user at least has to handle the source, and could peek inside.

Online filters could also be compromised, which is why we cache by default, and require a regolith install --force (or another command -syntax isn't 100% decided yet) to flush them + redownload.


We need to make the user agree to some kind of "I understand the risks" clause. Of course, we cannot just store this inside of the regolith.json, because then somebody could simply have it pre-checked (like the MC server EULA).

We should instead look into storing the "regolith safety level" somewhere else.

Add notification about remote filter releases?

We could store the git SHA of the installed commit, and then do a quick check to see if anything needs to be updated?

Not sure if better to auto-run when compiling, or add a check command?

The default rn is that filters will easily get out-dated, since even running regolith install will skip satisfied dependencies. You have to manually delete (or did we add command to clear out the tmp directory?) before reinstalling.

Method for downloading folder from github

This will be used for storing online-filters in the .regolith/cache (do we want a different folder name?).

The start of this can be found in remote_filters.go. I found a library (go-getter) that looks like it should do the job.

As Stirante pointed out, we probably want to use some kind of name-spacing of folders:
.regolith/cache/github.com/bedrock-OSS/filters/texture_list/....

The data flow:

  • An 'online' filter specifies a URL where the filter is located
  • If the filter exists in the cache, use it
  • If the filter does NOT exist in the cache, throw a warning, and say: please run 'regolith install', or 'regolith run -- install.
  • Installing should run through every profile, and install everything by unpacking the folder into the correct namespace.

Write standalone installer for python

Some systems may not have python installed, or may have the wrong version. We should install a stand-alone python version if this missmatch exists.

Write "recycle bin" for Regolith

Should be a folder in .regolith where stuff is copied when moved/deleted.

This will make regolith slower, but safer. Should be configured in config.json

Add notification about new release

When running regolith, it should check whether there is a newer version of regolith available. We can limit it only to regolith install because if filter definition changes, it would make easier for the user to try updating regolith.

Write run-target for javascript.

Our current implementation is pretty strict in what can be run. Right now, only Python.

The reason we have unique run-targets for each language instead of just running arbitrary shell command is because its safer, and because it allows us to add additional logic as-needed, for example -u for python to enforce the buffer to flush.

Possible error in InstallDependency logic

I'm not fixing that because I don't understand the intention behind that code and maybe I'm missing something important but possibly there is an error in the logic of this function:

// Check whether filter, that the user wants to run meet the requirements
checked := map[string]bool{}
for _, filter := range result.Filters {
if filter.RunWith != "" {
if c, ok := checked[filter.RunWith]; ok || !c {
if f, ok := FilterTypes[filter.RunWith]; ok {
checked[filter.RunWith] = true
f.install(filter, path)
} else {
Logger.Warnf("Filter type '%s' not supported", filter.RunWith)
}
}
}
}

On line 100 there is an the condition used in if statement will always return true. The values in checked map are at that point either missing or true.

  • CASE 1: checked[filter.RunWith] exists -> ok == true AND c == true -> ok || !c == true
  • CASE 2: checked[filter.RunWith] is missing-> ok == false AND c == false -> ok || !c == true
    ok || !c is always true.

Regolith doesn't create the .regolith path

Logs from running regolith.exe in clean regolith-project

PS D:\Golang\regolith-project\regolith-project> regolith.exe run
[INFO]  Running profile: dev
[DEBUG] Cleaning .regolith/tmp and build folders
[INFO]  Running filter 'Delete Blocks'
{error 26 0  chdir D:\Golang\regolith-project\regolith-project\.regolith\tmp: The system cannot find the path specified.}
bedrock-oss.github.com/regolith/src.RunSubProcess
        D:/Golang/regolith-project/regolith-github-repo/src/filters.go:109
bedrock-oss.github.com/regolith/src.RunPythonFilter
        D:/Golang/regolith-project/regolith-github-repo/src/filters.go:97
bedrock-oss.github.com/regolith/src.RunFilter
        D:/Golang/regolith-project/regolith-github-repo/src/filters.go:88
bedrock-oss.github.com/regolith/src.RunProfile
        D:/Golang/regolith-project/regolith-github-repo/src/filters.go:68
main.main.func2
        D:/Golang/regolith-project/regolith-github-repo/main.go:57
github.com/urfave/cli/v2.(*Command).Run
        C:/Users/Laptop/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:163
github.com/urfave/cli/v2.(*App).RunContext
        C:/Users/Laptop/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:313
github.com/urfave/cli/v2.(*App).Run
        C:/Users/Laptop/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:224
main.main
        D:/Golang/regolith-project/regolith-github-repo/main.go:85
runtime.main
        D:/programs/Go/src/runtime/proc.go:225

Write log-levels system

Currently, we debug everything. We should have some log-levels defined, and we can select what level we want in regolith.json.

Maybe Error, Warning, Log, Verbose, VeryVerbose?

Write run-target for regolith standard-filters library.

Most online filters need to be specified via URL, but the standard library can be accessed via name.

Write the logic that allows you to specify a short-name like "texture_list", and have it automatically resolve into the correct github URL, to be treated like a normal online-filter.

We can make a few assumptions here, like the repo name, the organization name, and the fact that all filters must be placed at the top level of the project (or do we want to organize filters different? Open question.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.