From b49009ac04a20a193e07024b70537d508d7d182d Mon Sep 17 00:00:00 2001 From: Daniel Wu Date: Sun, 29 Oct 2023 23:05:13 -0400 Subject: [PATCH] add pnpm to serverless --- cmd/serverless/core/add/add.go | 9 +++++++-- cmd/serverless/core/remove/remove.go | 9 +++++++-- cmd/serverless/functions/add/add.go | 9 +++++++-- cmd/serverless/functions/remove/remove.go | 9 +++++++-- cmd/serverless/install/install.go | 6 +++++- cmd/serverless/serverless.go | 1 + cmd/serverless/start/start.go | 6 +++++- 7 files changed, 39 insertions(+), 10 deletions(-) diff --git a/cmd/serverless/core/add/add.go b/cmd/serverless/core/add/add.go index 953ce33..c24933f 100644 --- a/cmd/serverless/core/add/add.go +++ b/cmd/serverless/core/add/add.go @@ -17,9 +17,14 @@ var AddCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { bash_args := []string{"add", args[0]} if cmd.Flag("dev").Value.String() == "true" { - bash_args = append(bash_args, "--dev") + bash_args = append(bash_args, "-D") } - core.ExecBashCmd("yarn", bash_args...) + if cmd.Flag("yarn").Value.String() == "true" { + core.ExecBashCmd("yarn", bash_args...) + } else { + core.ExecBashCmd("pnpm", bash_args...) + } + }, } diff --git a/cmd/serverless/core/remove/remove.go b/cmd/serverless/core/remove/remove.go index e4c45d8..6352dc8 100644 --- a/cmd/serverless/core/remove/remove.go +++ b/cmd/serverless/core/remove/remove.go @@ -17,9 +17,14 @@ var RemoveCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { bash_args := []string{"remove", args[0]} if cmd.Flag("dev").Value.String() == "true" { - bash_args = append(bash_args, "--dev") + bash_args = append(bash_args, "-D") } - core.ExecBashCmd("yarn", bash_args...) + if cmd.Flag("yarn").Value.String() == "true" { + core.ExecBashCmd("yarn", bash_args...) + } else { + core.ExecBashCmd("pnpm", bash_args...) + } + }, } diff --git a/cmd/serverless/functions/add/add.go b/cmd/serverless/functions/add/add.go index 653368e..e13fda2 100644 --- a/cmd/serverless/functions/add/add.go +++ b/cmd/serverless/functions/add/add.go @@ -17,9 +17,14 @@ var AddCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { bash_args := []string{"add", args[0]} if cmd.Flag("dev").Value.String() == "true" { - bash_args = append(bash_args, "--dev") + bash_args = append(bash_args, "-D") } - functions.ExecBashCmd("yarn", bash_args...) + if cmd.Flag("yarn").Value.String() == "true" { + functions.ExecBashCmd("yarn", bash_args...) + } else { + functions.ExecBashCmd("pnpm", bash_args...) + } + }, } diff --git a/cmd/serverless/functions/remove/remove.go b/cmd/serverless/functions/remove/remove.go index e20ad26..4cfbca4 100644 --- a/cmd/serverless/functions/remove/remove.go +++ b/cmd/serverless/functions/remove/remove.go @@ -17,9 +17,14 @@ var RemoveCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { bash_args := []string{"remove", args[0]} if cmd.Flag("dev").Value.String() == "true" { - bash_args = append(bash_args, "--dev") + bash_args = append(bash_args, "-D") } - functions.ExecBashCmd("yarn", bash_args...) + if cmd.Flag("yarn").Value.String() == "true" { + functions.ExecBashCmd("yarn", bash_args...) + } else { + functions.ExecBashCmd("pnpm", bash_args...) + } + }, } diff --git a/cmd/serverless/install/install.go b/cmd/serverless/install/install.go index 994c87f..7f4ffbb 100644 --- a/cmd/serverless/install/install.go +++ b/cmd/serverless/install/install.go @@ -19,7 +19,11 @@ var InstallCmd = &cobra.Command{ if cmd.Flag("force").Value.String() == "true" { bash_args = append(bash_args, "--force") } - serverless.ExecBashCmd("yarn", bash_args...) + if cmd.Flag("yarn").Value.String() == "true" { + serverless.ExecBashCmd("yarn", bash_args...) + } else { + serverless.ExecBashCmd("pnpm", bash_args...) + } }, } diff --git a/cmd/serverless/serverless.go b/cmd/serverless/serverless.go index c1bd309..4c22d7e 100644 --- a/cmd/serverless/serverless.go +++ b/cmd/serverless/serverless.go @@ -20,6 +20,7 @@ var ServerlessCmd = &cobra.Command{ func init() { cmd.RootCmd.AddCommand(ServerlessCmd) + cmd.RootCmd.PersistentFlags().Bool("yarn", false, "Uses yarn instead of pnpm") } func ExecBashCmd(name string, args ...string) string { diff --git a/cmd/serverless/start/start.go b/cmd/serverless/start/start.go index 71f8a65..270d82b 100644 --- a/cmd/serverless/start/start.go +++ b/cmd/serverless/start/start.go @@ -15,7 +15,11 @@ var StartCmd = &cobra.Command{ Long: `Starts SST's Live Lambda Development environment in the terminal`, Args: cobra.ExactArgs(0), Run: func(cmd *cobra.Command, args []string) { - serverless.ExecBashCmd("yarn", "sst", "dev") + if cmd.Flag("yarn").Value.String() == "true" { + serverless.ExecBashCmd("yarn", "sst", "dev") + } else { + serverless.ExecBashCmd("pnpm", "sst", "dev") + } }, }