MCPcopy
hub / github.com/spicetify/cli / AdditionalOptions

Function AdditionalOptions

src/apply/apply.go:29–107  ·  view source on GitHub ↗

AdditionalOptions .

(appsFolderPath string, flags Flag)

Source from the content-addressed store, hash-verified

27
28// AdditionalOptions .
29func AdditionalOptions(appsFolderPath string, flags Flag) {
30 jsModifiers := []func(path string, flags Flag){
31 insertExpFeatures,
32 insertSidebarConfig,
33 insertHomeConfig,
34 }
35 filesToModified := map[string][]func(path string, flags Flag){
36 filepath.Join(appsFolderPath, "xpui", "index.html"): {
37 htmlMod,
38 },
39 filepath.Join(appsFolderPath, "xpui", "xpui.js"): jsModifiers,
40 filepath.Join(appsFolderPath, "xpui", "xpui-modules.js"): jsModifiers,
41 filepath.Join(appsFolderPath, "xpui", "xpui-snapshot.js"): {
42 insertCustomApp,
43 },
44 filepath.Join(appsFolderPath, "xpui", "home-v2.js"): {
45 insertHomeConfig,
46 },
47 filepath.Join(appsFolderPath, "xpui", "xpui-desktop-modals.js"): {
48 insertVersionInfo,
49 },
50 }
51
52 verParts := strings.Split(flags.SpotifyVer, ".")
53 spotifyMajor, spotifyMinor, spotifyPatch := 0, 0, 0
54 if len(verParts) > 0 {
55 spotifyMajor, _ = strconv.Atoi(verParts[0])
56 }
57 if len(verParts) > 1 {
58 spotifyMinor, _ = strconv.Atoi(verParts[1])
59 }
60 if len(verParts) > 2 {
61 spotifyPatch, _ = strconv.Atoi(verParts[2])
62 }
63
64 filesToModified[filepath.Join(appsFolderPath, "xpui", "xpui.js")] = append(filesToModified[filepath.Join(appsFolderPath, "xpui", "xpui.js")], insertCustomApp)
65 if spotifyMajor >= 1 && spotifyMinor >= 2 && spotifyPatch >= 57 {
66 filesToModified[filepath.Join(appsFolderPath, "xpui", "xpui.js")] = append(filesToModified[filepath.Join(appsFolderPath, "xpui", "xpui.js")], insertExpFeatures)
67 } else {
68 filesToModified[filepath.Join(appsFolderPath, "xpui", "vendor~xpui.js")] = []func(string, Flag){insertExpFeatures}
69 }
70
71 if flags.SidebarConfig {
72 if err := utils.CopyFile(
73 filepath.Join(utils.GetJsHelperDir(), "sidebarConfig.js"),
74 filepath.Join(appsFolderPath, "xpui", "helper")); err != nil {
75 utils.PrintError(err.Error())
76 flags.SidebarConfig = false
77 }
78 }
79
80 if flags.HomeConfig {
81 if err := utils.CopyFile(
82 filepath.Join(utils.GetJsHelperDir(), "homeConfig.js"),
83 filepath.Join(appsFolderPath, "xpui", "helper")); err != nil {
84 utils.PrintError(err.Error())
85 flags.HomeConfig = false
86 }

Callers 1

ApplyFunction · 0.92

Calls 3

CopyFileFunction · 0.92
GetJsHelperDirFunction · 0.92
PrintErrorFunction · 0.92

Tested by

no test coverage detected