package arcast import ( "embed" "encoding/json" "io/fs" "path/filepath" "forge.cadoles.com/arcad/arcast/pkg/server" "github.com/pkg/errors" ) var ( DefaultApps []server.App //go:embed apps/main/build/** appsFS embed.FS ) func init() { defaultApps, err := loadApps( "apps/main/build", ) if err != nil { panic(errors.WithStack(err)) } DefaultApps = defaultApps } func loadApps(appDirs ...string) ([]server.App, error) { apps := make([]server.App, 0) for _, dir := range appDirs { rawManifest, err := fs.ReadFile(appsFS, filepath.Join(dir, "arcast-app.json")) if err != nil { return nil, errors.WithStack(err) } var app server.App if err := json.Unmarshal(rawManifest, &app); err != nil { return nil, errors.WithStack(err) } fs, err := fs.Sub(appsFS, dir) if err != nil { return nil, errors.WithStack(err) } app.FS = fs apps = append(apps, app) } return apps, nil }