Skip to content

Commit 86853c9

Browse files
authored
remove no-python option for creating app (arduino#121)
* remove no-python option for creating app * remove flag no-python * fix test * fix test
1 parent 3f54506 commit 86853c9

File tree

14 files changed

+11
-158
lines changed

14 files changed

+11
-158
lines changed

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/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{

internal/api/docs/openapi.yaml

Lines changed: 0 additions & 6 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

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/e2e/client/client.gen.go

Lines changed: 0 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/e2e/daemon/app_test.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ func TestCreateApp(t *testing.T) {
9393
{
9494
name: "should return 400 bad request when icon is not a single emoji",
9595
parameters: client.CreateAppParams{
96-
SkipPython: f.Ptr(false),
9796
SkipSketch: f.Ptr(false),
9897
},
9998
body: client.CreateAppRequest{
@@ -107,7 +106,6 @@ func TestCreateApp(t *testing.T) {
107106
{
108107
name: "should create app successfully when icon is empty",
109108
parameters: client.CreateAppParams{
110-
SkipPython: f.Ptr(false),
111109
SkipSketch: f.Ptr(false),
112110
},
113111
body: client.CreateAppRequest{
@@ -121,7 +119,6 @@ func TestCreateApp(t *testing.T) {
121119
{
122120
name: "should return 201 Created on first successful creation",
123121
parameters: client.CreateAppParams{
124-
SkipPython: f.Ptr(false),
125122
SkipSketch: f.Ptr(false),
126123
},
127124
body: defaultRequestBody,
@@ -130,30 +127,15 @@ func TestCreateApp(t *testing.T) {
130127
{
131128
name: "should return 409 Conflict when creating a duplicate app",
132129
parameters: client.CreateAppParams{
133-
SkipPython: f.Ptr(false),
134130
SkipSketch: f.Ptr(false),
135131
},
136132
body: defaultRequestBody,
137133
expectedStatusCode: http.StatusConflict,
138134
expectedErrorDetails: f.Ptr("app already exists"),
139135
},
140-
{
141-
name: "should return 201 Created on successful creation with skip_python",
142-
parameters: client.CreateAppParams{
143-
SkipPython: f.Ptr(true),
144-
SkipSketch: f.Ptr(false),
145-
},
146-
body: client.CreateAppRequest{
147-
Icon: f.Ptr("🌎"),
148-
Name: "HelloWorld_2",
149-
Description: f.Ptr("My HelloWorld_2 description"),
150-
},
151-
expectedStatusCode: http.StatusCreated,
152-
},
153136
{
154137
name: "should return 201 Created on successful creation with skip_sketch",
155138
parameters: client.CreateAppParams{
156-
SkipPython: f.Ptr(false),
157139
SkipSketch: f.Ptr(true),
158140
},
159141
body: client.CreateAppRequest{
@@ -163,16 +145,6 @@ func TestCreateApp(t *testing.T) {
163145
},
164146
expectedStatusCode: http.StatusCreated,
165147
},
166-
{
167-
name: "should return 400 Bad Request when creating an app with both filters set to true",
168-
parameters: client.CreateAppParams{
169-
SkipPython: f.Ptr(true),
170-
SkipSketch: f.Ptr(true),
171-
},
172-
body: defaultRequestBody,
173-
expectedStatusCode: http.StatusBadRequest,
174-
expectedErrorDetails: f.Ptr("cannot skip both python and sketch"),
175-
},
176148
}
177149

178150
for _, tc := range testCases {
@@ -985,7 +957,6 @@ func TestAppList(t *testing.T) {
985957
expectedAppNumber := 5
986958
for i := 0; i < expectedAppNumber; i++ {
987959
r, err := httpClient.CreateApp(t.Context(), &client.CreateAppParams{
988-
SkipPython: f.Ptr(false),
989960
SkipSketch: f.Ptr(false),
990961
}, client.CreateAppRequest{
991962
Icon: f.Ptr("🌎"),
@@ -1003,7 +974,6 @@ func TestAppList(t *testing.T) {
1003974

1004975
t.Run("AppListDefault_success", func(t *testing.T) {
1005976
r, err := httpClient.CreateApp(t.Context(), &client.CreateAppParams{
1006-
SkipPython: f.Ptr(false),
1007977
SkipSketch: f.Ptr(false),
1008978
}, client.CreateAppRequest{
1009979
Icon: f.Ptr("🌎"),

internal/orchestrator/app/generator/app_generator.go

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,22 @@ import (
3333

3434
const templateRoot = "app_template"
3535

36-
type Opts int
37-
38-
const (
39-
None Opts = 0
40-
SkipSketch Opts = 1 << iota
41-
SkipPython
42-
)
43-
4436
//go:embed all:app_template
4537
var fsApp embed.FS
4638

47-
func GenerateApp(basePath *paths.Path, app app.AppDescriptor, options Opts) error {
39+
func GenerateApp(basePath *paths.Path, app app.AppDescriptor, skipSketch bool) error {
4840
if err := basePath.MkdirAll(); err != nil {
4941
return fmt.Errorf("failed to create app directory: %w", err)
5042
}
51-
isSkipSketchSet := options&SkipSketch != 0
52-
isSkipPythonSet := options&SkipPython != 0
53-
54-
if !isSkipSketchSet {
43+
if !skipSketch {
5544
if err := generateSketch(basePath); err != nil {
5645
return fmt.Errorf("failed to create sketch: %w", err)
5746
}
5847
}
59-
if !isSkipPythonSet {
60-
if err := generatePython(basePath); err != nil {
61-
return fmt.Errorf("failed to create python: %w", err)
62-
}
63-
}
6448

49+
if err := generatePython(basePath); err != nil {
50+
return fmt.Errorf("failed to create python: %w", err)
51+
}
6552
if err := generateApp(basePath, app); err != nil {
6653
return fmt.Errorf("failed to create app.yaml: %w", err)
6754
}

internal/orchestrator/app/generator/app_generator_test.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,25 @@ func TestGenerateApp(t *testing.T) {
4040

4141
testCases := []struct {
4242
name string
43-
options Opts
43+
skipSketch bool
4444
goldenPath string
4545
}{
4646
{
4747
name: "generate complete app",
48-
options: None,
4948
goldenPath: "testdata/app-all.golden",
5049
},
5150
{
5251
name: "skip sketch",
53-
options: SkipSketch,
52+
skipSketch: true,
5453
goldenPath: "testdata/app-no-sketch.golden",
5554
},
56-
{
57-
name: "skip python",
58-
options: SkipPython,
59-
goldenPath: "testdata/app-no-python.golden",
60-
},
6155
}
6256

6357
for _, tc := range testCases {
6458
t.Run(tc.name, func(t *testing.T) {
6559
tempDir := t.TempDir()
6660

67-
err := GenerateApp(paths.New(tempDir), baseApp, tc.options)
61+
err := GenerateApp(paths.New(tempDir), baseApp, tc.skipSketch)
6862
require.NoError(t, err)
6963

7064
if os.Getenv("UPDATE_GOLDEN") == "true" {

internal/orchestrator/app/generator/testdata/app-no-python.golden/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

internal/orchestrator/app/generator/testdata/app-no-python.golden/README.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)