Refactor UI state management and improve error handling in the application. Added success and error messages to enhance user feedback during package creation and device connection status updates.

This commit is contained in:
2026-01-29 10:45:12 -06:00
parent a44f433bba
commit f5a688e741
7 changed files with 120 additions and 77 deletions
+9 -12
View File
@@ -1,10 +1,9 @@
package main
import (
"io/fs"
"encoding/json"
"io/fs"
"strings"
"log"
)
type PackageJSON struct {
@@ -35,39 +34,37 @@ func loadPackageJSON(fsys fs.FS) (*PackageJSON, error) {
func createCpkg(fsys fs.FS, pkgData *PackageJSON) (*cpkg, error) {
pkg := NewCpkg(pkgData.Pkg)
// Walk through all directories recursively
err := fs.WalkDir(fsys, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
// Skip directories themselves (we only want files)
if d.IsDir() {
return nil
}
// Skip certain files
fileName := d.Name()
if fileName == "debug.log" || strings.HasSuffix(fileName, ".cpkg") {
log.Println("Skipping file:", path)
return nil
}
// Add file with full relative path
log.Println("Adding file:", path)
err = pkg.AddFile(fsys, path)
if err != nil {
return err
}
return nil
})
if err != nil {
return nil, err
}
success, err := pkg.Create()
if err != nil {
return nil, err
@@ -76,4 +73,4 @@ func createCpkg(fsys fs.FS, pkgData *PackageJSON) (*cpkg, error) {
return nil, err
}
return pkg, nil
}
}