refactor(yay): move cfg inside of runtime (#2259)

* rework relationship between runtime and cfg

* separate runtime from cfg

* simplify instantiation logic

* move installer to appropriate package

* move operator to sync package

* add tests for srcinfo service

* consolidate srcinfo service in sync

* add logger to srcinfo

* add logger to preparer

* remove unused text functions

* remove remaining text.* from srcinfo

* remove global logger parts

* remove global org method exports

* remove global logger

* move text->input

* add rule to prevent fmt.Print

* update golangci go version

* remove outdated FAQs

* remove outdated FAQs
This commit is contained in:
Jo
2023-08-06 21:39:41 +02:00
committed by GitHub
parent 7483393377
commit 8916cd174b
74 changed files with 1475 additions and 1367 deletions

23
vcs.go
View File

@@ -2,7 +2,6 @@ package main
import (
"context"
"os"
"sync"
"github.com/Jguer/aur"
@@ -10,9 +9,9 @@ import (
"github.com/Jguer/yay/v12/pkg/db"
"github.com/Jguer/yay/v12/pkg/dep"
"github.com/Jguer/yay/v12/pkg/settings"
"github.com/Jguer/yay/v12/pkg/srcinfo"
"github.com/Jguer/yay/v12/pkg/text"
"github.com/Jguer/yay/v12/pkg/runtime"
"github.com/Jguer/yay/v12/pkg/sync/srcinfo"
"github.com/Jguer/yay/v12/pkg/sync/workdir"
)
func infoToInstallInfo(info []aur.Pkg) []map[string]*dep.InstallInfo {
@@ -31,11 +30,11 @@ func infoToInstallInfo(info []aur.Pkg) []map[string]*dep.InstallInfo {
}
// createDevelDB forces yay to create a DB of the existing development packages.
func createDevelDB(ctx context.Context, cfg *settings.Configuration, dbExecutor db.Executor) error {
func createDevelDB(ctx context.Context, run *runtime.Runtime, dbExecutor db.Executor) error {
remoteNames := dbExecutor.InstalledRemotePackageNames()
cfg.Runtime.QueryBuilder.Execute(ctx, dbExecutor, remoteNames)
info, err := cfg.Runtime.AURClient.Get(ctx, &aur.Query{
run.QueryBuilder.Execute(ctx, dbExecutor, remoteNames)
info, err := run.AURClient.Get(ctx, &aur.Query{
Needles: remoteNames,
By: aur.Name,
Contains: false,
@@ -44,15 +43,15 @@ func createDevelDB(ctx context.Context, cfg *settings.Configuration, dbExecutor
return err
}
preper := NewPreparerWithoutHooks(dbExecutor, cfg.Runtime.CmdBuilder, cfg, false)
preper := workdir.NewPreparerWithoutHooks(dbExecutor, run.CmdBuilder, run.Cfg, run.Logger.Child("workdir"), false)
mapInfo := infoToInstallInfo(info)
pkgBuildDirsByBase, err := preper.Run(ctx, os.Stdout, mapInfo)
pkgBuildDirsByBase, err := preper.Run(ctx, run, mapInfo)
if err != nil {
return err
}
srcinfos, err := srcinfo.ParseSrcinfoFilesByBase(pkgBuildDirsByBase, false)
srcinfos, err := srcinfo.ParseSrcinfoFilesByBase(run.Logger.Child("srcinfo"), pkgBuildDirsByBase, false)
if err != nil {
return err
}
@@ -63,14 +62,14 @@ func createDevelDB(ctx context.Context, cfg *settings.Configuration, dbExecutor
wg.Add(1)
go func(i string, iP int) {
cfg.Runtime.VCSStore.Update(ctx, srcinfos[i].Packages[iP].Pkgname, srcinfos[i].Source)
run.VCSStore.Update(ctx, srcinfos[i].Packages[iP].Pkgname, srcinfos[i].Source)
wg.Done()
}(i, iP)
}
}
wg.Wait()
text.OperationInfoln(gotext.Get("GenDB finished. No packages were installed"))
run.Logger.OperationInfoln(gotext.Get("GenDB finished. No packages were installed"))
return err
}