Add ditto archive helper
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0c48594842
commit
1acf07af16
22
internal/archive/archive.go
Normal file
22
internal/archive/archive.go
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
package archive
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/leonmika/wails-release/internal/runner"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ZipApp wraps a .app bundle into a .app.zip via ditto, preserving
|
||||||
|
// extended attributes and producing an archive Apple's notary service
|
||||||
|
// will accept.
|
||||||
|
func ZipApp(ctx context.Context, r runner.Runner, app, zipPath string) error {
|
||||||
|
_, err := r.Run(ctx, runner.Spec{
|
||||||
|
Name: "ditto",
|
||||||
|
Args: []string{"-c", "-k", "--keepParent", app, zipPath},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("ditto archive %s -> %s: %w", app, zipPath, err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
24
internal/archive/archive_test.go
Normal file
24
internal/archive/archive_test.go
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
package archive_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/leonmika/wails-release/internal/archive"
|
||||||
|
"github.com/leonmika/wails-release/internal/runner"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestZipApp_BuildsCorrectDittoArgs(t *testing.T) {
|
||||||
|
f := &runner.Fake{}
|
||||||
|
f.On("ditto", nil).Return(nil, nil)
|
||||||
|
|
||||||
|
err := archive.ZipApp(context.Background(), f, "/build/MyApp.app", "/dist/MyApp-1.2.3.app.zip")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unexpected: %v", err)
|
||||||
|
}
|
||||||
|
want := []string{"-c", "-k", "--keepParent", "/build/MyApp.app", "/dist/MyApp-1.2.3.app.zip"}
|
||||||
|
if !reflect.DeepEqual(f.Calls[0].Args, want) {
|
||||||
|
t.Fatalf("args got %v want %v", f.Calls[0].Args, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue