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

Function Apply

src/cmd/apply.go:17–99  ·  view source on GitHub ↗

Apply .

(spicetifyVersion string)

Source from the content-addressed store, hash-verified

15
16// Apply .
17func Apply(spicetifyVersion string) {
18 utils.MigrateConfigFolder()
19
20 backupSpicetifyVersion := backupSection.Key("with").MustString("")
21 if spicetifyVersion != backupSpicetifyVersion {
22 utils.PrintInfo(`Preprocessed Spotify data is outdated. Please run "spicetify restore backup apply" to receive new features and bug fixes`)
23 os.Exit(1)
24 }
25
26 // Copy raw assets to Spotify Apps folder if Spotify is never applied
27 // before.
28 // extractedStock is for preventing copy raw assets 2 times when
29 // replaceColors is false.
30 extractedStock := false
31 if !spotifystatus.Get(appDestPath).IsApplied() {
32 spinner, _ := utils.Spinner.Start("Copying raw assets")
33 if err := os.RemoveAll(appDestPath); err != nil {
34 spinner.Fail("Failed to copy raw assets")
35 utils.Fatal(err)
36 }
37 if err := utils.Copy(rawFolder, appDestPath, true, nil); err != nil {
38 spinner.Fail("Failed to copy raw assets")
39 utils.Fatal(err)
40 }
41 spinner.Success("Copied raw assets")
42 extractedStock = true
43 }
44
45 if replaceColors {
46 spinner, _ := utils.Spinner.Start("Overwriting themed assets")
47 if err := utils.Copy(themedFolder, appDestPath, true, nil); err != nil {
48 spinner.Fail("Failed to overwrite themed assets")
49 utils.Fatal(err)
50 }
51 spinner.Success("Overwrote themed assets")
52 } else if !extractedStock {
53 spinner, _ := utils.Spinner.Start("Overwriting raw assets")
54 if err := utils.Copy(rawFolder, appDestPath, true, nil); err != nil {
55 spinner.Fail("Failed to overwrite raw assets")
56 utils.Fatal(err)
57 }
58 spinner.Success("Overwrote raw assets")
59 }
60
61 RefreshTheme()
62
63 if preprocSection.Key("expose_apis").MustBool(false) {
64 utils.CopyFile(
65 filepath.Join(utils.GetJsHelperDir(), "spicetifyWrapper.js"),
66 filepath.Join(appDestPath, "xpui", "helper"))
67 }
68
69 extensionList := featureSection.Key("extensions").Strings("|")
70 customAppsList := featureSection.Key("custom_apps").Strings("|")
71
72 spinner, _ := utils.Spinner.Start("Applying additional modifications")
73 apply.AdditionalOptions(appDestPath, apply.Flag{
74 CurrentTheme: settingSection.Key("current_theme").MustString(""),

Callers 2

mainFunction · 0.92
AutoFunction · 0.85

Calls 13

MigrateConfigFolderFunction · 0.92
PrintInfoFunction · 0.92
FatalFunction · 0.92
CopyFunction · 0.92
CopyFileFunction · 0.92
GetJsHelperDirFunction · 0.92
AdditionalOptionsFunction · 0.92
RefreshThemeFunction · 0.85
RefreshExtensionsFunction · 0.85
nodeModuleSymlinkFunction · 0.85
RefreshAppsFunction · 0.85
PatchFunction · 0.70

Tested by

no test coverage detected