Skip to content

Commit 10b70eb

Browse files
committed
[WIP] Here's the new PackageManager
1 parent 0088cd3 commit 10b70eb

File tree

14 files changed

+191
-10
lines changed

14 files changed

+191
-10
lines changed

commands/board/attach.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func runAttachCommand(cmd *cobra.Command, args []string) {
8484

8585
time.Sleep(duration)
8686

87+
// FIXME: Replace with the PackageManager
8788
homeFolder, err := configs.ArduinoHomeFolder.Get()
8889
if err != nil {
8990
formatter.PrintError(err, "Cannot Parse Board Index file.")
@@ -145,6 +146,7 @@ func runAttachCommand(cmd *cobra.Command, args []string) {
145146
formatter.PrintResult("BOARD ATTACHED.")
146147
}
147148

149+
// FIXME: Those should probably go in a "BoardManager" pkg or something
148150
// findSerialConnectedBoard find the board which is connected to the specified URI via serial port, using a monitor and a set of Boards
149151
// for the matching.
150152
func findSerialConnectedBoard(bs boards.Boards, monitor *discovery.Monitor, deviceURI *url.URL) *boards.Board {

commands/board/list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var listCommand = &cobra.Command{
3939
// runListCommand detects and lists the connected arduino boards
4040
// (either via serial or network ports).
4141
func runListCommand(cmd *cobra.Command, args []string) {
42+
// FIXME: Replace with the PackageManager
4243
packageFolder, err := configs.PackagesFolder.Get()
4344
if err != nil {
4445
formatter.PrintError(err, "Cannot Parse Board Index file.")

commands/compile/compile.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ func run(cmd *cobra.Command, args []string) {
117117
}
118118
}
119119

120+
// FIXME: Replace with the PackageManager
120121
isCtagsInstalled, err := cores.IsToolInstalled(packageName, "ctags")
121122
if err != nil {
122123
formatter.PrintError(err, "Cannot check ctags installation.")
@@ -195,6 +196,7 @@ func run(cmd *cobra.Command, args []string) {
195196
formatter.PrintError(err, "Cannot get the core version.")
196197
os.Exit(commands.ErrBadCall)
197198
}
199+
// FIXME: this is building the CommandLine to run the builder; we should move it to a "cores.compute" pkg
198200
// Add dependency tools paths to build properties with versions corresponding to specific core version.
199201
var packageIndex packageindex.Index
200202
packageindex.LoadIndex(&packageIndex)

commands/config/init.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func runInitCommand(cmd *cobra.Command, args []string) {
8585
logrus.Info("Done")
8686
}
8787

88+
// FIXME: is this any useful?
8889
// ConfigsFromQuestions asks some questions to the user to properly initialize configs.
8990
// It does not have much sense to use it in JSON formatting, though.
9091
func configsFromQuestions() {

commands/core/args.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func parsePlatformReferenceArgs(args []string) []platformReference {
7878
return ret
7979
}
8080

81+
// FIXME: Replace move to the PackageManager
8182
// findItemsToDownload takes a set of platformReference and returns a set of items to download and
8283
// a set of outputs for non existing platforms.
8384
func findItemsToDownload(sc *cores.Packages, items []platformReference) ([]*cores.PlatformRelease, []*cores.ToolRelease, []output.ProcessResult) {

commands/core/core.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ var command = &cobra.Command{
5555
Example: "arduino core update-index # to update the package index file.",
5656
}
5757

58+
// FIXME: Move to the PackageManager
59+
5860
// getInstalledCores gets the installed cores and puts them in the output struct.
5961
func getInstalledCores(packageName string, cores *[]output.InstalledStuff) {
6062
getInstalledStuff(cores, configs.CoresFolder(packageName))
@@ -118,6 +120,5 @@ func getPackagesStatusContext() (*cores.Packages, error) {
118120
return &status, nil
119121
}
120122

121-
status := index.CreateStatusContext()
122-
return &status, nil
123+
return index.CreateStatusContext(), nil
123124
}

commands/core/download.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"github.com/bcmi-labs/arduino-cli/cores"
4141
"github.com/sirupsen/logrus"
4242
"github.com/spf13/cobra"
43+
"github.com/bcmi-labs/arduino-cli/cores/packagemanager"
4344
)
4445

4546
func init() {
@@ -75,6 +76,22 @@ func runDownloadCommand(cmd *cobra.Command, args []string) {
7576
Tools: []output.ProcessResult{},
7677
}
7778

79+
// FIXME: that's just a PoC; please have mercy...
80+
fmt.Printf("TESTING THE FLUENT PKGMGR\n")
81+
82+
_, err = packagemanager.PackageManager().AddDefaultPackageIndex()
83+
fmt.Printf("Loading default package index, error: %v\n", err)
84+
85+
tool, err := packagemanager.PackageManager().Package("not-found").Tool("avrdude").IsInstalled()
86+
fmt.Printf("Tool status: %s, %v\n", tool, err)
87+
88+
tool, err = packagemanager.PackageManager().Package("arduino").Tool("not-found").IsInstalled()
89+
fmt.Printf("Tool status: %s, %v\n", tool, err)
90+
91+
tool, err = packagemanager.PackageManager().Package("arduino").Tool("avrdude").IsInstalled()
92+
fmt.Printf("Tool status: %s, %v\n", tool, err)
93+
94+
7895
downloadToolsArchives(toolsToDownload, &outputResults)
7996

8097
downloadPlatformArchives(coresToDownload, &outputResults)
@@ -83,6 +100,9 @@ func runDownloadCommand(cmd *cobra.Command, args []string) {
83100
logrus.Info("Done")
84101
}
85102

103+
// FIXME: Move to the PackageManager and look for a way to uncouple of the printing logic
104+
// All this stuff is pkgmgr responsibility for sure
105+
86106
func downloadToolsArchives(tools []*cores.ToolRelease, results *output.CoreProcessResults) {
87107
downloads := map[string]*releases.DownloadResource{}
88108
for _, tool := range tools {

commands/core/install.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
6969

7070
logrus.Info("Preparing download")
7171

72+
// FIXME: Isn't this the same code as in core/download.go? Should be refactored
7273
coresToDownload, toolsToDownload, failOutputs := findItemsToDownload(status, parsePlatformReferenceArgs(args))
7374
failOutputsCount := len(failOutputs)
7475
outputResults := output.CoreProcessResults{

commands/core/list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func runListCommand(cmd *cobra.Command, args []string) {
7575
os.Exit(commands.ErrCoreConfig)
7676
}
7777

78+
// FIXME: Use the PackageManager instead
7879
pkgs := output.InstalledPackageList{
7980
InstalledPackages: make([]output.InstalledPackage, 0, 10),
8081
}

common/formatter/pretty_print/pretty_print_core.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ import (
3434
"github.com/bcmi-labs/arduino-cli/cores"
3535
"github.com/bcmi-labs/arduino-cli/cores/packageindex"
3636
"github.com/bcmi-labs/arduino-cli/task"
37+
"github.com/bcmi-labs/arduino-cli/cores/packagemanager"
3738
)
3839

3940
// DownloadCoreFileIndex shows info regarding the download of a missing (or corrupted) file index of core packages.
4041
func DownloadCoreFileIndex() task.Task {
41-
return DownloadFileIndex(packageindex.DownloadPackagesFile)
42+
return DownloadFileIndex(packagemanager.PackageManager().DownloadPackagesFile)
4243
}
4344

4445
// CorruptedCoreIndexFix pretty prints messages regarding corrupted index fixes of cores.

0 commit comments

Comments
 (0)