fix: keep default templates and plugins folder working
This commit is contained in:
parent
9d14ba50af
commit
58795b66b2
|
|
@ -231,6 +231,26 @@ func (a *App) OpenVaultFolder() error {
|
|||
return cmd.Run()
|
||||
}
|
||||
|
||||
func ensurePluginsFolder(vaultPath string) (string, error) {
|
||||
path := filepath.Join(vaultPath, ".verstak", "plugins")
|
||||
if err := os.MkdirAll(path, 0o750); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return path, nil
|
||||
}
|
||||
|
||||
func (a *App) OpenPluginsFolder() error {
|
||||
if !a.IsReady() {
|
||||
return fmt.Errorf("vault not open")
|
||||
}
|
||||
target, err := ensurePluginsFolder(a.vault)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cmd := exec.Command("xdg-open", target)
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
func (a *App) Search(query string) ([]SearchResultDTO, error) {
|
||||
if err := a.requireVault(); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestEnsurePluginsFolder(t *testing.T) {
|
||||
vault := t.TempDir()
|
||||
|
||||
path, err := ensurePluginsFolder(vault)
|
||||
if err != nil {
|
||||
t.Fatalf("ensurePluginsFolder: %v", err)
|
||||
}
|
||||
|
||||
want := filepath.Join(vault, ".verstak", "plugins")
|
||||
if path != want {
|
||||
t.Fatalf("plugins path = %q, want %q", path, want)
|
||||
}
|
||||
if info, err := os.Stat(path); err != nil {
|
||||
t.Fatalf("stat plugins dir: %v", err)
|
||||
} else if !info.IsDir() {
|
||||
t.Fatalf("plugins path is not a directory: %s", path)
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
}
|
||||
|
||||
async function openPluginsDir() {
|
||||
try { await wailsCall('OpenFolder', '') } catch(e) {}
|
||||
try { await wailsCall('OpenPluginsFolder') } catch(e) {}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ func DefaultAppConfig() *AppConfig {
|
|||
Version: AppConfigVersion,
|
||||
Theme: "system",
|
||||
Language: "ru",
|
||||
EnabledTemplates: []string{"folder", "project", "client", "document", "recipe"},
|
||||
EnabledTemplates: []string{"folder.default", "project.default", "client.default", "document.default", "recipe.default"},
|
||||
EnabledPlugins: []string{},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package config_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"verstak/internal/core/config"
|
||||
"verstak/internal/core/templates"
|
||||
)
|
||||
|
||||
func TestDefaultAppConfigEnabledTemplatesMatchSystemTemplateIDs(t *testing.T) {
|
||||
cfg := config.DefaultAppConfig()
|
||||
if len(cfg.EnabledTemplates) == 0 {
|
||||
t.Fatal("default enabled templates is empty")
|
||||
}
|
||||
|
||||
reg := templates.NewRegistry()
|
||||
if err := reg.LoadSystem(); err != nil {
|
||||
t.Fatalf("LoadSystem: %v", err)
|
||||
}
|
||||
|
||||
for _, id := range cfg.EnabledTemplates {
|
||||
if _, ok := reg.Get(id); !ok {
|
||||
t.Fatalf("default enabled template %q does not match any system template ID", id)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue