feat: remove SML references (#64)

* feat: update ficsit-resolver

* feat: remove SML references

* feat: read GameVersion from uplugin

* ci: docker-compose => docker compose
This commit is contained in:
mircearoata 2024-08-14 03:27:07 +03:00 committed by GitHub
parent d051b5800a
commit d744884f25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 26 additions and 203 deletions

View file

@ -96,7 +96,7 @@ jobs:
- name: Boot ftp and sftp
if: ${{ matrix.os == 'ubuntu-latest' }}
run: docker-compose -f docker-compose-test.yml up -d
run: docker compose -f docker-compose-test.yml up -d
- name: Download GQL schema
run: "npx graphqurl https://api.ficsit.dev/v2/query --introspect -H 'content-type: application/json' > schema.graphql"

View file

@ -5,6 +5,7 @@ type UPlugin struct {
FriendlyName string `json:"FriendlyName"`
Description string `json:"Description"`
CreatedBy string `json:"CreatedBy"`
GameVersion string `json:"GameVersion"`
Plugins []Plugins `json:"Plugins"`
}
type Plugins struct {

View file

@ -332,7 +332,7 @@ func (i *Installation) resolveProfile(ctx *GlobalContext, platform *Platform) (*
return nil, err
}
depResolver := resolver.NewDependencyResolver(ctx.Provider, viper.GetString("api-base"))
depResolver := resolver.NewDependencyResolver(ctx.Provider)
gameVersion, err := i.getGameVersion(platform)
if err != nil {
@ -548,7 +548,7 @@ func (i *Installation) UpdateMods(ctx *GlobalContext, mods []string) error {
return fmt.Errorf("failed to read lock file: %w", err)
}
resolver := resolver.NewDependencyResolver(ctx.Provider, viper.GetString("api-base"))
resolver := resolver.NewDependencyResolver(ctx.Provider)
gameVersion, err := i.getGameVersion(platform)
if err != nil {

View file

@ -1,7 +1,6 @@
package cli
import (
"context"
"encoding/json"
"errors"
"fmt"
@ -299,7 +298,7 @@ func (p *Profile) Resolve(resolver resolver.DependencyResolver, lockFile *resolv
}
}
resultLockfile, err := resolver.ResolveModDependencies(context.TODO(), toResolve, lockFile, gameVersion, p.RequiredTargets)
resultLockfile, err := resolver.ResolveModDependencies(toResolve, lockFile, gameVersion, p.RequiredTargets)
if err != nil {
return nil, fmt.Errorf("failed resolving profile dependencies: %w", err)
}

View file

@ -6,6 +6,7 @@ import (
"github.com/Khan/genqlient/graphql"
resolver "github.com/satisfactorymodding/ficsit-resolver"
"github.com/spf13/viper"
"github.com/satisfactorymodding/ficsit-cli/ficsit"
)
@ -32,34 +33,6 @@ func (p FicsitProvider) ModVersions(context context.Context, modReference string
return ficsit.ModVersions(context, p.client, modReference, filter)
}
func (p FicsitProvider) SMLVersions(context context.Context) ([]resolver.SMLVersion, error) {
response, err := ficsit.SMLVersions(context, p.client)
if err != nil {
return nil, err
}
smlVersions := make([]resolver.SMLVersion, len(response.SmlVersions.Sml_versions))
for i, version := range response.GetSmlVersions().Sml_versions {
targets := make([]resolver.SMLVersionTarget, len(version.Targets))
for j, target := range version.Targets {
targets[j] = resolver.SMLVersionTarget{
TargetName: resolver.TargetName(target.TargetName),
Link: target.Link,
}
}
smlVersions[i] = resolver.SMLVersion{
ID: version.Id,
Version: version.Version,
SatisfactoryVersion: version.Satisfactory_version,
Targets: targets,
}
}
return smlVersions, nil
}
func (p FicsitProvider) ModVersionsWithDependencies(_ context.Context, modID string) ([]resolver.ModVersion, error) {
response, err := ficsit.GetAllModVersions(modID)
if err != nil {
@ -84,8 +57,8 @@ func (p FicsitProvider) ModVersionsWithDependencies(_ context.Context, modID str
targets := make([]resolver.Target, len(modVersion.Targets))
for j, target := range modVersion.Targets {
targets[j] = resolver.Target{
VersionID: target.VersionID,
TargetName: resolver.TargetName(target.TargetName),
Link: viper.GetString("api-base") + target.Link,
Hash: target.Hash,
Size: target.Size,
}
@ -94,6 +67,7 @@ func (p FicsitProvider) ModVersionsWithDependencies(_ context.Context, modID str
modVersions[i] = resolver.ModVersion{
ID: modVersion.ID,
Version: modVersion.Version,
GameVersion: modVersion.GameVersion,
Dependencies: dependencies,
Targets: targets,
}

View file

@ -28,10 +28,6 @@ func (p LocalProvider) Mods(_ context.Context, filter ficsit.ModFilter) (*ficsit
mods := make([]ficsit.ModsModsGetModsModsMod, 0)
cachedMods.Range(func(modReference string, files []cache.File) bool {
if modReference == "SML" {
return true
}
if len(filter.References) > 0 {
skip := true
@ -127,25 +123,6 @@ func (p LocalProvider) GetMod(_ context.Context, modReference string) (*ficsit.G
}, nil
}
func (p LocalProvider) SMLVersions(_ context.Context) ([]resolver.SMLVersion, error) {
cachedSMLFiles, err := cache.GetCacheMod("SML")
if err != nil {
return nil, fmt.Errorf("failed to get cache: %w", err)
}
smlVersions := make([]resolver.SMLVersion, 0)
for _, smlFile := range cachedSMLFiles {
smlVersions = append(smlVersions, resolver.SMLVersion{
ID: "SML:" + smlFile.Plugin.SemVersion,
Version: smlFile.Plugin.SemVersion,
SatisfactoryVersion: 0, // TODO: where can this be obtained from?
})
}
return smlVersions, nil
}
func (p LocalProvider) ModVersionsWithDependencies(_ context.Context, modID string) ([]resolver.ModVersion, error) {
cachedModFiles, err := cache.GetCacheMod(modID)
if err != nil {
@ -158,6 +135,7 @@ func (p LocalProvider) ModVersionsWithDependencies(_ context.Context, modID stri
versions = append(versions, resolver.ModVersion{
ID: modID + ":" + modFile.Plugin.SemVersion,
Version: modFile.Plugin.SemVersion,
GameVersion: modFile.Plugin.GameVersion,
})
}

View file

@ -36,13 +36,6 @@ func (p MixedProvider) GetMod(context context.Context, modReference string) (*fi
return p.onlineProvider.GetMod(context, modReference)
}
func (p MixedProvider) SMLVersions(context context.Context) ([]resolver.SMLVersion, error) {
if p.Offline {
return p.offlineProvider.SMLVersions(context) // nolint
}
return p.onlineProvider.SMLVersions(context) // nolint
}
func (p MixedProvider) ModVersionsWithDependencies(context context.Context, modID string) ([]resolver.ModVersion, error) {
if p.Offline {
return p.offlineProvider.ModVersionsWithDependencies(context, modID) // nolint

View file

@ -1,7 +1,6 @@
package cli
import (
"context"
"log/slog"
"math"
"os"
@ -9,7 +8,6 @@ import (
"github.com/MarvinJWendt/testza"
resolver "github.com/satisfactorymodding/ficsit-resolver"
"github.com/spf13/viper"
"github.com/satisfactorymodding/ficsit-cli/cfg"
)
@ -43,9 +41,9 @@ func TestUpdateMods(t *testing.T) {
ctx.Provider = MockProvider{}
depResolver := resolver.NewDependencyResolver(ctx.Provider, viper.GetString("api-base"))
depResolver := resolver.NewDependencyResolver(ctx.Provider)
oldLockfile, err := depResolver.ResolveModDependencies(context.Background(), map[string]string{
oldLockfile, err := depResolver.ResolveModDependencies(map[string]string{
"FicsitRemoteMonitoring": "0.9.8",
}, nil, math.MaxInt, nil)

View file

@ -1,15 +0,0 @@
# @genqlient(omitempty: true)
query SMLVersions {
smlVersions: getSMLVersions(filter: {limit: 100}) {
count
sml_versions {
id
version
satisfactory_version
targets {
targetName
link
}
}
}
}

View file

@ -675,72 +675,6 @@ const (
OrderDesc Order = "desc"
)
// SMLVersionsResponse is returned by SMLVersions on success.
type SMLVersionsResponse struct {
SmlVersions SMLVersionsSmlVersionsGetSMLVersions `json:"smlVersions"`
}
// GetSmlVersions returns SMLVersionsResponse.SmlVersions, and is useful for accessing the field via an interface.
func (v *SMLVersionsResponse) GetSmlVersions() SMLVersionsSmlVersionsGetSMLVersions {
return v.SmlVersions
}
// SMLVersionsSmlVersionsGetSMLVersions includes the requested fields of the GraphQL type GetSMLVersions.
type SMLVersionsSmlVersionsGetSMLVersions struct {
Count int `json:"count"`
Sml_versions []SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersion `json:"sml_versions"`
}
// GetCount returns SMLVersionsSmlVersionsGetSMLVersions.Count, and is useful for accessing the field via an interface.
func (v *SMLVersionsSmlVersionsGetSMLVersions) GetCount() int { return v.Count }
// GetSml_versions returns SMLVersionsSmlVersionsGetSMLVersions.Sml_versions, and is useful for accessing the field via an interface.
func (v *SMLVersionsSmlVersionsGetSMLVersions) GetSml_versions() []SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersion {
return v.Sml_versions
}
// SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersion includes the requested fields of the GraphQL type SMLVersion.
type SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersion struct {
Id string `json:"id"`
Version string `json:"version"`
Satisfactory_version int `json:"satisfactory_version"`
Targets []SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersionTargetsSMLVersionTarget `json:"targets"`
}
// GetId returns SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersion.Id, and is useful for accessing the field via an interface.
func (v *SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersion) GetId() string { return v.Id }
// GetVersion returns SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersion.Version, and is useful for accessing the field via an interface.
func (v *SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersion) GetVersion() string {
return v.Version
}
// GetSatisfactory_version returns SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersion.Satisfactory_version, and is useful for accessing the field via an interface.
func (v *SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersion) GetSatisfactory_version() int {
return v.Satisfactory_version
}
// GetTargets returns SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersion.Targets, and is useful for accessing the field via an interface.
func (v *SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersion) GetTargets() []SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersionTargetsSMLVersionTarget {
return v.Targets
}
// SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersionTargetsSMLVersionTarget includes the requested fields of the GraphQL type SMLVersionTarget.
type SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersionTargetsSMLVersionTarget struct {
TargetName TargetName `json:"targetName"`
Link string `json:"link"`
}
// GetTargetName returns SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersionTargetsSMLVersionTarget.TargetName, and is useful for accessing the field via an interface.
func (v *SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersionTargetsSMLVersionTarget) GetTargetName() TargetName {
return v.TargetName
}
// GetLink returns SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersionTargetsSMLVersionTarget.Link, and is useful for accessing the field via an interface.
func (v *SMLVersionsSmlVersionsGetSMLVersionsSml_versionsSMLVersionTargetsSMLVersionTarget) GetLink() string {
return v.Link
}
type TargetName string
const (
@ -1267,46 +1201,6 @@ func Mods(
return &data, err
}
// The query or mutation executed by SMLVersions.
const SMLVersions_Operation = `
query SMLVersions {
smlVersions: getSMLVersions(filter: {limit:100}) {
count
sml_versions {
id
version
satisfactory_version
targets {
targetName
link
}
}
}
}
`
func SMLVersions(
ctx context.Context,
client graphql.Client,
) (*SMLVersionsResponse, error) {
req := &graphql.Request{
OpName: "SMLVersions",
Query: SMLVersions_Operation,
}
var err error
var data SMLVersionsResponse
resp := &graphql.Response{Data: &data}
err = client.MakeRequest(
ctx,
req,
resp,
)
return &data, err
}
// The query or mutation executed by Version.
const Version_Operation = `
query Version ($modId: String!, $version: String!) {

View file

@ -9,6 +9,7 @@ type AllVersionsResponse struct {
type ModVersion struct {
ID string `json:"id"`
Version string `json:"version"`
GameVersion string `json:"game_version"`
Dependencies []Dependency `json:"dependencies"`
Targets []Target `json:"targets"`
}
@ -22,6 +23,7 @@ type Dependency struct {
type Target struct {
VersionID string `json:"version_id"`
TargetName string `json:"target_name"`
Link string `json:"link"`
Hash string `json:"hash"`
Size int64 `json:"size"`
}

View file

@ -17,8 +17,6 @@ bindings:
type: string
GuideID:
type: string
SMLVersionID:
type: string
Date:
type: time.Time
unmarshaler: github.com/satisfactorymodding/ficsit-cli/ficsit/utils.UnmarshalDateTime

2
go.mod
View file

@ -25,7 +25,7 @@ require (
github.com/puzpuzpuz/xsync/v3 v3.0.2
github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f
github.com/samber/slog-multi v1.0.2
github.com/satisfactorymodding/ficsit-resolver v0.0.2
github.com/satisfactorymodding/ficsit-resolver v0.0.3
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.1
goftp.io/server/v2 v2.0.1

4
go.sum
View file

@ -205,8 +205,8 @@ github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM=
github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
github.com/samber/slog-multi v1.0.2 h1:6BVH9uHGAsiGkbbtQgAOQJMpKgV8unMrHhhJaw+X1EQ=
github.com/samber/slog-multi v1.0.2/go.mod h1:uLAvHpGqbYgX4FSL0p1ZwoLuveIAJvBECtE07XmYvFo=
github.com/satisfactorymodding/ficsit-resolver v0.0.2 h1:dj/OsDLpaMUqCHpfBVHvDMUv2nf5gT4HS2ydBMkmtcQ=
github.com/satisfactorymodding/ficsit-resolver v0.0.2/go.mod h1:ckKMmMvDoYbbkEbWXEsMes608uvv6EKphXPhHX8LKSc=
github.com/satisfactorymodding/ficsit-resolver v0.0.3 h1:Q+BV1w1S42accsHbew9BmwcYdbAtSYfeVlQpRJiBhGg=
github.com/satisfactorymodding/ficsit-resolver v0.0.3/go.mod h1:ckKMmMvDoYbbkEbWXEsMes608uvv6EKphXPhHX8LKSc=
github.com/sebdah/goldie/v2 v2.5.3 h1:9ES/mNN+HNUbNWpVAlrzuZ7jE+Nrczbj8uFRjM7624Y=
github.com/sebdah/goldie/v2 v2.5.3/go.mod h1:oZ9fp0+se1eapSRjfYbsV/0Hqhbuu3bJVvKI/NNtssI=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=

View file

@ -3,6 +3,7 @@ package components
import (
"github.com/Khan/genqlient/graphql"
tea "github.com/charmbracelet/bubbletea"
resolver "github.com/satisfactorymodding/ficsit-resolver"
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/satisfactorymodding/ficsit-cli/cli/provider"
@ -19,6 +20,7 @@ type RootModel interface {
GetAPIClient() graphql.Client
GetProvider() provider.Provider
GetResolver() resolver.DependencyResolver
Size() tea.WindowSizeMsg
SetSize(size tea.WindowSizeMsg)

View file

@ -7,7 +7,6 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
resolver "github.com/satisfactorymodding/ficsit-resolver"
"github.com/spf13/viper"
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/satisfactorymodding/ficsit-cli/cli/provider"
@ -29,7 +28,7 @@ func newModel(global *cli.GlobalContext) *rootModel {
Width: 20,
Height: 14,
},
dependencyResolver: resolver.NewDependencyResolver(global.Provider, viper.GetString("api-base")),
dependencyResolver: resolver.NewDependencyResolver(global.Provider),
}
m.headerComponent = components.NewHeaderComponent(m)
@ -71,6 +70,10 @@ func (m *rootModel) GetProvider() provider.Provider {
return m.global.Provider
}
func (m *rootModel) GetResolver() resolver.DependencyResolver {
return m.dependencyResolver
}
func (m *rootModel) Size() tea.WindowSizeMsg {
return m.currentSize
}

View file

@ -13,8 +13,6 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/muesli/reflow/truncate"
resolver "github.com/satisfactorymodding/ficsit-resolver"
"github.com/spf13/viper"
"github.com/satisfactorymodding/ficsit-cli/ficsit"
"github.com/satisfactorymodding/ficsit-cli/tea/components"
@ -112,9 +110,7 @@ func (m updateModsList) LoadModData() {
return
}
resolver := resolver.NewDependencyResolver(m.root.GetProvider(), viper.GetString("api-base"))
updatedLockfile, err := currentProfile.Resolve(resolver, nil, gameVersion)
updatedLockfile, err := currentProfile.Resolve(m.root.GetResolver(), nil, gameVersion)
if err != nil {
return
}