Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions assets/README.md

This file was deleted.

Empty file removed assets/app/go.mod
Empty file.
2 changes: 1 addition & 1 deletion cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func assertTargetFileExists(targetFilename string) {
if targetFilename == config.BuildTargetDefault {
log.Warnf("Let hover add the \"lib/main_desktop.dart\" file? ")
if askForConfirmation() {
fileutils.CopyAsset("app/main_desktop.dart", filepath.Join("lib", "main_desktop.dart"), fileutils.AssetsBox())
fileutils.CopyAsset("app/main_desktop.dart", filepath.Join("lib", "main_desktop.dart"))
log.Infof("Target file \"lib/main_desktop.dart\" has been created.")
log.Infof(" Depending on your project, you might want to tweak it.")
return
Expand Down
8 changes: 4 additions & 4 deletions cmd/init-plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ var createPluginCmd = &cobra.Command{
"urlVSCRepo": vcsPath,
}

fileutils.ExecuteTemplateFromAssetsBox("plugin/plugin.go.tmpl", filepath.Join(build.BuildPath, "plugin.go"), fileutils.AssetsBox(), templateData)
fileutils.ExecuteTemplateFromAssetsBox("plugin/README.md.tmpl", filepath.Join(build.BuildPath, "README.md"), fileutils.AssetsBox(), templateData)
fileutils.ExecuteTemplateFromAssetsBox("plugin/import.go.tmpl.tmpl", filepath.Join(build.BuildPath, "import.go.tmpl"), fileutils.AssetsBox(), templateData)
fileutils.ExecuteTemplateFromAssets("plugin/plugin.go.tmpl", filepath.Join(build.BuildPath, "plugin.go"), templateData)
fileutils.ExecuteTemplateFromAssets("plugin/README.md.tmpl", filepath.Join(build.BuildPath, "README.md"), templateData)
fileutils.ExecuteTemplateFromAssets("plugin/import.go.tmpl.tmpl", filepath.Join(build.BuildPath, "import.go.tmpl"), templateData)

dlibPath := filepath.Join(build.BuildPath, "dlib")
err = os.Mkdir(dlibPath, 0775)
if err != nil {
log.Errorf("Failed to create '%s' directory: %v", dlibPath, err)
os.Exit(1)
}
fileutils.ExecuteTemplateFromAssetsBox("plugin/README.md.dlib.tmpl", filepath.Join(dlibPath, "README.md"), fileutils.AssetsBox(), templateData)
fileutils.ExecuteTemplateFromAssets("plugin/README.md.dlib.tmpl", filepath.Join(dlibPath, "README.md"), templateData)

platforms := []string{"darwin", "linux", "windows"}
for _, platform := range platforms {
Expand Down
10 changes: 5 additions & 5 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ var initCmd = &cobra.Command{

emptyConfig := config.Config{}

fileutils.CopyAsset("app/main.go", filepath.Join(desktopCmdPath, "main.go"), fileutils.AssetsBox())
fileutils.CopyAsset("app/options.go", filepath.Join(desktopCmdPath, "options.go"), fileutils.AssetsBox())
fileutils.CopyAsset("app/icon.png", filepath.Join(desktopAssetsPath, "icon.png"), fileutils.AssetsBox())
fileutils.CopyAsset("app/gitignore", filepath.Join(build.BuildPath, ".gitignore"), fileutils.AssetsBox())
fileutils.ExecuteTemplateFromAssetsBox("app/hover.yaml.tmpl", filepath.Join(build.BuildPath, "hover.yaml"), fileutils.AssetsBox(), map[string]string{
fileutils.CopyAsset("app/main.go.tmpl", filepath.Join(desktopCmdPath, "main.go"))
fileutils.CopyAsset("app/options.go.tmpl", filepath.Join(desktopCmdPath, "options.go"))
fileutils.CopyAsset("app/icon.png", filepath.Join(desktopAssetsPath, "icon.png"))
fileutils.CopyAsset("app/gitignore", filepath.Join(build.BuildPath, ".gitignore"))
fileutils.ExecuteTemplateFromAssets("app/hover.yaml.tmpl", filepath.Join(build.BuildPath, "hover.yaml"), map[string]string{
"applicationName": emptyConfig.GetApplicationName(projectName),
"executableName": emptyConfig.GetExecutableName(projectName),
"packageName": emptyConfig.GetPackageName(projectName),
Expand Down
2 changes: 1 addition & 1 deletion cmd/packaging/packaging.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (t *packagingTask) init(ignoreAlreadyExists bool) {
log.Errorf("Failed to create directory %s: %v", filepath.Dir(destinationFile), err)
os.Exit(1)
}
fileutils.CopyAsset(fmt.Sprintf("packaging/%s", sourceFile), destinationFile, fileutils.AssetsBox())
fileutils.CopyAsset(fmt.Sprintf("packaging/%s", sourceFile), destinationFile)
}
if t.generateInitFiles != nil {
log.Infof("Generating dynamic init files")
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/go-flutter-desktop/hover
go 1.18

require (
github.com/GeertJohan/go.rice v1.0.2
github.com/JackMordaunt/icns v1.0.0
github.com/Kodeworks/golang-image-ico v0.0.0-20141118225523-73f0f4cfade9
github.com/google/uuid v1.3.0
Expand All @@ -20,7 +19,6 @@ require (
)

require (
github.com/daaku/go.zipexe v1.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/go-github v17.0.0+incompatible // indirect
github.com/google/go-querystring v1.1.0 // indirect
Expand Down
11 changes: 0 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0=
github.com/GeertJohan/go.rice v1.0.2 h1:PtRw+Tg3oa3HYwiDBZyvOJ8LdIyf6lAovJJtr7YOAYk=
github.com/GeertJohan/go.rice v1.0.2/go.mod h1:af5vUNlDNkCjOZeSGFgIJxDje9qdjsO6hshx0gTmZt4=
github.com/JackMordaunt/icns v1.0.0 h1:41cNyWyQrG6beMw7m93LFK5o1GhefflsBTkauUkUtG8=
github.com/JackMordaunt/icns v1.0.0/go.mod h1:ubRqphS0f2OD07BuNaQSuw9uHUVQNBX5g38n6i2bdqM=
github.com/Kodeworks/golang-image-ico v0.0.0-20141118225523-73f0f4cfade9 h1:1ltqoej5GtaWF8jaiA49HwsZD459jqm9YFz9ZtMFpQA=
github.com/Kodeworks/golang-image-ico v0.0.0-20141118225523-73f0f4cfade9/go.mod h1:7uhhqiBaR4CpN0k9rMjOtjpcfGd6DG2m04zQxKnWQ0I=
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E=
github.com/daaku/go.zipexe v1.0.1 h1:wV4zMsDOI2SZ2m7Tdz1Ps96Zrx+TzaK15VbUaGozw0M=
github.com/daaku/go.zipexe v1.0.1/go.mod h1:5xWogtqlYnfBXkSB1o9xysukNP9GTvaNkqzUZbt3Bw8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -25,12 +18,10 @@ github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mO
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
github.com/nkovacs/streamquote v1.0.0/go.mod h1:BN+NaZ2CmdKqUuTUXUEm9j95B2TRbpOWpxbJYzzgUsc=
github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE=
github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U=
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
Expand All @@ -54,8 +45,6 @@ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PK
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e h1:IWllFTiDjjLIf2oeKxpIUmtiDV5sn71VgeQgg6vcE7k=
github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e/go.mod h1:d7u6HkTYKSv5m6MCKkOQlHwaShTMl3HjqSGW3XtVhXM=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/net v0.0.0-20220708220712-1185a9018129 h1:vucSRfWwTsoXro7P+3Cjlr6flUMtzCwzlvkxEQtHHB0=
Expand Down
28 changes: 0 additions & 28 deletions internal/fileutils/assets.go

This file was deleted.

File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions internal/fileutils/embed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package fileutils

import "embed"

//go:embed assets
var assets embed.FS
25 changes: 8 additions & 17 deletions internal/fileutils/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"strings"
"text/template"

rice "github.com/GeertJohan/go.rice"

"github.com/go-flutter-desktop/hover/internal/log"
)

Expand Down Expand Up @@ -214,31 +212,24 @@ func ExecuteTemplateFromFile(boxed, to string, templateData interface{}) {
executeTemplateFromString(string(templateString), to, templateData)
}

// ExecuteTemplateFromAssetsBox create file from a template asset
func ExecuteTemplateFromAssetsBox(boxed, to string, assetsBox *rice.Box, templateData interface{}) {
templateString, err := assetsBox.String(boxed)
// ExecuteTemplateFromAssets create file from a template asset
func ExecuteTemplateFromAssets(name, to string, templateData interface{}) {
data, err := assets.ReadFile(fmt.Sprintf("assets/%s", name))
if err != nil {
log.Errorf("Failed to find template file: %v\n", err)
os.Exit(1)
}
executeTemplateFromString(templateString, to, templateData)
executeTemplateFromString(string(data), to, templateData)
}

// CopyAsset copies a file from asset
func CopyAsset(boxed, to string, assetsBox *rice.Box) {
file, err := os.Create(to)
if err != nil {
log.Errorf("Failed to create %s: %v", to, err)
os.Exit(1)
}
defer file.Close()
boxedFile, err := assetsBox.Open(boxed)
func CopyAsset(name, to string) {
data, err := assets.ReadFile(fmt.Sprintf("assets/%s", name))
if err != nil {
log.Errorf("Failed to find boxed file %s: %v", boxed, err)
log.Errorf("Failed to find asset file %s: %v", name, err)
os.Exit(1)
}
defer boxedFile.Close()
_, err = io.Copy(file, boxedFile)
err = os.WriteFile(to, data, 0o600)
if err != nil {
log.Errorf("Failed to write file %s: %v", to, err)
os.Exit(1)
Expand Down
Loading