refactor: update import paths to use internal package

This commit is contained in:
Antoine Aflalo
2025-02-13 19:39:06 -05:00
parent 5428134d15
commit dd7b6a332c
25 changed files with 54 additions and 54 deletions

View File

@@ -24,7 +24,7 @@ changelog:
order: 2 order: 2
builds: builds:
- id: cbzoptimizer - id: cbzoptimizer
main: main.go main: cmd/cbzoptimizer/main.go
goos: goos:
- linux - linux
goarch: goarch:

View File

@@ -1,10 +1,10 @@
package cmd package commands
import ( import (
"fmt" "fmt"
"github.com/belphemur/CBZOptimizer/v2/converter" utils2 "github.com/belphemur/CBZOptimizer/v2/internal/utils"
"github.com/belphemur/CBZOptimizer/v2/converter/constant" "github.com/belphemur/CBZOptimizer/v2/pkg/converter"
"github.com/belphemur/CBZOptimizer/v2/utils" "github.com/belphemur/CBZOptimizer/v2/pkg/converter/constant"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/thediveo/enumflag/v2" "github.com/thediveo/enumflag/v2"
"os" "os"
@@ -45,7 +45,7 @@ func ConvertCbzCommand(cmd *cobra.Command, args []string) error {
return fmt.Errorf("path is required") return fmt.Errorf("path is required")
} }
if !utils.IsValidFolder(path) { if !utils2.IsValidFolder(path) {
return fmt.Errorf("the path needs to be a folder") return fmt.Errorf("the path needs to be a folder")
} }
@@ -92,7 +92,7 @@ func ConvertCbzCommand(cmd *cobra.Command, args []string) error {
go func() { go func() {
defer wg.Done() defer wg.Done()
for path := range fileChan { for path := range fileChan {
err := utils.Optimize(&utils.OptimizeOptions{ err := utils2.Optimize(&utils2.OptimizeOptions{
ChapterConverter: chapterConverter, ChapterConverter: chapterConverter,
Path: path, Path: path,
Quality: quality, Quality: quality,

View File

@@ -1,11 +1,11 @@
package cmd package commands
import ( import (
"github.com/belphemur/CBZOptimizer/v2/cbz" "github.com/belphemur/CBZOptimizer/v2/internal/cbz"
"github.com/belphemur/CBZOptimizer/v2/converter" "github.com/belphemur/CBZOptimizer/v2/internal/manga"
"github.com/belphemur/CBZOptimizer/v2/converter/constant" "github.com/belphemur/CBZOptimizer/v2/internal/utils/errs"
"github.com/belphemur/CBZOptimizer/v2/manga" "github.com/belphemur/CBZOptimizer/v2/pkg/converter"
"github.com/belphemur/CBZOptimizer/v2/utils/errs" "github.com/belphemur/CBZOptimizer/v2/pkg/converter/constant"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"log" "log"
"os" "os"

View File

@@ -1,4 +1,4 @@
package cmd package commands
import ( import (
"fmt" "fmt"

View File

@@ -1,10 +1,10 @@
package cmd package commands
import ( import (
"fmt" "fmt"
"github.com/belphemur/CBZOptimizer/v2/converter" utils2 "github.com/belphemur/CBZOptimizer/v2/internal/utils"
"github.com/belphemur/CBZOptimizer/v2/converter/constant" "github.com/belphemur/CBZOptimizer/v2/pkg/converter"
"github.com/belphemur/CBZOptimizer/v2/utils" "github.com/belphemur/CBZOptimizer/v2/pkg/converter/constant"
"github.com/pablodz/inotifywaitgo/inotifywaitgo" "github.com/pablodz/inotifywaitgo/inotifywaitgo"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
@@ -53,7 +53,7 @@ func WatchCommand(_ *cobra.Command, args []string) error {
return fmt.Errorf("path is required") return fmt.Errorf("path is required")
} }
if !utils.IsValidFolder(path) { if !utils2.IsValidFolder(path) {
return fmt.Errorf("the path needs to be a folder") return fmt.Errorf("the path needs to be a folder")
} }
@@ -114,7 +114,7 @@ func WatchCommand(_ *cobra.Command, args []string) error {
for _, e := range event.Events { for _, e := range event.Events {
switch e { switch e {
case inotifywaitgo.CLOSE_WRITE, inotifywaitgo.MOVE: case inotifywaitgo.CLOSE_WRITE, inotifywaitgo.MOVE:
err := utils.Optimize(&utils.OptimizeOptions{ err := utils2.Optimize(&utils2.OptimizeOptions{
ChapterConverter: chapterConverter, ChapterConverter: chapterConverter,
Path: event.Filename, Path: event.Filename,
Quality: quality, Quality: quality,

16
cmd/cbzoptimizer/main.go Normal file
View File

@@ -0,0 +1,16 @@
package main
import (
"github.com/belphemur/CBZOptimizer/v2/cmd/cbzoptimizer/commands"
)
var (
version = "dev"
commit = "none"
date = "unknown"
)
func main() {
commands.SetVersionInfo(version, commit, date)
commands.Execute()
}

2
go.mod
View File

@@ -1,6 +1,6 @@
module github.com/belphemur/CBZOptimizer/v2 module github.com/belphemur/CBZOptimizer/v2
go 1.23.1 go 1.24
toolchain go1.24.0 toolchain go1.24.0

View File

@@ -3,8 +3,8 @@ package cbz
import ( import (
"archive/zip" "archive/zip"
"fmt" "fmt"
"github.com/belphemur/CBZOptimizer/v2/manga" "github.com/belphemur/CBZOptimizer/v2/internal/manga"
"github.com/belphemur/CBZOptimizer/v2/utils/errs" "github.com/belphemur/CBZOptimizer/v2/internal/utils/errs"
"os" "os"
"time" "time"
) )

View File

@@ -4,8 +4,8 @@ import (
"archive/zip" "archive/zip"
"bytes" "bytes"
"fmt" "fmt"
"github.com/belphemur/CBZOptimizer/v2/manga" "github.com/belphemur/CBZOptimizer/v2/internal/manga"
"github.com/belphemur/CBZOptimizer/v2/utils/errs" "github.com/belphemur/CBZOptimizer/v2/internal/utils/errs"
"os" "os"
"testing" "testing"
"time" "time"

View File

@@ -6,8 +6,8 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/araddon/dateparse" "github.com/araddon/dateparse"
"github.com/belphemur/CBZOptimizer/v2/manga" "github.com/belphemur/CBZOptimizer/v2/internal/manga"
"github.com/belphemur/CBZOptimizer/v2/utils/errs" "github.com/belphemur/CBZOptimizer/v2/internal/utils/errs"
"io" "io"
"path/filepath" "path/filepath"
"strings" "strings"

View File

@@ -3,9 +3,9 @@ package utils
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/belphemur/CBZOptimizer/v2/cbz" "github.com/belphemur/CBZOptimizer/v2/internal/cbz"
"github.com/belphemur/CBZOptimizer/v2/converter" "github.com/belphemur/CBZOptimizer/v2/pkg/converter"
errors2 "github.com/belphemur/CBZOptimizer/v2/converter/errors" errors2 "github.com/belphemur/CBZOptimizer/v2/pkg/converter/errors"
"log" "log"
"strings" "strings"
) )

16
main.go
View File

@@ -1,16 +0,0 @@
package main
import (
"github.com/belphemur/CBZOptimizer/v2/cmd"
)
var (
version = "dev"
commit = "none"
date = "unknown"
)
func main() {
cmd.SetVersionInfo(version, commit, date)
cmd.Execute()
}

View File

@@ -2,9 +2,9 @@ package converter
import ( import (
"fmt" "fmt"
"github.com/belphemur/CBZOptimizer/v2/converter/constant" "github.com/belphemur/CBZOptimizer/v2/internal/manga"
"github.com/belphemur/CBZOptimizer/v2/converter/webp" "github.com/belphemur/CBZOptimizer/v2/pkg/converter/constant"
"github.com/belphemur/CBZOptimizer/v2/manga" "github.com/belphemur/CBZOptimizer/v2/pkg/converter/webp"
"github.com/samber/lo" "github.com/samber/lo"
"strings" "strings"
) )

View File

@@ -2,9 +2,9 @@ package converter
import ( import (
"bytes" "bytes"
"github.com/belphemur/CBZOptimizer/v2/converter/constant" "github.com/belphemur/CBZOptimizer/v2/internal/utils/errs"
"github.com/belphemur/CBZOptimizer/v2/manga" "github.com/belphemur/CBZOptimizer/v2/manga"
"github.com/belphemur/CBZOptimizer/v2/utils/errs" "github.com/belphemur/CBZOptimizer/v2/pkg/converter/constant"
"golang.org/x/exp/slices" "golang.org/x/exp/slices"
"image" "image"
"image/jpeg" "image/jpeg"

View File

@@ -4,9 +4,9 @@ import (
"bytes" "bytes"
"errors" "errors"
"fmt" "fmt"
"github.com/belphemur/CBZOptimizer/v2/converter/constant" "github.com/belphemur/CBZOptimizer/v2/internal/manga"
converterrors "github.com/belphemur/CBZOptimizer/v2/converter/errors" "github.com/belphemur/CBZOptimizer/v2/pkg/converter/constant"
"github.com/belphemur/CBZOptimizer/v2/manga" converterrors "github.com/belphemur/CBZOptimizer/v2/pkg/converter/errors"
"github.com/oliamb/cutter" "github.com/oliamb/cutter"
"golang.org/x/exp/slices" "golang.org/x/exp/slices"
_ "golang.org/x/image/webp" _ "golang.org/x/image/webp"