From 165a78ff1a0cc3b8b0da998e6e9c13b9e22ec217 Mon Sep 17 00:00:00 2001 From: Daniel Wu Date: Sun, 29 Oct 2023 22:20:01 -0400 Subject: [PATCH 1/2] add pnpm for frontend --- cmd/frontend/add/add.go | 8 ++++++-- cmd/frontend/frontend.go | 1 + cmd/frontend/install/install.go | 6 +++++- cmd/frontend/remove/remove.go | 8 ++++++-- cmd/frontend/start/start.go | 7 ++++++- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/cmd/frontend/add/add.go b/cmd/frontend/add/add.go index 59e4b62..ba1cccf 100644 --- a/cmd/frontend/add/add.go +++ b/cmd/frontend/add/add.go @@ -17,9 +17,13 @@ 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") + } + if cmd.Flag("yarn").Value.String() == "true" { + frontend.ExecBashCmd("yarn", bash_args...) + } else { + frontend.ExecBashCmd("pnpm", bash_args...) } - frontend.ExecBashCmd("yarn", bash_args...) }, } diff --git a/cmd/frontend/frontend.go b/cmd/frontend/frontend.go index 2dc6f9d..1428ba2 100644 --- a/cmd/frontend/frontend.go +++ b/cmd/frontend/frontend.go @@ -21,6 +21,7 @@ var FrontendCmd = &cobra.Command{ func init() { cmd.RootCmd.AddCommand(FrontendCmd) + FrontendCmd.PersistentFlags().Bool("yarn", false, "Uses yarn instead of pnpm") } func ExecBashCmd(name string, args ...string) string { diff --git a/cmd/frontend/install/install.go b/cmd/frontend/install/install.go index d2ce2cb..753e541 100644 --- a/cmd/frontend/install/install.go +++ b/cmd/frontend/install/install.go @@ -19,7 +19,11 @@ var InstallCmd = &cobra.Command{ if cmd.Flag("force").Value.String() == "true" { bash_args = append(bash_args, "--force") } - frontend.ExecBashCmd("yarn", bash_args...) + if cmd.Flag("yarn").Value.String() == "true" { + frontend.ExecBashCmd("yarn", bash_args...) + } else { + frontend.ExecBashCmd("pnpm", bash_args...) + } }, } diff --git a/cmd/frontend/remove/remove.go b/cmd/frontend/remove/remove.go index 1b6cd9a..b2fc0e8 100644 --- a/cmd/frontend/remove/remove.go +++ b/cmd/frontend/remove/remove.go @@ -17,9 +17,13 @@ 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") + } + if cmd.Flag("yarn").Value.String() == "true" { + frontend.ExecBashCmd("yarn", bash_args...) + } else { + frontend.ExecBashCmd("pnpm", bash_args...) } - frontend.ExecBashCmd("yarn", bash_args...) }, } diff --git a/cmd/frontend/start/start.go b/cmd/frontend/start/start.go index a5f4632..cd5965d 100644 --- a/cmd/frontend/start/start.go +++ b/cmd/frontend/start/start.go @@ -17,7 +17,12 @@ var StartCmd = &cobra.Command{ Long: `Starts an instance of the nextjs frontend in the terminal`, Args: cobra.ExactArgs(0), Run: func(cmd *cobra.Command, args []string) { - frontend.ExecBashCmd("yarn", "next", "dev", "-p", fmt.Sprintf("%v", cmd.Flag("port").Value)) + if cmd.Flag("yarn").Value.String() == "true" { + frontend.ExecBashCmd("yarn", "start", "-p", fmt.Sprintf("%v", cmd.Flag("port").Value)) + } else { + frontend.ExecBashCmd("pnpm", "start", "-p", fmt.Sprintf("%v", cmd.Flag("port").Value)) + } + }, } From b49009ac04a20a193e07024b70537d508d7d182d Mon Sep 17 00:00:00 2001 From: Daniel Wu Date: Sun, 29 Oct 2023 23:05:13 -0400 Subject: [PATCH 2/2] 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") + } }, }