Skip to content

Commit

Permalink
Merge pull request #11 from DSGT-DLP/pnpm
Browse files Browse the repository at this point in the history
Pnpm
  • Loading branch information
dwu359 authored Nov 1, 2023
2 parents 1d4a279 + b49009a commit 160b391
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 16 deletions.
8 changes: 6 additions & 2 deletions cmd/frontend/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
},
}

Expand Down
1 change: 1 addition & 0 deletions cmd/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion cmd/frontend/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}
},
}

Expand Down
8 changes: 6 additions & 2 deletions cmd/frontend/remove/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
},
}

Expand Down
7 changes: 6 additions & 1 deletion cmd/frontend/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

},
}

Expand Down
9 changes: 7 additions & 2 deletions cmd/serverless/core/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}

},
}

Expand Down
9 changes: 7 additions & 2 deletions cmd/serverless/core/remove/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}

},
}

Expand Down
9 changes: 7 additions & 2 deletions cmd/serverless/functions/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}

},
}

Expand Down
9 changes: 7 additions & 2 deletions cmd/serverless/functions/remove/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}

},
}

Expand Down
6 changes: 5 additions & 1 deletion cmd/serverless/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}
},
}

Expand Down
1 change: 1 addition & 0 deletions cmd/serverless/serverless.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion cmd/serverless/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
},
}

Expand Down

0 comments on commit 160b391

Please sign in to comment.