Skip to content

Commit f11f161

Browse files
author
Massimiliano Pippi
authored
Remove Sketchbook concept, introduce User data folder (#516)
* rename Sketchbook folder to User * missing join on path
1 parent 23e2a9d commit f11f161

File tree

25 files changed

+103
-122
lines changed

25 files changed

+103
-122
lines changed

Diff for: arduino/cores/packagemanager/package_manager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ func (pm *PackageManager) FindToolsRequiredForBoard(board *cores.Board) ([]*core
402402
foundTools := map[string]*cores.ToolRelease{}
403403

404404
// a Platform may not specify required tools (because it's a platform that comes from a
405-
// sketchbook/hardware dir without a package_index.json) then add all available tools
405+
// user/hardware dir without a package_index.json) then add all available tools
406406
for _, targetPackage := range pm.Packages {
407407
for _, tool := range targetPackage.Tools {
408408
rel := tool.GetLatestInstalled()

Diff for: arduino/cores/packagemanager/package_manager_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ func TestFindToolsRequiredForBoard(t *testing.T) {
219219
fmt.Println(viper.AllSettings())
220220
pm := packagemanager.NewPackageManager(
221221
dataDir1,
222-
paths.New(viper.GetString("directories.Packages")),
222+
configuration.PackagesDir(),
223223
paths.New(viper.GetString("directories.Downloads")),
224224
dataDir1,
225225
)

Diff for: arduino/libraries/libraries.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func (library *Library) PriorityForArchitecture(arch string) uint8 {
141141
return bonus + 0x01
142142
case PlatformBuiltIn:
143143
return bonus + 0x02
144-
case Sketchbook:
144+
case User:
145145
return bonus + 0x03
146146
}
147147
panic(fmt.Sprintf("Invalid library location: %d", library.Location))

Diff for: arduino/libraries/libraries_location.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ const (
3333
PlatformBuiltIn
3434
// ReferencedPlatformBuiltIn are libraries bundled in a PlatformRelease referenced for build
3535
ReferencedPlatformBuiltIn
36-
// Sketchbook are user installed libraries
37-
Sketchbook
36+
// User are user installed libraries
37+
User
3838
)
3939

4040
func (d *LibraryLocation) String() string {
@@ -45,8 +45,8 @@ func (d *LibraryLocation) String() string {
4545
return "platform"
4646
case ReferencedPlatformBuiltIn:
4747
return "ref-platform"
48-
case Sketchbook:
49-
return "sketchbook"
48+
case User:
49+
return "user"
5050
}
5151
panic(fmt.Sprintf("invalid LibraryLocation value %d", *d))
5252
}
@@ -60,8 +60,8 @@ func (d *LibraryLocation) MarshalJSON() ([]byte, error) {
6060
return json.Marshal("platform")
6161
case ReferencedPlatformBuiltIn:
6262
return json.Marshal("ref-platform")
63-
case Sketchbook:
64-
return json.Marshal("sketchbook")
63+
case User:
64+
return json.Marshal("user")
6565
}
6666
return nil, fmt.Errorf("invalid library location value: %d", *d)
6767
}
@@ -79,8 +79,8 @@ func (d *LibraryLocation) UnmarshalJSON(b []byte) error {
7979
*d = PlatformBuiltIn
8080
case "ref-platform":
8181
*d = ReferencedPlatformBuiltIn
82-
case "sketchbook":
83-
*d = Sketchbook
82+
case "user":
83+
*d = User
8484
}
8585
return fmt.Errorf("invalid library location: %s", s)
8686
}

Diff for: arduino/libraries/librariesmanager/install.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (lm *LibrariesManager) InstallPrerequisiteCheck(indexLibrary *librariesinde
4242
var replaced *libraries.Library
4343
if installedLibs, have := lm.Libraries[saneName]; have {
4444
for _, installedLib := range installedLibs.Alternatives {
45-
if installedLib.Location != libraries.Sketchbook {
45+
if installedLib.Location != libraries.User {
4646
continue
4747
}
4848
if installedLib.Version.Equal(indexLibrary.Version) {
@@ -52,9 +52,9 @@ func (lm *LibrariesManager) InstallPrerequisiteCheck(indexLibrary *librariesinde
5252
}
5353
}
5454

55-
libsDir := lm.getSketchbookLibrariesDir()
55+
libsDir := lm.getUserLibrariesDir()
5656
if libsDir == nil {
57-
return nil, nil, fmt.Errorf("sketchbook directory not set")
57+
return nil, nil, fmt.Errorf("User directory not set")
5858
}
5959

6060
libPath := libsDir.Join(saneName)
@@ -68,9 +68,9 @@ func (lm *LibrariesManager) InstallPrerequisiteCheck(indexLibrary *librariesinde
6868

6969
// Install installs a library on the specified path.
7070
func (lm *LibrariesManager) Install(indexLibrary *librariesindex.Release, libPath *paths.Path) error {
71-
libsDir := lm.getSketchbookLibrariesDir()
71+
libsDir := lm.getUserLibrariesDir()
7272
if libsDir == nil {
73-
return fmt.Errorf("sketchbook directory not set")
73+
return fmt.Errorf("User directory not set")
7474
}
7575
return indexLibrary.Resource.Install(lm.DownloadsDir, libsDir, libPath)
7676
}

Diff for: arduino/libraries/librariesmanager/librariesmanager.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ func (sc *LibrariesManager) RescanLibraries() error {
168168
return nil
169169
}
170170

171-
func (sc *LibrariesManager) getSketchbookLibrariesDir() *paths.Path {
171+
func (sc *LibrariesManager) getUserLibrariesDir() *paths.Path {
172172
for _, dir := range sc.LibrariesDir {
173-
if dir.Location == libraries.Sketchbook {
173+
if dir.Location == libraries.User {
174174
return dir.Path
175175
}
176176
}
@@ -208,17 +208,17 @@ func (sc *LibrariesManager) LoadLibrariesFromDir(librariesDir *LibrariesDir) err
208208

209209
// FindByReference return the installed library matching the Reference
210210
// name and version or, if the version is nil, the library installed
211-
// in the sketchbook.
211+
// in the User folder.
212212
func (sc *LibrariesManager) FindByReference(libRef *librariesindex.Reference) *libraries.Library {
213213
saneName := utils.SanitizeName(libRef.Name)
214214
alternatives, have := sc.Libraries[saneName]
215215
if !have {
216216
return nil
217217
}
218-
// TODO: Move "search into sketchbook" into another method...
218+
// TODO: Move "search into user" into another method...
219219
if libRef.Version == nil {
220220
for _, candidate := range alternatives.Alternatives {
221-
if candidate.Location == libraries.Sketchbook {
221+
if candidate.Location == libraries.User {
222222
return candidate
223223
}
224224
}

Diff for: arduino/libraries/librariesresolver/cpp_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ import (
2424
"github.com/stretchr/testify/require"
2525
)
2626

27-
var l1 = &libraries.Library{Name: "Calculus Lib", Location: libraries.Sketchbook}
28-
var l2 = &libraries.Library{Name: "Calculus Lib-master", Location: libraries.Sketchbook}
29-
var l3 = &libraries.Library{Name: "Calculus Lib Improved", Location: libraries.Sketchbook}
30-
var l4 = &libraries.Library{Name: "Another Calculus Lib", Location: libraries.Sketchbook}
31-
var l5 = &libraries.Library{Name: "Yet Another Calculus Lib Improved", Location: libraries.Sketchbook}
32-
var l6 = &libraries.Library{Name: "Calculus Unified Lib", Location: libraries.Sketchbook}
33-
var l7 = &libraries.Library{Name: "AnotherLib", Location: libraries.Sketchbook}
27+
var l1 = &libraries.Library{Name: "Calculus Lib", Location: libraries.User}
28+
var l2 = &libraries.Library{Name: "Calculus Lib-master", Location: libraries.User}
29+
var l3 = &libraries.Library{Name: "Calculus Lib Improved", Location: libraries.User}
30+
var l4 = &libraries.Library{Name: "Another Calculus Lib", Location: libraries.User}
31+
var l5 = &libraries.Library{Name: "Yet Another Calculus Lib Improved", Location: libraries.User}
32+
var l6 = &libraries.Library{Name: "Calculus Unified Lib", Location: libraries.User}
33+
var l7 = &libraries.Library{Name: "AnotherLib", Location: libraries.User}
3434

3535
func TestClosestMatchWithTotallyDifferentNames(t *testing.T) {
3636
libraryList := libraries.List{}

Diff for: arduino/sketches/sketches.go

-22
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ import (
2424
"github.com/arduino/go-paths-helper"
2525
)
2626

27-
// SketchBook is a sketchbook
28-
type SketchBook struct {
29-
Path *paths.Path
30-
}
31-
3227
// Sketch is a sketch for Arduino
3328
type Sketch struct {
3429
Name string
@@ -47,23 +42,6 @@ type BoardMetadata struct {
4742
Name string `json:"name,omitempty"`
4843
}
4944

50-
// NewSketchBook returns a new SketchBook object
51-
func NewSketchBook(path *paths.Path) *SketchBook {
52-
return &SketchBook{
53-
Path: path,
54-
}
55-
}
56-
57-
// NewSketch loads a sketch from the sketchbook
58-
func (sketchbook *SketchBook) NewSketch(name string) (*Sketch, error) {
59-
sketch := &Sketch{
60-
FullPath: sketchbook.Path.Join(name),
61-
Name: name,
62-
}
63-
sketch.ImportMetadata()
64-
return sketch, nil
65-
}
66-
6745
// NewSketchFromPath loads a sketch from the specified path
6846
func NewSketchFromPath(path *paths.Path) (*Sketch, error) {
6947
sketch := &Sketch{

0 commit comments

Comments
 (0)