Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
add support for python3.10, python3.11, and nodejs18.x
Browse files Browse the repository at this point in the history
  • Loading branch information
hozan23 committed Sep 28, 2023
1 parent 3441d6c commit 34e895e
Show file tree
Hide file tree
Showing 7 changed files with 2,206 additions and 19 deletions.
7 changes: 5 additions & 2 deletions cmd/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ func newCmdPush() *cobra.Command {
Space will automatically update your Builder instance with the new revision.
If you don't want to follow the logs of the build and update, pass the --skip-logs argument which will exit the process as soon as the build is started instead of waiting for it to finish.
If you don't want to follow the logs of the build and update, pass the
--skip-logs argument which will exit the process as soon as the build is started
instead of waiting for it to finish.
Tip: Use the .spaceignore file to exclude certain files and directories from being uploaded during push.
Tip: Use the .spaceignore file to exclude certain files and directories from
being uploaded during push.
`,
Args: cobra.NoArgs,
PreRunE: utils.CheckAll(utils.CheckProjectInitialized("dir"), utils.CheckNotEmpty("id", "tag")),
Expand Down
3 changes: 3 additions & 0 deletions internal/spacefile/schemas/spacefile.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@
"svelte-kit",
"python3.9",
"python3.8",
"python3.10",
"python3.11",
"nodejs16",
"nodejs18",
"custom"
]
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/scanner/frameworks.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,5 @@ func detectFramework(dir string) (string, error) {
return framework.Name, nil
}
}
return "nodejs16", nil
return shared.Node18, nil
}
4 changes: 2 additions & 2 deletions pkg/scanner/runtimes.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func pythonScanner(dir string) (*shared.Micro, error) {
m := &shared.Micro{
Name: name,
Src: dir,
Engine: shared.Python39,
Engine: shared.Python311,
}

return m, nil
Expand All @@ -49,7 +49,7 @@ func nodeScanner(dir string) (*shared.Micro, error) {
m := &shared.Micro{
Name: name,
Src: dir,
Engine: shared.Node16x,
Engine: shared.Node18x,
}

framework, err := detectFramework(dir)
Expand Down
12 changes: 7 additions & 5 deletions pkg/scanner/scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ type ScanTestInfo struct {

var (
microsTestInfo = []ScanTestInfo{
{Name: "python", Path: "testdata/micros/python", ExpectedEngine: shared.Python39},
{Name: "python", Path: "testdata/micros/python", ExpectedEngine: shared.Python311},
{Name: "go", Path: "testdata/micros/go", ExpectedEngine: shared.Custom},
{Name: "next", Path: "testdata/micros/next", ExpectedEngine: shared.Next},
{Name: "node", Path: "testdata/micros/node", ExpectedEngine: "nodejs16"},
{Name: "node", Path: "testdata/micros/node", ExpectedEngine: shared.Node18},
{Name: "nuxt", Path: "testdata/micros/nuxt", ExpectedEngine: shared.Nuxt},
{Name: "react", Path: "testdata/micros/react", ExpectedEngine: shared.React},
{Name: "static", Path: "testdata/micros/static", ExpectedEngine: shared.Static},
Expand Down Expand Up @@ -47,10 +47,10 @@ func TestScanMultiMicroProject(t *testing.T) {

expectedMicros := []string{"python", "go", "next", "node", "nuxt", "react", "static", "svelte", "svelte-kit", "vue"}
expectedMicrosToEngines := map[string]string{
"python": shared.Python39,
"python": shared.Python311,
"go": shared.Custom,
"next": shared.Next,
"node": "nodejs16",
"node": shared.Node18,
"nuxt": shared.Nuxt,
"react": shared.React,
"static": shared.Static,
Expand All @@ -73,7 +73,9 @@ func TestScanMultiMicroProject(t *testing.T) {
if !slices.Contains(expectedMicros, micro.Name) {
t.Fatalf("micro %s at %s is detected, but should not be detected as part of a multi-micro project", micro.Name, micro.Src)
}
assert.Equal(t, micro.Engine, expectedMicrosToEngines[micro.Name], "detected engine for micro %s as %s, but expected %s", micro.Name, micro.Engine, expectedMicrosToEngines[micro.Name])
assert.Equal(t, micro.Engine, expectedMicrosToEngines[micro.Name],
"detected engine for micro %s as %s, but expected %s",
micro.Name, micro.Engine, expectedMicrosToEngines[micro.Name])
})
}
}
Expand Down
53 changes: 44 additions & 9 deletions shared/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,33 @@ const (
SvelteKit = "svelte-kit"
Python38 = "python3.8"
Python39 = "python3.9"
Python310 = "python3.10"
Python311 = "python3.11"
Node14x = "nodejs14.x"
Node16x = "nodejs16.x"
Node18x = "nodejs18.x"
Node18 = "nodejs18"
Custom = "custom"
)

var (
SupportedEngines = []string{Static, React, Svelte, Vue, Next, Nuxt, SvelteKit, Python38, Python39, Node14x, Node16x, Custom}
SupportedEngines = []string{
Static,
React,
Svelte,
Vue,
Next,
Nuxt,
SvelteKit,
Python38,
Python39,
Python310,
Python311,
Node14x,
Node16x,
Node18x,
Custom,
}

EngineAliases = map[string]string{
"static": Static,
Expand All @@ -40,25 +60,32 @@ var (
"svelte-kit": SvelteKit,
"python3.9": Python39,
"python3.8": Python38,
"python3.10": Python310,
"python3.11": Python311,
"nodejs14.x": Node14x,
"nodejs14": Node14x,
"nodejs16.x": Node16x,
"nodejs16": Node16x,
"nodejs18.x": Node18x,
"nodejs18": Node18x,
"custom": Custom,
}

EnginesToRuntimes = map[string]string{
Static: Node14x,
React: Node14x,
Svelte: Node14x,
Vue: Node14x,
Next: Node16x,
Nuxt: Node16x,
SvelteKit: Node16x,
Static: Node18x,
React: Node18x,
Svelte: Node18x,
Vue: Node18x,
Next: Node18x,
Nuxt: Node18x,
SvelteKit: Node18x,
Python38: Python38,
Python39: Python38,
Python310: Python310,
Python311: Python311,
Node14x: Node14x,
Node16x: Node16x,
Node18x: Node18x,
Custom: Custom,
}

Expand All @@ -83,6 +110,13 @@ var (
Nuxt: "npm run dev -- --port $PORT",
SvelteKit: "npm run dev -- --port $PORT",
}

pythonEngines = map[string]string{
Python38: Python38,
Python39: Python38,
Python310: Python310,
Python311: Python311,
}
)

type ActionEvent struct {
Expand Down Expand Up @@ -225,7 +259,8 @@ func IsFrontendEngine(engine string) bool {
}

func IsPythonEngine(engine string) bool {
return engine == Python38 || engine == Python39
_, ok := pythonEngines[engine]
return ok
}

func IsFullstackEngine(engine string) bool {
Expand Down
Loading

0 comments on commit 34e895e

Please sign in to comment.