|
2 | 2 | package depsync |
3 | 3 |
|
4 | 4 | import ( |
5 | | - "fmt" |
6 | | - "path/filepath" |
7 | | - |
| 5 | + "github.com/indaco/sley/internal/operations" |
8 | 6 | "github.com/indaco/sley/internal/plugins" |
9 | | - "github.com/indaco/sley/internal/plugins/dependencycheck" |
10 | | - "github.com/indaco/sley/internal/printer" |
11 | 7 | "github.com/indaco/sley/internal/semver" |
12 | 8 | ) |
13 | 9 |
|
14 | | -// SyncDependencies updates all configured dependency files to match the new version. |
15 | | -// Returns nil if dependency checker is not enabled or auto-sync is disabled. |
16 | | -// The bumpedPaths parameter contains paths that were already bumped as modules |
17 | | -// and should be excluded from the output (they're still synced but not displayed twice). |
| 10 | +// SyncDependencies delegates to operations.SyncDependencies. |
| 11 | +// Kept for backward compatibility with existing callers outside the bump command. |
18 | 12 | func SyncDependencies(registry *plugins.PluginRegistry, version semver.SemVersion, bumpedPaths ...string) error { |
19 | | - dc := registry.GetDependencyChecker() |
20 | | - if dc == nil { |
21 | | - return nil |
22 | | - } |
23 | | - |
24 | | - if !dc.IsEnabled() || !dc.GetConfig().AutoSync { |
25 | | - return nil |
26 | | - } |
27 | | - |
28 | | - files := dc.GetConfig().Files |
29 | | - if len(files) == 0 { |
30 | | - return nil |
31 | | - } |
32 | | - |
33 | | - if err := dc.SyncVersions(version.String()); err != nil { |
34 | | - return fmt.Errorf("failed to sync dependency versions: %w", err) |
35 | | - } |
36 | | - |
37 | | - // Build set of bumped paths for quick lookup |
38 | | - bumpedSet := make(map[string]bool, len(bumpedPaths)) |
39 | | - for _, p := range bumpedPaths { |
40 | | - bumpedSet[p] = true |
41 | | - } |
42 | | - |
43 | | - // Filter files to only show ones not already bumped as modules |
44 | | - var additionalFiles []dependencycheck.FileConfig |
45 | | - for _, file := range files { |
46 | | - if !bumpedSet[file.Path] { |
47 | | - additionalFiles = append(additionalFiles, file) |
48 | | - } |
49 | | - } |
50 | | - |
51 | | - // Only print section if there are additional files to show |
52 | | - if len(additionalFiles) > 0 { |
53 | | - fmt.Println("Sync dependencies") |
54 | | - for _, file := range additionalFiles { |
55 | | - name := deriveDependencyName(file.Path) |
56 | | - fmt.Printf(" %s %s %s%s\n", printer.SuccessBadge("✓"), name, printer.Faint("("+file.Path+")"), printer.Faint(": "+version.String())) |
57 | | - } |
58 | | - } |
59 | | - |
60 | | - return nil |
61 | | -} |
62 | | - |
63 | | -// deriveDependencyName extracts a display name from a file path. |
64 | | -// For .version files, uses the parent directory name. |
65 | | -// For other files (package.json, etc.), uses the filename. |
66 | | -func deriveDependencyName(path string) string { |
67 | | - base := filepath.Base(path) |
68 | | - if base == ".version" { |
69 | | - dir := filepath.Dir(path) |
70 | | - return filepath.Base(dir) |
71 | | - } |
72 | | - return base |
| 13 | + return operations.SyncDependencies(registry, version, bumpedPaths...) |
73 | 14 | } |
0 commit comments