Move db and config back to internal

This commit is contained in:
Elara 2023-09-22 15:21:34 -07:00
parent 4774ec3343
commit ac45087ead
27 changed files with 40 additions and 37 deletions

View File

@ -27,7 +27,7 @@ import (
"go.elara.ws/lure/internal/osutils"
"go.elara.ws/lure/internal/types"
"go.elara.ws/lure/pkg/build"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/internal/config"
"go.elara.ws/lure/pkg/manager"
"go.elara.ws/lure/pkg/repos"
)

View File

@ -30,7 +30,6 @@ import (
"go.elara.ws/logger"
"go.elara.ws/lure/cmd/lure-api-server/internal/api"
"go.elara.ws/lure/internal/log"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/pkg/repos"
)
@ -55,7 +54,7 @@ func main() {
log.Logger = logger.NewMulti(log.Logger, logger.NewJSON(fl))
}
err := repos.Pull(ctx, config.Config().Repos)
err := repos.Pull(ctx, nil)
if err != nil {
log.Fatal("Error pulling repositories").Err(err).Send()
}

View File

@ -30,7 +30,6 @@ import (
"strings"
"go.elara.ws/lure/internal/log"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/pkg/repos"
)
@ -88,7 +87,7 @@ func repoPullWorker(ctx context.Context, sigCh <-chan struct{}) {
for {
select {
case <-sigCh:
err := repos.Pull(ctx, config.Config().Repos)
err := repos.Pull(ctx, nil)
if err != nil {
log.Warn("Error while pulling repositories").Err(err).Send()
}

4
fix.go
View File

@ -23,8 +23,8 @@ import (
"github.com/urfave/cli/v2"
"go.elara.ws/lure/internal/log"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/pkg/db"
"go.elara.ws/lure/internal/config"
"go.elara.ws/lure/internal/db"
"go.elara.ws/lure/pkg/repos"
)

View File

@ -27,7 +27,7 @@ import (
"github.com/urfave/cli/v2"
"go.elara.ws/lure/internal/cliutils"
"go.elara.ws/lure/internal/overrides"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/internal/config"
"go.elara.ws/lure/pkg/distro"
"go.elara.ws/lure/pkg/repos"
"gopkg.in/yaml.v3"

View File

@ -26,8 +26,8 @@ import (
"go.elara.ws/lure/internal/log"
"go.elara.ws/lure/internal/types"
"go.elara.ws/lure/pkg/build"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/pkg/db"
"go.elara.ws/lure/internal/config"
"go.elara.ws/lure/internal/db"
"go.elara.ws/lure/pkg/manager"
"go.elara.ws/lure/pkg/repos"
)

View File

@ -26,8 +26,8 @@ import (
"go.elara.ws/lure/internal/log"
"go.elara.ws/lure/internal/pager"
"go.elara.ws/lure/internal/translations"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/pkg/db"
"go.elara.ws/lure/internal/config"
"go.elara.ws/lure/internal/db"
)
// YesNoPrompt asks the user a yes or no question, using def as the default answer

View File

@ -27,7 +27,7 @@ import (
"github.com/jmoiron/sqlx"
"go.elara.ws/lure/internal/log"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/internal/config"
"golang.org/x/exp/slices"
"modernc.org/sqlite"
)

View File

@ -24,7 +24,7 @@ import (
"testing"
"github.com/jmoiron/sqlx"
"go.elara.ws/lure/pkg/db"
"go.elara.ws/lure/internal/db"
)
var testPkg = db.Package{

View File

@ -25,7 +25,7 @@ import (
"os"
"path/filepath"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/internal/config"
)
// BasePath returns the base path of the download cache

View File

@ -27,7 +27,7 @@ import (
"testing"
"go.elara.ws/lure/internal/dlcache"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/internal/config"
)
func init() {

View File

@ -23,7 +23,7 @@ import (
"strings"
"go.elara.ws/lure/internal/cpu"
"go.elara.ws/lure/pkg/db"
"go.elara.ws/lure/internal/db"
"go.elara.ws/lure/pkg/distro"
"golang.org/x/exp/slices"
"golang.org/x/text/language"

View File

@ -23,8 +23,8 @@ import (
"github.com/urfave/cli/v2"
"go.elara.ws/lure/internal/log"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/pkg/db"
"go.elara.ws/lure/internal/config"
"go.elara.ws/lure/internal/db"
"go.elara.ws/lure/pkg/manager"
"go.elara.ws/lure/pkg/repos"
"golang.org/x/exp/slices"

View File

@ -30,8 +30,8 @@ import (
"go.elara.ws/logger"
"go.elara.ws/lure/internal/log"
"go.elara.ws/lure/internal/translations"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/pkg/db"
"go.elara.ws/lure/internal/config"
"go.elara.ws/lure/internal/db"
"go.elara.ws/lure/pkg/manager"
)

View File

@ -46,8 +46,8 @@ import (
"go.elara.ws/lure/internal/shutils/decoder"
"go.elara.ws/lure/internal/shutils/helpers"
"go.elara.ws/lure/internal/types"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/pkg/db"
"go.elara.ws/lure/internal/config"
"go.elara.ws/lure/internal/db"
"go.elara.ws/lure/pkg/distro"
"go.elara.ws/lure/pkg/manager"
"go.elara.ws/lure/pkg/repos"

View File

@ -24,8 +24,8 @@ import (
"go.elara.ws/lure/internal/log"
"go.elara.ws/lure/internal/types"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/pkg/db"
"go.elara.ws/lure/internal/config"
"go.elara.ws/lure/internal/db"
)
// InstallPkgs installs native packages via the package manager,

View File

@ -18,7 +18,7 @@
package repos
import "go.elara.ws/lure/pkg/db"
import "go.elara.ws/lure/internal/db"
// FindPkgs looks for packages matching the inputs inside the database.
// It returns a map that maps the package name input to any packages found for it.

View File

@ -25,7 +25,7 @@ import (
"testing"
"go.elara.ws/lure/internal/types"
"go.elara.ws/lure/pkg/db"
"go.elara.ws/lure/internal/db"
"go.elara.ws/lure/pkg/repos"
)

View File

@ -34,12 +34,12 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/format/diff"
"github.com/pelletier/go-toml/v2"
"go.elara.ws/lure/internal/config"
"go.elara.ws/lure/internal/db"
"go.elara.ws/lure/internal/log"
"go.elara.ws/lure/internal/shutils"
"go.elara.ws/lure/internal/shutils/decoder"
"go.elara.ws/lure/internal/types"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/pkg/db"
"go.elara.ws/lure/pkg/distro"
"go.elara.ws/vercmp"
"mvdan.cc/sh/v3/expand"
@ -50,7 +50,12 @@ import (
// Pull pulls the provided repositories. If a repo doesn't exist, it will be cloned
// and its packages will be written to the DB. If it does exist, it will be pulled.
// In this case, only changed packages will be processed if possible.
// If repos is set to nil, the repos in the LURE config will be used.
func Pull(ctx context.Context, repos []types.Repo) error {
if repos == nil {
repos = config.Config().Repos
}
for _, repo := range repos {
repoURL, err := url.Parse(repo.URL)
if err != nil {

View File

@ -25,8 +25,8 @@ import (
"testing"
"go.elara.ws/lure/internal/types"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/pkg/db"
"go.elara.ws/lure/internal/config"
"go.elara.ws/lure/internal/db"
"go.elara.ws/lure/pkg/repos"
)

View File

@ -9,8 +9,8 @@ import (
"strconv"
"strings"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/pkg/db"
"go.elara.ws/lure/internal/config"
"go.elara.ws/lure/internal/db"
)
// Filter represents search filters.

View File

@ -26,8 +26,8 @@ import (
"github.com/urfave/cli/v2"
"go.elara.ws/lure/internal/log"
"go.elara.ws/lure/internal/types"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/pkg/db"
"go.elara.ws/lure/internal/config"
"go.elara.ws/lure/internal/db"
"go.elara.ws/lure/pkg/repos"
"golang.org/x/exp/slices"
)

View File

@ -26,8 +26,8 @@ import (
"go.elara.ws/lure/internal/log"
"go.elara.ws/lure/internal/types"
"go.elara.ws/lure/pkg/build"
"go.elara.ws/lure/pkg/config"
"go.elara.ws/lure/pkg/db"
"go.elara.ws/lure/internal/config"
"go.elara.ws/lure/internal/db"
"go.elara.ws/lure/pkg/distro"
"go.elara.ws/lure/pkg/manager"
"go.elara.ws/lure/pkg/repos"