-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtui.go
More file actions
702 lines (586 loc) · 18.8 KB
/
tui.go
File metadata and controls
702 lines (586 loc) · 18.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
package main
import (
"blanktiger/hm/configuration"
conf "blanktiger/hm/configuration"
"blanktiger/hm/instructions"
"blanktiger/hm/lib"
"fmt"
"io"
"os"
"reflect"
"slices"
"strings"
"github.com/charmbracelet/bubbles/key"
blist "github.com/charmbracelet/bubbles/list"
tea "github.com/charmbracelet/bubbletea"
lg "github.com/charmbracelet/lipgloss"
)
type screen int
const (
cliArgsScreen screen = iota
configsScreen
globalDepsScreen
// will gather information on wheter the user wants to save info from previous
// screens to disk (make configs public/private, include/exclude global dependencies)
userChoicesScreen
)
func isValidScreen(screenId int) bool {
switch screenId {
case int(cliArgsScreen), int(configsScreen), int(globalDepsScreen), int(userChoicesScreen):
return true
default:
return false
}
}
type listItem string
func (l listItem) FilterValue() string {
return string(l)
}
type itemDelegate struct{}
func (d itemDelegate) Height() int { return 1 }
func (d itemDelegate) Spacing() int { return 0 }
func (d itemDelegate) Update(_ tea.Msg, _ *blist.Model) tea.Cmd { return nil }
func (d itemDelegate) Render(w io.Writer, m blist.Model, index int, item blist.Item) {
i, ok := item.(listItem)
if !ok {
return
}
str := fmt.Sprintf("%s", i)
prefixSelected := "-> "
prefixNormal := " "
fn := listItemStyle.Render
if index == m.Index() {
str = prefixSelected + str
fn = selectedListItemStyle.Render
} else {
// TODO: maybe just highlight the arrow instead of the whole line
str = prefixNormal + str
}
fmt.Fprint(w, fn(str))
}
// styles
var (
baseListItemPaddingLeft = 0
titleStyle = lg.NewStyle()
listItemStyle = lg.NewStyle().PaddingLeft(baseListItemPaddingLeft)
selectedListItemStyle = lg.NewStyle().Foreground(lg.Color(accentColor)).Bold(true).PaddingLeft(baseListItemPaddingLeft)
paginationStyle = blist.DefaultStyles().PaginationStyle
helpStyle = blist.DefaultStyles().HelpStyle
listStyle = lg.NewStyle()
footerStyle = lg.NewStyle().Foreground(lg.Color(accentColor))
selectedStyle = lg.NewStyle().Bold(true).Foreground(lg.Color(accentColor))
listEntryStyle = lg.NewStyle()
)
// TODO: set up logging, logger should output everything to a file
type model struct {
lockfile *lib.Lockfile
conf *configuration.Configuration
// all configs from lockfile (non hidden + hidden)
configs []lib.Config
// index in the configs list -> is it selected
configSelection map[int]bool
// this is all global dependencies that are split, so that when we iterate
// it's like all of them are on a separate line in the DEPENDENCIES file
flatGlobalDeps []lib.GlobalDependency
// index in the global dependencies list -> is it selected
globalDepsSelection map[int]bool
choiceSelection map[int]bool
userChoices choices
cliArgsSelection map[int]bool
currentScreen screen
termWidth int
termHeight int
cliArgsList blist.Model
configsList blist.Model
globalDepsList blist.Model
choicesList blist.Model
listHeight int
}
type choices struct {
PersistConfigSelection bool `txt:"Persist config selection"`
PersistGlobalDepsSelection bool `txt:"Persist global dependencies selection"`
}
func initModel(lockfile *lib.Lockfile, conf *configuration.Configuration) model {
selected := make(map[int]bool)
for idx := range lockfile.Configs {
selected[idx] = true
}
offset := len(lockfile.Configs)
for idx := range lockfile.HiddenConfigs {
selected[idx+offset] = false
}
allConfigs := slices.Concat(lockfile.Configs, lockfile.HiddenConfigs)
allConfigNames := []blist.Item{}
for _, cfg := range lockfile.Configs {
item := listItem("[*] " + cfg.Name)
allConfigNames = append(allConfigNames, item)
}
for _, cfg := range lockfile.HiddenConfigs {
item := listItem("[ ] " + cfg.Name)
allConfigNames = append(allConfigNames, item)
}
defaultWidth := 20
defaultListHeight := 25
configsList := blist.New(allConfigNames, itemDelegate{}, defaultWidth, defaultListHeight)
{
configsList.Title = "Configs - select the ones you want to copy/symlink."
configsList.SetShowStatusBar(false)
configsList.SetFilteringEnabled(true)
configsList.Styles.PaginationStyle = paginationStyle
configsList.Styles.HelpStyle = helpStyle
configsList.AdditionalFullHelpKeys = additionalFullHelpKeysGeneral
configsList.AdditionalShortHelpKeys = additionalShortHelpKeysGeneral
}
globalDepsSelection := make(map[int]bool)
globalDepNames := []blist.Item{}
flatGlobalDeps := []lib.GlobalDependency{}
depIdx := 0
for _, dep := range lockfile.GlobalDependencies {
if dep.Instruction.Method == instructions.Bash {
flatGlobalDeps = append(flatGlobalDeps, dep)
globalDepNames = append(globalDepNames, listItem("[*] "+formatGlobalDep(dep)))
globalDepsSelection[depIdx] = true
depIdx++
continue
}
for subDepPkg := range strings.SplitSeq(dep.Instruction.Pkg, " ") {
subDep := dep
inst := *subDep.Instruction
subDep.Instruction = &inst
subDep.Instruction.Pkg = subDepPkg
flatGlobalDeps = append(flatGlobalDeps, subDep)
globalDepNames = append(globalDepNames, listItem("[*] "+formatGlobalDep(subDep)))
globalDepsSelection[depIdx] = true
depIdx++
}
}
globalDepsList := blist.New(globalDepNames, itemDelegate{}, defaultWidth, defaultListHeight)
{
globalDepsList.Title = "Packages (global dependencies) - select ones that should be installed."
globalDepsList.SetShowStatusBar(false)
globalDepsList.SetFilteringEnabled(true)
globalDepsList.Styles.PaginationStyle = paginationStyle
globalDepsList.Styles.HelpStyle = helpStyle
globalDepsList.AdditionalFullHelpKeys = additionalFullHelpKeysGeneral
globalDepsList.AdditionalShortHelpKeys = additionalShortHelpKeysGeneral
}
cliArgsSelection := make(map[int]bool)
cliArgsTxt := buildListValuesBasedOnType(*conf)
cliArgsList := blist.New(cliArgsTxt, itemDelegate{}, defaultWidth, defaultListHeight)
{
cliArgsList.Title = "Program flags"
cliArgsList.SetShowStatusBar(false)
cliArgsList.SetFilteringEnabled(true)
cliArgsList.Styles.PaginationStyle = paginationStyle
cliArgsList.Styles.HelpStyle = helpStyle
cliArgsList.AdditionalFullHelpKeys = additionalFullHelpKeysGeneral
cliArgsList.AdditionalShortHelpKeys = additionalShortHelpKeysGeneral
}
choiceSelection := make(map[int]bool)
userChoices := choices{}
choicesTxt := buildListValuesBasedOnType(userChoices)
choicesList := blist.New(choicesTxt, itemDelegate{}, defaultWidth, defaultListHeight)
{
choicesList.Title = "Additional information"
choicesList.SetShowStatusBar(false)
choicesList.SetFilteringEnabled(true)
choicesList.Styles.PaginationStyle = paginationStyle
choicesList.Styles.HelpStyle = helpStyle
choicesList.AdditionalFullHelpKeys = additionalFullHelpKeysLastScreen
choicesList.AdditionalShortHelpKeys = additionalShortHelpKeysLastScreen
}
return model{
lockfile: lockfile,
conf: conf,
configs: allConfigs,
configSelection: selected,
flatGlobalDeps: flatGlobalDeps,
globalDepsSelection: globalDepsSelection,
userChoices: userChoices,
choiceSelection: choiceSelection,
cliArgsSelection: cliArgsSelection,
listHeight: defaultListHeight,
cliArgsList: cliArgsList,
configsList: configsList,
globalDepsList: globalDepsList,
choicesList: choicesList,
}
}
// this function skips all values that are not bool in the passed in `value`
func buildListValuesBasedOnType(value any) []blist.Item {
list := []blist.Item{}
t := reflect.TypeOf(value)
v := reflect.ValueOf(value)
for i := range t.NumField() {
field := t.Field(i)
if field.Type.Kind() != reflect.Bool {
continue
}
tagTxt := field.Tag.Get("txt")
if tagTxt == "exclude" {
continue
}
value := v.Field(i)
prefix := "[ ] "
if value.Bool() {
prefix = "[*] "
}
list = append(list, listItem(prefix+tagTxt))
}
return list
}
func (m model) Init() tea.Cmd {
fmt.Println()
return nil
}
func (m model) View() string {
list := ""
switch m.currentScreen {
case cliArgsScreen:
list = m.cliArgsList.View()
case configsScreen:
list = m.configsList.View()
case globalDepsScreen:
list = m.globalDepsList.View()
case userChoicesScreen:
list = m.choicesList.View()
default:
panic("invalid screen id")
}
listStyle := listStyle.Width(m.termWidth)
windowStyle := lg.NewStyle().Width(m.termWidth)
return windowStyle.Render(lg.JoinVertical(lg.Top, listStyle.Render(list)))
}
const accentColor = "#17d87e"
func (m *model) nextScreen() tea.Cmd {
switch m.currentScreen {
// NOTE: no need for special handling, cli args are saved automatically while updating them
case cliArgsScreen:
case configsScreen:
selectedConfigs := []lib.Config{}
hiddenConfigs := []lib.Config{}
for idx, isSelected := range m.configSelection {
if isSelected {
selectedConfigs = append(selectedConfigs, m.configs[idx])
} else {
hiddenConfigs = append(hiddenConfigs, m.configs[idx])
}
}
m.lockfile.Configs = selectedConfigs
m.lockfile.HiddenConfigs = hiddenConfigs
case globalDepsScreen:
selectedGlobalDeps := []lib.GlobalDependency{}
for idx, isSelected := range m.globalDepsSelection {
if isSelected {
selectedGlobalDeps = append(selectedGlobalDeps, m.flatGlobalDeps[idx])
}
// TODO: hidden configs should also probably be preserved
// else {
// m.hiddenGlobalDeps = append(m.hiddenGlobalDeps, m.flatGlobalDeps[idx])
// }
}
m.lockfile.GlobalDependencies = selectedGlobalDeps
// NOTE: no need for special handling, choices are always saved when we are updating them
case userChoicesScreen:
}
newScreenId := int(m.currentScreen) + 1
if isValidScreen(newScreenId) {
m.currentScreen = screen(newScreenId)
}
return nil
}
func (m *model) prevScreen() tea.Cmd {
newScreenId := int(m.currentScreen) - 1
if isValidScreen(newScreenId) {
m.currentScreen = screen(newScreenId)
} else {
m.currentScreen = screen(0)
}
return nil
}
var shortHelpKeysGeneral = make([]key.Binding, len(helpGeneral))
var longHelpKeysGeneral = make([]key.Binding, len(helpGeneral))
func additionalFullHelpKeysGeneral() []key.Binding {
return longHelpKeysGeneral
}
func additionalShortHelpKeysGeneral() []key.Binding {
return shortHelpKeysGeneral
}
var shortHelpKeysLastScreen = make([]key.Binding, len(helpGeneral)+len(helpLastScreen))
var longHelpKeysLastScreen = make([]key.Binding, len(helpGeneral)+len(helpLastScreen))
func additionalFullHelpKeysLastScreen() []key.Binding {
return longHelpKeysLastScreen
}
func additionalShortHelpKeysLastScreen() []key.Binding {
return shortHelpKeysLastScreen
}
var sizeUpdates = 0
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg.(type) {
case tea.WindowSizeMsg:
sizeUpdates++
windowSize := msg.(tea.WindowSizeMsg)
m.updateSize(windowSize)
if sizeUpdates > 1 {
return m, tea.ClearScreen
} else {
return m, nil
}
case tea.KeyMsg:
switch msg.(tea.KeyMsg).String() {
case "ctrl+c", "q":
// TODO: maybe there is a nicer way to do this with bubbletea (something builtin)
os.Exit(1)
case " ":
return m, m.updateAfterSelectingInList()
case "enter":
if !isValidScreen(int(m.currentScreen) + 1) {
return m, tea.Quit
}
case "tab":
return m, m.nextScreen()
case "shift+tab":
return m, m.prevScreen()
}
}
var cmd tea.Cmd
switch m.currentScreen {
case cliArgsScreen:
m.cliArgsList, cmd = m.cliArgsList.Update(msg)
case configsScreen:
m.configsList, cmd = m.configsList.Update(msg)
case globalDepsScreen:
m.globalDepsList, cmd = m.globalDepsList.Update(msg)
case userChoicesScreen:
m.choicesList, cmd = m.choicesList.Update(msg)
}
return m, cmd
}
func (m *model) updateSize(windowSize tea.WindowSizeMsg) {
m.termWidth = windowSize.Width
{
m.configsList.SetWidth(m.termWidth)
m.configsList.Styles.TitleBar.Width(m.termWidth)
m.configsList.Styles.Title.Width(m.termWidth)
m.configsList.Styles.HelpStyle.Width(m.termWidth).Align(lg.Center)
}
{
m.globalDepsList.SetWidth(m.termWidth)
m.globalDepsList.Styles.TitleBar.Width(m.termWidth)
m.globalDepsList.Styles.Title.Width(m.termWidth)
m.globalDepsList.Styles.HelpStyle.Width(m.termWidth).Align(lg.Center)
}
{
m.choicesList.SetWidth(m.termWidth)
m.choicesList.Styles.TitleBar.Width(m.termWidth)
m.choicesList.Styles.Title.Width(m.termWidth)
m.choicesList.Styles.HelpStyle.Width(m.termWidth).Align(lg.Center)
}
}
func (m *model) updateAfterSelectingInList() tea.Cmd {
switch m.currentScreen {
case cliArgsScreen:
cur := m.cliArgsList.GlobalIndex()
pv := reflect.ValueOf(m.conf)
v := pv.Elem()
// toggle fields value
curValue := v.Field(cur).Bool()
v.Field(cur).SetBool(!curValue)
return m.cliArgsList.SetItems(buildListValuesBasedOnType(*m.conf))
case configsScreen:
cur := m.configsList.GlobalIndex()
m.configSelection[cur] = !m.configSelection[cur]
updatedItems := []blist.Item{}
for idx := range m.configsList.Items() {
if isSelected, ok := m.configSelection[idx]; ok {
cfgAtIdx := m.configs[idx]
if isSelected {
updatedItems = append(updatedItems, listItem("[*] "+cfgAtIdx.Name))
} else {
updatedItems = append(updatedItems, listItem("[ ] "+cfgAtIdx.Name))
}
}
}
return m.configsList.SetItems(updatedItems)
case globalDepsScreen:
cur := m.globalDepsList.GlobalIndex()
m.globalDepsSelection[cur] = !m.globalDepsSelection[cur]
updatedItems := []blist.Item{}
for idx := range m.globalDepsList.Items() {
if isSelected, ok := m.globalDepsSelection[idx]; ok {
dep := m.flatGlobalDeps[idx]
if isSelected {
updatedItems = append(updatedItems, listItem("[*] "+formatGlobalDep(dep)))
} else {
updatedItems = append(updatedItems, listItem("[ ] "+formatGlobalDep(dep)))
}
}
}
return m.globalDepsList.SetItems(updatedItems)
case userChoicesScreen:
cur := m.choicesList.GlobalIndex()
pv := reflect.ValueOf(&m.userChoices)
v := pv.Elem()
// toggle fields value
curValue := v.Field(cur).Bool()
v.Field(cur).SetBool(!curValue)
return m.choicesList.SetItems(buildListValuesBasedOnType(m.userChoices))
default:
panic("we somehow got to an incorrect screen, exiting")
}
}
func formatGlobalDep(dep lib.GlobalDependency) string {
return string(dep.Instruction.Method) + ":" + dep.Instruction.Pkg
}
type helpKey struct {
shortBinding key.Binding
longBinding key.Binding
}
var helpGeneral = []helpKey{
{
shortBinding: key.NewBinding(
key.WithKeys("Space"),
key.WithHelp("Space", "Toggle"),
),
longBinding: key.NewBinding(
key.WithKeys("Space"),
key.WithHelp("Space", "Toggle current option"),
),
},
{
shortBinding: key.NewBinding(
key.WithKeys("Tab"),
key.WithHelp("Tab", "Next"),
),
longBinding: key.NewBinding(
key.WithKeys("Tab"),
key.WithHelp("Tab", "Go to the next page"),
),
},
{
shortBinding: key.NewBinding(
key.WithKeys("Shift+Tab"),
key.WithHelp("Shift+Tab", "Prev"),
),
longBinding: key.NewBinding(
key.WithKeys("Shift+Tab"),
key.WithHelp("Shift+Tab", "Go to the previous page"),
),
},
}
var helpLastScreen = []helpKey{
{
shortBinding: key.NewBinding(
key.WithKeys("Enter"),
key.WithHelp("Enter", "Run"),
),
longBinding: key.NewBinding(
key.WithKeys("Enter"),
key.WithHelp("Enter", "Finish selection and run"),
),
},
}
func tuiMain(c *conf.Configuration) error {
for idx, h := range helpGeneral {
shortHelpKeysGeneral[idx] = h.shortBinding
longHelpKeysGeneral[idx] = h.longBinding
shortHelpKeysLastScreen[idx] = h.shortBinding
longHelpKeysLastScreen[idx] = h.longBinding
}
for idxOffset, h := range helpLastScreen {
idx := idxOffset + len(helpGeneral) - 1
shortHelpKeysLastScreen[idx] = h.shortBinding
longHelpKeysLastScreen[idx] = h.longBinding
}
lockAfter, err := lib.CreateLockBasedOnConfigs(c)
if err != nil {
c.Logger.Info("something went wrong while trying to create a new lockfile based on your config files in your source directory", "err", err)
return err
}
// config/DEPENDENCIES file parsing
globalDependencies, err := lib.ParseGlobalDependencies(c.SourceCfgDir)
if err != nil {
c.Logger.Error("couldn't parse global dependencies file", "path", c.SourceCfgDir, "err", err)
return err
}
lockAfter.GlobalDependencies = globalDependencies
{
m := initModel(lockAfter, c)
p := tea.NewProgram(m)
_m, err := p.Run()
if err != nil {
return err
}
m = _m.(model)
return executeBasedOnUserSelection(m)
}
}
func executeBasedOnUserSelection(m model) error {
c := m.conf
lockBefore, err := lib.ReadOrCreateLockfile(c.LockfilePath)
if err != nil {
c.Logger.Info("encountered an error while trying to read an existing lockfile (probably doesnt exist), creating a new one instead", "err", err)
lockBefore = &lib.EmptyLockfile
}
lockAfter := m.lockfile
if m.userChoices.PersistConfigSelection {
err = lockAfter.PersistConfigSelection()
if err != nil {
return err
}
}
if m.userChoices.PersistGlobalDepsSelection {
err = lockAfter.PersistGlobalDepsSelection(c.SourceCfgDir)
if err != nil {
return err
}
}
lib.CopyInstallInfo(lockBefore, lockAfter)
globalDepsChanged := lib.DidGlobalDependenciesChange(&lockBefore.GlobalDependencies, &lockAfter.GlobalDependencies)
globalDepsInstalled := lib.WereGlobalDependenciesInstalled(&lockAfter.GlobalDependencies)
if c.Install || c.OnlyInstall || c.Upgrade {
if globalDepsChanged || !globalDepsInstalled || c.Upgrade {
err = lib.InstallGlobalDependencies(&lockAfter.GlobalDependencies)
if err != nil {
lib.Logger.Error("something went wrong while trying to install global dependencies", "err", err)
return err
}
} else {
lib.Logger.Info("global dependencies didn't change since last installation, not installing", "depsChanged", globalDepsChanged, "previouslyInstalled", globalDepsInstalled)
}
}
if !c.OnlyUninstall && !c.OnlyInstall {
toSymlink := lockAfter.Configs
if c.CopyMode {
err = lib.Copy(c, toSymlink)
} else {
err = lib.Symlink(c, toSymlink)
}
if err != nil {
c.Logger.Error("encountered an error while copying/symlinking", "error", err)
return err
}
toRemove := lockAfter.HiddenConfigs
err = lib.Remove(c, toRemove)
} else {
lib.Logger.Info("skipping copying/symlinking the config, because --only-install or --only-uninstall was passed")
}
if (c.Install || c.OnlyInstall || c.Upgrade) && !c.OnlyUninstall {
infoForUpdate := lib.Install(lockAfter)
lockAfter.UpdateInstallInfo(infoForUpdate)
}
if (c.Uninstall || c.OnlyUninstall) && !c.OnlyInstall {
infoForUpdate := lib.Uninstall(lockAfter)
lockAfter.UpdateInstallInfo(infoForUpdate)
}
err = lockAfter.Save(c.LockfilePath, c.DefaultIndent)
if err != nil {
lib.Logger.Error("something went wrong while trying to save the lockfile", "err", err)
}
diff := lib.DiffLocks(*lockBefore, *lockAfter)
err = diff.Save(c.LockfileDiffPath, c.DefaultIndent)
if err != nil {
lib.Logger.Error("something went wrong while trying to save the lockfile diff", "err", err)
}
return nil
}