Documentation
¶
Overview ¶
Functions related to user_config.json
Index ¶
- Constants
- Variables
- func ApplyFilter(filterName string, filterArgs []string, debug bool) error
- func AreFilesEqual(a, b string) (bool, error)
- func CheckProfileImpl(profile Profile, profileName string, config Config, parentContext *RunContext, ...) error
- func CheckSuspiciousLocation() error
- func CheckUpdate(version string, status chan UpdateStatus)
- func Clean(debug, userCache, filterCache bool) error
- func CleanCurrentProject() error
- func CleanFilterCache() error
- func CleanUserCache() error
- func CopyFile(source, target string) error
- func CreateEnvironmentVariables(filterDir string) ([]string, error)
- func DownloadResolverMaps(forceUpdate bool) ([]string, []string, error)
- func EscapePathPart(s string) string
- func EvalCondition(expression string, ctx RunContext) (bool, error)
- func EvalString(expression string, ctx RunContext) (string, error)
- func ExportProject(ctx RunContext) error
- func FindByJSONPath[T any](obj interface{}, path string) (T, error)
- func FindEducationDir() (string, error)
- func FindMojangDir(build string) (string, error)
- func FindPreviewDir() (string, error)
- func FindStandardMojangDir() (string, error)
- func ForceMoveFile(source, target string) error
- func FullFilterToNiceFilterName(name string) string
- func GetAbsoluteWorkingDirectory(dotRegolithPath string) string
- func GetDevelopmentExportPaths(bpName, rpName, comMojang string) (bpPath string, rpPath string, err error)
- func GetDotRegolith(projectRoot string) (string, error)
- func GetExactExportPaths(exportTarget ExportTarget) (bpPath string, rpPath string, err error)
- func GetExportNames(exportTarget ExportTarget, ctx RunContext) (bpName string, rpName string, err error)
- func GetExportPaths(exportTarget ExportTarget, ctx RunContext) (bpPath string, rpPath string, err error)
- func GetFirstNonexistentSubpath(path string) (string, bool, error)
- func GetHeadSha(url string) (string, error)
- func GetLatestRemoteFilterTag(url, name string) (string, error)
- func GetMatchingDirContents(path string, files []string) ([]string, error)
- func GetRemoteFilterDownloadRef(url, name, version string) (string, error)
- func GetWorldExportPaths(worldPath, worldName, build, bpName, rpName string) (bpPath string, rpPath string, err error)
- func Init(debug, force bool) error
- func InitLogging(dev bool)
- func InplaceExportProject(config *Config, dotRegolithPath string) (err error)
- func Install(filters []string, force, refreshResolvers, refreshFilters bool, ...) error
- func InstallAll(force, update, debug, refreshFilters bool) error
- func IsDirEmpty(path string) (bool, error)
- func IsExperimentEnabled(exp Experiment) bool
- func ListRemoteFilterTags(url, name string) ([]string, error)
- func LoadConfigAsMap() (map[string]interface{}, error)
- func LogStd(in io.ReadCloser, logFunc func(template string, args ...interface{}), ...)
- func ManageConfig(debug, full, delete, append bool, index int, args []string) error
- func MeasureEnd()
- func MeasureStart(name string, args ...interface{})
- func MoveOrCopy(source string, destination string, makeReadOnly bool, copyParentAcl bool) error
- func NewDirWatcher(config *Config, interruption chan string, errors chan error, ...) error
- func NewRevertibleFsOperations(backupPath string) (*revertibleFsOperations, error)
- func NiceSubfilterName(name string, i int) string
- func NotImplementedError(text string) error
- func PostorderWalkDir(root string, fn filepath.WalkFunc) error
- func ResolvePath(path string) (string, error)
- func ResolveUrl(shortName string, refreshResolvers bool) (string, error)
- func Run(profileName string, debug bool) error
- func RunGitProcess(args []string, workingDir string) ([]string, error)
- func RunProfile(context RunContext) error
- func RunProfileImpl(context RunContext) (bool, error)
- func RunSubProcess(command string, args []string, filterDir string, workingDir string, ...) error
- func SetupTmpFiles(config Config, dotRegolithPath string) error
- func ShortFilterName(name string) string
- func SliceAny[T interface{}](slice []T, predicate func(T) bool) bool
- func SyncDirectories(source string, destination string, makeReadOnly bool) error
- func UpdateResolvers(debug bool) error
- func Watch(profileName string, debug bool) error
- type Config
- type DenoFilter
- type DenoFilterDefinition
- type DirWatcher
- type DotNetFilter
- type DotNetFilterDefinition
- type EditedFiles
- type ExeFilter
- type ExeFilterDefinition
- type Experiment
- type ExperimentInfo
- type ExportTarget
- type Filter
- func (f *Filter) Check() error
- func (f *Filter) CopyArguments(parent *RemoteFilter)
- func (f *Filter) GetId() string
- func (f *Filter) GetSettings() map[string]interface{}
- func (f *Filter) IsDisabled(ctx RunContext) (bool, error)
- func (f *Filter) IsUsingDataExport(_ string, _ RunContext) (bool, error)
- func (f *Filter) Run(context RunContext) (bool, error)
- type FilterCollection
- type FilterDefinition
- type FilterInstaller
- type FilterRunner
- type JavaFilter
- type JavaFilterDefinition
- type NimFilter
- type NimFilterDefinition
- type NodeJSFilter
- type NodeJSFilterDefinition
- type Packs
- type Profile
- type ProfileFilter
- type PythonFilter
- type PythonFilterDefinition
- type RegolithProject
- type RemoteFilter
- func (f *RemoteFilter) Check(context RunContext) error
- func (f *RemoteFilter) GetCachedVersion(dotRegolithPath string) (*string, error)
- func (f *RemoteFilter) GetDownloadPath(dotRegolithPath string) string
- func (f *RemoteFilter) IsCached(dotRegolithPath string) bool
- func (f *RemoteFilter) IsUsingDataExport(dotRegolithPath string, _ RunContext) (bool, error)
- func (f *RemoteFilter) Run(context RunContext) (bool, error)
- type RemoteFilterDefinition
- func (f *RemoteFilterDefinition) Check(context RunContext) error
- func (f *RemoteFilterDefinition) CopyFilterData(dataPath string, dotRegolithPath string)
- func (f *RemoteFilterDefinition) CreateFilterRunner(runConfiguration map[string]interface{}) (FilterRunner, error)
- func (f *RemoteFilterDefinition) Download(isForced bool, dotRegolithPath string, refreshFilters bool) error
- func (f *RemoteFilterDefinition) GetDownloadPath(dotRegolithPath string) string
- func (f *RemoteFilterDefinition) InstallDependencies(_ *RemoteFilterDefinition, dotRegolithPath string) error
- func (f *RemoteFilterDefinition) InstalledVersion(dotRegolithPath string) (string, error)
- func (f *RemoteFilterDefinition) LoadFilterJson(dotRegolithPath string) (map[string]interface{}, error)
- func (f *RemoteFilterDefinition) SaveVersionInfo(version, dotRegolithPath string) error
- func (f *RemoteFilterDefinition) Uninstall(dotRegolithPath string)
- func (f *RemoteFilterDefinition) Update(force bool, dotRegolithPath, dataPath string, refreshFilters bool) error
- type ResolverMapItem
- type RunContext
- type ShellFilter
- type ShellFilterDefinition
- type UpdateStatus
- type UserConfig
- type World
Constants ¶
const ConfigFilePath = "config.json"
const EditedFilesPath = "cache/edited_files.json"
const GitIgnore = "/build\n/.regolith"
const StandardLibraryUrl = "github.com/Bedrock-OSS/regolith-filters"
Variables ¶
var AvailableExperiments = map[Experiment]ExperimentInfo{ SizeTimeCheck: {"size_time_check", sizeTimeCheckDesc}, }
var EnableTimings = false
var EnabledExperiments []string
var Logger *zap.SugaredLogger
var LoggerLevel zap.AtomicLevel
var Version = "unversioned"
Functions ¶
func ApplyFilter ¶
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 ¶
AreFilesEqual compares files from two paths A and B and returns true if they're equal.
func CheckProfileImpl ¶
func CheckSuspiciousLocation ¶
func CheckSuspiciousLocation() error
func CheckUpdate ¶
func CheckUpdate(version string, status chan UpdateStatus)
func Clean ¶
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 ¶
CopyFile copies a file from source to target. If it's necessary it creates the target directory.
func CreateEnvironmentVariables ¶
CreateEnvironmentVariables creates an array of environment variables including custom ones
func DownloadResolverMaps ¶
DownloadResolverMaps downloads the resolver repositories and returns lists of urls and paths
func EscapePathPart ¶
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 ¶
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 FindEducationDir ¶
func FindMojangDir ¶
func FindPreviewDir ¶
func FindStandardMojangDir ¶
func ForceMoveFile ¶
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 GetAbsoluteWorkingDirectory ¶
GetAbsoluteWorkingDirectory returns an absolute path to [dotRegolithPath]/tmp
func GetDotRegolith ¶
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 ¶
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 ¶
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 ¶
GetLatestRemoteFilterTag returns the most up-to-date tag of the remote filter specified by the filter name and URL.
func GetMatchingDirContents ¶
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 ¶
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 Init ¶
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 ¶
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 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 ¶
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 ¶
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 ¶
ListRemoteFilterTags returns the list tags of the remote filter specified by the filter name and URL.
func LoadConfigAsMap ¶
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 ¶
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 ¶
MoveOrCopy tries to move the source to destination first and in case of failure it copies the files instead.
func NewDirWatcher ¶
func NewRevertibleFsOperations ¶
NewRevertibleFsOperations creates a new FsOperationBatch struct.
func NiceSubfilterName ¶
func NotImplementedError ¶
NotImplementedError is used by default functions, that need implementation.
func PostorderWalkDir ¶
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 ResolveUrl ¶
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 ¶
Run handles the "regolith run" command. It runs selected profile and exports created resource pack and behavior pack to the target destination.
func RunGitProcess ¶
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 ¶
SetupTmpFiles set up the workspace for the filters.
func ShortFilterName ¶
func SyncDirectories ¶
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 ¶
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.
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 ¶
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 {
// contains filtered or unexported fields
}
DirWatcher handles watching for changes in a multiple root directories.
fsnotify doesn't *officially* support recursive file watching yet. Windows and and Linux are supported, but not macOS. For now, this implementation uses a custom fork with patches to manually enable it.
Fork patch: https://github.com/arexon/fsnotify/blob/main/fsnotify.go#L481
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 ¶
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
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 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 Build string `json:"build,omitempty"` // The type of Minecraft build for the 'develop' }
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) CopyArguments ¶
func (f *Filter) CopyArguments(parent *RemoteFilter)
func (*Filter) GetSettings ¶
func (*Filter) IsDisabled ¶
func (f *Filter) IsDisabled(ctx RunContext) (bool, error)
func (*Filter) IsUsingDataExport ¶
func (f *Filter) IsUsingDataExport(_ string, _ 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, ctx RunContext) (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
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 ¶
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)
func (*Profile) ForeachFilter ¶
func (p *Profile) ForeachFilter( context RunContext, fn func(FilterRunner) error, unpackNestedProfiles bool, ) error
ForeachFilter iterates over the filters of the profile and applies the given function to each filter. If unpackNestedProfiles is true, it will unpack the nested profiles and apply the function to their filters as well.
type ProfileFilter ¶
func (*ProfileFilter) Check ¶
func (f *ProfileFilter) Check(context RunContext) error
func (*ProfileFilter) IsUsingDataExport ¶
func (f *ProfileFilter) IsUsingDataExport(dotRegolithPath string, ctx RunContext) (bool, 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"` FormatVersion string `json:"formatVersion,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, _ RunContext) (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)
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) 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 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
Source Files
¶
- compatibility_other_os.go
- config.go
- config_unparsed.go
- errors.go
- evaluator.go
- experiments.go
- export.go
- file_protection.go
- file_system.go
- filter.go
- filter_deno.go
- filter_dotnet.go
- filter_exe.go
- filter_java.go
- filter_nim.go
- filter_nodejs.go
- filter_profile.go
- filter_python.go
- filter_remote.go
- filter_shell.go
- install_add.go
- logging.go
- main_functions.go
- profile.go
- resolver.go
- update.go
- user_config.go
- utils.go
- utils_minecraft.go
- watcher.go