Skip to content

Commit 2221a74

Browse files
authored
feat(cli): remove deno serverless & support run .ts serverless in nodejs (#935)
# Description 1. Support users use `TypeScript` to write a llm sfn, For an example, refer to `example/10-ai/llm-sfn-get-weather-ts`. 2. Add `yomo run app.ts` command to run the ts sfn. 3. Remove the default SFN name 'app'. If a name is not provided, the cli will prompt the user to add it. 4. Remove deno serverless support
1 parent b790a89 commit 2221a74

File tree

22 files changed

+1027
-478
lines changed

22 files changed

+1027
-478
lines changed

cli/cli.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
// defaultSFNFile is the default serverless file name
1919
const (
2020
defaultSFNSourceFile = "app.go"
21+
defaultSFNSourceTSFile = "app.ts"
2122
defaultSFNTestSourceFile = "app_test.go"
2223
defaultSFNCompliedFile = "sfn.yomo"
2324
defaultSFNWASIFile = "sfn.wasm"

cli/run.go

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@ package cli
1717

1818
import (
1919
"os"
20-
"path/filepath"
2120

2221
"github.com/spf13/cobra"
2322
"github.com/yomorun/yomo/pkg/log"
2423

2524
// serverless registrations
2625
"github.com/yomorun/yomo/cli/serverless"
27-
_ "github.com/yomorun/yomo/cli/serverless/deno"
2826
_ "github.com/yomorun/yomo/cli/serverless/exec"
2927
_ "github.com/yomorun/yomo/cli/serverless/golang"
28+
_ "github.com/yomorun/yomo/cli/serverless/nodejs"
3029
_ "github.com/yomorun/yomo/cli/serverless/wasm"
3130
"github.com/yomorun/yomo/cli/viper"
3231
)
@@ -37,7 +36,7 @@ var runCmd = &cobra.Command{
3736
Short: "Run a YoMo Stream Function",
3837
Long: "Run a YoMo Stream Function",
3938
Run: func(cmd *cobra.Command, args []string) {
40-
if err := parseFileArg(args, &opts, defaultSFNCompliedFile, defaultSFNWASIFile, defaultSFNSourceFile); err != nil {
39+
if err := parseFileArg(args, &opts, defaultSFNCompliedFile, defaultSFNWASIFile, defaultSFNSourceFile, defaultSFNSourceTSFile); err != nil {
4140
log.FailureStatusEvent(os.Stdout, err.Error())
4241
return
4342
}
@@ -68,24 +67,12 @@ var runCmd = &cobra.Command{
6867
)
6968
return
7069
}
71-
// build if it's go file
72-
if ext := filepath.Ext(opts.Filename); ext == ".go" {
73-
log.PendingStatusEvent(os.Stdout, "Building YoMo Stream Function instance...")
74-
if err := s.Build(true); err != nil {
75-
log.FailureStatusEvent(os.Stdout, err.Error())
76-
os.Exit(127)
77-
}
78-
log.SuccessStatusEvent(os.Stdout, "YoMo Stream Function build successful!")
79-
}
80-
// run
81-
// wasi
82-
if ext := filepath.Ext(opts.Filename); ext == ".wasm" {
83-
wasmRuntime := opts.Runtime
84-
if wasmRuntime == "" {
85-
wasmRuntime = "wazero"
86-
}
87-
log.InfoStatusEvent(os.Stdout, "WASM runtime: %s", wasmRuntime)
70+
71+
if err := s.Build(true); err != nil {
72+
log.FailureStatusEvent(os.Stdout, err.Error())
73+
os.Exit(127)
8874
}
75+
8976
log.InfoStatusEvent(
9077
os.Stdout,
9178
"Starting YoMo Stream Function instance, connecting to zipper: %v",
@@ -103,7 +90,7 @@ func init() {
10390
rootCmd.AddCommand(runCmd)
10491

10592
runCmd.Flags().StringVarP(&opts.ZipperAddr, "zipper", "z", "localhost:9000", "YoMo-Zipper endpoint addr")
106-
runCmd.Flags().StringVarP(&opts.Name, "name", "n", "app", "yomo stream function name.")
93+
runCmd.Flags().StringVarP(&opts.Name, "name", "n", "", "yomo stream function name.")
10794
runCmd.Flags().StringVarP(&opts.ModFile, "modfile", "m", "", "custom go.mod")
10895
runCmd.Flags().StringVarP(&opts.Credential, "credential", "d", "", "client credential payload, eg: `token:dBbBiRE7`")
10996
runCmd.Flags().StringVarP(&opts.Runtime, "runtime", "r", "", "serverless runtime type")

cli/serverless/deno/mod/mod.ts

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

cli/serverless/deno/runtime.go

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

0 commit comments

Comments
 (0)