Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit08135da

Browse files
committed
Updates to libraries-api.
Now some libraries may be tagged as dependencies, and also beautomatically removed if no more needed.
1 parentf61b73f commit08135da

File tree

7 files changed

+42
-31
lines changed

7 files changed

+42
-31
lines changed

‎cmd/gendoc/docs.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,8 +1042,9 @@ Contains a JSON object with the details of an error.
10421042
Method:http.MethodDelete,
10431043
Path:"/v1/apps/{appID}/sketch/libraries/{libRef}",
10441044
Parameters: (*struct {
1045-
IDstring`path:"appID" description:"application identifier."`
1046-
LibRefstring`path:"libRef" description:"library reference (\"LibraryName\" or \"LibraryName@Version\")."`
1045+
IDstring`path:"appID" description:"application identifier."`
1046+
LibRefstring`path:"libRef" description:"library reference (\"LibraryName\" or \"LibraryName@Version\")."`
1047+
RemoveDependenciesstring`query:"remove_deps" description:"if set to \"true\", the library's dependencies will be removed as well if not needed anymore."`
10471048
})(nil),
10481049
CustomSuccessResponse:&CustomResponseDef{
10491050
ContentType:"application/json",

‎go.mod‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ replace (
1414
)
1515

1616
// Required until https://github.com/arduino/arduino-cli/pull/3019 is merged and released
17-
replacegithub.com/arduino/arduino-cli =>github.com/cmaglie/arduino-cliv0.0.0-20251006122726-27fe68b0a18a
17+
replacegithub.com/arduino/arduino-cli =>github.com/cmaglie/arduino-cliv0.0.0-20251029100020-2327b357349d
1818

1919
require (
2020
github.com/Andrew-M-C/go.emojiv1.1.4

‎go.sum‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004 h1:lkAMpLVBDaj17e
170170
github.com/cloudflare/cfsslv0.0.0-20180223231731-4e2dcbde5004/go.mod h1:yMWuSON2oQp+43nFtAV/uvKQIFpSPerB57DCt9t8sSA=
171171
github.com/cloudflare/circlv1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
172172
github.com/cloudflare/circlv1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
173-
github.com/cmaglie/arduino-cliv0.0.0-20251006122726-27fe68b0a18a h1:xjGwmLNEUTb+QWUmUxwrb24Awbt4/rdpFG7lVUR3skI=
174-
github.com/cmaglie/arduino-cliv0.0.0-20251006122726-27fe68b0a18a/go.mod h1:aH/Lfub80ymf3vpF0gUWx/sckVUNB0gDoPlABAx97SE=
173+
github.com/cmaglie/arduino-cliv0.0.0-20251029100020-2327b357349d h1:Hpm/DaAji25rxW1JPr1DK7A1wnUygOw0ftAs6UiHAq0=
174+
github.com/cmaglie/arduino-cliv0.0.0-20251029100020-2327b357349d/go.mod h1:aH/Lfub80ymf3vpF0gUWx/sckVUNB0gDoPlABAx97SE=
175175
github.com/cmaglie/pbv1.0.27 h1:ynGj8vBXR+dtj4B7Q/W/qGt31771Ux5iFfRQBnwdQiA=
176176
github.com/cmaglie/pbv1.0.27/go.mod h1:GilkKZMXYjBA4NxItWFfO+lwkp59PLHQ+IOW/b/kmZI=
177177
github.com/cncf/udpa/gov0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=

‎internal/api/docs/openapi.yaml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,14 @@ paths:
302302
from the sketch project file.
303303
operationId:appSketchRemoveLibrary
304304
parameters:
305+
-description:if set to "true", the library's dependencies will be removed
306+
as well if not needed anymore.
307+
in:query
308+
name:remove_deps
309+
schema:
310+
description:if set to "true", the library's dependencies will be removed
311+
as well if not needed anymore.
312+
type:string
305313
-description:application identifier.
306314
in:path
307315
name:appID

‎internal/api/handlers/app_sketch_libs.go‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,14 @@ func HandleSketchRemoveLibrary(idProvider *app.IDProvider) http.HandlerFunc {
9090
return
9191
}
9292

93-
ifremovedLib,err:=orchestrator.RemoveSketchLibrary(r.Context(),app,libRef);err!=nil {
93+
// Get query param addDeps (default false)
94+
removeDeps,_:=strconv.ParseBool(r.URL.Query().Get("remove_deps"))
95+
ifremovedLibs,err:=orchestrator.RemoveSketchLibrary(r.Context(),app,libRef,removeDeps);err!=nil {
9496
render.EncodeResponse(w,http.StatusInternalServerError, models.ErrorResponse{Details:"unable to remove sketch library"})
9597
return
9698
}else {
9799
render.EncodeResponse(w,http.StatusOK,SketchRemoveLibraryResponse{
98-
RemovedLibraries:[]orchestrator.LibraryReleaseID{removedLib},
100+
RemovedLibraries:removedLibs,
99101
})
100102
return
101103
}

‎internal/orchestrator/sketch_libs.go‎

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ func AddSketchLibrary(ctx context.Context, app app.ArduinoApp, libRef LibraryRel
4646
resp,err:=srv.ProfileLibAdd(ctx,&rpc.ProfileLibAddRequest{
4747
Instance:inst,
4848
SketchPath:app.MainSketchPath.String(),
49-
Library:&rpc.SketchProfileLibraryReference{
50-
Library:&rpc.SketchProfileLibraryReference_IndexLibrary_{
51-
IndexLibrary:&rpc.SketchProfileLibraryReference_IndexLibrary{
49+
Library:&rpc.ProfileLibraryReference{
50+
Library:&rpc.ProfileLibraryReference_IndexLibrary_{
51+
IndexLibrary:&rpc.ProfileLibraryReference_IndexLibrary{
5252
Name:libRef.Name,
5353
Version:libRef.Version,
5454
},
@@ -62,11 +62,11 @@ func AddSketchLibrary(ctx context.Context, app app.ArduinoApp, libRef LibraryRel
6262
returnf.Map(resp.GetAddedLibraries(),rpcProfileLibReferenceToLibReleaseID),nil
6363
}
6464

65-
funcRemoveSketchLibrary(ctx context.Context,app app.ArduinoApp,libRefLibraryReleaseID) (LibraryReleaseID,error) {
65+
funcRemoveSketchLibrary(ctx context.Context,app app.ArduinoApp,libRefLibraryReleaseID,removeDepsbool) ([]LibraryReleaseID,error) {
6666
srv:=commands.NewArduinoCoreServer()
6767
varinst*rpc.Instance
6868
ifres,err:=srv.Create(ctx,&rpc.CreateRequest{});err!=nil {
69-
returnLibraryReleaseID{},err
69+
returnnil,err
7070
}else {
7171
inst=res.Instance
7272
}
@@ -77,23 +77,24 @@ func RemoveSketchLibrary(ctx context.Context, app app.ArduinoApp, libRef Library
7777
// TODO: LOG progress/error?
7878
returnnil
7979
}));err!=nil {
80-
returnLibraryReleaseID{},err
80+
returnnil,err
8181
}
8282

8383
resp,err:=srv.ProfileLibRemove(ctx,&rpc.ProfileLibRemoveRequest{
84-
Library:&rpc.SketchProfileLibraryReference{
85-
Library:&rpc.SketchProfileLibraryReference_IndexLibrary_{
86-
IndexLibrary:&rpc.SketchProfileLibraryReference_IndexLibrary{
84+
Library:&rpc.ProfileLibraryReference{
85+
Library:&rpc.ProfileLibraryReference_IndexLibrary_{
86+
IndexLibrary:&rpc.ProfileLibraryReference_IndexLibrary{
8787
Name:libRef.Name,
8888
},
8989
},
9090
},
91-
SketchPath:app.MainSketchPath.String(),
91+
SketchPath:app.MainSketchPath.String(),
92+
RemoveDependencies:&removeDeps,
9293
})
9394
iferr!=nil {
94-
returnLibraryReleaseID{},err
95+
returnnil,err
9596
}
96-
returnrpcProfileLibReferenceToLibReleaseID(resp.GetLibrary()),nil
97+
returnf.Map(resp.GetRemovedLibraries(),rpcProfileLibReferenceToLibReleaseID),nil
9798
}
9899

99100
funcListSketchLibraries(ctx context.Context,app app.ArduinoApp) ([]LibraryReleaseID,error) {
@@ -107,19 +108,17 @@ func ListSketchLibraries(ctx context.Context, app app.ArduinoApp) ([]LibraryRele
107108
}
108109

109110
// Keep only index libraries
110-
libs:=f.Filter(resp.Libraries,func(l*rpc.SketchProfileLibraryReference)bool {
111+
libs:=f.Filter(resp.Libraries,func(l*rpc.ProfileLibraryReference)bool {
111112
returnl.GetIndexLibrary()!=nil
112113
})
113-
res:=f.Map(libs,func(l*rpc.SketchProfileLibraryReference)LibraryReleaseID {
114-
returnLibraryReleaseID{
115-
Name:l.GetIndexLibrary().GetName(),
116-
Version:l.GetIndexLibrary().GetVersion(),
117-
}
118-
})
119-
returnres,nil
114+
returnf.Map(libs,rpcProfileLibReferenceToLibReleaseID),nil
120115
}
121116

122-
funcrpcProfileLibReferenceToLibReleaseID(ref*rpc.SketchProfileLibraryReference)LibraryReleaseID {
117+
funcrpcProfileLibReferenceToLibReleaseID(ref*rpc.ProfileLibraryReference)LibraryReleaseID {
123118
l:=ref.GetIndexLibrary()
124-
returnNewLibraryReleaseID(l.GetName(),l.GetVersion())
119+
returnLibraryReleaseID{
120+
Name:l.GetName(),
121+
Version:l.GetVersion(),
122+
IsDependency:l.GetIsDependency(),
123+
}
125124
}

‎internal/orchestrator/sketch_libs_release_id.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ import (
2727
// - name[@version]
2828
// Version is optional, if not provided, the latest version available will be used.
2929
typeLibraryReleaseIDstruct {
30-
Namestring
31-
Versionstring
30+
Namestring
31+
Versionstring
32+
IsDependencybool
3233
}
3334

3435
funcNewLibraryReleaseID(namestring,versionstring)LibraryReleaseID {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp