Skip to content

Commit 37476f1

Browse files
committed
Another round of renames without code change
1 parent 57deac1 commit 37476f1

File tree

10 files changed

+83
-84
lines changed

10 files changed

+83
-84
lines changed

commands/core/args.go

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
"github.com/bcmi-labs/arduino-cli/cores"
4040
)
4141

42-
// downloadItem represents a core or tool download
42+
// downloadItem represents a platform or a tool to download
4343
// TODO: can be greatly simplified by usign directly a pointer to the Platform or Tool
4444
type downloadItem struct {
4545
Package string
@@ -48,14 +48,14 @@ type downloadItem struct {
4848

4949
// platformReference represents a tuple to identify a Platform
5050
type platformReference struct {
51-
Package string // The package where this core belongs to.
52-
CoreName string // The core name.
53-
CoreVersion string // The version of the core, to get the release.
51+
Package string // The package where this Platform belongs to.
52+
PlatformArchitecture string
53+
PlatformVersion string
5454
}
5555

5656
var coreTupleRegexp = regexp.MustCompile("[a-zA-Z0-9]+:[a-zA-Z0-9]+(=([0-9]|[0-9].)*[0-9]+)?")
5757

58-
// parsePlatformReferenceArgs parses a sequence of "packager:name=version" tokens and returns a CoreIDTuple slice.
58+
// parsePlatformReferenceArgs parses a sequence of "packager:arch=version" tokens and returns a platformReference slice.
5959
//
6060
// If version is not present it is assumed as "latest" version.
6161
func parsePlatformReferenceArgs(args []string) []platformReference {
@@ -71,25 +71,26 @@ func parsePlatformReferenceArgs(args []string) []platformReference {
7171
split = append(split, "latest")
7272
}
7373
ret = append(ret, platformReference{
74-
Package: split[0],
75-
CoreName: split[1],
76-
CoreVersion: split[2],
74+
Package: split[0],
75+
PlatformArchitecture: split[1],
76+
PlatformVersion: split[2],
7777
})
7878
} else {
79+
// TODO: handle errors properly
7980
ret = append(ret, platformReference{
80-
Package: "invalid-arg",
81-
CoreName: arg,
81+
Package: "invalid-arg",
82+
PlatformArchitecture: arg,
8283
})
8384
}
8485
}
8586
return ret
8687
}
8788

88-
// findDownloadItems takes a set of platformReference and returns a set of items to download and
89+
// findItemsToDownload takes a set of platformReference and returns a set of items to download and
8990
// a set of outputs for non existing platforms.
90-
func findDownloadItems(sc *cores.StatusContext, items []platformReference) ([]*cores.PlatformRelease, []*cores.ToolRelease, []output.ProcessResult) {
91+
func findItemsToDownload(sc *cores.PackagesStatus, items []platformReference) ([]*cores.PlatformRelease, []*cores.ToolRelease, []output.ProcessResult) {
9192
itemC := len(items)
92-
retCores := []*cores.PlatformRelease{}
93+
retPlatforms := []*cores.PlatformRelease{}
9394
retTools := []*cores.ToolRelease{}
9495
fails := make([]output.ProcessResult, 0, itemC)
9596

@@ -100,38 +101,38 @@ func findDownloadItems(sc *cores.StatusContext, items []platformReference) ([]*c
100101
for _, item := range items {
101102
if item.Package == "invalid-arg" {
102103
fails = append(fails, output.ProcessResult{
103-
ItemName: item.CoreName,
104-
Error: "Invalid item (not PACKAGER:CORE[=VERSION])",
104+
ItemName: item.PlatformArchitecture,
105+
Error: "Invalid item (not PACKAGER:ARCH[=VERSION])",
105106
})
106107
continue
107108
}
108109
pkg, exists := sc.Packages[item.Package]
109110
if !exists {
110111
fails = append(fails, output.ProcessResult{
111-
ItemName: item.CoreName,
112+
ItemName: item.PlatformArchitecture,
112113
Error: fmt.Sprintf("Package %s not found", item.Package),
113114
})
114115
continue
115116
}
116-
core, exists := pkg.Plaftorms[item.CoreName]
117+
platform, exists := pkg.Plaftorms[item.PlatformArchitecture]
117118
if !exists {
118119
fails = append(fails, output.ProcessResult{
119-
ItemName: item.CoreName,
120-
Error: "Core not found",
120+
ItemName: item.PlatformArchitecture,
121+
Error: "Platform not found",
121122
})
122123
continue
123124
}
124125

125-
_, exists = presenceMap[item.CoreName]
126+
_, exists = presenceMap[item.PlatformArchitecture]
126127
if exists { //skip
127128
continue
128129
}
129130

130-
release := core.GetVersion(item.CoreVersion)
131+
release := platform.GetVersion(item.PlatformVersion)
131132
if release == nil {
132133
fails = append(fails, output.ProcessResult{
133-
ItemName: item.CoreName,
134-
Error: fmt.Sprintf("Version %s Not Found", item.CoreVersion),
134+
ItemName: item.PlatformArchitecture,
135+
Error: fmt.Sprintf("Version %s Not Found", item.PlatformVersion),
135136
})
136137
continue
137138
}
@@ -140,15 +141,15 @@ func findDownloadItems(sc *cores.StatusContext, items []platformReference) ([]*c
140141
toolDeps, err := sc.GetDepsOfPlatformRelease(release)
141142
if err != nil {
142143
fails = append(fails, output.ProcessResult{
143-
ItemName: item.CoreName,
144-
Error: fmt.Sprintf("Cannot get tool dependencies of %s core: %s", core.Name, err.Error()),
144+
ItemName: item.PlatformArchitecture,
145+
Error: fmt.Sprintf("Cannot get tool dependencies of plafotmr %s: %s", platform.Name, err.Error()),
145146
})
146147
continue
147148
}
148149

149-
retCores = append(retCores, release)
150+
retPlatforms = append(retPlatforms, release)
150151

151-
presenceMap[core.Name] = true
152+
presenceMap[platform.Name] = true
152153
for _, tool := range toolDeps {
153154
if presenceMap[tool.Tool.Name] {
154155
continue
@@ -157,5 +158,5 @@ func findDownloadItems(sc *cores.StatusContext, items []platformReference) ([]*c
157158
retTools = append(retTools, tool)
158159
}
159160
}
160-
return retCores, retTools, fails
161+
return retPlatforms, retTools, fails
161162
}

commands/core/core.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func getInstalledStuff(stuff *[]output.InstalledStuff, folder pathutils.Path) {
107107
}
108108
}
109109

110-
func getPackagesStatusContext() (*cores.StatusContext, error) {
110+
func getPackagesStatusContext() (*cores.PackagesStatus, error) {
111111
var index packageindex.Index
112112
err := packageindex.LoadIndex(&index)
113113
if err != nil {

commands/core/download.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func runDownloadCommand(cmd *cobra.Command, args []string) {
6969

7070
logrus.Info("Preparing download")
7171

72-
coresToDownload, toolsToDownload, failOutputs := findDownloadItems(status, parsePlatformReferenceArgs(args))
72+
coresToDownload, toolsToDownload, failOutputs := findItemsToDownload(status, parsePlatformReferenceArgs(args))
7373
outputResults := output.CoreProcessResults{
7474
Cores: failOutputs,
7575
Tools: []output.ProcessResult{},
@@ -103,7 +103,7 @@ func downloadPlatformArchives(platforms []*cores.PlatformRelease, results *outpu
103103
downloads := []releases.DownloadItem{}
104104
for _, platform := range platforms {
105105
downloads = append(downloads, releases.DownloadItem{
106-
Name: platform.Platform.ParentPackage.Name + ":" + platform.Platform.Name + "@" + platform.Version,
106+
Name: platform.Platform.Package.Name + ":" + platform.Platform.Name + "@" + platform.Version,
107107
Resource: platform.Resource,
108108
})
109109
}

commands/core/install.go

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

7070
logrus.Info("Preparing download")
7171

72-
coresToDownload, toolsToDownload, failOutputs := findDownloadItems(status, parsePlatformReferenceArgs(args))
72+
coresToDownload, toolsToDownload, failOutputs := findItemsToDownload(status, parsePlatformReferenceArgs(args))
7373
failOutputsCount := len(failOutputs)
7474
outputResults := output.CoreProcessResults{
7575
Cores: failOutputs,
@@ -82,12 +82,12 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
8282

8383
logrus.Info("Installing tool dependencies")
8484
for i, item := range toolsToDownload {
85-
logrus.WithField("Package", item.Tool.ParentPackage.Name).
85+
logrus.WithField("Package", item.Tool.Package.Name).
8686
WithField("Name", item.Tool.Name).
8787
WithField("Version", item.Version).
8888
Info("Installing tool")
8989

90-
toolRoot, err := configs.ToolsFolder(item.Tool.ParentPackage.Name).Get()
90+
toolRoot, err := configs.ToolsFolder(item.Tool.Package.Name).Get()
9191
if err != nil {
9292
formatter.PrintError(err, "Cannot get tool install path, try again.")
9393
os.Exit(commands.ErrCoreConfig)
@@ -122,12 +122,12 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
122122
}
123123

124124
for i, item := range coresToDownload {
125-
logrus.WithField("Package", item.Platform.ParentPackage.Name).
125+
logrus.WithField("Package", item.Platform.Package.Name).
126126
WithField("Name", item.Platform.Name).
127127
WithField("Version", item.Version).
128128
Info("Installing core")
129129

130-
coreRoot, err := configs.CoresFolder(item.Platform.ParentPackage.Name).Get()
130+
coreRoot, err := configs.CoresFolder(item.Platform.Package.Name).Get()
131131
if err != nil {
132132
formatter.PrintError(err, "Cannot get core install path, try again.")
133133
os.Exit(commands.ErrCoreConfig)

common/formatter/pretty_print/pretty_print_core.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ func DownloadCoreFileIndex() task.Wrapper {
4141
}
4242

4343
// CorruptedCoreIndexFix pretty prints messages regarding corrupted index fixes of cores.
44-
func CorruptedCoreIndexFix(index packageindex.Index) (cores.StatusContext, error) {
44+
func CorruptedCoreIndexFix(index packageindex.Index) (cores.PackagesStatus, error) {
4545
downloadTask := DownloadCoreFileIndex()
4646
parseTask := coreIndexParse(index)
4747

4848
result := corruptedIndexFixResults(downloadTask, parseTask)
4949

50-
return result[1].Result.(cores.StatusContext), result[1].Error
50+
return result[1].Result.(cores.PackagesStatus), result[1].Error
5151
}
5252

5353
// coreIndexParse pretty prints info about parsing an index file of libraries.

cores/cores.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ import (
4040

4141
// Platform represents a platform package.
4242
type Platform struct {
43-
Name string // The name of the Core Package.
44-
Architecture string // The name of the architecture of this package.
45-
Category string // The category which this core package belongs to.
46-
Releases map[string]*PlatformRelease // The Releases of this core package, labeled by version.
47-
ParentPackage *Package `json:"-"`
43+
Architecture string // The name of the architecture of this package.
44+
Name string
45+
Category string
46+
Releases map[string]*PlatformRelease // The Releases of this platform, labeled by version.
47+
Package *Package `json:"-"`
4848
}
4949

50-
// PlatformRelease represents a release of a core package.
50+
// PlatformRelease represents a release of a plaform package.
5151
type PlatformRelease struct {
5252
Resource *releases.DownloadResource
5353
Version string
@@ -56,10 +56,10 @@ type PlatformRelease struct {
5656
Platform *Platform `json:"-"`
5757
}
5858

59-
// ToolDependencies is a set of tuples representing summary data of a tool dependency set.
59+
// ToolDependencies is a set of tool dependency
6060
type ToolDependencies []*ToolDependency
6161

62-
// ToolDependency is a tuple representing summary data of a tool.
62+
// ToolDependency is a tuple that uniquely identifies a specific version of a Tool
6363
type ToolDependency struct {
6464
ToolName string
6565
ToolVersion string
@@ -75,7 +75,7 @@ func (platform *Platform) GetVersion(version string) *PlatformRelease {
7575
return platform.Releases[version]
7676
}
7777

78-
// Versions returns all the version numbers in this Core Package.
78+
// Versions returns all the version numbers in this Platform Package.
7979
func (platform *Platform) Versions() semver.Versions {
8080
versions := make(semver.Versions, 0, len(platform.Releases))
8181
for _, release := range platform.Releases {
@@ -89,7 +89,6 @@ func (platform *Platform) Versions() semver.Versions {
8989
}
9090

9191
// latestVersion obtains latest version number.
92-
//
9392
// It uses lexicographics to compare version strings.
9493
func (platform *Platform) latestVersion() string {
9594
versions := platform.Versions()

cores/install_uninstall.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ import (
4747
// respects umask on linux.
4848
var DirPermissions os.FileMode = 0777
4949

50-
// Install installs a specific release of a core.
50+
// InstallPlatform installs a specific release of a platform.
5151
// TODO: But why not passing the Platform?
52-
func InstallPlatform(destCoresDir string, release *releases.DownloadResource) error {
52+
func InstallPlatform(destDir string, release *releases.DownloadResource) error {
5353
if release == nil {
54-
return errors.New("Not existing version of the core")
54+
return errors.New("Not existing version of the platform")
5555
}
5656

5757
cacheFilePath, err := releases.ArchivePath(release)
@@ -65,26 +65,26 @@ func InstallPlatform(destCoresDir string, release *releases.DownloadResource) er
6565
return err
6666
}
6767
tempFolder := filepath.Join(arduinoFolder, "tmp", "packages",
68-
fmt.Sprintf("core-%d", time.Now().Unix()))
68+
fmt.Sprintf("platform-%d", time.Now().Unix()))
6969
err = os.MkdirAll(tempFolder, DirPermissions)
7070
if err != nil {
7171
return err
7272
}
7373
defer os.RemoveAll(tempFolder)
7474

7575
// Make container dir
76-
destCoresDirParent := filepath.Dir(destCoresDir)
77-
err = os.MkdirAll(destCoresDirParent, DirPermissions)
76+
destDirParent := filepath.Dir(destDir)
77+
err = os.MkdirAll(destDirParent, DirPermissions)
7878
if err != nil {
7979
return err
8080
}
8181
defer func() {
8282
// cleaning empty directories
83-
if empty, _ := IsDirEmpty(destCoresDir); empty {
84-
os.RemoveAll(destCoresDir)
83+
if empty, _ := IsDirEmpty(destDir); empty {
84+
os.RemoveAll(destDir)
8585
}
86-
if empty, _ := IsDirEmpty(destCoresDirParent); empty {
87-
os.RemoveAll(destCoresDirParent)
86+
if empty, _ := IsDirEmpty(destDirParent); empty {
87+
os.RemoveAll(destDirParent)
8888
}
8989
}()
9090

@@ -99,17 +99,17 @@ func InstallPlatform(destCoresDir string, release *releases.DownloadResource) er
9999
return err
100100
}
101101

102-
root := coreRealRoot(tempFolder)
102+
root := platformRealRoot(tempFolder)
103103
if root == "invalid" {
104104
return errors.New("invalid archive structure")
105105
}
106106

107-
err = os.Rename(root, destCoresDir)
107+
err = os.Rename(root, destDir)
108108
if err != nil {
109109
return err
110110
}
111111

112-
err = createPackageFile(destCoresDir)
112+
err = createPackageFile(destDir)
113113
if err != nil {
114114
return err
115115
}
@@ -207,7 +207,7 @@ func IsDirEmpty(path string) (bool, error) {
207207
return false, err
208208
}
209209

210-
func coreRealRoot(root string) string {
210+
func platformRealRoot(root string) string {
211211
realRoot := "invalid"
212212
filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
213213
if strings.HasSuffix(path, "platform.txt") {

cores/packageindex/index.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ type indexHelp struct {
110110
}
111111

112112
// CreateStatusContext creates a status context from index data.
113-
func (index Index) CreateStatusContext() cores.StatusContext {
114-
res := cores.StatusContext{
113+
func (index Index) CreateStatusContext() cores.PackagesStatus {
114+
res := cores.PackagesStatus{
115115
Packages: map[string]*cores.Package{},
116116
}
117117
for _, p := range index.Packages {
@@ -135,7 +135,7 @@ func (pack indexPackage) extractPackage() *cores.Package {
135135
name := tool.Name
136136
if p.Tools[name] == nil {
137137
p.Tools[name] = tool.extractTool()
138-
p.Tools[name].ParentPackage = p
138+
p.Tools[name].Package = p
139139
}
140140
p.Tools[name].Releases[tool.Version] = tool.extractToolRelease()
141141
p.Tools[name].Releases[tool.Version].Tool = p.Tools[name]
@@ -145,7 +145,7 @@ func (pack indexPackage) extractPackage() *cores.Package {
145145
name := platform.Architecture
146146
if p.Plaftorms[name] == nil {
147147
p.Plaftorms[name] = platform.extractPlatform()
148-
p.Plaftorms[name].ParentPackage = p
148+
p.Plaftorms[name].Package = p
149149
}
150150
release := platform.extractPlatformRelease()
151151
release.Platform = p.Plaftorms[name]

0 commit comments

Comments
 (0)