### Install and Run Regolith Docs Locally Source: https://github.com/bedrock-oss/regolith/blob/main/docs/readme.md Follow these commands to install dependencies and start the local development server for the Regolith documentation. ```bash cd docs npm install npm run docs:dev ``` -------------------------------- ### CI/CD Pipeline Setup with Regolith Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/README.md Prepare a CI/CD pipeline by installing dependencies with `regolith install-all` and compiling for production with `regolith run release`. ```bash regolith install-all # Install all dependencies regolith run release # Compile for production # Zip and upload build artifacts ``` -------------------------------- ### Complete User Configuration Example Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/user-config.md An example of a complete user_config.json file, demonstrating various configuration options. ```json { "use_project_app_data_storage": false, "username": "Developer", "resolvers": [ "github.com/Bedrock-OSS/regolith-filter-resolver", "github.com/MyOrg/my-filter-resolver" ], "resolver_cache_update_cooldown": "24h", "filter_cache_update_cooldown": "168h", "tmp_dir": "/tmp/regolith", "node_runner_override": { "node": "bun" }, "python_runner": "/usr/bin/python3.11", "node_runner": "/usr/bin/node", "npm_runner": "/usr/bin/npm", "deno_runner": "/home/user/.deno/bin/deno", "bun_runner": "/home/user/.bun/bin/bun", "java_runner": "/usr/bin/java", "dotnet_runner": "/usr/bin/dotnet", "nim_runner": "/usr/bin/nim", "nimble_runner": "/usr/bin/nimble" } ``` -------------------------------- ### Install Specific Filters Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/main-api.md Use `Install` to download and install specific filters. You can specify versions, force reinstallation, refresh caches, and target specific profiles. It also supports loading a custom environment file. ```go err := regolith.Install( []string{"name_ninja==1.0.0"}, false, // force false, // refreshResolvers false, // refreshFilters []string{"default"}, false, // debug "", // env ) ``` -------------------------------- ### Async Filter Configuration Example Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/filter-types.md Example JSON configuration for an AsyncFilter, listing filters to be run concurrently. ```json { "filter": "async", "settings": { "filters": ["filter1", "filter2"] } } ``` -------------------------------- ### Initialize Regolith Project and Install Filter Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/README.md Use 'regolith init' to create a new project and 'regolith install' to add a filter. Ensure the filter name is valid. ```bash regolith init # Create new project regolith install name_ninja # Install a filter ``` -------------------------------- ### Complete Example config.json Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/configuration.md This is a comprehensive example of a `config.json` file, demonstrating various settings for project name, packs, Regolith configuration including format version, data paths, filter definitions, and multiple profiles with different filter and export settings. ```json { "name": "My Add-on", "author": "Me", "packs": { "behaviorPack": "BP", "resourcePack": "RP" }, "regolith": { "formatVersion": "1.8.0", "dataPath": "data", "watchPaths": ["BP", "RP", "data"], "filterDefinitions": { "name_ninja": { "url": "github.com/Bedrock-OSS/regolith-filters/name_ninja", "version": "latest" }, "my_python_filter": { "path": "local_filters/python_filter" } }, "profiles": { "default": { "filters": [ { "filter": "name_ninja", "arguments": ["BP", "RP"], "settings": { "mode": "replace" } }, { "filter": "my_python_filter", "disabled": false } ], "export": { "target": "develop", "build": "standard", "rpName": "My RP", "bpName": "My BP" }, "preShell": ["echo Building..."], "postShell": ["echo Done!"] }, "debug": { "filters": [ { "filter": "name_ninja", "arguments": ["BP", "RP"] } ], "export": { "target": "local", "rpName": "My RP Debug", "bpName": "My BP Debug" } } } } } ``` -------------------------------- ### Initialize Logging System Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Sets up the zap logger with appropriate levels and formatting. This should be called once at program start. ```go func InitLogging(dev bool) ``` ```go regolith.InitLogging(true) // dev=true enables debug logging defer regolith.ShutdownLogging() ``` -------------------------------- ### Install Dependencies Source: https://github.com/bedrock-oss/regolith/blob/main/README.md Recursively install all project dependencies using Go. This command is essential for developers setting up the Regolith project. ```bash go get -u ./ ... ``` -------------------------------- ### Check Git Installation Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/errors.md Confirm that Git is installed and accessible in your environment by checking its version. This is a prerequisite for many filter installations. ```bash git --version ``` -------------------------------- ### GitHub Actions CI/CD Pipeline Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/integration-guide.md Example GitHub Actions workflow for building and testing Regolith configurations. Includes installing Regolith, running builds, and uploading artifacts. ```yaml name: Build on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Install Regolith run: | wget https://github.com/Bedrock-OSS/regolith/releases/download/.../regolith-linux-amd64 chmod +x regolith-linux-amd64 - name: Build run: ./regolith-linux-amd64 run production - name: Upload Artifacts uses: actions/upload-artifact@v2 with: name: addon path: build/ ``` -------------------------------- ### Install or Update All Defined Filters Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/main-api.md Use `InstallAll` to install or update all filters listed in your `config.json`. It supports forceful reinstallation, updating to the latest stable versions, and refreshing filter caches. It can also load a custom environment file. ```go err := regolith.InstallAll(false, false, false, false, "") ``` -------------------------------- ### Profile Filter Configuration Example Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/filter-types.md Example JSON configuration for a ProfileFilter, specifying a nested profile to execute. ```json { "profiles": { "default": { "filters": [ { "filter": "nested_profile_name" } ] } } } ``` -------------------------------- ### Install GoReleaser Source: https://github.com/bedrock-oss/regolith/blob/main/README.md Install the latest version of GoReleaser, a tool for automating release processes. This is a prerequisite for using the local build script. ```bash go install github.com/goreleaser/goreleaser@latest ``` -------------------------------- ### Profile Execution Error: Filter Check Failed (Python Example) Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/errors.md This error indicates that filter dependencies, such as Python, are not met. Install the required runtime or interpreter to resolve this. The specific message may vary based on the missing dependency. ```Text Filter check failed. Filter: ``` ```Text Python is not installed ``` ```Text Node.js is not installed ``` ```Text Java is not installed ``` -------------------------------- ### Filter Installation Error: Filter Already Installed Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/errors.md This error occurs when attempting to install a filter that is already present, without using the '--force' or '--update' flag. Use the appropriate flag to either force the installation or update the existing filter. ```Text The filter is already on the filter definitions list. Filter: If you want to force the installation, please add '--update' flag ``` -------------------------------- ### FilterInstaller Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/types.md Interface for filter installation and creation, defining methods to manage filter dependencies and execution setup. ```APIDOC ## FilterInstaller Interface for filter installation and creation. ### Methods - `InstallDependencies(parent *RemoteFilterDefinition, dotRegolithPath string) error` - Installs filter dependencies (Python venv, npm packages, etc.) - `Check(context RunContext) error` - Verifies filter requirements are met - `CreateFilterRunner(runConfiguration map[string]any, id string) (FilterRunner, error)` - Creates a FilterRunner instance for execution ``` -------------------------------- ### Packs Configuration Example Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/configuration.md Specifies the paths to the behavior pack and resource pack source folders. Paths are relative to the project root. ```json { "packs": { "behaviorPack": "BP", "resourcePack": "RP" } } ``` -------------------------------- ### Install All Filters for CI/CD Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/integration-guide.md Installs all filters defined in your project's configuration, typically used in CI/CD environments to ensure all dependencies are met before compilation. ```bash # Install filters (once per CI run) regolith install-all ``` -------------------------------- ### InitLogging Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Initializes the logging system. This function sets up the zap logger with the appropriate level and formatting. It should be called once at program start. ```APIDOC ## InitLogging ### Description Initializes the logging system. Sets up zap logger with appropriate level and formatting. Call once at program start. ### Function Signature ```go func InitLogging(dev bool) ``` ### Example ```go regolith.InitLogging(true) // dev=true enables debug logging defer regolith.ShutdownLogging() ``` ``` -------------------------------- ### Filter Installation Error: Git Not Installed Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/errors.md This is a warning indicating that Git is not installed on the system, which is required for downloading remote filters. Download Git from https://git-scm.com/downloads to resolve this. ```Text Git is not installed. Git is required to download filters. You can download Git from https://git-scm.com/downloads ``` -------------------------------- ### Install Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/main-api.md Downloads and installs filters from the internet, adding them to the `filterDefinitions` list in `config.json`. It supports specifying filter versions, forcing reinstallation, and refreshing resolver/filter caches. Profiles can also be specified. ```APIDOC ## Install ### Description Downloads and installs filters from the internet, adding them to the `filterDefinitions` list in `config.json`. It supports specifying filter versions, forcing reinstallation, and refreshing resolver/filter caches. Profiles can also be specified. ### Function Signature ```go func Install(filters []string, force bool, refreshResolvers bool, refreshFilters bool, profiles []string, debug bool, env string) error ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Table | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | filters | []string | yes | N/A | List of filters to install in format ``, `==`, or `` | | force | bool | yes | false | Force installation even if filter already exists | | refreshResolvers | bool | yes | false | Force refresh of resolver repositories | | refreshFilters | bool | yes | false | Force refresh of filter cache | | profiles | []string | yes | []string{} | List of profile names to add filter to; uses "default" if empty | | debug | bool | yes | false | Enable debug logging output | | env | string | yes | "" | Path to custom .env file to load | ### Returns `error` - Error if installation fails, nil on success ### Behavior Parses install arguments and downloads specified filters. Filter versions can be specified as: - Semantic version (e.g., `1.2.3`) - `latest` keyword (searches for latest version tag) - `HEAD` keyword (uses latest main branch SHA) - Git commit SHA - Git tag name If no version is specified, tries `latest` first, then falls back to `HEAD`. ### Example ```go err := regolith.Install( []string{"name_ninja==1.0.0"}, false, // force false, // refreshResolvers false, // refreshFilters []string{"default"}, false, // debug "", // env ) ``` ``` -------------------------------- ### Regolith Configuration Example Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/README.md Edit 'config.json' to define project settings, including filter chains and export targets for profiles. ```json { "regolith": { "formatVersion": "1.8.0", "profiles": { "default": { "filters": [{"filter": "name_ninja"}], "export": {"target": "develop", "build": "standard"} } } } } ``` -------------------------------- ### Install Filter Dependencies Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/execution-system.md Installs dependencies for various filter types based on their configuration files (e.g., requirements.txt for Python, package.json for Node.js). ```go func (fi FilterInstaller) InstallDependencies( parent *RemoteFilterDefinition, dotRegolithPath string, ) error ``` -------------------------------- ### Install Regolith Filters Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/integration-guide.md Installs specified filters for your project. Ensure you have configured the filters in your config.json. ```bash # Install filters regolith install name_ninja ``` -------------------------------- ### Get Exact Export Paths Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Retrieves export paths for exact mode. ```go func GetExactExportPaths(exportTarget ExportTarget) (string, string, error) ``` -------------------------------- ### Profile Configuration Example Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/configuration.md Defines an execution profile, including the ordered list of filters to apply, export targets, and optional pre/post shell commands. ```json { "profiles": { "default": { "filters": [ { "filter": "filter_name", "description": "Display name", "disabled": false, "arguments": ["arg1", "arg2"], "settings": { "setting_key": "value" }, "when": "condition_expression", "extraArguments": "ignore" } ], "export": { "target": "develop", "build": "standard", "rpName": "My Resource Pack", "bpName": "My Behavior Pack" }, "preShell": ["echo Starting"], "postShell": ["echo Done"] } } } ``` -------------------------------- ### Gitignore Configuration Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/integration-guide.md Example `.gitignore` file content for a Regolith project, excluding build outputs, caches, and development artifacts. ```text # Build outputs build/ dist/ # Cache (use project storage) .regolith/ # User-specific (use app data storage) # .regolith already ignored above # Development artifacts *.tmp *.log ``` -------------------------------- ### Setup Temporary Files for Filter Execution Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/execution-system.md Prepares the temporary workspace for filter execution by creating and copying necessary directories. It can also create symlinks to export paths if enabled. ```go func SetupTmpFiles(context RunContext) error ``` -------------------------------- ### Executable Filter Configuration Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/filter-types.md Example JSON configuration for an Executable filter, specifying the path to the filter directory. ```json { "filterDefinitions": { "my_exe_filter": { "path": "local_filters/my_filter" } } } ``` -------------------------------- ### Filter Nesting Configuration Example Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/execution-system.md Shows how to configure filter nesting, where one profile can reference another. This allows for modularity and reuse of filter configurations. ```json { "profile1": { "filters": [ {"filter": "some_filter"}, {"filter": "profile2"} ] }, "profile2": { "filters": [ {"filter": "another_filter"} ] } } ``` -------------------------------- ### .NET Filter Configuration Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/filter-types.md Example JSON configuration for a .NET filter, specifying the path to the filter directory. ```json { "filterDefinitions": { "my_dotnet_filter": { "path": "local_filters/my_filter" } } } ``` -------------------------------- ### Get Development Export Paths Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Retrieves export paths for development or packs mode. ```go func GetDevelopmentExportPaths(bpName, rpName, comMojang string) (string, string, error) ``` -------------------------------- ### Initialize a New Regolith Project Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/integration-guide.md Use this command to set up a new Regolith project. After initialization, you will need to edit the config.json file with your specific settings and then install any necessary filters. ```bash # Initialize new project regolith init ``` -------------------------------- ### Bun Filter Configuration Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/filter-types.md Example JSON configuration for a Bun filter, specifying the path to the filter directory. ```json { "filterDefinitions": { "my_bun_filter": { "path": "local_filters/my_filter" } } } ``` -------------------------------- ### Regolith Configuration Example Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/configuration.md Contains Regolith-specific settings, including format version, data path, paths to watch, filter definitions, and execution profiles. ```json { "regolith": { "formatVersion": "1.8.0", "dataPath": "data", "watchPaths": ["BP", "RP", "data"], "filterDefinitions": {}, "profiles": {} } } ``` -------------------------------- ### FilterInstaller Interface Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/types.md Interface for filter installation and creation. Implementations handle dependency management and filter runner creation. ```go type FilterInstaller interface { InstallDependencies(parent *RemoteFilterDefinition, dotRegolithPath string) error Check(context RunContext) error CreateFilterRunner(runConfiguration map[string]any, id string) (FilterRunner, error) } ``` -------------------------------- ### Nim Filter Configuration Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/filter-types.md Example JSON configuration for a Nim filter, specifying the path to the filter directory. ```json { "filterDefinitions": { "my_nim_filter": { "path": "local_filters/my_filter" } } } ``` -------------------------------- ### InstallDependencies Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Installs filter dependencies such as virtual environments and packages. This function handles filter-type-specific dependency installation, including Python venvs, Node packages, Java compilation, and Deno imports. ```APIDOC ## InstallDependencies ### Description Installs filter dependencies (venvs, packages, etc.). Filter-type-specific dependency installation: - Python: Creates venv, installs from requirements.txt - Node/Bun: Runs npm install from package.json - Java: Compiles if needed - Deno: Uses import maps - etc. ### Method ```go func (fi FilterInstaller) InstallDependencies(parent *RemoteFilterDefinition, dotRegolithPath string) error ``` ``` -------------------------------- ### Typical .gitignore for Regolith Projects Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/configuration.md This example shows common entries for a `.gitignore` file in a Regolith project, ensuring that generated cache and build directories, as well as Minecraft's `com.mojang` folder, are not tracked by version control. ```text .regolith/ build/ com.mojang/ ``` -------------------------------- ### Gitattributes Configuration for Line Endings Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/integration-guide.md Example `.gitattributes` file to ensure consistent line endings (LF) for configuration files like JSON, Python, JavaScript, and shell scripts. ```text # Ensure consistent line endings in configs *.json text eol=lf *.py text eol=lf *.js text eol=lf *.sh text eol=lf ``` -------------------------------- ### Shell Filter Configuration Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/filter-types.md Example JSON configuration for a Shell filter, specifying the path to the filter directory. ```json { "filterDefinitions": { "my_shell_filter": { "path": "local_filters/my_filter" } } } ``` -------------------------------- ### Java Filter Configuration Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/filter-types.md Example JSON configuration for a Java filter, specifying the path to the filter directory. ```json { "filterDefinitions": { "my_java_filter": { "path": "local_filters/my_filter" } } } ``` -------------------------------- ### InstallAll Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/main-api.md Installs or updates all filters defined in the `filterDefinitions` list of `config.json`. It can forcefully reinstall filters or update them to the latest stable version. The filter cache can also be refreshed. ```APIDOC ## InstallAll ### Description Installs or updates all filters defined in the `filterDefinitions` list of `config.json`. It can forcefully reinstall filters or update them to the latest stable version. The filter cache can also be refreshed. ### Function Signature ```go func InstallAll(force bool, update bool, debug bool, refreshFilters bool, env string) error ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Table | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | force | bool | yes | false | Forcefully reinstall every filter | | update | bool | yes | false | Update remote filters to latest stable version | | debug | bool | yes | false | Enable debug logging output | | refreshFilters | bool | yes | false | Force refresh of filter cache | | env | string | yes | "" | Path to custom .env file to load | ### Returns `error` - Error if installation fails, nil on success ### Behavior By default, filters already installed with correct version are ignored. With `force=true`, all filters are reinstalled. With `update=true`, remote filters are updated to their latest available versions. ### Example ```go err := regolith.InstallAll(false, false, false, false, "") ``` ``` -------------------------------- ### Check Network Connectivity Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/errors.md Before troubleshooting filter installation, verify your network connection by pinging a reliable external host like github.com. ```bash ping github.com ``` -------------------------------- ### Get Export Paths for Behavior and Resource Packs Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Determines the export paths for behavior and resource packs based on export configuration and format version. Handles different path resolution strategies for various format versions. ```Go func GetExportPaths(exportTarget ExportTarget, ctx RunContext) (bpPath string, rpPath string, err error) ``` ```Go bpPath, rpPath, err := regolith.GetExportPaths(exportTarget, context) ``` -------------------------------- ### Deno Filter Definition and Example Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/filter-types.md Defines a Deno filter that executes TypeScript/JavaScript filters using the Deno runtime. Configuration specifies the path to the filter directory. ```go type DenoFilterDefinition struct { FilterDefinition RunWith string } type DenoFilter struct { Filter Definition DenoFilterDefinition } ``` ```json { "filterDefinitions": { "my_deno_filter": { "path": "local_filters/my_filter" } } } ``` -------------------------------- ### Set npm Runner Path Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/user-config.md Specify the exact path to the npm executable. Used for installing Node.js filter dependencies. ```bash regolith config npm_runner "/usr/bin/npm" ``` -------------------------------- ### Filter Definitions Example Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/configuration.md Defines available filters, including remote filters specified by URL and version, and local filters specified by path. ```json { "filterDefinitions": { "my_filter": { "url": "github.com/Bedrock-OSS/regolith-filters/my_filter", "version": "1.0.0" }, "python_filter": { "path": "local_filters/py_filter" }, "node_filter": { "path": "local_filters/node_filter" } } } ``` -------------------------------- ### Remote Filter Definition and Example Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/filter-types.md Defines a remote filter that downloads and executes filters from remote repositories. Configuration specifies the URL and version. ```go type RemoteFilterDefinition struct { FilterDefinition Url string Version string VenvSlot int } type RemoteFilter struct { Filter Definition RemoteFilterDefinition } ``` ```json { "filterDefinitions": { "my_filter": { "url": "github.com/Bedrock-OSS/regolith-filters/my_filter", "version": "1.0.0" } } } ``` -------------------------------- ### Node.js Filter Definition and Example Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/filter-types.md Defines a Node.js filter that executes JavaScript filters using the Node.js runtime. Configuration specifies the path and optionally the Node.js executable. ```go type NodeJSFilterDefinition struct { FilterDefinition RunWith string } type NodeJSFilter struct { Filter Definition NodeJSFilterDefinition } ``` ```json { "filterDefinitions": { "my_node_filter": { "path": "local_filters/my_filter", "runWith": "/usr/bin/node" } } } ``` -------------------------------- ### View All Configuration Settings Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/user-config.md Use this command to display all current user configuration settings. ```bash regolith config ``` -------------------------------- ### View Configuration with Defaults Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/user-config.md Display all configuration settings, including default values for unset properties. ```bash regolith config --full ``` -------------------------------- ### Filter Installation Error: Filter Not Installed Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/errors.md This error occurs when a filter is referenced in a profile but has not been downloaded. Use the 'regolith install ' command to download the necessary filter files. ```Text Filter is not downloaded. You can download filter files using command: regolith install ``` -------------------------------- ### Python Filter Dependencies (requirements.txt) Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/integration-guide.md Lists the Python package dependencies required for the custom Python filter. Ensure these packages are installed before running the filter. ```text click>=8.0.0 colorama>=0.4.0 ``` -------------------------------- ### Python Filter Definition and Example Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/filter-types.md Defines a Python filter that executes Python scripts in an isolated virtual environment. Configuration includes the path to the filter and optionally the Python executable. ```go type PythonFilterDefinition struct { FilterDefinition RunWith string VenvSlot int } type PythonFilter struct { Filter Definition PythonFilterDefinition } ``` ```json { "filterDefinitions": { "my_python_filter": { "path": "local_filters/my_filter", "runWith": "/usr/bin/python3" } } } ``` -------------------------------- ### Filter Installation Error: Failed to Download Filter Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/errors.md This error occurs due to network issues or an invalid filter URL. Verify your network connection and ensure the filter name or URL is correct. ```Text Failed to download filter. Filter: ``` -------------------------------- ### Create Resource Pack Directory and File Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/integration-guide.md This snippet demonstrates how to create a directory structure for a resource pack and add an initial file. ```bash mkdir -p RP/textures/custom echo "Processing..." > RP/textures/custom/info.txt ``` -------------------------------- ### Initialize a New Regolith Project Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/main-api.md Use `Init` to create a new Regolith project structure. It can optionally force initialization and load a custom environment file. ```go err := regolith.Init(false, false, "") if err != nil { log.Fatal(err) } ``` -------------------------------- ### Verify Filter URL Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/errors.md Ensure the URL for a filter is correct and accessible by attempting to download its configuration file using `curl`. This helps diagnose installation failures. ```bash curl https://raw.githubusercontent.com/.../filter.json ``` -------------------------------- ### Get Absolute Working Directory for Filters Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Gets the absolute path to the temporary working directory used for filter execution. This path is typically .regolith/tmp but can be customized. ```Go func GetAbsoluteWorkingDirectory(dotRegolithPath string) (string, error) ``` ```Go tmpPath, err := regolith.GetAbsoluteWorkingDirectory(dotRegolithPath) ``` -------------------------------- ### Programmatically Set User Configuration Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/user-config.md Demonstrates how to create and modify a UserConfig object in Go, setting string, boolean, and array properties. ```go package main import "github.com/Bedrock-OSS/regolith/regolith" func main() { config := regolith.NewUserConfig() // Set string property username := "Developer" config.Username = &username // Set boolean property useAppData := true config.UseProjectAppDataStorage = &useAppData // Add to string array config.Resolvers = append( config.Resolvers, "https://example.com/resolver", ) } ``` -------------------------------- ### StartWatchingSourceFiles Method Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/execution-system.md Initiates file watching for specified directories, including behavior pack, resource pack, data, and custom watch paths. It sends notifications to the interruption channel when changes are detected. ```go func (c *RunContext) StartWatchingSourceFiles() error ``` ```go err := context.StartWatchingSourceFiles() if err != nil { return err } ``` -------------------------------- ### Init Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/main-api.md Initializes a new Regolith project in the current directory. It creates the basic project structure and configuration files. The `force` option allows overriding existing files, and `env` specifies a custom environment file. ```APIDOC ## Init ### Description Initializes a new Regolith project in the current directory. It creates the basic project structure and configuration files. The `force` option allows overriding existing files, and `env` specifies a custom environment file. ### Function Signature ```go func Init(debug bool, force bool, env string) error ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Table | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | debug | bool | yes | false | Enable debug logging output | | force | bool | yes | false | Force initialization even if files exist | | env | string | yes | "" | Path to custom .env file to load | ### Returns `error` - Error if initialization fails, nil on success ### Behavior Creates a new Regolith project structure with `config.json` file and empty RP, BP, data, and .regolith folders. When force is false, the command will fail if non-empty files are detected. When force is true, it will override potential safeguards. ### Example ```go err := regolith.Init(false, false, "") if err != nil { log.Fatal(err) } ``` ``` -------------------------------- ### Build Executable Natively Source: https://github.com/bedrock-oss/regolith/blob/main/README.md Create a native executable file for the Regolith project. This is a standard Go build command. ```bash go build ``` -------------------------------- ### GetAbsoluteWorkingDirectory Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Gets the absolute path to the working directory for filter execution. This is typically `.regolith/tmp` but can be customized. ```APIDOC ## GetAbsoluteWorkingDirectory ### Description Gets the absolute path to the working directory for filter execution. This is typically `.regolith/tmp` but can be customized via user config's `tmp_dir` setting. ### Method ```go func GetAbsoluteWorkingDirectory(dotRegolithPath string) (string, error) ``` ### Parameters #### Path Parameters - **dotRegolithPath** (string) - Required - Path to .regolith directory ### Response #### Success Response - **string** - Absolute path to working/tmp directory - **error** - Error if path cannot be determined ### Request Example ```go tmpPath, err := regolith.GetAbsoluteWorkingDirectory(dotRegolithPath) ``` ``` -------------------------------- ### Export Project Workflow Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/execution-system.md Outlines the steps involved in exporting a project for each active ExportTarget, including determining paths, validation, copying files, and updating manifests. ```go func ExportProject(context RunContext) error ``` -------------------------------- ### Load Configuration as Map Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Loads and parses config.json from the current directory, returning it as a generic map for flexible, dynamic property access. ```Go func LoadConfigAsMap() (map[string]any, error) ``` ```Go configMap, err := regolith.LoadConfigAsMap() if err != nil { log.Fatal(err) } ``` -------------------------------- ### Conditional Filter Execution Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/integration-guide.md Conditionally execute filters based on profile properties. This example disables a filter when the profile is 'production'. ```json "filters": [ { "filter": "dev_tools", "when": "profile != 'production'", "disabled": false } ] ``` -------------------------------- ### Performance Tuning for Fast Iteration Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/README.md Optimize for fast development iteration using `--symlink-export`, a RAM disk for temporary directories, or overriding the Node.js runner with Bun. ```bash # Fast iteration (development) regolith watch --symlink-export # No file copying regolith config tmp_dir "/run/user/uid" # RAM disk regolith config node_runner_override node bun # Faster JS ``` -------------------------------- ### Override Node.js Runner to Deno Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/user-config.md Configure Regolith to use Deno as the runtime for Node.js filters. Ensure Deno is installed and accessible. ```bash regolith config node_runner_override node deno ``` -------------------------------- ### Build Project with GoReleaser Source: https://github.com/bedrock-oss/regolith/blob/main/README.md Use a local script to build the Regolith project with GoReleaser. This script automates the release build process. ```bash ./scripts/build-local.sh ``` -------------------------------- ### Define Shell Commands with Platform Variants Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/types.md Represents shell commands with platform-specific variants. Allows defining commands for all platforms, or specific commands for Windows, Linux, and macOS. Includes methods for retrieving commands for the current OS and custom JSON marshaling. ```go type ShellCommands struct { All []string `json:"-"` Windows []string `json:"windows,omitempty"` Linux []string `json:"linux,omitempty"` Darwin []string `json:"darwin,omitempty"` } ``` -------------------------------- ### Get Filter Cache Path Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Retrieves the cache path for downloaded filters. This is essential for managing filter downloads and their storage locations. ```go func getFilterCache(url string) (string, error) ``` -------------------------------- ### Get Resolver Cache Path Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Retrieves the cache path for a given resolver. This function is part of the resolver and cache management system. ```go func getResolverCache(resolver string) (string, error) ``` -------------------------------- ### Run Regolith Profile Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/main-api.md Executes a Regolith profile with specified configurations. Use this for a single build process. ```go func Run(profileName string, extraFilterArgs []string, debug bool, env string, unsafeMode bool, symlinkExport bool, disableSizeTimeCheck bool) error ``` ```go err := regolith.Run( "default", []string{}, false, // debug "", // env false, // unsafeMode false, // symlinkExport false, // disableSizeTimeCheck ) ``` -------------------------------- ### Get Short Filter Name Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Extracts the short name from a full filter identifier. This function is used to simplify filter references. ```go func ShortFilterName(name string) string ``` -------------------------------- ### Create Environment Variables for Subprocess Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Prepares environment variables for filter subprocesses, including PATH and working directory settings. ```go func CreateEnvironmentVariables(filterDir string) ([]string, error) ``` -------------------------------- ### GetDevelopmentExportPaths Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Gets export paths for development/packs mode. This function retrieves the paths for behavior packs and resource packs when in development mode. ```APIDOC ## GetDevelopmentExportPaths ### Description Gets export paths for development/packs mode. ### Function Signature ```go func GetDevelopmentExportPaths(bpName, rpName, comMojang string) (string, string, error) ``` ### Returns - `(bpPath, rpPath, error)` ``` -------------------------------- ### Watch Regolith Profile Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/main-api.md Starts Regolith in watch mode to automatically re-run profiles on file changes. Ideal for development workflows. ```go func Watch(profileName string, extraFilterArgs []string, debug bool, env string, unsafeMode bool, symlinkExport bool, disableSizeTimeCheck bool) error ``` ```go err := regolith.Watch( "default", []string{}, false, // debug "", // env false, // unsafeMode false, // symlinkExport false, // disableSizeTimeCheck ) ``` -------------------------------- ### Verify Filter Directory Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/errors.md Check if the local directory for a specific filter exists and contains the necessary files. This is important when filters are not installed correctly. ```bash ls local_filters/my_filter/ ``` -------------------------------- ### View Specific Configuration Property Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/user-config.md Retrieve the value of a single configuration property. ```bash regolith config username ``` -------------------------------- ### Find Minecraft Preview com.mojang Directory Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Finds the com.mojang directory for the Minecraft Preview version. ```Go func FindPreviewDir(pathType ComMojangPathType) (string, error) ``` -------------------------------- ### Set Nimble Package Manager Path Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/user-config.md Specify the exact path to the Nimble package manager executable. Used for installing Nim filter dependencies. ```bash regolith config nimble_runner "/usr/bin/nimble" ``` -------------------------------- ### Symlink Export Configuration Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/execution-system.md Demonstrates the configuration for symlink export, where temporary directories are symlinked to export directories. This offers immediate reflection of changes but has OS and Minecraft version limitations. ```bash tmp/BP/ → (symlink) → export/BP/ tmp/RP/ → (symlink) → export/RP/ ``` -------------------------------- ### Create Filter Runner from Configuration Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Instantiates a FilterRunner based on filter configuration. It automatically selects the appropriate FilterRunner subtype (e.g., Python, Node) and is used during profile execution. ```go func (fi FilterInstaller) CreateFilterRunner(runConfiguration map[string]any, id string) (FilterRunner, error) ``` ```go runner, err := filterDef.CreateFilterRunner(filterConfig, "my_filter") ``` -------------------------------- ### GetExactExportPaths Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Gets export paths for exact mode. This function retrieves the paths for behavior packs and resource packs when using exact export mode. ```APIDOC ## GetExactExportPaths ### Description Gets export paths for exact mode. ### Function Signature ```go func GetExactExportPaths(exportTarget ExportTarget) (string, string, error) ``` ### Returns - `(bpPath, rpPath, error)` ``` -------------------------------- ### GetExportPaths Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Gets the export paths for behavior and resource packs based on export configuration. Handles different format versions and path resolution strategies. ```APIDOC ## GetExportPaths ### Description Gets the export paths for behavior and resource packs based on export configuration. Handles format version differences (v1.2.0, v1.4.0+) with different path resolution strategies. ### Method ```go func GetExportPaths(exportTarget ExportTarget, ctx RunContext) (bpPath string, rpPath string, err error) ``` ### Parameters #### Path Parameters - **exportTarget** (ExportTarget) - Required - Export target configuration - **ctx** (RunContext) - Required - Execution context ### Response #### Success Response - **bpPath** (string) - Path for behavior packs - **rpPath** (string) - Path for resource packs - **err** (error) - Error if paths cannot be determined ### Request Example ```go bpPath, rpPath, err := regolith.GetExportPaths(exportTarget, context) ``` ``` -------------------------------- ### Download and Parse Filter Definition Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Fetches and parses a filter definition from a remote repository. It returns the appropriate FilterInstaller implementation. ```go func FilterDefinitionFromTheInternet(url string, name string, version string) (FilterInstaller, error) ``` -------------------------------- ### GetDotRegolith Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Gets the path to the .regolith cache directory for the current project. It can return a path within the project directory or in user app data based on configuration. ```APIDOC ## GetDotRegolith ### Description Gets the path to the .regolith cache directory for the current project. If `use_project_app_data_storage` is enabled in user config, returns path in user app data instead of project directory. The path is computed from a hash of the project root. ### Method ```go func GetDotRegolith(projectRoot string) (string, error) ``` ### Parameters #### Path Parameters - **projectRoot** (string) - Required - Path to project root directory ### Response #### Success Response - **string** - Absolute path to .regolith directory - **error** - Error if path cannot be determined ### Request Example ```go dotRegolithPath, err := regolith.GetDotRegolith(".") if err != nil { log.Fatal(err) } ``` ``` -------------------------------- ### Run Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/main-api.md Executes Regolith using the specified profile. It loads the profile, sets up a temporary workspace, runs filters, and exports compiled files. If no profile name is provided, it defaults to 'default'. ```APIDOC ## Run ### Description Executes Regolith using the specified profile. Loads the profile from config.json, sets up temporary workspace, runs all filters in sequence, and exports compiled files to the specified export targets. If profileName is empty, uses the "default" profile. ### Function Signature ```go func Run(profileName string, extraFilterArgs []string, debug bool, env string, unsafeMode bool, symlinkExport bool, disableSizeTimeCheck bool) error ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Table | Parameter | Type | Required | Default | Description | |---|---|---|---|---| | profileName | string | yes | "" | Name of profile to run; uses "default" if empty | | extraFilterArgs | []string | yes | []string{} | Additional arguments to pass to filters | | debug | bool | yes | false | Enable debug logging output | | env | string | yes | "" | Path to custom .env file to load | | unsafeMode | bool | yes | false | Disable file protection safety checks for faster exports | | symlinkExport | bool | yes | false | Create symlinks from tmp directory to export target | | disableSizeTimeCheck | bool | yes | false | Disable size and modification time check optimization | ### Returns `error` - Error if execution fails, nil on success ### Example ```go err := regolith.Run( "default", []string{}, false, // debug "", // env false, // unsafeMode false, // symlinkExport false, // disableSizeTimeCheck ) ``` ``` -------------------------------- ### View All Filter Resolvers Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/user-config.md Display the complete list of filter resolver URLs currently configured. ```bash regolith config resolvers --full ``` -------------------------------- ### Typical Regolith Project File Structure Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/configuration.md This outlines the standard directory layout for a Regolith project, including locations for project configuration, behavior and resource pack sources, filter data, local filter implementations, cache, and build outputs. ```text project/ ├── config.json # Project configuration ├── BP/ # Behavior pack source │ ├── manifest.json │ ├── functions/ │ └── ... ├── RP/ # Resource pack source │ ├── manifest.json │ ├── textures/ │ └── ... ├── data/ # Data folder for filters ├── local_filters/ # Local filter implementations │ ├── my_filter/ │ │ ├── main.py │ │ └── filter.json │ └── ... ├── .regolith/ # Cache (generated, .gitignore'd) │ ├── cache/ │ │ ├── filters/ │ │ └── resolvers/ │ └── tmp/ ├── build/ # Build outputs (generated, .gitignore'd) │ ├── BP/ │ └── RP/ └── .gitignore ``` -------------------------------- ### Add Custom Filter Resolver Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/user-config.md Append a new filter resolver URL to the list of repositories Regolith searches when installing filters by name. Resolvers are searched in the order they appear. ```bash regolith config resolvers "https://github.com/MyOrg/my-resolver" --append ``` -------------------------------- ### Run Git Command Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Executes a git command and returns its output lines. This is used for filter version resolution and updates. ```go func RunGitProcess(args []string, workingDir string) ([]string, error) ``` -------------------------------- ### Check All Regolith Resolvers Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/user-config.md Displays a full list of configured resolvers, useful for troubleshooting 'Resolver not found' errors. ```bash # Check resolvers: regolith config resolvers --full ``` -------------------------------- ### Filter 'when' Expression Example Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/configuration.md Illustrates how to use conditional expressions for filter execution. Filters will only run if the 'when' expression evaluates to true, allowing for profile-specific or debug-dependent execution. ```json { "when": "profile == 'development' && debug == 'true'" } ``` -------------------------------- ### Watch Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/main-api.md Starts Regolith in watch mode, automatically re-running the 'Run' command when source files change. It monitors specified paths and triggers execution upon detection of modifications. ```APIDOC ## Watch ### Description Starts Regolith in watch mode, automatically running when source files change. Monitors changes in project RP, BP, and data folders (as specified in config's watchPaths). When changes are detected, automatically triggers the `Run` command with the specified profile. Continues watching until process is interrupted. ### Function Signature ```go func Watch(profileName string, extraFilterArgs []string, debug bool, env string, unsafeMode bool, symlinkExport bool, disableSizeTimeCheck bool) error ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Table | Parameter | Type | Required | Default | Description | |---|---|---|---|---| | profileName | string | yes | "" | Name of profile to watch; uses "default" if empty | | extraFilterArgs | []string | yes | []string{} | Additional arguments to pass to filters | | debug | bool | yes | false | Enable debug logging output | | env | string | yes | "" | Path to custom .env file to load | | unsafeMode | bool | yes | false | Disable file protection safety checks for faster exports | | symlinkExport | bool | yes | false | Create symlinks from tmp directory to export target | | disableSizeTimeCheck | bool | yes | false | Disable size and modification time check optimization | ### Returns `error` - Error if execution fails, nil on success ### Example ```go err := regolith.Watch( "default", []string{}, false, // debug "", // env false, // unsafeMode false, // symlinkExport false, // disableSizeTimeCheck ) ``` ``` -------------------------------- ### Enable Debug and Timings Logging Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/errors.md For maximum information during debugging, run Regolith with both the `--debug` and `--timings` flags. This provides detailed logs and performance metrics. ```bash regolith run --debug --timings ``` -------------------------------- ### FindPreviewDir Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Finds Minecraft Preview's com.mojang directory. ```APIDOC ## FindPreviewDir ### Description Finds Minecraft Preview's com.mojang directory. ### Method ```go func FindPreviewDir(pathType ComMojangPathType) (string, error) ``` ### Parameters #### Path Parameters - **pathType** (ComMojangPathType) - Required - Type of path: PacksPath, etc. ### Response #### Success Response - **string** - Path to preview com.mojang - **error** - Error if directory cannot be found ``` -------------------------------- ### Get Project .regolith Cache Directory Source: https://github.com/bedrock-oss/regolith/blob/main/_autodocs/utilities.md Retrieves the absolute path to the .regolith cache directory for the current project. It may return a path within user app data if configured. ```Go func GetDotRegolith(projectRoot string) (string, error) ``` ```Go dotRegolithPath, err := regolith.GetDotRegolith(".") if err != nil { log.Fatal(err) } ```