Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): remove deno serverless & support run .ts serverless in nodejs #935

Merged
merged 8 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
// defaultSFNFile is the default serverless file name
const (
defaultSFNSourceFile = "app.go"
defaultSFNSourceTSFile = "app.ts"
defaultSFNTestSourceFile = "app_test.go"
defaultSFNCompliedFile = "sfn.yomo"
defaultSFNWASIFile = "sfn.wasm"
Expand Down
29 changes: 8 additions & 21 deletions cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ package cli

import (
"os"
"path/filepath"

"github.com/spf13/cobra"
"github.com/yomorun/yomo/pkg/log"

// serverless registrations
"github.com/yomorun/yomo/cli/serverless"
_ "github.com/yomorun/yomo/cli/serverless/deno"
_ "github.com/yomorun/yomo/cli/serverless/exec"
_ "github.com/yomorun/yomo/cli/serverless/golang"
_ "github.com/yomorun/yomo/cli/serverless/nodejs"
_ "github.com/yomorun/yomo/cli/serverless/wasm"
"github.com/yomorun/yomo/cli/viper"
)
Expand All @@ -37,7 +36,7 @@ var runCmd = &cobra.Command{
Short: "Run a YoMo Stream Function",
Long: "Run a YoMo Stream Function",
Run: func(cmd *cobra.Command, args []string) {
if err := parseFileArg(args, &opts, defaultSFNCompliedFile, defaultSFNWASIFile, defaultSFNSourceFile); err != nil {
if err := parseFileArg(args, &opts, defaultSFNCompliedFile, defaultSFNWASIFile, defaultSFNSourceFile, defaultSFNSourceTSFile); err != nil {
log.FailureStatusEvent(os.Stdout, err.Error())
return
}
Expand Down Expand Up @@ -68,24 +67,12 @@ var runCmd = &cobra.Command{
)
return
}
// build if it's go file
if ext := filepath.Ext(opts.Filename); ext == ".go" {
log.PendingStatusEvent(os.Stdout, "Building YoMo Stream Function instance...")
if err := s.Build(true); err != nil {
log.FailureStatusEvent(os.Stdout, err.Error())
os.Exit(127)
}
log.SuccessStatusEvent(os.Stdout, "YoMo Stream Function build successful!")
}
// run
// wasi
if ext := filepath.Ext(opts.Filename); ext == ".wasm" {
wasmRuntime := opts.Runtime
if wasmRuntime == "" {
wasmRuntime = "wazero"
}
log.InfoStatusEvent(os.Stdout, "WASM runtime: %s", wasmRuntime)

if err := s.Build(true); err != nil {
log.FailureStatusEvent(os.Stdout, err.Error())
os.Exit(127)
}

log.InfoStatusEvent(
os.Stdout,
"Starting YoMo Stream Function instance, connecting to zipper: %v",
Expand All @@ -103,7 +90,7 @@ func init() {
rootCmd.AddCommand(runCmd)

runCmd.Flags().StringVarP(&opts.ZipperAddr, "zipper", "z", "localhost:9000", "YoMo-Zipper endpoint addr")
runCmd.Flags().StringVarP(&opts.Name, "name", "n", "app", "yomo stream function name.")
runCmd.Flags().StringVarP(&opts.Name, "name", "n", "", "yomo stream function name.")
runCmd.Flags().StringVarP(&opts.ModFile, "modfile", "m", "", "custom go.mod")
runCmd.Flags().StringVarP(&opts.Credential, "credential", "d", "", "client credential payload, eg: `token:dBbBiRE7`")
runCmd.Flags().StringVarP(&opts.Runtime, "runtime", "r", "", "serverless runtime type")
Expand Down
116 changes: 0 additions & 116 deletions cli/serverless/deno/mod/mod.ts

This file was deleted.

198 changes: 0 additions & 198 deletions cli/serverless/deno/runtime.go

This file was deleted.

Loading