regolith

package
v0.0.0-...-85de330 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Functions related to user_config.json

Index

Constants

View Source
const ConfigFilePath = "config.json"
View Source
const EditedFilesPath = "cache/edited_files.json"
View Source
const GitIgnore = "/build\n/.regolith"
View Source
const StandardLibraryUrl = "github.com/Bedrock-OSS/regolith-filters"

Variables

View Source
var AvailableExperiments = map[Experiment]ExperimentInfo{
	SizeTimeCheck: {"size_time_check", sizeTimeCheckDesc},
}
View Source
var EnableTimings = false
View Source
var EnabledExperiments []string
View Source
var LoggerLevel zap.AtomicLevel
View Source
var Version = "unversioned"

Functions

func ApplyFilter

func ApplyFilter(filterName string, filterArgs []string, debug bool) error

ApplyFilter handles the "regolith apply-filter" command. ApplyFilter mode modifies RP and BP file in place (using source). The config and properties of the filter are passed via commandline.

func AreFilesEqual

func AreFilesEqual(a, b string) (bool, error)

AreFilesEqual compares files from two paths A and B and returns true if they're equal.

func CheckProfileImpl

func CheckProfileImpl(
	profile Profile, profileName string, config Config,
	parentContext *RunContext, dotRegolithPath string,
) error

func CheckSuspiciousLocation

func CheckSuspiciousLocation() error

func CheckUpdate

func CheckUpdate(version string, status chan UpdateStatus)

func Clean

func Clean(debug, userCache, filterCache bool) error

Clean handles the "regolith clean" command. It cleans the cache from the dotRegolithPath directory.

The "debug" parameter is a boolean that determines if the debug messages should be printed.

func CleanCurrentProject

func CleanCurrentProject() error

func CleanFilterCache

func CleanFilterCache() error

func CleanUserCache

func CleanUserCache() error

func CopyFile

func CopyFile(source, target string) error

CopyFile copies a file from source to target. If it's necessary it creates the target directory.

func CreateEnvironmentVariables

func CreateEnvironmentVariables(filterDir string) ([]string, error)

CreateEnvironmentVariables creates an array of environment variables including custom ones

func DownloadResolverMaps

func DownloadResolverMaps(forceUpdate bool) ([]string, []string, error)

DownloadResolverMaps downloads the resolver repositories and returns lists of urls and paths

func EscapePathPart

func EscapePathPart(s string) string

func EvalCondition

func EvalCondition(expression string, ctx RunContext) (bool, error)

EvalCondition evaluates a condition expression with the given context.

func EvalString

func EvalString(expression string, ctx RunContext) (string, error)

EvalString evaluates an expression with the given context and returns the result as a string.

func ExportProject

func ExportProject(ctx RunContext) error

ExportProject copies files from the tmp paths (tmp/BP and tmp/RP) into the project's export target. The paths are generated with GetExportPaths.

func FindByJSONPath

func FindByJSONPath[T any](obj interface{}, path string) (T, error)

FindByJSONPath finds a value in a JSON element by a simple path. Returns nil and an error if the path is not found or invalid.

func FindMojangDir

func FindMojangDir() (string, error)

func FindPreviewDir

func FindPreviewDir() (string, error)

func ForceMoveFile

func ForceMoveFile(source, target string) error

ForceMoveFile is a function that forces to move file in file system. If os.Move fails, it creates a copy of the file to the target location and then deletes the original file.

func FullFilterToNiceFilterName

func FullFilterToNiceFilterName(name string) string

func GetAbsoluteWorkingDirectory

func GetAbsoluteWorkingDirectory(dotRegolithPath string) string

GetAbsoluteWorkingDirectory returns an absolute path to [dotRegolithPath]/tmp

func GetDevelopmentExportPaths

func GetDevelopmentExportPaths(bpName, rpName, comMojang string) (bpPath string, rpPath string, err error)

func GetDotRegolith

func GetDotRegolith(projectRoot string) (string, error)

GetDotRegolith returns the path to the directory where Regolith stores its cached data (like filters, Python venvs, etc.). If user config setting for using app data by profiles is set to false it returns relative directory: ".regolith" otherwise it returns path inside the AppData directory. Based on the hash value of the project's root directory. If the path isn't .regolith it also logs a message which tells where the data is stored unless the silent flag is set to true. The projectRoot path can be relative or absolute and is resolved to an absolute path.

func GetExactExportPaths

func GetExactExportPaths(exportTarget ExportTarget) (bpPath string, rpPath string, err error)

func GetExportNames

func GetExportNames(exportTarget ExportTarget, ctx RunContext) (bpName string, rpName string, err error)

GetExportNames returns the names for the behavior pack and resource pack based on the evaluated values of the "bpName" and "rpName" from the exportTarget object.

func GetExportPaths

func GetExportPaths(
	exportTarget ExportTarget, ctx RunContext,
) (bpPath string, rpPath string, err error)

GetExportPaths returns file paths for exporting behavior pack and resource pack based on exportTarget (a structure with data related to export settings) and the name of the project.

func GetFirstNonexistentSubpath

func GetFirstNonexistentSubpath(path string) (string, bool, error)

GetFirstNonexistentSubpath takes a path and returns its ancestor. The returned path that doesn't exist but has an existing parent. The function returns 3 values - the path, a boolean indicating if the path was found successfully and an error. If the input path already exists, it returns ("", false, nil).

func GetHeadSha

func GetHeadSha(url string) (string, error)

GetHeadSha returns the SHA of the HEAD of the repository specified by the filter URL. This function does not check whether the filter actually exists in the repository.

func GetLatestRemoteFilterTag

func GetLatestRemoteFilterTag(url, name string) (string, error)

GetLatestRemoteFilterTag returns the most up-to-date tag of the remote filter specified by the filter name and URL.

func GetMatchingDirContents

func GetMatchingDirContents(path string, files []string) ([]string, error)

GetMatchingDirContents returns a list of files in the directory that match the ones specified in the files parameter. If the path is not a directory or info about the path can't be obtained it returns an empty list and an error.

func GetRemoteFilterDownloadRef

func GetRemoteFilterDownloadRef(url, name, version string) (string, error)

GetRemoteFilterDownloadRef returns a reference for go-getter to be used to download a filter, based on the url, name and version properties from the "regolith install" command arguments.

func GetWorldExportPaths

func GetWorldExportPaths(exportTarget ExportTarget, bpName, rpName string) (bpPath string, rpPath string, err error)

func Init

func Init(debug, force bool) error

Init handles the "regolith init" command. It initializes a new Regolith project in the current directory.

The "debug" parameter is a boolean that determines if the debug messages should be printed.

func InitLogging

func InitLogging(dev bool)

func InplaceExportProject

func InplaceExportProject(
	config *Config, dotRegolithPath string,
) (err error)

InplaceExportProject copies the files from the tmp paths (tmp/BP, tmp/RP and tmp/data) into the project's source files. It's used by the "regolith apply-filter" command. This operation is destructive and cannot be undone.

func Install

func Install(filters []string, force, refreshResolvers, refreshFilters, add bool, profiles []string, debug bool) error

Install handles the "regolith install" command. It installs specific filters from the internet and adds them to the filtersDefinitions list in the config.json file.

The "filters" parameter is a list of filters to install in the format <filter-url>==<filter-version> or <filter-url>. "filter-url" is the URL of the filter to install. "filter-version" is the version of the filter. It can be semver, git commit hash, "HEAD", or "latest". "HEAD" means that the filter will be updated to the latest SHA commit and "latest" updates the filter to the latest version tag. If "filter-version" is not specified, the filter will be installed with the latest version or HEAD if there is no valid version tags.

The "force" parameter is a boolean that determines if the installation should be forced even if the filter is already installed.

The "debug" parameter is a boolean that determines if the debug messages should be printed.

func InstallAll

func InstallAll(force, debug, refreshFilters bool) error

InstallAll handles the "regolith install-all" command. It installs all of the filters and their dependencies from the filtersDefinitions list in the config.json file.

The "force" parameter is a boolean that determines if the installation should be forced even if the filter is already installed.

The "debug" parameter is a boolean that determines if the debug messages should be printed.

func IsDirEmpty

func IsDirEmpty(path string) (bool, error)

IsDirEmpty checks whether the path points at empty directory. If the path is not a directory or info about the path can't be obtained it returns false. If the path is a directory, and it is empty, it returns true.

func IsExperimentEnabled

func IsExperimentEnabled(exp Experiment) bool

func ListRemoteFilterTags

func ListRemoteFilterTags(url, name string) ([]string, error)

ListRemoteFilterTags returns the list tags of the remote filter specified by the filter name and URL.

func LoadConfigAsMap

func LoadConfigAsMap() (map[string]interface{}, error)

LoadConfigAsMap loads the config.json file as map[string]interface{}

func LogStd

func LogStd(in io.ReadCloser, logFunc func(template string, args ...interface{}), outputLabel string)

LogStd logs the output of a sub-process

func ManageConfig

func ManageConfig(debug, full, delete, append bool, index int, args []string) error

ManageConfig handles the "regolith config" command. It can modify or print the user configuration

  • debug - print debug messages
  • global - modify global configuration
  • local - modify local configuration
  • delete - delete the specified value
  • append - append a value to an array property of the configuration. Applies only to the array properties
  • index - the index of the value to modify. Applies only to the array properties
  • args - the arguments of the command, the length of the list must be 0, 1 or 2. The length determines the action of the command.

func MeasureEnd

func MeasureEnd()

func MeasureStart

func MeasureStart(name string, args ...interface{})

func MoveOrCopy

func MoveOrCopy(
	source string, destination string, makeReadOnly bool, copyParentAcl bool,
) error

MoveOrCopy tries to move the source to destination first and in case of failure it copies the files instead.

func NewRevertibleFsOperations

func NewRevertibleFsOperations(backupPath string) (*revertibleFsOperations, error)

NewRevertibleFsOperations creates a new FsOperationBatch struct.

func NiceSubfilterName

func NiceSubfilterName(name string, i int) string

func NotImplementedError

func NotImplementedError(text string) error

NotImplementedError is used by default functions, that need implementation.

func PostorderWalkDir

func PostorderWalkDir(root string, fn filepath.WalkFunc) error

PostorderWalkDir walks a directory like filepath.WalkDir but the order is defined by the postorder traversal algorithm (leafs first, than their root). Since the function calls the walkFunc for the leafs first, it's impossible to ignore directories using "filepath.SkipDir" as an error like in the regular filepath.WalkDir.

func ResolvePath

func ResolvePath(path string) (string, error)

func ResolveUrl

func ResolveUrl(shortName string, refreshResolvers bool) (string, error)

ResolveUrl tries to resolve the URL to a filter based on a shortName. If it fails it updates the resolver.json file and tries again

func Run

func Run(profileName string, debug bool) error

Run handles the "regolith run" command. It runs selected profile and exports created resource pack and behavior pack to the target destination.

func RunGitProcess

func RunGitProcess(args []string, workingDir string) ([]string, error)

RunGitProcess runs a git command with specified arguments and working directory

func RunProfile

func RunProfile(context RunContext) error

RunProfile loads the profile from config.json and runs it based on the context. If context is in the watch mode, it can repeat the process multiple times in case of interruptions (changes in the source files).

func RunProfileImpl

func RunProfileImpl(context RunContext) (bool, error)

RunProfileImpl runs the profile from the given context and returns true if the execution was interrupted.

func RunSubProcess

func RunSubProcess(command string, args []string, filterDir string, workingDir string, outputLabel string) error

RunSubProcess runs a sub-process with specified arguments and working directory

func SetupTmpFiles

func SetupTmpFiles(config Config, dotRegolithPath string) error

SetupTmpFiles set up the workspace for the filters.

func ShortFilterName

func ShortFilterName(name string) string

func SliceAny

func SliceAny[T interface{}](slice []T, predicate func(T) bool) bool

SliceAny returns true if any of the elements in the slice satisfy the predicate.

func SyncDirectories

func SyncDirectories(
	source string, destination string, makeReadOnly bool,
) error

SyncDirectories copies the source to destination while checking size and modification time. If the file in the destination is different than the one in the source, it's overwritten, otherwise it's skipped (the destination file is not modified).

func UpdateResolvers

func UpdateResolvers(debug bool) error

UpdateResolvers handles the "regolith update-resolvers" command. It updates cached resolver repositories.

The "debug" parameter is a boolean that determines if the debug messages should be printed.

func Watch

func Watch(profileName string, debug bool) error

Watch handles the "regolith watch" command. It watches the project directories, and it runs selected profile and exports created resource pack and behavior pack to the target destination when the project changes.

Types

type Config

type Config struct {
	Name            string `json:"name,omitempty"`
	Author          string `json:"author,omitempty"`
	Packs           `json:"packs,omitempty"`
	RegolithProject `json:"regolith,omitempty"`
}

Config represents the full configuration file of Regolith, as saved in "config.json".

func ConfigFromObject

func ConfigFromObject(obj map[string]interface{}) (*Config, error)

ConfigFromObject creates a "Config" object from map[string]interface{}

type DenoFilter

type DenoFilter struct {
	Filter
	Definition DenoFilterDefinition `json:"-"`
}

func (*DenoFilter) Check

func (f *DenoFilter) Check(context RunContext) error

func (*DenoFilter) Run

func (f *DenoFilter) Run(context RunContext) (bool, error)

type DenoFilterDefinition

type DenoFilterDefinition struct {
	FilterDefinition
	Script string `json:"script,omitempty"`
}

func DenoFilterDefinitionFromObject

func DenoFilterDefinitionFromObject(id string, obj map[string]interface{}) (*DenoFilterDefinition, error)

func (*DenoFilterDefinition) Check

func (f *DenoFilterDefinition) Check(context RunContext) error

func (*DenoFilterDefinition) CreateFilterRunner

func (f *DenoFilterDefinition) CreateFilterRunner(runConfiguration map[string]interface{}) (FilterRunner, error)

func (*DenoFilterDefinition) InstallDependencies

func (f *DenoFilterDefinition) InstallDependencies(
	parent *RemoteFilterDefinition, dotRegolithPath string,
) error

type DirWatcher

type DirWatcher struct{}

func NewDirWatcher

func NewDirWatcher(path string) (*DirWatcher, error)

func (*DirWatcher) Close

func (d *DirWatcher) Close() error

func (*DirWatcher) WaitForChange

func (d *DirWatcher) WaitForChange() error

func (*DirWatcher) WaitForChangeGroup

func (d *DirWatcher) WaitForChangeGroup(
	groupTimeout uint32, interruptionChannel chan string,
	interruptionMessage string,
) error

type DotNetFilter

type DotNetFilter struct {
	Filter
	Definition DotNetFilterDefinition `json:"-"`
}

func (*DotNetFilter) Check

func (f *DotNetFilter) Check(context RunContext) error

func (*DotNetFilter) Run

func (f *DotNetFilter) Run(context RunContext) (bool, error)

type DotNetFilterDefinition

type DotNetFilterDefinition struct {
	FilterDefinition
	Path string `json:"path,omitempty"`
}

func DotNetFilterDefinitionFromObject

func DotNetFilterDefinitionFromObject(id string, obj map[string]interface{}) (*DotNetFilterDefinition, error)

func (*DotNetFilterDefinition) Check

func (f *DotNetFilterDefinition) Check(context RunContext) error

func (*DotNetFilterDefinition) CreateFilterRunner

func (f *DotNetFilterDefinition) CreateFilterRunner(runConfiguration map[string]interface{}) (FilterRunner, error)

func (*DotNetFilterDefinition) InstallDependencies

func (f *DotNetFilterDefinition) InstallDependencies(*RemoteFilterDefinition, string) error

type EditedFiles

type EditedFiles struct {
	Rp map[string]filesList `json:"rp"`
	Bp map[string]filesList `json:"bp"`
}

EditedFiles is used to load edited_files.json from cache in order to check if the files are safe to delete.

func LoadEditedFiles

func LoadEditedFiles(dotRegolithPath string) EditedFiles

LoadEditedFiles data from edited_files.json or returns an empty object if file doesn't exist.

func NewEditedFiles

func NewEditedFiles() EditedFiles

NewEditedFiles creates new EditedFiles object with lists of the files from rpPath and bpPath.

func (*EditedFiles) CheckDeletionSafety

func (f *EditedFiles) CheckDeletionSafety(rpPath string, bpPath string) error

CheckDeletionSafety checks whether it's safe to delete files from rpPath and bpPath based on the lists of removable files from EditedFiles object.

func (*EditedFiles) Dump

func (f *EditedFiles) Dump(dotRegolithPath string) error

Dump dumps EditedFiles to EditedFilesPath in JSON format.

func (*EditedFiles) UpdateFromPaths

func (f *EditedFiles) UpdateFromPaths(rpPath string, bpPath string) error

UpdateFromPaths updates the edited files data based on the paths to the resource pack and behavior pack.

type ExeFilter

type ExeFilter struct {
	Filter
	Definition ExeFilterDefinition `json:"definition,omitempty"`
}

func (*ExeFilter) Check

func (f *ExeFilter) Check(context RunContext) error

func (*ExeFilter) Run

func (f *ExeFilter) Run(context RunContext) (bool, error)

type ExeFilterDefinition

type ExeFilterDefinition struct {
	FilterDefinition
	Exe string `json:"exe,omitempty"`
}

func ExeFilterDefinitionFromObject

func ExeFilterDefinitionFromObject(
	id string, obj map[string]interface{},
) (*ExeFilterDefinition, error)

func (*ExeFilterDefinition) Check

func (f *ExeFilterDefinition) Check(context RunContext) error

func (*ExeFilterDefinition) CreateFilterRunner

func (f *ExeFilterDefinition) CreateFilterRunner(
	runConfiguration map[string]interface{},
) (FilterRunner, error)

func (*ExeFilterDefinition) InstallDependencies

func (f *ExeFilterDefinition) InstallDependencies(
	*RemoteFilterDefinition, string,
) error

type Experiment

type Experiment int
const (
	// SizeTimeCheck is an experiment that checks the size and modification time when exporting
	SizeTimeCheck Experiment = iota
)

type ExperimentInfo

type ExperimentInfo struct {
	Name        string
	Description string
}

type ExportTarget

type ExportTarget struct {
	Target    string `json:"target,omitempty"` // The mode of exporting. "develop" or "exact"
	RpPath    string `json:"rpPath,omitempty"` // Relative or absolute path to resource pack for "exact" export target
	BpPath    string `json:"bpPath,omitempty"` // Relative or absolute path to resource pack for "exact" export target
	RpName    string `json:"rpName,omitempty"`
	BpName    string `json:"bpName,omitempty"`
	WorldName string `json:"worldName,omitempty"`
	WorldPath string `json:"worldPath,omitempty"`
	ReadOnly  bool   `json:"readOnly"` // Whether the exported files should be read-only
}

ExportTarget is a part of "config.json" that contains export information for a profile, which denotes where compiled files will go. When editing, adjust ExportTargetFromObject function as well.

func ExportTargetFromObject

func ExportTargetFromObject(obj map[string]interface{}) (ExportTarget, error)

ExportTargetFromObject creates a "ExportTarget" object from map[string]interface{}

type Filter

type Filter struct {
	Id          string                 `json:"filter,omitempty"`
	Description string                 `json:"name,omitempty"`
	Disabled    bool                   `json:"disabled,omitempty"`
	Arguments   []string               `json:"arguments,omitempty"`
	Settings    map[string]interface{} `json:"settings,omitempty"`
	When        string                 `json:"when,omitempty"`
}

func (*Filter) Check

func (f *Filter) Check() error

func (*Filter) CopyArguments

func (f *Filter) CopyArguments(parent *RemoteFilter)

func (*Filter) GetId

func (f *Filter) GetId() string

func (*Filter) GetSettings

func (f *Filter) GetSettings() map[string]interface{}

func (*Filter) IsDisabled

func (f *Filter) IsDisabled(ctx RunContext) (bool, error)

func (*Filter) IsUsingDataExport

func (f *Filter) IsUsingDataExport(_ string) (bool, error)

func (*Filter) Run

func (f *Filter) Run(context RunContext) (bool, error)

type FilterCollection

type FilterCollection struct {
	Filters []FilterRunner `json:"filters"`
}

FilterCollection is a list of filters

type FilterDefinition

type FilterDefinition struct {
	Id string `json:"-"`
}

func FilterDefinitionFromObject

func FilterDefinitionFromObject(id string) *FilterDefinition

type FilterInstaller

type FilterInstaller interface {
	InstallDependencies(parent *RemoteFilterDefinition, dotRegolithPath string) error
	Check(context RunContext) error
	CreateFilterRunner(runConfiguration map[string]interface{}) (FilterRunner, error)
}

func FilterInstallerFromObject

func FilterInstallerFromObject(id string, obj map[string]interface{}) (FilterInstaller, error)

type FilterRunner

type FilterRunner interface {
	// CopyArguments copies the arguments from the parent filter to this
	// filter. It's used  for the remote filters.
	CopyArguments(parent *RemoteFilter)

	// Run runs the filter. If the context is in the watch mode, it also
	// checks whether there were any interruptions.
	// It returns true if the filter was interrupted. If the watch mode is
	// disabled it always returns false.
	Run(context RunContext) (bool, error)

	// IsDisabled returns whether the filter is disabled.
	IsDisabled(ctx RunContext) (bool, error)

	// GetId returns the id of the filter.
	GetId() string

	// GetSettings returns the settings of the filter.
	GetSettings() map[string]interface{}

	// Check checks whether the requirements of the filter are met. For
	// example, a Python filter requires Python to be installed.
	Check(context RunContext) error

	// IsUsingDataExport returns whether the filter wants its data to be
	// exported back to the data folder after running the profile.
	IsUsingDataExport(dotRegolithPath string) (bool, error)
}

func FilterRunnerFromObjectAndDefinitions

func FilterRunnerFromObjectAndDefinitions(
	obj map[string]interface{}, filterDefinitions map[string]FilterInstaller,
) (FilterRunner, error)

type JavaFilter

type JavaFilter struct {
	Filter
	Definition JavaFilterDefinition `json:"-"`
}

func (*JavaFilter) Check

func (f *JavaFilter) Check(context RunContext) error

func (*JavaFilter) Run

func (f *JavaFilter) Run(context RunContext) (bool, error)

type JavaFilterDefinition

type JavaFilterDefinition struct {
	FilterDefinition
	Script string `json:"script,omitempty"`
}

func JavaFilterDefinitionFromObject

func JavaFilterDefinitionFromObject(id string, obj map[string]interface{}) (*JavaFilterDefinition, error)

func (*JavaFilterDefinition) Check

func (f *JavaFilterDefinition) Check(context RunContext) error

func (*JavaFilterDefinition) CreateFilterRunner

func (f *JavaFilterDefinition) CreateFilterRunner(runConfiguration map[string]interface{}) (FilterRunner, error)

func (*JavaFilterDefinition) InstallDependencies

func (f *JavaFilterDefinition) InstallDependencies(*RemoteFilterDefinition, string) error

type NimFilter

type NimFilter struct {
	Filter
	Definition NimFilterDefinition `json:"-"`
}

func (*NimFilter) Check

func (f *NimFilter) Check(context RunContext) error

func (*NimFilter) Run

func (f *NimFilter) Run(context RunContext) (bool, error)

type NimFilterDefinition

type NimFilterDefinition struct {
	FilterDefinition
	Script string `json:"script,omitempty"`

	// Requirements is an optional path to the folder with the nimble file. If not specified
	// the parent of the script path is used instead.
	Requirements string `json:"requirements,omitempty"`
}

func NimFilterDefinitionFromObject

func NimFilterDefinitionFromObject(
	id string, obj map[string]interface{},
) (*NimFilterDefinition, error)

func (*NimFilterDefinition) Check

func (f *NimFilterDefinition) Check(context RunContext) error

func (*NimFilterDefinition) CreateFilterRunner

func (f *NimFilterDefinition) CreateFilterRunner(runConfiguration map[string]interface{}) (FilterRunner, error)

func (*NimFilterDefinition) InstallDependencies

func (f *NimFilterDefinition) InstallDependencies(
	parent *RemoteFilterDefinition, dotRegolithPath string,
) error

type NodeJSFilter

type NodeJSFilter struct {
	Filter
	Definition NodeJSFilterDefinition `json:"-"`
}

func (*NodeJSFilter) Check

func (f *NodeJSFilter) Check(context RunContext) error

func (*NodeJSFilter) Run

func (f *NodeJSFilter) Run(context RunContext) (bool, error)

type NodeJSFilterDefinition

type NodeJSFilterDefinition struct {
	FilterDefinition
	Script string `json:"script,omitempty"`

	// Requirements is an optional path to the folder with the package.json file.
	// If not specified the parent of the script path is used instead.
	Requirements string `json:"requirements,omitempty"`
}

func NodeJSFilterDefinitionFromObject

func NodeJSFilterDefinitionFromObject(id string, obj map[string]interface{}) (*NodeJSFilterDefinition, error)

func (*NodeJSFilterDefinition) Check

func (f *NodeJSFilterDefinition) Check(context RunContext) error

func (*NodeJSFilterDefinition) CreateFilterRunner

func (f *NodeJSFilterDefinition) CreateFilterRunner(runConfiguration map[string]interface{}) (FilterRunner, error)

func (*NodeJSFilterDefinition) InstallDependencies

func (f *NodeJSFilterDefinition) InstallDependencies(parent *RemoteFilterDefinition, dotRegolithPath string) error

type Packs

type Packs struct {
	BehaviorFolder string `json:"behaviorPack,omitempty"`
	ResourceFolder string `json:"resourcePack,omitempty"`
}

Packs is a part of "config.json" that points to the source behavior and resource packs.

func PacksFromObject

func PacksFromObject(obj map[string]interface{}) Packs

ProfileFromObject creates a "Profile" object from map[string]interface{}

type Profile

type Profile struct {
	FilterCollection
	ExportTarget ExportTarget `json:"export,omitempty"`
}

Profile is a collection of filters and an export target When editing, adjust ProfileFromObject function as well

func ProfileFromObject

func ProfileFromObject(
	obj map[string]interface{}, filterDefinitions map[string]FilterInstaller,
) (Profile, error)

type ProfileFilter

type ProfileFilter struct {
	Filter
	Profile string `json:"-"`
}

func (*ProfileFilter) Check

func (f *ProfileFilter) Check(context RunContext) error

func (*ProfileFilter) Run

func (f *ProfileFilter) Run(context RunContext) (bool, error)

type PythonFilter

type PythonFilter struct {
	Filter
	Definition PythonFilterDefinition `json:"-"`
}

func (*PythonFilter) Check

func (f *PythonFilter) Check(context RunContext) error

func (*PythonFilter) CopyArguments

func (f *PythonFilter) CopyArguments(parent *RemoteFilter)

func (*PythonFilter) Run

func (f *PythonFilter) Run(context RunContext) (bool, error)

type PythonFilterDefinition

type PythonFilterDefinition struct {
	FilterDefinition
	Script   string `json:"script,omitempty"`
	VenvSlot int    `json:"venvSlot,omitempty"`

	// Requirements is an optional path to the file with the requirements
	// (usually requirements.txt). If not specified, the parent path of the
	// script is used.
	Requirements string `json:"requirements,omitempty"`
}

func PythonFilterDefinitionFromObject

func PythonFilterDefinitionFromObject(id string, obj map[string]interface{}) (*PythonFilterDefinition, error)

func (*PythonFilterDefinition) Check

func (f *PythonFilterDefinition) Check(context RunContext) error

func (*PythonFilterDefinition) CreateFilterRunner

func (f *PythonFilterDefinition) CreateFilterRunner(runConfiguration map[string]interface{}) (FilterRunner, error)

func (*PythonFilterDefinition) InstallDependencies

func (f *PythonFilterDefinition) InstallDependencies(
	parent *RemoteFilterDefinition, dotRegolithPath string,
) error

type RegolithProject

type RegolithProject struct {
	Profiles          map[string]Profile         `json:"profiles,omitempty"`
	FilterDefinitions map[string]FilterInstaller `json:"filterDefinitions"`
	DataPath          string                     `json:"dataPath,omitempty"`
}

RegolithProject is a part of "config.json" with the regolith namespace within the Minecraft Project Schema

func RegolithProjectFromObject

func RegolithProjectFromObject(
	obj map[string]interface{},
) (RegolithProject, error)

RegolithProjectFromObject creates a "RegolithProject" object from map[string]interface{}

type RemoteFilter

type RemoteFilter struct {
	Filter
	Definition RemoteFilterDefinition `json:"-"`
}

func (*RemoteFilter) Check

func (f *RemoteFilter) Check(context RunContext) error

func (*RemoteFilter) GetCachedVersion

func (f *RemoteFilter) GetCachedVersion(dotRegolithPath string) (*string, error)

GetCachedVersion returns cached version of the remote filter.

func (*RemoteFilter) GetDownloadPath

func (f *RemoteFilter) GetDownloadPath(dotRegolithPath string) string

GetDownloadPath returns the path location where the filter can be found.

func (*RemoteFilter) IsCached

func (f *RemoteFilter) IsCached(dotRegolithPath string) bool

IsCached checks whether the filter of given URL is already saved in cache.

func (*RemoteFilter) IsUsingDataExport

func (f *RemoteFilter) IsUsingDataExport(dotRegolithPath string) (bool, error)

func (*RemoteFilter) Run

func (f *RemoteFilter) Run(context RunContext) (bool, error)

type RemoteFilterDefinition

type RemoteFilterDefinition struct {
	FilterDefinition
	Url     string `json:"url,omitempty"`
	Version string `json:"version,omitempty"`
	// RemoteFilters can propagate some of the properties unique to other types
	// of filers (like Python's venvSlot).
	VenvSlot int `json:"venvSlot,omitempty"`
}

func FilterDefinitionFromTheInternet

func FilterDefinitionFromTheInternet(
	url, name, version string,
) (*RemoteFilterDefinition, error)

FilterDefinitionFromTheInternet downloads a filter from the internet and returns its data.

func RemoteFilterDefinitionFromObject

func RemoteFilterDefinitionFromObject(id string, obj map[string]interface{}) (*RemoteFilterDefinition, error)

func (*RemoteFilterDefinition) Check

func (f *RemoteFilterDefinition) Check(context RunContext) error

func (*RemoteFilterDefinition) CopyFilterData

func (f *RemoteFilterDefinition) CopyFilterData(dataPath string, dotRegolithPath string)

CopyFilterData copies the filter's data to the data folder.

func (*RemoteFilterDefinition) CreateFilterRunner

func (f *RemoteFilterDefinition) CreateFilterRunner(runConfiguration map[string]interface{}) (FilterRunner, error)

func (*RemoteFilterDefinition) Download

func (f *RemoteFilterDefinition) Download(
	isForced bool, dotRegolithPath string, refreshFilters bool,
) error

Download

func (*RemoteFilterDefinition) GetDownloadPath

func (f *RemoteFilterDefinition) GetDownloadPath(dotRegolithPath string) string

GetDownloadPath returns the path location where the filter can be found.

func (*RemoteFilterDefinition) InstallDependencies

func (f *RemoteFilterDefinition) InstallDependencies(_ *RemoteFilterDefinition, dotRegolithPath string) error

TODO - this code is almost a duplicate of the code in the (f *RemoteFilter) SubfilterCollection()

func (*RemoteFilterDefinition) InstalledVersion

func (f *RemoteFilterDefinition) InstalledVersion(dotRegolithPath string) (string, error)

InstalledVersion reads the version saved in the filter.json

func (*RemoteFilterDefinition) LoadFilterJson

func (f *RemoteFilterDefinition) LoadFilterJson(dotRegolithPath string) (map[string]interface{}, error)

LoadFilterJson loads the filter.json file of the remote filter to a map.

func (*RemoteFilterDefinition) SaveVersionInfo

func (f *RemoteFilterDefinition) SaveVersionInfo(version, dotRegolithPath string) error

SaveVersionInfo saves puts the specified version string into the filter.json of the remote filter.

func (*RemoteFilterDefinition) Uninstall

func (f *RemoteFilterDefinition) Uninstall(dotRegolithPath string)

func (*RemoteFilterDefinition) Update

func (f *RemoteFilterDefinition) Update(force bool, dotRegolithPath string, isInstall, refreshFilters bool) error

type ResolverMapItem

type ResolverMapItem struct {
	Url string `json:"url"`
}

func ResolverMapFromObject

func ResolverMapFromObject(obj map[string]interface{}) (ResolverMapItem, error)

type RunContext

type RunContext struct {
	AbsoluteLocation string
	Config           *Config
	Profile          string
	Parent           *RunContext
	DotRegolithPath  string
	Settings         map[string]interface{}
	// contains filtered or unexported fields
}

func (*RunContext) AwaitInterruption

func (c *RunContext) AwaitInterruption() string

AwaitInterruption locks the goroutine with the interruption channel until the Config is interrupted and returns the interruption message.

func (*RunContext) GetProfile

func (c *RunContext) GetProfile() (Profile, error)

GetProfile returns the Profile structure from the context.

func (*RunContext) IsInWatchMode

func (c *RunContext) IsInWatchMode() bool

IsInWatchMode returns a value that shows whether the context is in the watch mode.

func (*RunContext) IsInterrupted

func (c *RunContext) IsInterrupted(ignoredSource ...string) bool

IsInterrupted returns true if there is a message on the interruptionChannel unless the source of the interruption is on the list of ignored sources. This function does not block.

func (*RunContext) StartWatchingSourceFiles

func (c *RunContext) StartWatchingSourceFiles() error

StartWatchingSourceFiles causes the Context to start goroutines that watch for changes in the source files and report that to the

type ShellFilter

type ShellFilter struct {
	Filter
	Definition ShellFilterDefinition `json:"definition,omitempty"`
}

func (*ShellFilter) Check

func (f *ShellFilter) Check(context RunContext) error

func (*ShellFilter) Run

func (f *ShellFilter) Run(context RunContext) (bool, error)

type ShellFilterDefinition

type ShellFilterDefinition struct {
	FilterDefinition
	Command string `json:"command,omitempty"`
}

func ShellFilterDefinitionFromObject

func ShellFilterDefinitionFromObject(
	id string, obj map[string]interface{},
) (*ShellFilterDefinition, error)

func (*ShellFilterDefinition) Check

func (f *ShellFilterDefinition) Check(context RunContext) error

func (*ShellFilterDefinition) CreateFilterRunner

func (f *ShellFilterDefinition) CreateFilterRunner(
	runConfiguration map[string]interface{},
) (FilterRunner, error)

func (*ShellFilterDefinition) InstallDependencies

func (f *ShellFilterDefinition) InstallDependencies(*RemoteFilterDefinition, string) error

type UpdateStatus

type UpdateStatus struct {
	ShouldUpdate bool
	Url          *string
	Err          *error
}

type UserConfig

type UserConfig struct {
	// UseProjectAppDataStorage is a flag that determines whether to use the
	// app data for project files (.regolith path). It's a pointer to a boolean
	// to allow for the default value to be nil.
	UseProjectAppDataStorage *bool `json:"use_project_app_data_storage,omitempty"`

	// Username is the name of the user. It's used in the "regolith init" command
	// to fill in the author field of the project config. It's a pointer to a
	// string to allow for the default value to be nil.
	Username *string `json:"username,omitempty"`

	// Resolvers is a list of URLs to resolvers that Regolith will use to find
	// filters for the "regolith install" command.
	Resolvers []string `json:"resolvers,omitempty"`

	// ResolverCacheUpdateCooldown is a cooldown duration, to not update resolver cache too often.
	ResolverCacheUpdateCooldown *string `json:"resolver_cache_update_cooldown,omitempty"`

	// FilterCacheUpdateCooldown is a cooldown duration, to not update resolver cache too often.
	FilterCacheUpdateCooldown *string `json:"filter_cache_update_cooldown,omitempty"`
}

func NewUserConfig

func NewUserConfig() *UserConfig

func (*UserConfig) String

func (u *UserConfig) String() string

type World

type World struct {
	Id   string `json:"id"`   // The name of the world directory
	Name string `json:"name"` // The name of the world in levelname.txt
	Path string `json:"path"`
}

func ListWorlds

func ListWorlds(mojangDir string) ([]*World, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL