diff --git a/docs/docs/guide/configuration.md b/docs/docs/guide/configuration.md index 83651e94..cbbbcef0 100644 --- a/docs/docs/guide/configuration.md +++ b/docs/docs/guide/configuration.md @@ -76,6 +76,7 @@ Example config, with many options explained: // Export target defines where your files will be exported "export": { "target": "development", + "build": "standard", "readOnly": false } } diff --git a/docs/docs/guide/create-a-filter.md b/docs/docs/guide/create-a-filter.md index 7217eb90..f9cd606c 100644 --- a/docs/docs/guide/create-a-filter.md +++ b/docs/docs/guide/create-a-filter.md @@ -48,6 +48,7 @@ At this point, you need to edit your `config.json` so that `giant_mobs` is regis ], "export": { "target": "development", + "build": "standard", "readOnly": true } } diff --git a/docs/docs/guide/export-targets.md b/docs/docs/guide/export-targets.md index 660f3e77..b35f6b89 100644 --- a/docs/docs/guide/export-targets.md +++ b/docs/docs/guide/export-targets.md @@ -29,11 +29,12 @@ These are the export targets that Regolith offers. ## Development -The development export target will place the compiled packs into your `com.mojang` `development_*_packs` folders. +The development export target will place the compiled packs into your `com.mojang` `development_*_packs` folders of the specified Minecraft build (standard, preview or education endition). ```json "export": { - "target": "development" + "target": "development", + "build": "standard" // or "preview" or "education" } ``` @@ -42,6 +43,7 @@ Optionally, you can use `rpName` and `bpName` to specify the names of the folder ```json "export": { "target": "development", + "build": "standard", "rpName": "'my_rp'", "bpName": "'my_bp'" } @@ -91,13 +93,14 @@ The exact export target doesn't support using `rpName` and `bpName`. The `rpPath 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. -You need to use *either* `worldName` or `worldPath` to select the world. `worldPath` supports environment variables by using the `%VARIABLE_NAME%` syntax. +You need to use *either* `worldName` or `worldPath` to select the world. `worldPath` supports environment variables by using the `%VARIABLE_NAME%` syntax. If you use `worldName`, you have to specify the Minecraft build you're using - `standard`, `preview` or `education`. Example: ```json "export": { "target": "world", + "build": "standard", "worldName": "..." // This // "worldPath": "..." // OR this } @@ -114,26 +117,6 @@ Optionally, you can use `rpName` and `bpName` to specify the names of the folder } ``` - -## Preview - -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. diff --git a/docs/docs/guide/getting-started.md b/docs/docs/guide/getting-started.md index 32f99357..5f723077 100644 --- a/docs/docs/guide/getting-started.md +++ b/docs/docs/guide/getting-started.md @@ -51,6 +51,7 @@ Next, open up `config.json`. We will be configuring a few fields here, for your "filters": [], "export": { "target": "development", + "build": "standard", "readOnly": false } } @@ -115,7 +116,8 @@ You should adjust the default profile in `config.json` to look like this: "default": { "export": { "readOnly": false, - "target": "development" + "target": "development", + "build": "standard" }, "filters": [ { diff --git a/docs/docs/guide/installing-filters.md b/docs/docs/guide/installing-filters.md index 4a6535c5..b6afe958 100644 --- a/docs/docs/guide/installing-filters.md +++ b/docs/docs/guide/installing-filters.md @@ -49,7 +49,8 @@ After installing, the filter will appear inside of `filter_definitions` of `conf "default": { "export": { "readOnly": false, - "target": "development" + "target": "development", + "build": "standard" }, "filters": [ { diff --git a/docs/docs/guide/profiles.md b/docs/docs/guide/profiles.md index e5ba0e82..85cc5414 100644 --- a/docs/docs/guide/profiles.md +++ b/docs/docs/guide/profiles.md @@ -40,6 +40,7 @@ Here is an example `config.json` with a second profile called `package`. ], "export": { "target": "development", + "build": "standard" } }, @@ -50,6 +51,7 @@ Here is an example `config.json` with a second profile called `package`. ], "export": { "target": "development", + "build": "standard" } } }, diff --git a/regolith/compatibility_other_os.go b/regolith/compatibility_other_os.go index 7fd9d3da..a7d520a0 100644 --- a/regolith/compatibility_other_os.go +++ b/regolith/compatibility_other_os.go @@ -5,6 +5,7 @@ package regolith import ( "os" + "github.com/Bedrock-OSS/go-burrito/burrito" ) @@ -50,10 +51,10 @@ func (d *DirWatcher) Close() error { return burrito.WrappedError(notImplementedOnThisSystemError) } -func FindMojangDir() (string, error) { +func FindStandardMojangDir() (string, error) { comMojang := os.Getenv("COM_MOJANG") if comMojang == "" { - return "", burrito.WrappedError(comMojangEnvUnsetError) + return "", burrito.WrappedError(comMojangEnvUnsetError) } return comMojang, nil } @@ -61,11 +62,19 @@ func FindMojangDir() (string, error) { func FindPreviewDir() (string, error) { comMojangPreview := os.Getenv("COM_MOJANG_PREVIEW") if comMojangPreview == "" { - return "", burrito.WrappedError(comMojangPreviewEnvUnsetError) + return "", burrito.WrappedError(comMojangPreviewEnvUnsetError) } return comMojangPreview, nil } +func FindEducationDir() (string, error) { + comMojangEdu := os.Getenv("COM_MOJANG_EDU") + if comMojangEdu == "" { + return "", burrito.WrappedError(comMojangEduEnvUnsetError) + } + return comMojangEdu, nil +} + func CheckSuspiciousLocation() error { return nil } diff --git a/regolith/compatibility_windows.go b/regolith/compatibility_windows.go index b0a251e2..5ac179cf 100644 --- a/regolith/compatibility_windows.go +++ b/regolith/compatibility_windows.go @@ -146,8 +146,9 @@ func (d *DirWatcher) Close() error { return windows.CloseHandle(d.handle) } -// FindMojangDir returns path to the com.mojang folder. -func FindMojangDir() (string, error) { +// FindStandardMojangDir returns path to the com.mojang folder in the standard +// Minecraft build. +func FindStandardMojangDir() (string, error) { result := filepath.Join( os.Getenv("LOCALAPPDATA"), "Packages", "Microsoft.MinecraftUWP_8wekyb3d8bbwe", "LocalState", "games", @@ -161,6 +162,8 @@ func FindMojangDir() (string, error) { return result, nil } +// FindPreviewDir returns path to the com.mojang folder in the preview +// Minecraft build. func FindPreviewDir() (string, error) { result := filepath.Join( os.Getenv("LOCALAPPDATA"), "Packages", @@ -176,13 +179,29 @@ func FindPreviewDir() (string, error) { return result, nil } +// FindEducationDir returns path to the com.mojang folder in the education +// edition Minecraft build. +func FindEducationDir() (string, error) { + result := filepath.Join( + os.Getenv("APPDATA"), "Minecraft Education Edition", "games", + "com.mojang") + if _, err := os.Stat(result); err != nil { + if os.IsNotExist(err) { + return "", burrito.WrapErrorf(err, osStatErrorIsNotExist, result) + } + return "", burrito.WrapErrorf( + err, osStatErrorAny, result) + } + return result, nil +} + func CheckSuspiciousLocation() error { path, err := os.Getwd() if err != nil { return burrito.WrapErrorf(err, osGetwdError) } // Check if project directory is within mojang dir - dir, err := FindMojangDir() + dir, err := FindStandardMojangDir() if err == nil { dir1 := filepath.Join(dir, "development_behavior_packs") if isPathWithinDirectory(path, dir1) { diff --git a/regolith/config.go b/regolith/config.go index 46913cde..095b376c 100644 --- a/regolith/config.go +++ b/regolith/config.go @@ -1,6 +1,11 @@ package regolith -import "github.com/Bedrock-OSS/go-burrito/burrito" +import ( + "github.com/Bedrock-OSS/go-burrito/burrito" + "golang.org/x/mod/semver" +) + +const latestCompatibleVersion = "1.4.0" const StandardLibraryUrl = "github.com/Bedrock-OSS/regolith-filters" const ConfigFilePath = "config.json" @@ -26,7 +31,8 @@ type ExportTarget struct { 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 + 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' } // Packs is a part of "config.json" that points to the source behavior and @@ -42,6 +48,7 @@ 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"` } // ConfigFromObject creates a "Config" object from map[string]interface{} @@ -109,6 +116,31 @@ func RegolithProjectFromObject( Profiles: make(map[string]Profile), FilterDefinitions: make(map[string]FilterInstaller), } + // FormatVersion + if version, ok := obj["formatVersion"]; !ok { + Logger.Warn("Format version is missing. Defaulting to 1.2.0") + result.FormatVersion = "1.2.0" + } else { + formatVersion, ok := version.(string) + if !ok { + return result, burrito.WrappedErrorf( + jsonPropertyTypeError, "formatVersion", "string") + } + result.FormatVersion = formatVersion + vFormatVersion := "v" + formatVersion + if !semver.IsValid("v" + formatVersion) { + return result, burrito.WrappedErrorf( + "Invalid value of formatVersion. The formatVersion must "+ + "be a semver version:\n"+ + "Current value: %s", formatVersion) + } + if semver.Compare(vFormatVersion, "v"+latestCompatibleVersion) > 0 { + return result, burrito.WrappedErrorf( + incompatibleFormatVersionError, + formatVersion, latestCompatibleVersion) + } + } + // DataPath if _, ok := obj["dataPath"]; !ok { return result, burrito.WrappedErrorf(jsonPropertyMissingError, "dataPath") @@ -197,5 +229,8 @@ func ExportTargetFromObject(obj map[string]interface{}) (ExportTarget, error) { // ReadOnly - can be empty readOnly, _ := obj["readOnly"].(bool) result.ReadOnly = readOnly + // Build - can be empty + build, _ := obj["build"].(string) + result.Build = build return result, nil } diff --git a/regolith/errors.go b/regolith/errors.go index 6f954b5a..b909689b 100644 --- a/regolith/errors.go +++ b/regolith/errors.go @@ -149,6 +149,9 @@ const ( // Error used when env variable COM_MOJANG_PREVIEW is not set on non Windows system comMojangPreviewEnvUnsetError = "COM_MOJANG_PREVIEW environment variable is not set." + // Error used when env variable COM_MOJANG_EDU is not set on non Windows system + comMojangEduEnvUnsetError = "COM_MOJANG_EDU environment variable is not set." + // Error used when SetupTmpFiles function fails setupTmpFilesError = "Failed to setup temporary files.\n" + "Regolith files path: %s" // .regolith @@ -222,4 +225,23 @@ const ( resolverResolveUrlError = "Failed to resolve the URL of the resolver file for the download.\n" + "Short URL: %s" + + // findMojangDirError is used when the FindMojangDir function fails + findMojangDirError = "Failed to find \"com.mojang\" directory." + + // findPreviewDirError is used when the FindPreviewDir function fails + findPreviewDirError = "Failed to find the preview \"com.mojang\" directory." + + // findEducationDirError is used when the FindEducationDir function fails + findEducationDirError = "Failed to find the \"com.mojang\" directory." + + invalidExportPathError = "The build property of the export is invalid:\n" + + "Current value: %q\n" + + "Valid values are: %s" + + // Error used when the formatVersion of the config file is incompatible + // with the current version of Regolith. + incompatibleFormatVersionError = "Incompatible formatVersion: \n" + + "Version in config: %s\n" + + "Latest compatible version: %s" ) diff --git a/regolith/export.go b/regolith/export.go index 593f0d61..a4919bac 100644 --- a/regolith/export.go +++ b/regolith/export.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/Bedrock-OSS/go-burrito/burrito" + "golang.org/x/mod/semver" ) // GetExportPaths returns file paths for exporting behavior pack and @@ -15,24 +16,71 @@ func GetExportPaths( exportTarget ExportTarget, ctx RunContext, ) (bpPath string, rpPath string, err error) { bpName, rpName, err := GetExportNames(exportTarget, ctx) + if err != nil { + return "", "", burrito.WrapError( + err, "Failed to get the export names.") + } + vFormatVersion := "v" + ctx.Config.FormatVersion + + if semver.Compare(vFormatVersion, "v1.4.0") < 0 { + bpPath, rpPath, err = getExportPathsV1_2_0( + exportTarget, bpName, rpName) + } else if semver.Compare(vFormatVersion, "v1.4.0") == 0 { + bpPath, rpPath, err = getExportPathsV1_4_0( + exportTarget, bpName, rpName) + } else { + err = burrito.WrappedErrorf( + incompatibleFormatVersionError, + ctx.Config.FormatVersion, latestCompatibleVersion) + } + return +} + +func FindMojangDir(build string) (string, error) { + if build == "standard" { + return FindStandardMojangDir() + } else if build == "preview" { + return FindPreviewDir() + } else if build == "education" { + return FindEducationDir() + // WARNING: If for some reason we will expand this in the future to + // match a new format version, we need to split this into versioned + // functions. + } else { + return "", burrito.WrappedErrorf( + invalidExportPathError, + // current value; valid values + build, "standard, preview, education") + } +} + +// getExportPathsV1_2_0 handles GetExportPaths for Regolith format versions +// below 1.4.0. +func getExportPathsV1_2_0( + exportTarget ExportTarget, bpName string, rpName string, +) (bpPath string, rpPath string, err error) { if exportTarget.Target == "development" { - comMojang, err := FindMojangDir() + comMojang, err := FindStandardMojangDir() if err != nil { return "", "", burrito.WrapError( - err, "Failed to find \"com.mojang\" directory.") + err, findMojangDirError) } 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.") + err, findPreviewDirError) } return GetDevelopmentExportPaths(bpName, rpName, comMojang) } else if exportTarget.Target == "exact" { return GetExactExportPaths(exportTarget) } else if exportTarget.Target == "world" { - return GetWorldExportPaths(exportTarget, bpName, rpName) + return GetWorldExportPaths( + exportTarget.WorldPath, + exportTarget.WorldName, + "standard", + bpName, rpName) } else if exportTarget.Target == "local" { bpPath = "build/" + bpName + "/" rpPath = "build/" + rpName + "/" @@ -46,12 +94,39 @@ func GetExportPaths( 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.") +// getExportPathsV1_4_0 handles GetExportPaths for Regolith format version +// 1.4.0. +func getExportPathsV1_4_0( + exportTarget ExportTarget, bpName string, rpName string, +) (bpPath string, rpPath string, err error) { + if exportTarget.Target == "development" { + comMojang, err := FindMojangDir(exportTarget.Build) + if err != nil { + return "", "", burrito.PassError(err) + } + return GetDevelopmentExportPaths(bpName, rpName, comMojang) + } else if exportTarget.Target == "world" { + return GetWorldExportPaths( + exportTarget.WorldPath, + exportTarget.WorldName, + exportTarget.Build, + bpName, rpName) + } else if exportTarget.Target == "exact" { + return GetExactExportPaths(exportTarget) + } 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) { bpPath = comMojang + "/development_behavior_packs/" + bpName rpPath = comMojang + "/development_resource_packs/" + rpName return @@ -71,14 +146,16 @@ func GetExactExportPaths(exportTarget ExportTarget) (bpPath string, rpPath strin return } -func GetWorldExportPaths(exportTarget ExportTarget, bpName, rpName string) (bpPath string, rpPath string, err error) { - if exportTarget.WorldPath != "" { - if exportTarget.WorldName != "" { +func GetWorldExportPaths( + worldPath, worldName, build, bpName, rpName string, +) (bpPath string, rpPath string, err error) { + if worldPath != "" { + if worldName != "" { return "", "", burrito.WrappedError( "Using both \"worldName\" and \"worldPath\" is not" + " allowed.") } - wPath, err := ResolvePath(exportTarget.WorldPath) + wPath, err := ResolvePath(worldPath) if err != nil { return "", "", burrito.WrapError( err, "Failed to resolve world path.") @@ -87,8 +164,8 @@ func GetWorldExportPaths(exportTarget ExportTarget, bpName, rpName string) (bpPa wPath, "behavior_packs", bpName) rpPath = filepath.Join( wPath, "resource_packs", rpName) - } else if exportTarget.WorldName != "" { - dir, err := FindMojangDir() + } else if worldName != "" { + dir, err := FindMojangDir(build) if err != nil { return "", "", burrito.WrapError( err, "Failed to find \"com.mojang\" directory.") @@ -98,7 +175,7 @@ func GetWorldExportPaths(exportTarget ExportTarget, bpName, rpName string) (bpPa return "", "", burrito.WrapError(err, "Failed to list worlds.") } for _, world := range worlds { - if world.Name == exportTarget.WorldName { + if world.Name == worldName { bpPath = filepath.Join( world.Path, "behavior_packs", bpName) rpPath = filepath.Join( diff --git a/regolith/main_functions.go b/regolith/main_functions.go index 0e43d9db..3414be13 100644 --- a/regolith/main_functions.go +++ b/regolith/main_functions.go @@ -449,6 +449,7 @@ func Init(debug, force bool) error { ResourceFolder: "./packs/RP", }, RegolithProject: RegolithProject{ + FormatVersion: "1.4.0", DataPath: "./packs/data", FilterDefinitions: map[string]FilterInstaller{}, Profiles: map[string]Profile{ @@ -458,6 +459,7 @@ func Init(debug, force bool) error { }, ExportTarget: ExportTarget{ Target: "development", + Build: "standard", ReadOnly: false, }, }, @@ -468,7 +470,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.2.json" + rawJsonData["$schema"] = "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.4.json" jsonBytes, _ = json.MarshalIndent(rawJsonData, "", "\t") err = os.WriteFile(ConfigFilePath, jsonBytes, 0644) diff --git a/test/common.go b/test/common.go index a83b44ff..cf8b4559 100644 --- a/test/common.go +++ b/test/common.go @@ -23,6 +23,11 @@ const ( // in data path. minimalProjectPath = "testdata/minimal_project" + // developmentExportTargets is a minimal project with 3 profiles - + // standard, education and preview. Each profile has different export + // targets. + developmentExportTargets = "testdata/development_export_targets" + // multitarget_project is a copy of minimal_project but with modified // config.json, to add multiple profiles with different export targets. multitargetProjectPath = "testdata/multitarget_project" diff --git a/test/development_export_windows_test.go b/test/development_export_windows_test.go new file mode 100644 index 00000000..38c70a7c --- /dev/null +++ b/test/development_export_windows_test.go @@ -0,0 +1,108 @@ +//go:build windows +// +build windows + +package test + +import ( + "os" + "path/filepath" + "testing" + + "github.com/Bedrock-OSS/regolith/regolith" +) + +// TestCustomDevelopmentExportLocation tests if the development export targets +// work as expected. It tesets the "development" target with the "build" +// property set to "standard" it will fail on a computer without +// Minecraft Bedrock Edition installed. +func TestDevelopmentStandardExportLocation(t *testing.T) { + if os.Getenv("CI") != "" { + t.Skip("Skipping test on local machine") + } + _testCustomDevelopmentExportLocation( + t, regolith.FindStandardMojangDir, "standard", + "TestDevelopmentStandardExportLocation") +} + +// TestDevelopmentEducationExportLocation tests if the development export +// targets work as expected. It tesets the "development" target with the +// "build" property set to "education" it will fail on a computer without +// Minecraft Bedrock Edition installed. +func TestDevelopmentEducationExportLocation(t *testing.T) { + if os.Getenv("CI") != "" { + t.Skip("Skipping test on local machine") + } + _testCustomDevelopmentExportLocation( + t, regolith.FindEducationDir, "education", + "TestDevelopmentEducationExportLocation") +} + +// TestDevelopmentPreviewExportLocation tests if the development export +// targets work as expected. It tesets the "development" target with the +// "build" property set to "preview" it will fail on a computer without +// Minecraft Bedrock Edition Preview installed. +func TestDevelopmentPreviewExportLocation(t *testing.T) { + if os.Getenv("CI") != "" { + t.Skip("Skipping test on local machine") + } + _testCustomDevelopmentExportLocation( + t, regolith.FindPreviewDir, "preview", + "TestDevelopmentPreviewExportLocation") +} + +func _testCustomDevelopmentExportLocation( + t *testing.T, mojangDirGetter func() (string, error), profileToRun string, + workingDirFolderName string, +) { + if os.Getenv("CI") != "" { + t.Skip("Skipping test on local machine") + } + regolith.InitLogging(true) + + // 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(workingDirFolderName, t) + + t.Log("Copying the project files into the testing directory...") + copyFilesOrFatal(developmentExportTargets, tmpDir, t) + os.Chdir(tmpDir) + + // FIND PATH TO com.mojang + t.Log("Finding the path to com.mojang...") + mojangDir, err := mojangDirGetter() + if err != nil { + t.Fatal(err.Error()) + } + + // LOAD DATA FROM CONFIG + // Get the name of the project from config + t.Log("Loading the data from config, befor running the test...") + configJson, err := regolith.LoadConfigAsMap() + if err != nil { + t.Fatal(err.Error()) + } + config, err := regolith.ConfigFromObject(configJson) + if err != nil { + t.Fatal(err.Error()) + } + bpPath := filepath.Join( + mojangDir, "development_behavior_packs", config.Name+"_bp") + rpPath := filepath.Join( + mojangDir, "development_resource_packs", config.Name+"_rp") + + // THE TEST + t.Log("Testing the 'regolith run' command...") + err = regolith.Run(profileToRun, true) + if err != nil { + t.Fatal("'regolith run' failed:", err) + } + + t.Log("Checking if the RP and BP have been exported...") + assertDirExistsOrFatal(rpPath, t) + defer os.RemoveAll(rpPath) + assertDirExistsOrFatal(bpPath, t) + defer os.RemoveAll(bpPath) +} diff --git a/test/export_windows_test.go b/test/export_windows_test.go index d8238036..b4a31fc7 100644 --- a/test/export_windows_test.go +++ b/test/export_windows_test.go @@ -23,6 +23,8 @@ func TestMoveFilesAcl(t *testing.T) { if os.Getenv("CI") != "" { t.Skip("Skipping test on local machine") } + regolith.InitLogging(true) + // Switch to current working directory at the end of the test defer os.Chdir(getWdOrFatal(t)) @@ -33,7 +35,7 @@ func TestMoveFilesAcl(t *testing.T) { // Find path to com.mojang t.Log("Finding the path to com.mojang...") - mojangDir, err := regolith.FindMojangDir() + mojangDir, err := regolith.FindStandardMojangDir() if err != nil { t.Fatal(err.Error()) } diff --git a/test/testdata/development_export_targets/.gitignore b/test/testdata/development_export_targets/.gitignore new file mode 100644 index 00000000..3f195ca9 --- /dev/null +++ b/test/testdata/development_export_targets/.gitignore @@ -0,0 +1,2 @@ +/build +/.regolith \ No newline at end of file diff --git a/test/testdata/development_export_targets/config.json b/test/testdata/development_export_targets/config.json new file mode 100644 index 00000000..f1218bca --- /dev/null +++ b/test/testdata/development_export_targets/config.json @@ -0,0 +1,36 @@ +{ + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.4.json", + "name": "regolith_test_project", + "author": "Bedrock-OSS", + "packs": { + "behaviorPack": "./packs/BP", + "resourcePack": "./packs/RP" + }, + "regolith": { + "formatVersion": "1.4.0", + "profiles": { + "standard": { + "filters": [], + "export": { + "target": "development", + "build": "standard" + } + }, + "education": { + "filters": [], + "export": { + "target": "development", + "build": "education" + } + }, + "preview": { + "filters": [], + "export": { + "target": "development", + "build": "preview" + } + } + }, + "dataPath": "./packs/data" + } +} \ No newline at end of file diff --git a/test/testdata/development_export_targets/packs/BP/manifest.json b/test/testdata/development_export_targets/packs/BP/manifest.json new file mode 100644 index 00000000..d493e864 --- /dev/null +++ b/test/testdata/development_export_targets/packs/BP/manifest.json @@ -0,0 +1,23 @@ +{ + "format_version": 2, + "header": { + "description": "This is test BP", + "name": "Regolith Test BP", + "uuid": "96b53fd2-b7a1-4d26-b74f-1b9394c8d0bc", + "version": [1, 0, 0], + "min_engine_version": [1, 16, 0] + }, + "modules": [ + { + "type": "data", + "uuid": "4eef1f3f-91b5-43df-b5ab-07e9aa89081b", + "version": [1, 0, 0] + } + ], + "dependencies": [ + { + "uuid": "6f6e3f0b-1627-488d-a9aa-2d1430ba368a", + "version": [1, 0, 0] + } + ] +} \ No newline at end of file diff --git a/test/testdata/development_export_targets/packs/RP/manifest.json b/test/testdata/development_export_targets/packs/RP/manifest.json new file mode 100644 index 00000000..3274a66f --- /dev/null +++ b/test/testdata/development_export_targets/packs/RP/manifest.json @@ -0,0 +1,17 @@ +{ + "format_version": 2, + "header": { + "description": "This is test RP", + "name": "Regolith Test RP", + "uuid": "6f6e3f0b-1627-488d-a9aa-2d1430ba368a", + "version": [1, 0, 0], + "min_engine_version": [1, 16, 0] + }, + "modules": [ + { + "type": "resources", + "uuid": "65b1ba69-462d-4199-aa3b-a0f161ed0bde", + "version": [1, 0, 0] + } + ] +} \ No newline at end of file diff --git a/test/testdata/development_export_targets/packs/data/example_data_file.json b/test/testdata/development_export_targets/packs/data/example_data_file.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/test/testdata/development_export_targets/packs/data/example_data_file.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test/testdata/fresh_project/config.json b/test/testdata/fresh_project/config.json index 522add5d..6883dd6e 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.2.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.4.json", "author": "Your name", "name": "Project name", "packs": { @@ -9,9 +9,11 @@ "regolith": { "dataPath": "./packs/data", "filterDefinitions": {}, + "formatVersion": "1.4.0", "profiles": { "default": { "export": { + "build": "standard", "readOnly": false, "target": "development" }, diff --git a/test/testdata/regolith_install/1.0.0/config.json b/test/testdata/regolith_install/1.0.0/config.json index 220bb8ae..3bccd486 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.2.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.4.json", "author": "Your name", "name": "Project name", "packs": { @@ -14,9 +14,11 @@ "version": "1.0.0" } }, + "formatVersion": "1.4.0", "profiles": { "default": { "export": { + "build": "standard", "readOnly": false, "target": "development" }, diff --git a/test/testdata/regolith_install/1.0.1/config.json b/test/testdata/regolith_install/1.0.1/config.json index 82aef93b..612c12be 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.2.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.4.json", "author": "Your name", "name": "Project name", "packs": { @@ -14,9 +14,11 @@ "version": "1.0.1" } }, + "formatVersion": "1.4.0", "profiles": { "default": { "export": { + "build": "standard", "readOnly": false, "target": "development" }, diff --git a/test/testdata/regolith_install/HEAD/config.json b/test/testdata/regolith_install/HEAD/config.json index 883cc0ce..3a247304 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.2.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.4.json", "author": "Your name", "name": "Project name", "packs": { @@ -14,9 +14,11 @@ "version": "HEAD" } }, + "formatVersion": "1.4.0", "profiles": { "default": { "export": { + "build": "standard", "readOnly": false, "target": "development" }, diff --git a/test/testdata/regolith_install/latest/config.json b/test/testdata/regolith_install/latest/config.json index 2ab3fc35..2c964104 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.2.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.4.json", "author": "Your name", "name": "Project name", "packs": { @@ -14,9 +14,11 @@ "version": "latest" } }, + "formatVersion": "1.4.0", "profiles": { "default": { "export": { + "build": "standard", "readOnly": false, "target": "development" }, diff --git a/test/testdata/regolith_install/sha/config.json b/test/testdata/regolith_install/sha/config.json index f0f92b75..7e22b7bb 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.2.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.4.json", "author": "Your name", "name": "Project name", "packs": { @@ -14,9 +14,11 @@ "version": "0c129227eb90e2f10a038755e4756fdd47e765e6" } }, + "formatVersion": "1.4.0", "profiles": { "default": { "export": { + "build": "standard", "readOnly": false, "target": "development" }, diff --git a/test/testdata/regolith_install/tag/config.json b/test/testdata/regolith_install/tag/config.json index 260d7c40..2cb76d4c 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.2.json", + "$schema": "https://raw.githubusercontent.com/Bedrock-OSS/regolith-schemas/main/config/v1.4.json", "author": "Your name", "name": "Project name", "packs": { @@ -14,9 +14,11 @@ "version": "TEST_TAG_1" } }, + "formatVersion": "1.4.0", "profiles": { "default": { "export": { + "build": "standard", "readOnly": false, "target": "development" },