(list ...string)
| 280 | } |
| 281 | |
| 282 | func RefreshApps(list ...string) { |
| 283 | spinner, _ := utils.Spinner.Start("Refreshing custom apps") |
| 284 | if len(list) == 0 { |
| 285 | list = featureSection.Key("custom_apps").Strings("|") |
| 286 | } |
| 287 | |
| 288 | for _, app := range list { |
| 289 | appName := `spicetify-routes-` + app |
| 290 | |
| 291 | customAppPath, err := utils.GetCustomAppPath(app) |
| 292 | if err != nil { |
| 293 | utils.PrintError(`Custom app "` + app + `" not found`) |
| 294 | continue |
| 295 | } |
| 296 | |
| 297 | jsFile := filepath.Join(customAppPath, "index.js") |
| 298 | jsFileContent, err := os.ReadFile(jsFile) |
| 299 | if err != nil { |
| 300 | utils.PrintError(`Custom app "` + app + `" does not have index.js`) |
| 301 | continue |
| 302 | } |
| 303 | |
| 304 | manifestFile := filepath.Join(customAppPath, "manifest.json") |
| 305 | manifestFileContent, err := os.ReadFile(manifestFile) |
| 306 | if err != nil { |
| 307 | manifestFileContent = []byte{'{', '}'} |
| 308 | } |
| 309 | os.WriteFile( |
| 310 | filepath.Join(appDestPath, "xpui", appName+".json"), |
| 311 | manifestFileContent, |
| 312 | 0700) |
| 313 | |
| 314 | var manifestJson utils.AppManifest |
| 315 | if err = json.Unmarshal(manifestFileContent, &manifestJson); err == nil { |
| 316 | for _, subfile := range manifestJson.Files { |
| 317 | subfilePath := filepath.Join(customAppPath, subfile) |
| 318 | subfileContent, err := os.ReadFile(subfilePath) |
| 319 | if err != nil { |
| 320 | continue |
| 321 | } |
| 322 | jsFileContent = append(jsFileContent, '\n') |
| 323 | jsFileContent = append(jsFileContent, subfileContent...) |
| 324 | } |
| 325 | for _, extensionFile := range manifestJson.ExtensionFiles { |
| 326 | subfilePath, err := filepath.Abs(filepath.Join(customAppPath, extensionFile)) |
| 327 | if err != nil { |
| 328 | continue |
| 329 | } |
| 330 | pushExtensions(app, subfilePath) |
| 331 | } |
| 332 | for _, assetExpr := range manifestJson.Assets { |
| 333 | assetsList, err := filepath.Glob(filepath.Join(customAppPath, assetExpr)) |
| 334 | if err != nil { |
| 335 | utils.PrintError(err.Error()) |
| 336 | continue |
| 337 | } |
| 338 | if len(assetsList) == 0 { |
| 339 | message := fmt.Sprintf("Custom App '%s': no assets found for expression '%s'", app, assetExpr) |
no test coverage detected