Skip to content

Commit 9db1dc7

Browse files
committed
Merge branch 'main' into upgraded_lib_api
2 parents 8008ea3 + 17f979f commit 9db1dc7

File tree

54 files changed

+1434
-524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1434
-524
lines changed

Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ vars:
88
GOLANGCI_LINT_VERSION: v2.4.0
99
GOIMPORTS_VERSION: v0.29.0
1010
DPRINT_VERSION: 0.48.0
11-
EXAMPLE_VERSION: "0.5.0"
11+
EXAMPLE_VERSION: "0.5.1"
1212
RUNNER_VERSION: "0.5.0"
1313
VERSION: # if version is not passed we hack the semver by encoding the commit as pre-release
1414
sh: echo "${VERSION:-0.0.0-$(git rev-parse --short HEAD)}"

cmd/arduino-app-cli/app/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ func Load(idOrPath string) (app.ArduinoApp, error) {
5050
return app.ArduinoApp{}, fmt.Errorf("invalid app path: %s", idOrPath)
5151
}
5252

53-
return app.Load(id.ToPath().String())
53+
return app.Load(id.ToPath())
5454
}

cmd/arduino-app-cli/app/new.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ func newCreateCmd(cfg config.Configuration) *cobra.Command {
3232
icon string
3333
description string
3434
bricks []string
35-
noPyton bool
3635
noSketch bool
3736
fromApp string
3837
)
@@ -44,22 +43,20 @@ func newCreateCmd(cfg config.Configuration) *cobra.Command {
4443
RunE: func(cmd *cobra.Command, args []string) error {
4544
cobra.MinimumNArgs(1)
4645
name := args[0]
47-
return createHandler(cmd.Context(), cfg, name, icon, description, noPyton, noSketch, fromApp)
46+
return createHandler(cmd.Context(), cfg, name, icon, description, noSketch, fromApp)
4847
},
4948
}
5049

5150
cmd.Flags().StringVarP(&icon, "icon", "i", "", "Icon for the app")
5251
cmd.Flags().StringVarP(&description, "description", "d", "", "Description for the app")
5352
cmd.Flags().StringVarP(&fromApp, "from-app", "", "", "Create the new app from the path of an existing app")
5453
cmd.Flags().StringArrayVarP(&bricks, "bricks", "b", []string{}, "List of bricks to include in the app")
55-
cmd.Flags().BoolVarP(&noPyton, "no-python", "", false, "Do not include Python files")
5654
cmd.Flags().BoolVarP(&noSketch, "no-sketch", "", false, "Do not include Sketch files")
57-
cmd.MarkFlagsMutuallyExclusive("no-python", "no-sketch")
5855

5956
return cmd
6057
}
6158

62-
func createHandler(ctx context.Context, cfg config.Configuration, name string, icon string, description string, noPython, noSketch bool, fromApp string) error {
59+
func createHandler(ctx context.Context, cfg config.Configuration, name string, icon string, description string, noSketch bool, fromApp string) error {
6360
if fromApp != "" {
6461
id, err := servicelocator.GetAppIDProvider().ParseID(fromApp)
6562
if err != nil {
@@ -88,7 +85,6 @@ func createHandler(ctx context.Context, cfg config.Configuration, name string, i
8885
Name: name,
8986
Icon: icon,
9087
Description: description,
91-
SkipPython: noPython,
9288
SkipSketch: noSketch,
9389
}, servicelocator.GetAppIDProvider(), cfg)
9490
if err != nil {

cmd/arduino-app-cli/internal/servicelocator/servicelocator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ func Init(cfg config.Configuration) {
4242

4343
var (
4444
GetBricksIndex = sync.OnceValue(func() *bricksindex.BricksIndex {
45-
return f.Must(bricksindex.GenerateBricksIndexFromFile(GetStaticStore().GetAssetsFolder()))
45+
return f.Must(bricksindex.Load(GetStaticStore().GetAssetsFolder()))
4646
})
4747

4848
GetModelsIndex = sync.OnceValue(func() *modelsindex.ModelsIndex {
49-
return f.Must(modelsindex.GenerateModelsIndexFromFile(GetStaticStore().GetAssetsFolder()))
49+
return f.Must(modelsindex.Load(GetStaticStore().GetAssetsFolder()))
5050
})
5151

5252
GetProvisioner = sync.OnceValue(func() *orchestrator.Provision {

cmd/gendoc/docs.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ Contains a JSON object with the details of an error.
609609
Path: "/v1/apps",
610610
Request: handlers.CreateAppRequest{},
611611
Parameters: (*struct {
612-
SkipPython bool `query:"skip-python" description:"If true, the app will not be created with the python part."`
613612
SkipSketch bool `query:"skip-sketch" description:"If true, the app will not be created with the sketch part."`
614613
})(nil),
615614
CustomSuccessResponse: &CustomResponseDef{
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# exclude adbd from service that need to be restarted.
2+
$nrconf{override_rc}{qr(^adbd\.service$)} = 0;
3+

internal/api/docs/openapi.yaml

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ paths:
4545
description: Creates a new app in the default app location.
4646
operationId: createApp
4747
parameters:
48-
- description: If true, the app will not be created with the python part.
49-
in: query
50-
name: skip-python
51-
schema:
52-
description: If true, the app will not be created with the python part.
53-
type: boolean
5448
- description: If true, the app will not be created with the sketch part.
5549
in: query
5650
name: skip-sketch
@@ -1155,6 +1149,15 @@ components:
11551149
$ref: '#/components/schemas/ErrorResponse'
11561150
description: Precondition Failed
11571151
schemas:
1152+
AIModel:
1153+
properties:
1154+
description:
1155+
type: string
1156+
id:
1157+
type: string
1158+
name:
1159+
type: string
1160+
type: object
11581161
AIModelItem:
11591162
properties:
11601163
brick_ids:
@@ -1191,7 +1194,7 @@ components:
11911194
properties:
11921195
bricks:
11931196
items:
1194-
$ref: '#/components/schemas/BrickInstance'
1197+
$ref: '#/components/schemas/BrickInstanceListItem'
11951198
nullable: true
11961199
type: array
11971200
type: object
@@ -1203,6 +1206,8 @@ components:
12031206
type: string
12041207
name:
12051208
type: string
1209+
require_model:
1210+
type: boolean
12061211
required:
12071212
- id
12081213
- name
@@ -1318,6 +1323,11 @@ components:
13181323
$ref: '#/components/schemas/CodeExample'
13191324
nullable: true
13201325
type: array
1326+
compatible_models:
1327+
items:
1328+
$ref: '#/components/schemas/AIModel'
1329+
nullable: true
1330+
type: array
13211331
description:
13221332
type: string
13231333
id:
@@ -1326,6 +1336,8 @@ components:
13261336
type: string
13271337
readme:
13281338
type: string
1339+
require_model:
1340+
type: boolean
13291341
status:
13301342
type: string
13311343
used_by_apps:
@@ -1344,6 +1356,11 @@ components:
13441356
type: string
13451357
category:
13461358
type: string
1359+
compatible_models:
1360+
items:
1361+
$ref: '#/components/schemas/AIModel'
1362+
nullable: true
1363+
type: array
13471364
config_variables:
13481365
items:
13491366
$ref: '#/components/schemas/BrickConfigVariable'
@@ -1354,6 +1371,35 @@ components:
13541371
type: string
13551372
name:
13561373
type: string
1374+
require_model:
1375+
type: boolean
1376+
status:
1377+
type: string
1378+
variables:
1379+
additionalProperties:
1380+
type: string
1381+
description: 'Deprecated: use config_variables instead. This field is kept
1382+
for backward compatibility.'
1383+
type: object
1384+
type: object
1385+
BrickInstanceListItem:
1386+
properties:
1387+
author:
1388+
type: string
1389+
category:
1390+
type: string
1391+
config_variables:
1392+
items:
1393+
$ref: '#/components/schemas/BrickConfigVariable'
1394+
type: array
1395+
id:
1396+
type: string
1397+
model:
1398+
type: string
1399+
name:
1400+
type: string
1401+
require_model:
1402+
type: boolean
13571403
status:
13581404
type: string
13591405
variables:
@@ -1373,13 +1419,10 @@ components:
13731419
type: string
13741420
id:
13751421
type: string
1376-
models:
1377-
items:
1378-
type: string
1379-
nullable: true
1380-
type: array
13811422
name:
13821423
type: string
1424+
require_model:
1425+
type: boolean
13831426
status:
13841427
type: string
13851428
type: object

internal/api/handlers/app_create.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,9 @@ func HandleAppCreate(
4444
defer r.Body.Close()
4545

4646
queryParams := r.URL.Query()
47-
skipPythonStr := queryParams.Get("skip-python")
4847
skipSketchStr := queryParams.Get("skip-sketch")
49-
50-
skipPython := queryParamsValidator(skipPythonStr)
5148
skipSketch := queryParamsValidator(skipSketchStr)
5249

53-
if skipPython && skipSketch {
54-
render.EncodeResponse(w, http.StatusBadRequest, models.ErrorResponse{Details: "cannot skip both python and sketch"})
55-
return
56-
}
57-
5850
var req CreateAppRequest
5951
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
6052
slog.Error("unable to decode app create request", slog.String("error", err.Error()))
@@ -68,7 +60,6 @@ func HandleAppCreate(
6860
Name: req.Name,
6961
Icon: req.Icon,
7062
Description: req.Description,
71-
SkipPython: skipPython,
7263
SkipSketch: skipSketch,
7364
},
7465
idProvider,

internal/api/handlers/app_delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func HandleAppDelete(
4242
return
4343
}
4444

45-
app, err := app.Load(id.ToPath().String())
45+
app, err := app.Load(id.ToPath())
4646
if err != nil {
4747
slog.Error("Unable to parse the app.yaml", slog.String("error", err.Error()), slog.String("path", id.String()))
4848
render.EncodeResponse(w, http.StatusInternalServerError, models.ErrorResponse{Details: "unable to find the app"})

internal/api/handlers/app_details.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func HandleAppDetails(
4545
return
4646
}
4747

48-
app, err := app.Load(id.ToPath().String())
48+
app, err := app.Load(id.ToPath())
4949
if err != nil {
5050
slog.Error("Unable to parse the app.yaml", slog.String("error", err.Error()), slog.String("path", id.String()))
5151
render.EncodeResponse(w, http.StatusInternalServerError, models.ErrorResponse{Details: "unable to find the app"})
@@ -81,7 +81,7 @@ func HandleAppDetailsEdits(
8181
render.EncodeResponse(w, http.StatusPreconditionFailed, models.ErrorResponse{Details: "invalid id"})
8282
return
8383
}
84-
appToEdit, err := app.Load(id.ToPath().String())
84+
appToEdit, err := app.Load(id.ToPath())
8585
if err != nil {
8686
slog.Error("Unable to parse the app.yaml", slog.String("error", err.Error()), slog.String("path", id.String()))
8787
render.EncodeResponse(w, http.StatusInternalServerError, models.ErrorResponse{Details: "unable to find the app"})

0 commit comments

Comments
 (0)