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

Updates to libraries-api.#35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
cmaglie wants to merge2 commits intomain
base:main
Choose a base branch
Loading
fromupgraded_lib_api
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletionscmd/gendoc/docs.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1042,8 +1042,9 @@ Contains a JSON object with the details of an error.
Method: http.MethodDelete,
Path: "/v1/apps/{appID}/sketch/libraries/{libRef}",
Parameters: (*struct {
ID string `path:"appID" description:"application identifier."`
LibRef string `path:"libRef" description:"library reference (\"LibraryName\" or \"LibraryName@Version\")."`
ID string `path:"appID" description:"application identifier."`
LibRef string `path:"libRef" description:"library reference (\"LibraryName\" or \"LibraryName@Version\")."`
RemoveDependencies string `query:"remove_deps" description:"if set to \"true\", the library's dependencies will be removed as well if not needed anymore."`
})(nil),
CustomSuccessResponse: &CustomResponseDef{
ContentType: "application/json",
Expand Down
2 changes: 1 addition & 1 deletiongo.mod
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,7 @@ replace (
)

// Required until https://github.com/arduino/arduino-cli/pull/3019 is merged and released
replace github.com/arduino/arduino-cli => github.com/cmaglie/arduino-cli v0.0.0-20251006122726-27fe68b0a18a
replace github.com/arduino/arduino-cli => github.com/cmaglie/arduino-cli v0.0.0-20251029100020-2327b357349d

require (
github.com/Andrew-M-C/go.emoji v1.1.4
Expand Down
4 changes: 2 additions & 2 deletionsgo.sum
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -170,8 +170,8 @@ github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004 h1:lkAMpLVBDaj17e
github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004/go.mod h1:yMWuSON2oQp+43nFtAV/uvKQIFpSPerB57DCt9t8sSA=
github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
github.com/cmaglie/arduino-cli v0.0.0-20251006122726-27fe68b0a18a h1:xjGwmLNEUTb+QWUmUxwrb24Awbt4/rdpFG7lVUR3skI=
github.com/cmaglie/arduino-cli v0.0.0-20251006122726-27fe68b0a18a/go.mod h1:aH/Lfub80ymf3vpF0gUWx/sckVUNB0gDoPlABAx97SE=
github.com/cmaglie/arduino-cli v0.0.0-20251029100020-2327b357349d h1:Hpm/DaAji25rxW1JPr1DK7A1wnUygOw0ftAs6UiHAq0=
github.com/cmaglie/arduino-cli v0.0.0-20251029100020-2327b357349d/go.mod h1:aH/Lfub80ymf3vpF0gUWx/sckVUNB0gDoPlABAx97SE=
github.com/cmaglie/pb v1.0.27 h1:ynGj8vBXR+dtj4B7Q/W/qGt31771Ux5iFfRQBnwdQiA=
github.com/cmaglie/pb v1.0.27/go.mod h1:GilkKZMXYjBA4NxItWFfO+lwkp59PLHQ+IOW/b/kmZI=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
Expand Down
8 changes: 8 additions & 0 deletionsinternal/api/docs/openapi.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -302,6 +302,14 @@ paths:
from the sketch project file.
operationId: appSketchRemoveLibrary
parameters:
- description: if set to "true", the library's dependencies will be removed
as well if not needed anymore.
in: query
name: remove_deps
schema:
description: if set to "true", the library's dependencies will be removed
as well if not needed anymore.
type: string
- description: application identifier.
in: path
name: appID
Expand Down
6 changes: 4 additions & 2 deletionsinternal/api/handlers/app_sketch_libs.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -90,12 +90,14 @@ func HandleSketchRemoveLibrary(idProvider *app.IDProvider) http.HandlerFunc {
return
}

if removedLib, err := orchestrator.RemoveSketchLibrary(r.Context(), app, libRef); err != nil {
// Get query param addDeps (default false)
removeDeps, _ := strconv.ParseBool(r.URL.Query().Get("remove_deps"))
if removedLibs, err := orchestrator.RemoveSketchLibrary(r.Context(), app, libRef, removeDeps); err != nil {
render.EncodeResponse(w, http.StatusInternalServerError, models.ErrorResponse{Details: "unable to remove sketch library"})
return
} else {
render.EncodeResponse(w, http.StatusOK, SketchRemoveLibraryResponse{
RemovedLibraries:[]orchestrator.LibraryReleaseID{removedLib},
RemovedLibraries:removedLibs,
})
return
}
Expand Down
44 changes: 22 additions & 22 deletionsinternal/orchestrator/sketch_libs.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,9 +46,9 @@ func AddSketchLibrary(ctx context.Context, app app.ArduinoApp, libRef LibraryRel
resp, err := srv.ProfileLibAdd(ctx, &rpc.ProfileLibAddRequest{
Instance: inst,
SketchPath: app.MainSketchPath.String(),
Library: &rpc.SketchProfileLibraryReference{
Library: &rpc.SketchProfileLibraryReference_IndexLibrary_{
IndexLibrary: &rpc.SketchProfileLibraryReference_IndexLibrary{
Library: &rpc.ProfileLibraryReference{
Library: &rpc.ProfileLibraryReference_IndexLibrary_{
IndexLibrary: &rpc.ProfileLibraryReference_IndexLibrary{
Name: libRef.Name,
Version: libRef.Version,
},
Expand All@@ -62,11 +62,11 @@ func AddSketchLibrary(ctx context.Context, app app.ArduinoApp, libRef LibraryRel
return f.Map(resp.GetAddedLibraries(), rpcProfileLibReferenceToLibReleaseID), nil
}

func RemoveSketchLibrary(ctx context.Context, app app.ArduinoApp, libRef LibraryReleaseID) (LibraryReleaseID, error) {
func RemoveSketchLibrary(ctx context.Context, app app.ArduinoApp, libRef LibraryReleaseID, removeDeps bool) ([]LibraryReleaseID, error) {
srv := commands.NewArduinoCoreServer()
var inst *rpc.Instance
if res, err := srv.Create(ctx, &rpc.CreateRequest{}); err != nil {
returnLibraryReleaseID{}, err
returnnil, err
} else {
inst = res.Instance
}
Expand All@@ -77,23 +77,25 @@ func RemoveSketchLibrary(ctx context.Context, app app.ArduinoApp, libRef Library
// TODO: LOG progress/error?
return nil
})); err != nil {
returnLibraryReleaseID{}, err
returnnil, err
}

resp, err := srv.ProfileLibRemove(ctx, &rpc.ProfileLibRemoveRequest{
Library: &rpc.SketchProfileLibraryReference{
Library: &rpc.SketchProfileLibraryReference_IndexLibrary_{
IndexLibrary: &rpc.SketchProfileLibraryReference_IndexLibrary{
Instance: inst,
Library: &rpc.ProfileLibraryReference{
Library: &rpc.ProfileLibraryReference_IndexLibrary_{
IndexLibrary: &rpc.ProfileLibraryReference_IndexLibrary{
Name: libRef.Name,
},
},
},
SketchPath: app.MainSketchPath.String(),
SketchPath: app.MainSketchPath.String(),
RemoveDependencies: &removeDeps,
})
if err != nil {
returnLibraryReleaseID{}, err
returnnil, err
}
returnrpcProfileLibReferenceToLibReleaseID(resp.GetLibrary()), nil
returnf.Map(resp.GetRemovedLibraries(), rpcProfileLibReferenceToLibReleaseID), nil
}

func ListSketchLibraries(ctx context.Context, app app.ArduinoApp) ([]LibraryReleaseID, error) {
Expand All@@ -107,19 +109,17 @@ func ListSketchLibraries(ctx context.Context, app app.ArduinoApp) ([]LibraryRele
}

// Keep only index libraries
libs := f.Filter(resp.Libraries, func(l *rpc.SketchProfileLibraryReference) bool {
libs := f.Filter(resp.Libraries, func(l *rpc.ProfileLibraryReference) bool {
return l.GetIndexLibrary() != nil
})
res := f.Map(libs, func(l *rpc.SketchProfileLibraryReference) LibraryReleaseID {
return LibraryReleaseID{
Name: l.GetIndexLibrary().GetName(),
Version: l.GetIndexLibrary().GetVersion(),
}
})
return res, nil
return f.Map(libs, rpcProfileLibReferenceToLibReleaseID), nil
}

func rpcProfileLibReferenceToLibReleaseID(ref *rpc.SketchProfileLibraryReference) LibraryReleaseID {
func rpcProfileLibReferenceToLibReleaseID(ref *rpc.ProfileLibraryReference) LibraryReleaseID {
l := ref.GetIndexLibrary()
return NewLibraryReleaseID(l.GetName(), l.GetVersion())
return LibraryReleaseID{
Name: l.GetName(),
Version: l.GetVersion(),
IsDependency: l.GetIsDependency(),
}
}
5 changes: 3 additions & 2 deletionsinternal/orchestrator/sketch_libs_release_id.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,8 +27,9 @@ import (
// - name[@version]
// Version is optional, if not provided, the latest version available will be used.
type LibraryReleaseID struct {
Name string
Version string
Name string
Version string
IsDependency bool
}

func NewLibraryReleaseID(name string, version string) LibraryReleaseID {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp