From b68c4ddf80b7913bb93544e6361962a2615e8fb8 Mon Sep 17 00:00:00 2001 From: Futrime Date: Tue, 17 Jan 2023 11:44:22 +0800 Subject: [PATCH 1/6] Fix GOPROXY fetching bugs --- CHANGELOG.md | 8 ++++++++ src/cmd/install/utils.go | 7 +++++-- src/tooth/toothfile/toothfile.go | 10 ++++++++-- src/tooth/toothfile/utils.go | 26 ++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 426905b..3acc488 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unrelease] +## [0.1.1] - 2023-01-11 + +### Fixed + +- Fix failing to fetch tooth when the repository does not contain go.mod file. +- Fix failing to parse tooth file when the tooth is downloaded via GOPROXY. + ## [0.1.0] - 2023-01-17 ### Added @@ -14,4 +21,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Basic functions: cache, install, list, show, tooth init, and uninstall. [unreleased]: https://github.com/LiteLDev/Lip/compare/v0.1.0...HEAD +[0.1.1]: https://github.com/LiteLDev/Lip/releases/tag/v0.1.0...v0.1.1 [0.1.0]: https://github.com/LiteLDev/Lip/releases/tag/v0.1.0 \ No newline at end of file diff --git a/src/cmd/install/utils.go b/src/cmd/install/utils.go index bdbd7f3..eee4817 100644 --- a/src/cmd/install/utils.go +++ b/src/cmd/install/utils.go @@ -131,7 +131,10 @@ func fetchVersionList(repoPath string) ([]versionutils.Version, error) { var versionList []versionutils.Version scanner := bufio.NewScanner(resp.Body) for scanner.Scan() { - version, err := versionutils.NewFromString(strings.TrimPrefix(scanner.Text(), "v")) + versionString := scanner.Text() + versionString = strings.TrimPrefix(versionString, "v") + versionString = strings.TrimSuffix(versionString, "+incompatible") + version, err := versionutils.NewFromString(versionString) if err != nil { continue } @@ -182,8 +185,8 @@ func fetchLatestVersion(repoPath string) (versionutils.Version, error) { return versionutils.Version{}, errors.New("cannot find a stable latest version: " + repoPath) } - // Remove the prefix v. versionString = strings.TrimPrefix(versionString, "v") + versionString = strings.TrimSuffix(versionString, "+incompatible") // Parse the version. version, err := versionutils.NewFromString(versionString) diff --git a/src/tooth/toothfile/toothfile.go b/src/tooth/toothfile/toothfile.go index 6e6791b..818b329 100644 --- a/src/tooth/toothfile/toothfile.go +++ b/src/tooth/toothfile/toothfile.go @@ -28,10 +28,13 @@ func New(filePath string) (ToothFile, error) { } defer r.Close() + // Get the file prefix. + filePrefix := getFilePrefix(r) + // Iterate through the files in the archive, // and find tooth.json. for _, f := range r.File { - if f.Name == "tooth.json" { + if f.Name == filePrefix+"tooth.json" { // Open tooth.json. rc, err := f.Open() if err != nil { @@ -122,6 +125,9 @@ func (t ToothFile) Install() error { } defer r.Close() + // Get the file prefix. + filePrefix := getFilePrefix(r) + for _, placement := range t.metadata.Placement { source := placement.Source destination := workSpaceDir + "/" + placement.Destination @@ -137,7 +143,7 @@ func (t ToothFile) Install() error { continue } - if f.Name == source { + if f.Name == filePrefix+source { // Open the source file. rc, err := f.Open() if err != nil { diff --git a/src/tooth/toothfile/utils.go b/src/tooth/toothfile/utils.go index 951b5e5..2a32019 100644 --- a/src/tooth/toothfile/utils.go +++ b/src/tooth/toothfile/utils.go @@ -37,3 +37,29 @@ func parseMetadataPlacement(metadata toothmetadata.Metadata, r *zip.ReadCloser) return metadata } + +// getFilePrefix returns the prefix of all files in a zip file. +func getFilePrefix(r *zip.ReadCloser) string { + prefix := "" + for _, file := range r.File { + if strings.HasSuffix(file.Name, "/") { // Skip directories. + continue + } + + // If the prefix is empty, set it to the first file. + if prefix == "" { + prefix = file.Name + continue + } + + // Find the common prefix between the prefix and the file. + for i := 0; i < len(prefix) && i < len(file.Name); i++ { + if prefix[i] != file.Name[i] { + prefix = prefix[:i] + break + } + } + } + + return prefix +} From 458981e4e31cb4ac6160e67e50f9f4e32b8ef177 Mon Sep 17 00:00:00 2001 From: Futrime Date: Tue, 17 Jan 2023 14:15:24 +0800 Subject: [PATCH 2/6] Change extension name to .tth --- CHANGELOG.md | 7 ++++++- docs/en/commands/lip_install.md | 10 +++++----- docs/en/developer_s_guide.md | 2 +- docs/en/getting_started.md | 8 ++++---- docs/en/tooth_json_file_reference.md | 2 +- src/cmd/install/install.go | 2 +- src/cmd/install/specifier.go | 2 +- src/localfile/localfile.go | 2 +- src/tooth/toothfile/toothfile.go | 14 +++++++------- src/tooth/toothfile/utils.go | 9 +++++++-- 10 files changed, 34 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3acc488..a7d7a17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,12 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unrelease] -## [0.1.1] - 2023-01-11 +## [0.2.0] - 2023-01-11 ### Fixed - Fix failing to fetch tooth when the repository does not contain go.mod file. - Fix failing to parse tooth file when the tooth is downloaded via GOPROXY. +- Fix failing to parse tooth when tooth.json is the only file in the tooth. + +### Changed + +- Change extension name of tooth files to .tth ## [0.1.0] - 2023-01-17 diff --git a/docs/en/commands/lip_install.md b/docs/en/commands/lip_install.md index 4c52f60..a56574c 100644 --- a/docs/en/commands/lip_install.md +++ b/docs/en/commands/lip_install.md @@ -12,7 +12,7 @@ lip install [options] Install a tooth from: - tooth repositories via Goproxy. -- local or remote standalone tooth files (with suffix `.tt`). +- local or remote standalone tooth files (with suffix `.tth`). For the tooth repository, you can specific the version by add suffix like `@1.2.3` or `@1.2.0-beta.3`. However, when another version is installed and you run Lip without `--upgrade` or `--force-reinstall` flag, Lip will not install the specific version. @@ -35,7 +35,7 @@ Note that `lip install` prefers to leave the installed version as-is unless `--u When looking at the items to be installed, Lip checks what type of item each is, in the following order: 1. Tooth repository, which can be accessed via Goproxy. -2. Local tooth file with suffix `.tt`. +2. Local tooth file with suffix `.tth`. In the first case, all letters will be converted to lowercase before processing. @@ -98,12 +98,12 @@ lip install --force-reinstall example.com/some_user/some_tooth Install from URL of a tooth: ```shell -lip install https://example.com/example.tt +lip install https://example.com/example.tth ``` Install from a local tooth: ```shell -lip install example.tt -lip install ./example/example.tt +lip install example.tth +lip install ./example/example.tth ``` \ No newline at end of file diff --git a/docs/en/developer_s_guide.md b/docs/en/developer_s_guide.md index 26a9279..1591a2d 100644 --- a/docs/en/developer_s_guide.md +++ b/docs/en/developer_s_guide.md @@ -25,7 +25,7 @@ Then you can fill in the information in tooth.json to make your work recognized ### Pack the tooth -Currently we have not provided commands to pack a tooth. You can just zip everything (make sure tooth.json is under the root of the zip file) and change its extension name from ".zip" to ".tt". +Currently we have not provided commands to pack a tooth. You can just zip everything (make sure tooth.json is under the root of the zip file) and change its extension name from ".zip" to ".tth". ## Next Steps diff --git a/docs/en/getting_started.md b/docs/en/getting_started.md index 697e664..d9d43ad 100644 --- a/docs/en/getting_started.md +++ b/docs/en/getting_started.md @@ -26,22 +26,22 @@ By default, Lip will fetch teeth via GOPROXY, a proxy of Git repos. ### Install a tooth from URL ```shell -> lip install https://example.com/exampletooth.tt +> lip install https://example.com/exampletooth.tth [...] Successfully installed all tooth files. ``` -Lip only supports URLs started with "http://" or "https://". All URLs should ends with ".tt". +Lip only supports URLs started with "http://" or "https://". All URLs should ends with ".tth". ### Install a tooth from a tooth file ```shell -> lip install exampletooth.tt +> lip install exampletooth.tth [...] Successfully installed all tooth files. ``` -The tooth file should have ".tt" extension name. +The tooth file should have ".tth" extension name. ### Install multiple teeth diff --git a/docs/en/tooth_json_file_reference.md b/docs/en/tooth_json_file_reference.md index a6136a4..b4c699d 100644 --- a/docs/en/tooth_json_file_reference.md +++ b/docs/en/tooth_json_file_reference.md @@ -92,7 +92,7 @@ Only lowercase letters, digits, dashes, underlines, dots and slashes [a-z0-9-_./ The tooth path must uniquely identify your tooth. For most teeth, the path is a URL where Lip can find the code. For teeth that won’t ever be downloaded directly, the tooth path can be just some name you control that will ensure uniqueness. -Note that the tooth path should not include protocol prefix (e.g. "https://" or "git://"), which already violates the syntax. Meanwhile, the tooth path should not end with ".tt", which will be regarded as a standalone tooth archive file. +Note that the tooth path should not include protocol prefix (e.g. "https://" or "git://"), which already violates the syntax. Meanwhile, the tooth path should not end with ".tth", which will be regarded as a standalone tooth archive file. If you would like to publish your tooth, please make the tooth path a real URL. For example, the first character should be a letter or a digit. diff --git a/src/cmd/install/install.go b/src/cmd/install/install.go index 7262bb8..3715939 100644 --- a/src/cmd/install/install.go +++ b/src/cmd/install/install.go @@ -26,7 +26,7 @@ Description: Install teeth from: - tooth repositories. - - local or remote standalone tooth files (with suffix .tt). + - local or remote standalone tooth files (with suffix .tth). Options: -h, --help Show help. diff --git a/src/cmd/install/specifier.go b/src/cmd/install/specifier.go index 9cf1cfd..13ed0e9 100644 --- a/src/cmd/install/specifier.go +++ b/src/cmd/install/specifier.go @@ -150,7 +150,7 @@ func (s Specifier) ToothVersion() version.Version { // getSpecifierType gets the type of the requirement specifier. func getSpecifierType(specifier string) SpecifierType { - if strings.HasSuffix(specifier, ".tt") { + if strings.HasSuffix(specifier, ".tth") { if strings.HasPrefix(specifier, "http://") || strings.HasPrefix(specifier, "https://") { return ToothURLSpecifierType } else { diff --git a/src/localfile/localfile.go b/src/localfile/localfile.go index 4358f5c..89618cb 100644 --- a/src/localfile/localfile.go +++ b/src/localfile/localfile.go @@ -53,7 +53,7 @@ func GetCachedToothFileName(fullSpecifier string) string { // Encode the full specifier with Base64. fullSpecifier = base64.StdEncoding.EncodeToString([]byte(fullSpecifier)) - return fullSpecifier + ".tt" + return fullSpecifier + ".tth" } // GetRecordFileName returns the file name of the record file. diff --git a/src/tooth/toothfile/toothfile.go b/src/tooth/toothfile/toothfile.go index 818b329..9f59d52 100644 --- a/src/tooth/toothfile/toothfile.go +++ b/src/tooth/toothfile/toothfile.go @@ -1,4 +1,4 @@ -// Package toothfile includes functions for .tt files. +// Package toothfile includes functions for .tth files. package toothfile import ( @@ -14,13 +14,13 @@ import ( recordutils "github.com/liteldev/lip/tooth/toothrecord" ) -// ToothFile is the struct that contains the metadata of a .tt file. +// ToothFile is the struct that contains the metadata of a .tth file. type ToothFile struct { filePath string metadata metadata.Metadata } -// New creates a new ToothFile struct from a file path of a .tt file. +// New creates a new ToothFile struct from a file path of a .tth file. func New(filePath string) (ToothFile, error) { r, err := zip.OpenReader(filePath) if err != nil { @@ -65,17 +65,17 @@ func New(filePath string) (ToothFile, error) { return ToothFile{}, errors.New("tooth.json not found in " + filePath) } -// FilePath returns the file path of the .tt file. +// FilePath returns the file path of the .tth file. func (t ToothFile) FilePath() string { return t.filePath } -// Metadata returns the metadata of the .tt file. +// Metadata returns the metadata of the .tth file. func (t ToothFile) Metadata() metadata.Metadata { return t.metadata } -// Install installs the .tt file. +// Install installs the .tth file. // TODO#1: Check if the tooth is already installed. // TODO#2: Directory placement. func (t ToothFile) Install() error { @@ -118,7 +118,7 @@ func (t ToothFile) Install() error { return err } - // Open the .tt file. + // Open the .tth file. r, err := zip.OpenReader(t.filePath) if err != nil { return errors.New("failed to open tooth file " + t.filePath) diff --git a/src/tooth/toothfile/utils.go b/src/tooth/toothfile/utils.go index 2a32019..f7547f7 100644 --- a/src/tooth/toothfile/utils.go +++ b/src/tooth/toothfile/utils.go @@ -41,13 +41,13 @@ func parseMetadataPlacement(metadata toothmetadata.Metadata, r *zip.ReadCloser) // getFilePrefix returns the prefix of all files in a zip file. func getFilePrefix(r *zip.ReadCloser) string { prefix := "" - for _, file := range r.File { + for i, file := range r.File { if strings.HasSuffix(file.Name, "/") { // Skip directories. continue } // If the prefix is empty, set it to the first file. - if prefix == "" { + if i == 0 { prefix = file.Name continue } @@ -61,5 +61,10 @@ func getFilePrefix(r *zip.ReadCloser) string { } } + // If tooth.json is the only file, set the prefix to empty. + if prefix == "tooth.json" { + prefix = "" + } + return prefix } From c51ab78d514256450c71f6e58864235c72be66ee Mon Sep 17 00:00:00 2001 From: Futrime Date: Tue, 17 Jan 2023 14:16:30 +0800 Subject: [PATCH 3/6] Create CNAME --- docs/CNAME | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/CNAME diff --git a/docs/CNAME b/docs/CNAME new file mode 100644 index 0000000..73b6ecf --- /dev/null +++ b/docs/CNAME @@ -0,0 +1 @@ +lip.docs.litebds.com \ No newline at end of file From 24614e1bfeaad60e1263b795c98548e3067c6f29 Mon Sep 17 00:00:00 2001 From: Futrime Date: Tue, 17 Jan 2023 16:49:06 +0800 Subject: [PATCH 4/6] Add possession field of tooth.json --- CHANGELOG.md | 6 ++++- docs/en/README.md | 16 ++++++++++- docs/en/_sidebar.md | 6 +---- ...eveloper_s_guide.md => creator_s_guide.md} | 4 +-- docs/en/tooth_json_file_reference.md | 27 ++++++++++++++++++- src/cmd/tooth/init/init.go | 5 +++- src/cmd/uninstall/uninstall.go | 15 +++++++++++ src/tooth/toothmetadata/metadata.go | 11 ++++++++ src/tooth/toothmetadata/metadata_test.go | 14 ++++++++++ src/tooth/toothrecord/record.go | 14 ++++++++++ 10 files changed, 107 insertions(+), 11 deletions(-) rename docs/en/{developer_s_guide.md => creator_s_guide.md} (90%) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7d7a17..70bd9e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.2.0] - 2023-01-11 +### Added + +- Possession field in tooth.json to specify directory to remove when uninstalling a tooth. + ### Fixed - Fix failing to fetch tooth when the repository does not contain go.mod file. @@ -26,5 +30,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Basic functions: cache, install, list, show, tooth init, and uninstall. [unreleased]: https://github.com/LiteLDev/Lip/compare/v0.1.0...HEAD -[0.1.1]: https://github.com/LiteLDev/Lip/releases/tag/v0.1.0...v0.1.1 +[0.2.0]: https://github.com/LiteLDev/Lip/releases/tag/v0.1.0...v0.2.0 [0.1.0]: https://github.com/LiteLDev/Lip/releases/tag/v0.1.0 \ No newline at end of file diff --git a/docs/en/README.md b/docs/en/README.md index 0db7acf..7051934 100644 --- a/docs/en/README.md +++ b/docs/en/README.md @@ -4,4 +4,18 @@ [![Latest Tag](https://img.shields.io/github/v/tag/LiteLDev/Lip?label=LATEST%20TAG&style=for-the-badge)](https://github.com/LiteLDev/Lip/releases/latest) [![Downloads](https://img.shields.io/github/downloads/LiteLDev/Lip/latest/total?style=for-the-badge)](https://github.com/LiteLDev/Lip/releases/latest) -Lip is a package installer for LiteLoaderBDS. You can use Lip to install packages from any LiteLoaderBDS registries, or directly from any Git repository. \ No newline at end of file +Lip is a package installer for LiteLoaderBDS. You can use Lip to install packages from any LiteLoaderBDS registries, or directly from any Git repository. + +Please take a look at our documentation for how to install and use Lip: + +- [Installation](installation.md) +- [Usage](getting_started.md) + +We release updates regularly. Find more details in our changelog: + +- [Changelog](https://github.com/LiteLDev/Lip/blob/main/CHANGELOG.md) + +If you find bugs, need help, or want to talk to the developers, please report with an issue: + +- [Open an issue](https://github.com/LiteLDev/Lip/issues/new/choose) + diff --git a/docs/en/_sidebar.md b/docs/en/_sidebar.md index 0a18fdf..4245220 100644 --- a/docs/en/_sidebar.md +++ b/docs/en/_sidebar.md @@ -4,7 +4,7 @@ - [Installation](installation.md) -- [Developer's Guide](developer_s_guide.md) +- [Creator's Guide](creator_s_guide.md) - Commands @@ -28,10 +28,6 @@ - [tooth.json File Reference](tooth_json_file_reference.md) -- Development - - - [Getting Started](development/getting_started.md) - - Maintenance - Global Data Directory diff --git a/docs/en/developer_s_guide.md b/docs/en/creator_s_guide.md similarity index 90% rename from docs/en/developer_s_guide.md rename to docs/en/creator_s_guide.md index 1591a2d..9cfb00f 100644 --- a/docs/en/developer_s_guide.md +++ b/docs/en/creator_s_guide.md @@ -1,6 +1,6 @@ -# Developer's Guide +# Creator's Guide -We're pleased that you are interested in developing your stuff on Lip. +We're pleased that you are interested in creating with Lip. ## Ensure you have a working Lip diff --git a/docs/en/tooth_json_file_reference.md b/docs/en/tooth_json_file_reference.md index b4c699d..1962cd0 100644 --- a/docs/en/tooth_json_file_reference.md +++ b/docs/en/tooth_json_file_reference.md @@ -50,6 +50,9 @@ A tooth.json includes directives as shown in the following example. These are de "source": "", "destination": "" } + ], + "possession": [ + "plugins/LiteLoader/" ] } ``` @@ -289,4 +292,26 @@ Extract from tooth root and place to BDS root: ### Notes -Do not add any prefix like "/", "./" or "../". Otherwise, Lip will refused to install the tooth. If the source is right the root of the tooth, just leave the value a blank string. Similarly, if the destination is the root of BDS, leave the value a blank string. \ No newline at end of file +Do not add any prefix like "/", "./" or "../". Otherwise, Lip will refused to install the tooth. If the source is right the root of the tooth, just leave the value a blank string. Similarly, if the destination is the root of BDS, leave the value a blank string. + +## possession + +Declares the which folders are in the possession of the tooth. When uninstalling, files in the declared folders will be removed. + +### Syntax + +Each item of the list should be a valid directory path relative to the root of BDS ending with "/". + +### Examples + +```json +{ + "possession": [ + "plugins/LiteLoader/" + ] +} +``` + +### Notes + +Do not take the possession of any directory that might be used by other tooth, e.g. public directories like worlds/. \ No newline at end of file diff --git a/src/cmd/tooth/init/init.go b/src/cmd/tooth/init/init.go index d9668f2..c6bdebb 100644 --- a/src/cmd/tooth/init/init.go +++ b/src/cmd/tooth/init/init.go @@ -30,7 +30,10 @@ const defaultToothJsonContent = `{ "source": "", "destination": "" } - ] + ], + "possession": [ + "" + ] }` const helpMessage = ` diff --git a/src/cmd/uninstall/uninstall.go b/src/cmd/uninstall/uninstall.go index fcde81c..1149bb8 100644 --- a/src/cmd/uninstall/uninstall.go +++ b/src/cmd/uninstall/uninstall.go @@ -182,6 +182,21 @@ func uninstall(recordFileName string) error { } } + // Iterate over the possessions and delete the folders as well as + // the files in the folders. + for _, possession := range currentRecord.Possession { + workspaceDir, err := localfile.WorkSpaceDir() + if err != nil { + return err + } + + // Remove the folder. + err = os.RemoveAll(workspaceDir + "/" + possession) + if err != nil { + return errors.New("cannot delete the folder " + workspaceDir + "/" + possession + ": " + err.Error()) + } + } + // Delete the record file. err = os.Remove(recordDir + "/" + recordFileName) if err != nil { diff --git a/src/tooth/toothmetadata/metadata.go b/src/tooth/toothmetadata/metadata.go index 47c1e53..eb85ce6 100644 --- a/src/tooth/toothmetadata/metadata.go +++ b/src/tooth/toothmetadata/metadata.go @@ -35,6 +35,7 @@ type Metadata struct { Dependencies map[string]([][]versionmatch.VersionMatch) Information InfoStruct Placement []PlacementStruct + Possession []string } // NewFromJSON decodes a JSON byte array into a Metadata struct. @@ -103,6 +104,11 @@ func NewFromJSON(jsonData []byte) (Metadata, error) { metadata.Placement[i].Destination = destination } + metadata.Possession = make([]string, len(metadataMap["possession"].([]interface{}))) + for i, possession := range metadataMap["possession"].([]interface{}) { + metadata.Possession[i] = possession.(string) + } + return metadata, nil } @@ -141,6 +147,11 @@ func (metadata Metadata) JSON() ([]byte, error) { metadataMap["placement"].([]interface{})[i].(map[string]interface{})["destination"] = placement.Destination } + metadataMap["possession"] = make([]interface{}, len(metadata.Possession)) + for i, possession := range metadata.Possession { + metadataMap["possession"].([]interface{})[i] = possession + } + // Encode metadataMap into JSON buf := bytes.NewBuffer([]byte{}) encoder := json.NewEncoder(buf) diff --git a/src/tooth/toothmetadata/metadata_test.go b/src/tooth/toothmetadata/metadata_test.go index e851f98..9de6a64 100644 --- a/src/tooth/toothmetadata/metadata_test.go +++ b/src/tooth/toothmetadata/metadata_test.go @@ -35,6 +35,9 @@ func TestNewFromJSON(t *testing.T) { "source": "test/test.test" } ], + "possession": [ + "plugins/LiteLoader/" + ], "tooth": "test.test/test/test", "version": "1.0.0" } @@ -114,6 +117,14 @@ func TestNewFromJSON(t *testing.T) { if metadata.Placement[0].Destination != "test/testdirectory" { t.Errorf("metadata.Placement is not correct") } + + if len(metadata.Possession) != 1 { + t.Errorf("metadata.Possession is not correct") + } + + if metadata.Possession[0] != "plugins/LiteLoader/" { + t.Errorf("metadata.Possession is not correct") + } } func TestJSON(t *testing.T) { @@ -146,6 +157,9 @@ func TestJSON(t *testing.T) { Destination: "test/testdirectory", }, }, + Possession: []string{ + "plugins/LiteLoader/", + }, } // Test diff --git a/src/tooth/toothrecord/record.go b/src/tooth/toothrecord/record.go index 5f3903b..c726d10 100644 --- a/src/tooth/toothrecord/record.go +++ b/src/tooth/toothrecord/record.go @@ -38,6 +38,7 @@ type Record struct { Dependencies map[string]([][]versionmatchutils.VersionMatch) Information InfoStruct Placement []PlacementStruct + Possession []string IsManuallyInstalled bool } @@ -106,6 +107,11 @@ func NewFromJSON(jsonData []byte) (Record, error) { record.Placement[i].Destination = placement.(map[string]interface{})["destination"].(string) } + record.Possession = make([]string, len(recordMap["possession"].([]interface{}))) + for i, possession := range recordMap["possession"].([]interface{}) { + record.Possession[i] = possession.(string) + } + record.IsManuallyInstalled = recordMap["is_manually_installed"].(bool) return record, nil @@ -133,6 +139,9 @@ func NewFromMetadata(metadata metadatautils.Metadata) Record { record.Placement[i].Destination = placement.Destination } + record.Possession = make([]string, len(metadata.Possession)) + copy(record.Possession, metadata.Possession) + record.IsManuallyInstalled = false return record @@ -173,6 +182,11 @@ func (record Record) JSON() ([]byte, error) { recordMap["placement"].([]interface{})[i].(map[string]interface{})["destination"] = placement.Destination } + recordMap["possession"] = make([]interface{}, len(record.Possession)) + for i, possession := range record.Possession { + recordMap["possession"].([]interface{})[i] = possession + } + recordMap["is_manually_installed"] = record.IsManuallyInstalled // Encode recordMap into JSON From 4affe849e9e6457a0b5d4c82c61a6bba53bb42db Mon Sep 17 00:00:00 2001 From: Futrime Date: Tue, 17 Jan 2023 16:52:44 +0800 Subject: [PATCH 5/6] Update PULL_REQUEST_TEMPLATE.md --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index fe531ad..97947d4 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -12,7 +12,7 @@ Thank you for your contribution to the repo. Before submitting this PR, please make sure: - [ ] Your code builds clean without any errors or warnings -- [ ] Your code follows the code style of LitelDev +- [ ] Your code follows the code style of LiteLDev - [ ] You have tested all functions - [ ] You have not used code without license - [ ] You have added statement for third-party code \ No newline at end of file From 4b71c6aa2d627e14d24a5358ee66579d86c25703 Mon Sep 17 00:00:00 2001 From: Futrime Date: Tue, 17 Jan 2023 16:53:01 +0800 Subject: [PATCH 6/6] Update PULL_REQUEST_TEMPLATE.md --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 97947d4..2647d05 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -8,7 +8,7 @@ ## Checklist before merging -Thank you for your contribution to the repo. +Thank you for your contribution to the repository. Before submitting this PR, please make sure: - [ ] Your code builds clean without any errors or warnings