diff --git a/docs/docs/guide/export-targets.md b/docs/docs/guide/export-targets.md index a2e0b7b1..660f3e77 100644 --- a/docs/docs/guide/export-targets.md +++ b/docs/docs/guide/export-targets.md @@ -29,7 +29,7 @@ These are the export targets that Regolith offers. ## Development -The development export target will place the compiled packs into your `com.mojang` `development_*_packs` folder, in a new folder called `_BP` or `_RP`. +The development export target will place the compiled packs into your `com.mojang` `development_*_packs` folders. ```json "export": { @@ -37,6 +37,16 @@ The development export target will place the compiled packs into your `com.mojan } ``` +Optionally, you can use `rpName` and `bpName` to specify the names of the folders that will be created in the `development_*_packs` folders. You can read more about these options at the end of this page of the documentation. + +```json +"export": { + "target": "development", + "rpName": "'my_rp'", + "bpName": "'my_bp'" +} +``` + ## Local This export target will place the compiled packs into a folder called `build`, created in your regolith project. This export target is mostly useful for quick testing. @@ -47,6 +57,18 @@ This export target will place the compiled packs into a folder called `build`, c } ``` +Local export optionally accepts `rpName` and `bpName` to specify the names of the folders that will be created in the `build` folders. You can read more about these options at the end of this page of the documentation. + +```json +"export": { + "target": "local", + "rpName": "'my_rp'", + "bpName": "'my_bp'" +} +``` + + + ## Exact The Exact export target will place the files to specific, user specified locations. This is useful when you need absolute control over Regoliths export functionality. @@ -63,6 +85,8 @@ Example: } ``` +The exact export target doesn't support using `rpName` and `bpName`. The `rpPath` and `bpPath` should provide full paths to the desired locations. + ## World The World export target will place the compiled files into a specific world. This is useful for teams that prefer working in-world, as opposed to in the development pack folders. @@ -74,17 +98,54 @@ Example: ```json "export": { "target": "world", - "worldName": "...", // This - "worldPath": "..." // OR this + "worldName": "..." // This + // "worldPath": "..." // OR this } ``` +Optionally, you can use `rpName` and `bpName` to specify the names of the folders that will be created in the world. You can read more about these options at the end of this page of the documentation. + +```json +"export": { + "target": "world", + "worldPath": "...", + "rpName": "'my_rp'", + "bpName": "'my_bp'" +} +``` + + ## Preview -The development export target will place the compiled packs into your (minecraft preview) `com.mojang` `development_*_packs` folder, in a new folder called `_bp` or `_rp`. +The development export target will place the compiled packs into your **(minecraft preview)** `com.mojang` `development_*_packs` folder. ```json "export": { "target": "preview" } ``` + +Optionally, you can use `rpName` and `bpName` to specify the names of the folders that will be created in the `development_*_packs` folders. You can read more about these options at the end of this page of the documentation. +```json +"export": { + "target": "preview", + "rpName": "'my_rp'", + "bpName": "'my_bp'" +} +``` + +# The `rpName` and `bpName` expressions + +The `rpName` and `bpName` are expressions evaulated using the [go-simple-eval](https://github.com/stirante/go-simple-eval/) library. They let you specify the names of the folders of the exported packs in some of the export targets. + +The go-simple-eval library allows you to use simple expressions to generate the names of the folders. The expressions can use the following variables: + +- `project.name` - The name of the project. +- `project.author` - The author of the project. +- `os` - The host operating system. +- `arch` - The host architecture. +- `debug` - whether regolith is running in debug mode or not. +- `version` - The version of regolith. +- `profile` - The name of the profile being run. + +Go-simple-eval can concatenate strings using the `+` operator. The strings must be enclosed in single quotes. diff --git a/regolith/condition_evaluator.go b/regolith/condition_evaluator.go deleted file mode 100644 index 186dae9a..00000000 --- a/regolith/condition_evaluator.go +++ /dev/null @@ -1,37 +0,0 @@ -package regolith - -import ( - "runtime" - - "github.com/Bedrock-OSS/go-burrito/burrito" - "github.com/stirante/go-simple-eval/eval" - "github.com/stirante/go-simple-eval/eval/utils" -) - -func EvalCondition(condition string, ctx RunContext) (bool, error) { - Logger.Debugf("Evaluating condition: %s", condition) - t := prepareScope(ctx) - Logger.Debugf("Evaluation scope: %s", utils.ToString(t)) - e, err := eval.Eval(condition, t) - if err != nil { - return false, burrito.WrapErrorf(err, "Failed to evaluate condition: %s", condition) - } - Logger.Debugf("Condition evaluated to: %s", utils.ToString(e)) - return utils.ToBoolean(e), nil -} - -func prepareScope(ctx RunContext) map[string]interface{} { - semverString, err := utils.ParseSemverString(Version) - if err != nil { - semverString = utils.Semver{} - } - return map[string]interface{}{ - "os": runtime.GOOS, - "arch": runtime.GOARCH, - "debug": burrito.PrintStackTrace, - "version": semverString, - "profile": ctx.Profile, - "filterLocation": ctx.AbsoluteLocation, - "settings": ctx.Settings, - } -} diff --git a/regolith/config.go b/regolith/config.go index a3e7b612..46913cde 100644 --- a/regolith/config.go +++ b/regolith/config.go @@ -17,10 +17,13 @@ type Config struct { // 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. 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 @@ -179,6 +182,12 @@ func ExportTargetFromObject(obj map[string]interface{}) (ExportTarget, error) { // BpPath - can be empty bpPath, _ := obj["bpPath"].(string) result.BpPath = bpPath + // RpName - can be empty + rpName, _ := obj["rpName"].(string) + result.RpName = rpName + // BpName - can be empty + bpName, _ := obj["bpName"].(string) + result.BpName = bpName // WorldName - can be empty worldName, _ := obj["worldName"].(string) result.WorldName = worldName diff --git a/regolith/evaluator.go b/regolith/evaluator.go new file mode 100644 index 00000000..b22c958c --- /dev/null +++ b/regolith/evaluator.go @@ -0,0 +1,60 @@ +package regolith + +import ( + "runtime" + + "github.com/Bedrock-OSS/go-burrito/burrito" + "github.com/stirante/go-simple-eval/eval" + "github.com/stirante/go-simple-eval/eval/utils" +) + +// EvalCondition evaluates a condition expression with the given context. +func EvalCondition(expression string, ctx RunContext) (bool, error) { + Logger.Debugf("Evaluating condition: %s", expression) + t := prepareScope(ctx) + Logger.Debugf("Evaluation scope: %s", utils.ToString(t)) + e, err := eval.Eval(expression, t) + if err != nil { + return false, burrito.WrapErrorf(err, "Failed to evaluate condition: %s", expression) + } + Logger.Debugf("Condition evaluated to: %s", utils.ToString(e)) + return utils.ToBoolean(e), nil +} + +// EvalString evaluates an expression with the given context and returns the +// result as a string. +func EvalString(expression string, ctx RunContext) (string, error) { + Logger.Debugf("Evaluating expression: %s", expression) + t := prepareScope(ctx) + Logger.Debugf("Evaluation scope: %s", utils.ToString(t)) + e, err := eval.Eval(expression, t) + if err != nil { + return "", burrito.WrapErrorf(err, "Failed to evaluate condition: %s", expression) + } + Logger.Debugf("Expression evaluated to: %s", utils.ToString(e)) + if v, ok := e.(string); ok { + return v, nil + } + return "", burrito.WrapErrorf(err, "Expression evaluated to non-string value: %s", expression) +} + +func prepareScope(ctx RunContext) map[string]interface{} { + semverString, err := utils.ParseSemverString(Version) + if err != nil { + semverString = utils.Semver{} + } + projectData := map[string]interface{}{ + "name": ctx.Config.Name, + "author": ctx.Config.Author, + } + return map[string]interface{}{ + "os": runtime.GOOS, + "arch": runtime.GOARCH, + "debug": burrito.PrintStackTrace, + "version": semverString, + "profile": ctx.Profile, + "filterLocation": ctx.AbsoluteLocation, + "settings": ctx.Settings, + "project": projectData, + } +} diff --git a/regolith/export.go b/regolith/export.go index 9925b1a1..36cdc5f8 100644 --- a/regolith/export.go +++ b/regolith/export.go @@ -12,98 +12,148 @@ import ( // resource pack based on exportTarget (a structure with data related to // export settings) and the name of the project. func GetExportPaths( - exportTarget ExportTarget, name string, + exportTarget ExportTarget, ctx RunContext, ) (bpPath string, rpPath string, err error) { + bpName, rpName, err := GetExportNames(exportTarget, ctx) if exportTarget.Target == "development" { comMojang, err := FindMojangDir() if err != nil { return "", "", burrito.WrapError( err, "Failed to find \"com.mojang\" directory.") } - - // TODO - I don't like the _rp and _bp suffixes. Can we get rid of that? - // I for example always name my packs "0". - bpPath = comMojang + "/development_behavior_packs/" + name + "_bp" - rpPath = comMojang + "/development_resource_packs/" + name + "_rp" + return GetDevelopmentExportPaths(bpName, rpName, comMojang) } else if exportTarget.Target == "preview" { comMojang, err := FindPreviewDir() if err != nil { return "", "", burrito.WrapError( err, "Failed to find preview \"com.mojang\" directory.") } - - // TODO - I don't like the _rp and _bp suffixes. Can we get rid of that? - // I for example always name my packs "0". - bpPath = comMojang + "/development_behavior_packs/" + name + "_bp" - rpPath = comMojang + "/development_resource_packs/" + name + "_rp" + return GetDevelopmentExportPaths(bpName, rpName, comMojang) } else if exportTarget.Target == "exact" { - bpPath, err = ResolvePath(exportTarget.BpPath) + return GetExactExportPaths(exportTarget) + } else if exportTarget.Target == "world" { + return GetWorldExportPaths(exportTarget, bpName, rpName) + } else if exportTarget.Target == "local" { + bpPath = "build/" + bpName + "/" + rpPath = "build/" + rpName + "/" + } else if exportTarget.Target == "none" { + bpPath = "" + rpPath = "" + } else { + err = burrito.WrappedErrorf( + "Export target %q is not valid", exportTarget.Target) + } + return +} + +func GetDevelopmentExportPaths(bpName, rpName, comMojang string) (bpPath string, rpPath string, err error) { + if err != nil { + return "", "", burrito.WrapError( + err, "Failed to find \"com.mojang\" directory.") + } + + bpPath = comMojang + "/development_behavior_packs/" + bpName + rpPath = comMojang + "/development_resource_packs/" + rpName + return +} + +func GetExactExportPaths(exportTarget ExportTarget) (bpPath string, rpPath string, err error) { + bpPath, err = ResolvePath(exportTarget.BpPath) + if err != nil { + return "", "", burrito.WrapError( + err, "Failed to resolve behavior pack path.") + } + rpPath, err = ResolvePath(exportTarget.RpPath) + if err != nil { + return "", "", burrito.WrapError( + err, "Failed to resolve resource pack path.") + } + return +} + +func GetWorldExportPaths(exportTarget ExportTarget, bpName, rpName string) (bpPath string, rpPath string, err error) { + if exportTarget.WorldPath != "" { + if exportTarget.WorldName != "" { + return "", "", burrito.WrappedError( + "Using both \"worldName\" and \"worldPath\" is not" + + " allowed.") + } + wPath, err := ResolvePath(exportTarget.WorldPath) if err != nil { return "", "", burrito.WrapError( - err, "Failed to resolve behavior pack path.") + err, "Failed to resolve world path.") } - rpPath, err = ResolvePath(exportTarget.RpPath) + bpPath = filepath.Join( + wPath, "behavior_packs", bpName) + rpPath = filepath.Join( + wPath, "resource_packs", rpName) + } else if exportTarget.WorldName != "" { + dir, err := FindMojangDir() if err != nil { return "", "", burrito.WrapError( - err, "Failed to resolve resource pack path.") + err, "Failed to find \"com.mojang\" directory.") } - } else if exportTarget.Target == "world" { - if exportTarget.WorldPath != "" { - if exportTarget.WorldName != "" { - return "", "", burrito.WrappedError( - "Using both \"worldName\" and \"worldPath\" is not" + - " allowed.") - } - wPath, err := ResolvePath(exportTarget.WorldPath) - if err != nil { - return "", "", burrito.WrapError( - err, "Failed to resolve world path.") - } - bpPath = filepath.Join( - wPath, "behavior_packs", name+"_bp") - rpPath = filepath.Join( - wPath, "resource_packs", name+"_rp") - } else if exportTarget.WorldName != "" { - dir, err := FindMojangDir() - if err != nil { - return "", "", burrito.WrapError( - err, "Failed to find \"com.mojang\" directory.") - } - worlds, err := ListWorlds(dir) - if err != nil { - return "", "", burrito.WrapError(err, "Failed to list worlds.") - } - for _, world := range worlds { - if world.Name == exportTarget.WorldName { - bpPath = filepath.Join( - world.Path, "behavior_packs", name+"_bp") - rpPath = filepath.Join( - world.Path, "resource_packs", name+"_rp") - } + worlds, err := ListWorlds(dir) + if err != nil { + return "", "", burrito.WrapError(err, "Failed to list worlds.") + } + for _, world := range worlds { + if world.Name == exportTarget.WorldName { + bpPath = filepath.Join( + world.Path, "behavior_packs", bpName) + rpPath = filepath.Join( + world.Path, "resource_packs", rpName) } - } else { - err = burrito.WrappedError( - "The \"world\" export target requires either a " + - "\"worldName\" or \"worldPath\" property") } - } else if exportTarget.Target == "local" { - bpPath = "build/BP/" - rpPath = "build/RP/" } else { - err = burrito.WrappedErrorf( - "Export target %q is not valid", exportTarget.Target) + err = burrito.WrappedError( + "The \"world\" export target requires either a " + + "\"worldName\" or \"worldPath\" property") + } + return +} + +// 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 GetExportNames(exportTarget ExportTarget, ctx RunContext) (bpName string, rpName string, err error) { + if exportTarget.BpName != "" { + bpName, err = EvalString(exportTarget.BpName, ctx) + if err != nil { + return "", "", burrito.WrapError( + err, "Failed to evaluate behavior pack name.") + } + } else { + bpName = ctx.Config.Name + "_bp" + } + if exportTarget.RpName != "" { + rpName, err = EvalString(exportTarget.RpName, ctx) + if err != nil { + return "", "", burrito.WrapError( + err, "Failed to evaluate resource pack name.") + } + } else { + rpName = ctx.Config.Name + "_rp" } return } // 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 ExportProject( - profile Profile, name, dataPath, dotRegolithPath string, -) error { +func ExportProject(ctx RunContext) error { + profile, err := ctx.GetProfile() + if err != nil { + return burrito.WrapError(err, runContextGetProfileError) + } + if profile.ExportTarget.Target == "none" { + Logger.Debugf("Export target is set to \"none\". Skipping export.") + return nil + } + dataPath := ctx.Config.DataPath + dotRegolithPath := ctx.DotRegolithPath // Get the export target paths exportTarget := profile.ExportTarget - bpPath, rpPath, err := GetExportPaths(exportTarget, name) + bpPath, rpPath, err := GetExportPaths(exportTarget, ctx) if err != nil { return burrito.WrapError( err, "Failed to get generate export paths.") diff --git a/regolith/main_functions.go b/regolith/main_functions.go index 1a22e31d..10922899 100644 --- a/regolith/main_functions.go +++ b/regolith/main_functions.go @@ -452,7 +452,7 @@ func Init(debug, force bool) error { // Add the schema property, this is a little hacky rawJsonData := make(map[string]interface{}, 0) json.Unmarshal(jsonBytes, &rawJsonData) - rawJsonData["$schema"] = "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.1.json" + rawJsonData["$schema"] = "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json" jsonBytes, _ = json.MarshalIndent(rawJsonData, "", "\t") err = os.WriteFile(ConfigFilePath, jsonBytes, 0644) diff --git a/regolith/profile.go b/regolith/profile.go index 0d2ca749..2a203075 100644 --- a/regolith/profile.go +++ b/regolith/profile.go @@ -113,11 +113,7 @@ func CheckProfileImpl( func RunProfile(context RunContext) error { start: // Prepare tmp files - profile, err := context.GetProfile() - if err != nil { - return burrito.WrapErrorf(err, runContextGetProfileError) - } - err = SetupTmpFiles(*context.Config, context.DotRegolithPath) + err := SetupTmpFiles(*context.Config, context.DotRegolithPath) if err != nil { return burrito.WrapErrorf(err, setupTmpFilesError, context.DotRegolithPath) } @@ -135,8 +131,7 @@ start: // Export files Logger.Info("Moving files to target directory.") start := time.Now() - err = ExportProject( - profile, context.Config.Name, context.Config.DataPath, context.DotRegolithPath) + err = ExportProject(context) if err != nil { return burrito.WrapError(err, exportProjectError) } @@ -260,6 +255,8 @@ type FilterCollection struct { Filters []FilterRunner `json:"filters"` } +// Profile is a collection of filters and an export target +// When editing, adjust ProfileFromObject function as well type Profile struct { FilterCollection ExportTarget ExportTarget `json:"export,omitempty"` diff --git a/test/common.go b/test/common.go index e9fa53b5..af250bab 100644 --- a/test/common.go +++ b/test/common.go @@ -70,6 +70,12 @@ const ( // the execution. conditionalFilterPath = "testdata/conditional_filter" + // customPackNamePath contains two subdirectories 'project' and + // 'expected_build_result'. The project is a Regolith project with custom + // rpName and bpName properties in the filter. The 'expected_build_result' + // contains the expected content of the build directory. + customPackNamePath = "testdata/custom_pack_name" + dataModifyRemoteFilter = "testdata/data_modify_remote_filter" ) diff --git a/test/custom_pack_name_test.go b/test/custom_pack_name_test.go new file mode 100644 index 00000000..ac0434ee --- /dev/null +++ b/test/custom_pack_name_test.go @@ -0,0 +1,40 @@ +package test + +import ( + "os" + "path/filepath" + "testing" + + "github.com/Bedrock-OSS/regolith/regolith" +) + +// TestCustomPackName runs a test that checks whether the rpName and bpName +// properties of a filter properly change the name of the directories created +// for resource pack and behavior pack in the "local" export mode. +func TestCustomPackName(t *testing.T) { + // Switch to current working directory at the end of the test + defer os.Chdir(getWdOrFatal(t)) + + // TEST PREPARATION + t.Log("Clearing the testing directory...") + tmpDir := prepareTestDirectory("TestCustomPackName", t) + + t.Log("Copying the project files into the testing directory...") + project := absOrFatal(filepath.Join(customPackNamePath, "project"), t) + copyFilesOrFatal(project, tmpDir, t) + + // Load abs path of the expected result and switch to the working directory + expectedBuildResult := absOrFatal( + filepath.Join(customPackNamePath, "expected_build_result"), t) + os.Chdir(tmpDir) + + // THE TEST + t.Log("Running Regolith with a conditional filter...") + if err := regolith.Run("default", true); err != nil { + t.Fatal("'regolith run' failed:", err.Error()) + } + + // TEST EVALUATION + t.Log("Evaluating the test results...") + comparePaths(expectedBuildResult, filepath.Join(tmpDir, "build"), t) +} diff --git a/test/local_filters_test.go b/test/local_filters_test.go index d07bac8e..8be38f22 100644 --- a/test/local_filters_test.go +++ b/test/local_filters_test.go @@ -119,7 +119,7 @@ func TestProfileFilterRun(t *testing.T) { // Load abs path of the expected result and switch to the working directory expectedBuildResult := absOrFatal( - filepath.Join(exeFilterPath, "expected_build_result"), t) + filepath.Join(profileFilterPath, "expected_build_result"), t) os.Chdir(tmpDir) // THE TEST diff --git a/test/testdata/apply_filter/filtered_project/config.json b/test/testdata/apply_filter/filtered_project/config.json index ad8fa269..4444ec8b 100644 --- a/test/testdata/apply_filter/filtered_project/config.json +++ b/test/testdata/apply_filter/filtered_project/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/apply_filter/project/config.json b/test/testdata/apply_filter/project/config.json index ad8fa269..4444ec8b 100644 --- a/test/testdata/apply_filter/project/config.json +++ b/test/testdata/apply_filter/project/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/conditional_filter/expected_build_result/BP/manifest.json b/test/testdata/conditional_filter/expected_build_result/regolith_test_project_bp/manifest.json similarity index 100% rename from test/testdata/conditional_filter/expected_build_result/BP/manifest.json rename to test/testdata/conditional_filter/expected_build_result/regolith_test_project_bp/manifest.json diff --git a/test/testdata/conditional_filter/expected_build_result/BP/out.txt b/test/testdata/conditional_filter/expected_build_result/regolith_test_project_bp/out.txt similarity index 100% rename from test/testdata/conditional_filter/expected_build_result/BP/out.txt rename to test/testdata/conditional_filter/expected_build_result/regolith_test_project_bp/out.txt diff --git a/test/testdata/conditional_filter/expected_build_result/RP/manifest.json b/test/testdata/conditional_filter/expected_build_result/regolith_test_project_rp/manifest.json similarity index 100% rename from test/testdata/conditional_filter/expected_build_result/RP/manifest.json rename to test/testdata/conditional_filter/expected_build_result/regolith_test_project_rp/manifest.json diff --git a/test/testdata/conditional_filter/project/config.json b/test/testdata/conditional_filter/project/config.json index 02fbd594..6a915909 100644 --- a/test/testdata/conditional_filter/project/config.json +++ b/test/testdata/conditional_filter/project/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "name": "regolith_test_project", "author": "Bedrock-OSS", "packs": { diff --git a/test/testdata/custom_pack_name/expected_build_result/CustomExportPackName_by_Bedrock-OSS_BP/some_bp_file.txt b/test/testdata/custom_pack_name/expected_build_result/CustomExportPackName_by_Bedrock-OSS_BP/some_bp_file.txt new file mode 100644 index 00000000..b97a0d79 --- /dev/null +++ b/test/testdata/custom_pack_name/expected_build_result/CustomExportPackName_by_Bedrock-OSS_BP/some_bp_file.txt @@ -0,0 +1 @@ +This is an example behavior pack file to test if exporting works as exected. \ No newline at end of file diff --git a/test/testdata/custom_pack_name/expected_build_result/CustomExportPackName_by_Bedrock-OSS_RP/some_rp_file.txt b/test/testdata/custom_pack_name/expected_build_result/CustomExportPackName_by_Bedrock-OSS_RP/some_rp_file.txt new file mode 100644 index 00000000..55a60ff6 --- /dev/null +++ b/test/testdata/custom_pack_name/expected_build_result/CustomExportPackName_by_Bedrock-OSS_RP/some_rp_file.txt @@ -0,0 +1 @@ +This is an example resource pack file to test if exporting works as exected. \ No newline at end of file diff --git a/test/testdata/custom_pack_name/project/.gitignore b/test/testdata/custom_pack_name/project/.gitignore new file mode 100644 index 00000000..3f195ca9 --- /dev/null +++ b/test/testdata/custom_pack_name/project/.gitignore @@ -0,0 +1,2 @@ +/build +/.regolith \ No newline at end of file diff --git a/test/testdata/custom_pack_name/project/config.json b/test/testdata/custom_pack_name/project/config.json new file mode 100644 index 00000000..c1bb592e --- /dev/null +++ b/test/testdata/custom_pack_name/project/config.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", + "author": "Bedrock-OSS", + "name": "CustomExportPackName", + "packs": { + "behaviorPack": "./packs/BP", + "resourcePack": "./packs/RP" + }, + "regolith": { + "dataPath": "./packs/data", + "filterDefinitions": {}, + "profiles": { + "default": { + "export": { + "readOnly": false, + "target": "local", + "bpName": "project.name + '_by_' + project.author + '_BP'", + "rpName": "project.name + '_by_' + project.author + '_RP'" + }, + "filters": [] + } + } + } +} \ No newline at end of file diff --git a/test/testdata/custom_pack_name/project/packs/BP/some_bp_file.txt b/test/testdata/custom_pack_name/project/packs/BP/some_bp_file.txt new file mode 100644 index 00000000..b97a0d79 --- /dev/null +++ b/test/testdata/custom_pack_name/project/packs/BP/some_bp_file.txt @@ -0,0 +1 @@ +This is an example behavior pack file to test if exporting works as exected. \ No newline at end of file diff --git a/test/testdata/custom_pack_name/project/packs/RP/some_rp_file.txt b/test/testdata/custom_pack_name/project/packs/RP/some_rp_file.txt new file mode 100644 index 00000000..55a60ff6 --- /dev/null +++ b/test/testdata/custom_pack_name/project/packs/RP/some_rp_file.txt @@ -0,0 +1 @@ +This is an example resource pack file to test if exporting works as exected. \ No newline at end of file diff --git a/test/testdata/data_modify_remote_filter/after_run/build/BP/.ignoreme b/test/testdata/custom_pack_name/project/packs/data/.ignoreme similarity index 100% rename from test/testdata/data_modify_remote_filter/after_run/build/BP/.ignoreme rename to test/testdata/custom_pack_name/project/packs/data/.ignoreme diff --git a/test/testdata/data_modify_remote_filter/after_run/.regolith/cache/edited_files.json b/test/testdata/data_modify_remote_filter/after_run/.regolith/cache/edited_files.json index adb9ebfd..bca28767 100644 --- a/test/testdata/data_modify_remote_filter/after_run/.regolith/cache/edited_files.json +++ b/test/testdata/data_modify_remote_filter/after_run/.regolith/cache/edited_files.json @@ -1,11 +1,11 @@ { "rp": { - "build/RP/": [ + "build/Project name_rp/": [ ".ignoreme" ] }, "bp": { - "build/BP/": [ + "build/Project name_bp/": [ ".ignoreme" ] } diff --git a/test/testdata/data_modify_remote_filter/after_run/build/RP/.ignoreme b/test/testdata/data_modify_remote_filter/after_run/build/Project name_bp/.ignoreme similarity index 100% rename from test/testdata/data_modify_remote_filter/after_run/build/RP/.ignoreme rename to test/testdata/data_modify_remote_filter/after_run/build/Project name_bp/.ignoreme diff --git a/test/testdata/exe_filter/expected_build_result/BP/.ignoreme b/test/testdata/data_modify_remote_filter/after_run/build/Project name_rp/.ignoreme similarity index 100% rename from test/testdata/exe_filter/expected_build_result/BP/.ignoreme rename to test/testdata/data_modify_remote_filter/after_run/build/Project name_rp/.ignoreme diff --git a/test/testdata/data_modify_remote_filter/after_run/config.json b/test/testdata/data_modify_remote_filter/after_run/config.json index ffdfc919..2937da2a 100644 --- a/test/testdata/data_modify_remote_filter/after_run/config.json +++ b/test/testdata/data_modify_remote_filter/after_run/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/data_modify_remote_filter/project/config.json b/test/testdata/data_modify_remote_filter/project/config.json index ffdfc919..2937da2a 100644 --- a/test/testdata/data_modify_remote_filter/project/config.json +++ b/test/testdata/data_modify_remote_filter/project/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/double_remote_project/config.json b/test/testdata/double_remote_project/config.json index 226bce18..3e0802ae 100644 --- a/test/testdata/double_remote_project/config.json +++ b/test/testdata/double_remote_project/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "name": "regolith_test_project", "author": "Bedrock-OSS", "packs": { diff --git a/test/testdata/double_remote_project_installed/config.json b/test/testdata/double_remote_project_installed/config.json index 226bce18..3e0802ae 100644 --- a/test/testdata/double_remote_project_installed/config.json +++ b/test/testdata/double_remote_project_installed/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "name": "regolith_test_project", "author": "Bedrock-OSS", "packs": { diff --git a/test/testdata/exe_filter/expected_build_result/RP/.ignoreme b/test/testdata/exe_filter/expected_build_result/exe_filter_test_project_bp/.ignoreme similarity index 100% rename from test/testdata/exe_filter/expected_build_result/RP/.ignoreme rename to test/testdata/exe_filter/expected_build_result/exe_filter_test_project_bp/.ignoreme diff --git a/test/testdata/exe_filter/expected_build_result/BP/hello.txt b/test/testdata/exe_filter/expected_build_result/exe_filter_test_project_bp/hello.txt similarity index 100% rename from test/testdata/exe_filter/expected_build_result/BP/hello.txt rename to test/testdata/exe_filter/expected_build_result/exe_filter_test_project_bp/hello.txt diff --git a/test/testdata/profile_filter/expected_build_result/BP/.ignoreme b/test/testdata/exe_filter/expected_build_result/exe_filter_test_project_rp/.ignoreme similarity index 100% rename from test/testdata/profile_filter/expected_build_result/BP/.ignoreme rename to test/testdata/exe_filter/expected_build_result/exe_filter_test_project_rp/.ignoreme diff --git a/test/testdata/exe_filter/project/config.json b/test/testdata/exe_filter/project/config.json index 77e70500..72c52796 100644 --- a/test/testdata/exe_filter/project/config.json +++ b/test/testdata/exe_filter/project/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "name": "exe_filter_test_project", "author": "Bedrock-OSS", "packs": { diff --git a/test/testdata/fresh_project/config.json b/test/testdata/fresh_project/config.json index 6d424a70..522add5d 100644 --- a/test/testdata/fresh_project/config.json +++ b/test/testdata/fresh_project/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/local_requirements/project/config.json b/test/testdata/local_requirements/project/config.json index 99c389f5..c6df94ac 100644 --- a/test/testdata/local_requirements/project/config.json +++ b/test/testdata/local_requirements/project/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "name": "Local Requirements Test Project", "author": "Bedrock-OSS", "packs": { diff --git a/test/testdata/minimal_project/config.json b/test/testdata/minimal_project/config.json index 7564eb0a..ce5bd8f8 100644 --- a/test/testdata/minimal_project/config.json +++ b/test/testdata/minimal_project/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "name": "regolith_test_project", "author": "Bedrock-OSS", "packs": { diff --git a/test/testdata/multitarget_project/config.json b/test/testdata/multitarget_project/config.json index 51e9e380..02388da0 100644 --- a/test/testdata/multitarget_project/config.json +++ b/test/testdata/multitarget_project/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "name": "regolith_test_project", "author": "Bedrock-OSS", "packs": { diff --git a/test/testdata/profile_filter/expected_build_result/RP/.ignoreme b/test/testdata/profile_filter/expected_build_result/nested_filter_test_project_bp/.ignoreme similarity index 100% rename from test/testdata/profile_filter/expected_build_result/RP/.ignoreme rename to test/testdata/profile_filter/expected_build_result/nested_filter_test_project_bp/.ignoreme diff --git a/test/testdata/profile_filter/expected_build_result/BP/hello.txt b/test/testdata/profile_filter/expected_build_result/nested_filter_test_project_bp/hello.txt similarity index 100% rename from test/testdata/profile_filter/expected_build_result/BP/hello.txt rename to test/testdata/profile_filter/expected_build_result/nested_filter_test_project_bp/hello.txt diff --git a/test/testdata/profile_filter/expected_build_result/nested_filter_test_project_rp/.ignoreme b/test/testdata/profile_filter/expected_build_result/nested_filter_test_project_rp/.ignoreme new file mode 100644 index 00000000..de58919d --- /dev/null +++ b/test/testdata/profile_filter/expected_build_result/nested_filter_test_project_rp/.ignoreme @@ -0,0 +1 @@ +This file is used for testing to simulate an empty directory because git doesn't allow saving empty directories. \ No newline at end of file diff --git a/test/testdata/profile_filter/project/config.json b/test/testdata/profile_filter/project/config.json index 242df18e..d8bd551b 100644 --- a/test/testdata/profile_filter/project/config.json +++ b/test/testdata/profile_filter/project/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "name": "nested_filter_test_project", "author": "Bedrock-OSS", "packs": { diff --git a/test/testdata/regolith_install/1.0.0/config.json b/test/testdata/regolith_install/1.0.0/config.json index e2efe87c..220bb8ae 100644 --- a/test/testdata/regolith_install/1.0.0/config.json +++ b/test/testdata/regolith_install/1.0.0/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/regolith_install/1.0.1/config.json b/test/testdata/regolith_install/1.0.1/config.json index 68d0859c..82aef93b 100644 --- a/test/testdata/regolith_install/1.0.1/config.json +++ b/test/testdata/regolith_install/1.0.1/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/regolith_install/HEAD/config.json b/test/testdata/regolith_install/HEAD/config.json index 84a67c90..883cc0ce 100644 --- a/test/testdata/regolith_install/HEAD/config.json +++ b/test/testdata/regolith_install/HEAD/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/regolith_install/latest/config.json b/test/testdata/regolith_install/latest/config.json index 4ceead87..2ab3fc35 100644 --- a/test/testdata/regolith_install/latest/config.json +++ b/test/testdata/regolith_install/latest/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/regolith_install/sha/config.json b/test/testdata/regolith_install/sha/config.json index b52d0ac0..f0f92b75 100644 --- a/test/testdata/regolith_install/sha/config.json +++ b/test/testdata/regolith_install/sha/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/regolith_install/tag/config.json b/test/testdata/regolith_install/tag/config.json index cab80677..260d7c40 100644 --- a/test/testdata/regolith_install/tag/config.json +++ b/test/testdata/regolith_install/tag/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/regolith_update/1.0.0/config.json b/test/testdata/regolith_update/1.0.0/config.json index 2913ce23..8e8840c5 100644 --- a/test/testdata/regolith_update/1.0.0/config.json +++ b/test/testdata/regolith_update/1.0.0/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/regolith_update/1.0.1/config.json b/test/testdata/regolith_update/1.0.1/config.json index b90139ce..f35ac642 100644 --- a/test/testdata/regolith_update/1.0.1/config.json +++ b/test/testdata/regolith_update/1.0.1/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/regolith_update/HEAD/config.json b/test/testdata/regolith_update/HEAD/config.json index 527595ed..91705a3d 100644 --- a/test/testdata/regolith_update/HEAD/config.json +++ b/test/testdata/regolith_update/HEAD/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/regolith_update/fresh_project/config.json b/test/testdata/regolith_update/fresh_project/config.json index 59bdcf69..522add5d 100644 --- a/test/testdata/regolith_update/fresh_project/config.json +++ b/test/testdata/regolith_update/fresh_project/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/regolith_update/latest/config.json b/test/testdata/regolith_update/latest/config.json index 17510b4c..558923fd 100644 --- a/test/testdata/regolith_update/latest/config.json +++ b/test/testdata/regolith_update/latest/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/regolith_update/sha/config.json b/test/testdata/regolith_update/sha/config.json index a7d25048..a3b51b04 100644 --- a/test/testdata/regolith_update/sha/config.json +++ b/test/testdata/regolith_update/sha/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/regolith_update/tag/config.json b/test/testdata/regolith_update/tag/config.json index a7ce9660..4b2236d9 100644 --- a/test/testdata/regolith_update/tag/config.json +++ b/test/testdata/regolith_update/tag/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "author": "Your name", "name": "Project name", "packs": { diff --git a/test/testdata/run_missing_rp_project/config.json b/test/testdata/run_missing_rp_project/config.json index 9ab9c9e8..5ca5dd6a 100644 --- a/test/testdata/run_missing_rp_project/config.json +++ b/test/testdata/run_missing_rp_project/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "name": "filter_tester example", "author": "Bedrock-OSS", "packs": { diff --git a/test/testdata/versioned_remote_filter_project/config.json b/test/testdata/versioned_remote_filter_project/config.json index e4c693b2..d0e7e9a6 100644 --- a/test/testdata/versioned_remote_filter_project/config.json +++ b/test/testdata/versioned_remote_filter_project/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "name": "regolith_test_project", "author": "Bedrock-OSS", "packs": { diff --git a/test/testdata/versioned_remote_filter_project_after_run/.regolith/cache/edited_files.json b/test/testdata/versioned_remote_filter_project_after_run/.regolith/cache/edited_files.json index a21b2719..efcc62ff 100644 --- a/test/testdata/versioned_remote_filter_project_after_run/.regolith/cache/edited_files.json +++ b/test/testdata/versioned_remote_filter_project_after_run/.regolith/cache/edited_files.json @@ -1,11 +1,11 @@ { "rp": { - "build/RP/": [ + "build/regolith_test_project_rp/": [ "manifest.json" ] }, "bp": { - "build/BP/": [ + "build/regolith_test_project_bp/": [ "hello_version.txt", "manifest.json" ] diff --git a/test/testdata/versioned_remote_filter_project_after_run/build/BP/hello_version.txt b/test/testdata/versioned_remote_filter_project_after_run/build/regolith_test_project_bp/hello_version.txt similarity index 100% rename from test/testdata/versioned_remote_filter_project_after_run/build/BP/hello_version.txt rename to test/testdata/versioned_remote_filter_project_after_run/build/regolith_test_project_bp/hello_version.txt diff --git a/test/testdata/versioned_remote_filter_project_after_run/build/BP/manifest.json b/test/testdata/versioned_remote_filter_project_after_run/build/regolith_test_project_bp/manifest.json similarity index 100% rename from test/testdata/versioned_remote_filter_project_after_run/build/BP/manifest.json rename to test/testdata/versioned_remote_filter_project_after_run/build/regolith_test_project_bp/manifest.json diff --git a/test/testdata/versioned_remote_filter_project_after_run/build/RP/manifest.json b/test/testdata/versioned_remote_filter_project_after_run/build/regolith_test_project_rp/manifest.json similarity index 100% rename from test/testdata/versioned_remote_filter_project_after_run/build/RP/manifest.json rename to test/testdata/versioned_remote_filter_project_after_run/build/regolith_test_project_rp/manifest.json diff --git a/test/testdata/versioned_remote_filter_project_after_run/config.json b/test/testdata/versioned_remote_filter_project_after_run/config.json index e4c693b2..d0e7e9a6 100644 --- a/test/testdata/versioned_remote_filter_project_after_run/config.json +++ b/test/testdata/versioned_remote_filter_project_after_run/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.2.json", "name": "regolith_test_project", "author": "Bedrock-OSS", "packs": {