configcmd and version: the config and version standard commands; darwin /var/run
core/configcmd: "<program> config create|validate|upgrade|path" from a Spec (name, application, minimal/full templates, Validate, Schema), taken over from yamase-core/pkg/configcmd and generalized: Filename, Optional (programs that run on defaults) and None (no configuration). core/version: "<program> version [--json]" over the values each program stamps into its internal/version; JSON keys match yasta's existing output (yavebu reads it), VCS fallback for unstamped builds. paths: macOS CLI/Service system-scope RuntimeDir is /var/run/<app> instead of /run/<app>, which macOS does not have. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ca0f06f978
commit
90132e2d76
13 files changed
+1824
-20
No files matched your search
@@ -13,6 +13,15 @@ import "yetano.dev/yetano/core"
|
||||
// preferences-adjacent files and its bulk data side by side); State gets
|
||||
// its own subdirectory so it doesn't collide with either.
|
||||
|
||||
// darwinFlavor is the Linux layout CLI and Service applications use on
|
||||
// macOS, except the system runtime base: macOS has no /run, its
|
||||
// equivalent is /var/run.
|
||||
var darwinFlavor = func() unixFlavor {
|
||||
f := linuxFlavor
|
||||
f.systemRuntimeBase = "/var/run"
|
||||
return f
|
||||
}()
|
||||
|
||||
func darwinAppSupportBase(scope core.Scope, home string) string {
|
||||
if scope == core.SystemScope {
|
||||
return "/Library/Application Support"
|
||||
|
||||
@@ -93,3 +93,19 @@ func TestDarwinServiceUsesXDGLikeLayout(t *testing.T) {
|
||||
t.Errorf("ConfigDir() = %q, want %q (macOS Service should match Linux layout)", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDarwinServiceSystemRuntimeDirIsVarRun(t *testing.T) {
|
||||
app := core.Application{Name: "yasta", Kind: core.Service, Scope: core.SystemScope}
|
||||
r := mustResolver(t, app, WithPlatform("darwin"), WithEnvironment(map[string]string{}))
|
||||
got, err := r.RuntimeDir()
|
||||
if err != nil {
|
||||
t.Fatalf("RuntimeDir: %v", err)
|
||||
}
|
||||
if want := "/var/run/yasta"; got != want {
|
||||
t.Errorf("RuntimeDir() = %q, want %q (macOS has no /run)", got, want)
|
||||
}
|
||||
lin := mustResolver(t, app, WithPlatform("linux"), WithEnvironment(map[string]string{}))
|
||||
if got, _ := lin.RuntimeDir(); got != "/run/yasta" {
|
||||
t.Errorf("linux RuntimeDir() = %q, want /run/yasta", got)
|
||||
}
|
||||
}
|
||||
+6
-3
@@ -23,13 +23,16 @@ type unixFlavor struct {
|
||||
}
|
||||
|
||||
// flavor selects the unixFlavor for r.platform. darwin (in CLI/Service
|
||||
// kind) and any GOOS not otherwise recognized fall back to the Linux
|
||||
// flavor as a documented, sane default -- see AGENTS.md TODO for tuning
|
||||
// individual BSDs later without a redesign.
|
||||
// kind) uses the Linux flavor with macOS's runtime base; any GOOS not
|
||||
// otherwise recognized falls back to the Linux flavor as a documented,
|
||||
// sane default -- see AGENTS.md TODO for tuning individual BSDs later
|
||||
// without a redesign.
|
||||
func (r *Resolver) flavor() unixFlavor {
|
||||
switch r.platform {
|
||||
case "freebsd":
|
||||
return freebsdFlavor
|
||||
case "darwin":
|
||||
return darwinFlavor
|
||||
default:
|
||||
return linuxFlavor
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user