feat: Add NFPM packaging and defer Playwright installation

This commit introduces NFPM configuration in `.goreleaser.yaml` to
generate native packages for various Linux distributions (e.g., .deb,
.rpm, .apk). This provides a more streamlined installation experience
for Linux users.

The Playwright browser installation logic has been moved from `main.go`
to the `Run` function of the `download` command. This change ensures
that Playwright binaries are only downloaded and installed when the
`download` command is actually invoked, improving initial application
startup performance and reducing unnecessary overhead for other commands.

The Goreleaser configuration has also been updated to version 2 syntax
and the `arm` architecture has been removed from builds.
This commit is contained in:
2025-10-06 18:07:54 +11:00
parent 34179b4dc0
commit 08e6280c34
5 changed files with 60 additions and 17 deletions

View File

@@ -8,10 +8,12 @@ import (
"bilinovel-downloader/text"
"encoding/json"
"fmt"
"io"
"log"
"os"
"path/filepath"
"github.com/playwright-community/playwright-go"
"github.com/spf13/cobra"
)
@@ -20,7 +22,16 @@ var downloadCmd = &cobra.Command{
Short: "Download a novel or volume",
Long: "Download a novel or volume",
Run: func(cmd *cobra.Command, args []string) {
err := runDownloadNovel()
log.Println("Installing playwright")
err := playwright.Install(&playwright.RunOptions{
Browsers: []string{"chromium"},
Stdout: io.Discard,
})
if err != nil {
log.Panicf("failed to install playwright")
}
err = runDownloadNovel()
if err != nil {
log.Printf("failed to download novel: %v", err)
}