-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
56 changed files
with
1,356 additions
and
1,172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,4 @@ linters: | |
|
||
linters-settings: | ||
whitespace: | ||
multi-func: true | ||
multi-func: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/GenerateNU/sac/cli/helpers" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var dbCmd = &cobra.Command{ | ||
Use: "database", | ||
Aliases: []string{"db"}, | ||
Short: "Database management commands", | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(dbCmd) | ||
dbCmd.AddCommand(dbInitCmd) | ||
dbCmd.AddCommand(dbDownCmd) | ||
dbCmd.AddCommand(dbResetCmd) | ||
dbCmd.AddCommand(dbInsertCmd) | ||
} | ||
|
||
var dbInitCmd = &cobra.Command{ | ||
Use: "init", | ||
Short: "Initialize the database", | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := helpers.InitDB() | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
var dbDownCmd = &cobra.Command{ | ||
Use: "down", | ||
Short: "Migrate down the database", | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := helpers.DownDB() | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
var dbResetCmd = &cobra.Command{ | ||
Use: "reset", | ||
Short: "Reset the database", | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := helpers.DownDB() | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
|
||
err = helpers.InitDB() | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
var dbInsertCmd = &cobra.Command{ | ||
Use: "insert", | ||
Short: "Insert mock data into the database", | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := helpers.InsertDB() | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
|
||
"github.com/GenerateNU/sac/cli/helpers" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var formatCmd = &cobra.Command{ | ||
Use: "format", | ||
Aliases: []string{"f"}, | ||
Short: "Formatting commands", | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(formatCmd) | ||
formatCmd.AddCommand(formatFrontendCmd) | ||
formatCmd.AddCommand(formatBackendCmd) | ||
formatCmd.AddCommand(formatCliCmd) | ||
|
||
formatFrontendCmd.AddCommand(formatWebCmd) | ||
formatFrontendCmd.AddCommand(formatMobileCmd) | ||
formatFrontendCmd.AddCommand(formatDashboardCmd) | ||
formatFrontendCmd.AddCommand(formatLibCmd) | ||
} | ||
|
||
var formatFrontendCmd = &cobra.Command{ | ||
Use: "frontend", | ||
Aliases: []string{"fe"}, | ||
Short: "Frontend formatting commands", | ||
} | ||
|
||
var formatWebCmd = &cobra.Command{ | ||
Use: "web", | ||
Aliases: []string{"w"}, | ||
Short: "Frontend web formatting commands", | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := helpers.Execute(exec.Command("yarn", "run", "format"), helpers.WEB_DIR) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
var formatMobileCmd = &cobra.Command{ | ||
Use: "mobile", | ||
Aliases: []string{"m"}, | ||
Short: "Formats the frontend mobile", | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := helpers.Execute(exec.Command("yarn", "run", "format"), helpers.MOBILE_DIR) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
var formatDashboardCmd = &cobra.Command{ | ||
Use: "dashboard", | ||
Aliases: []string{"d"}, | ||
Short: "Formats the frontend dashboard", | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := helpers.Execute(exec.Command("yarn", "run", "format"), helpers.DASHBOARD_DIR) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
var formatLibCmd = &cobra.Command{ | ||
Use: "lib", | ||
Aliases: []string{"l"}, | ||
Short: "Formats the frontend lib", | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := helpers.Execute(exec.Command("yarn", "run", "format"), helpers.LIB_DIR) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
var formatBackendCmd = &cobra.Command{ | ||
Use: "backend", | ||
Short: "Formats the backend", | ||
Aliases: []string{"be"}, | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
_, err := exec.LookPath("gofumpt") | ||
if err != nil { | ||
fmt.Println("gofumpt is not installed. Please run the following command to install it:") | ||
fmt.Println("go install mvdan.cc/gofumpt@latest") | ||
os.Exit(1) | ||
} | ||
|
||
err = helpers.Execute(exec.Command("gofumpt", "-l", "-w", "."), helpers.BACKEND_DIR) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
var formatCliCmd = &cobra.Command{ | ||
Use: "cli", | ||
Short: "Formats the cli", | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
_, err := exec.LookPath("gofumpt") | ||
if err != nil { | ||
fmt.Println("gofumpt is not installed. Please run the following command to install it:") | ||
fmt.Println("go install mvdan.cc/gofumpt@latest") | ||
os.Exit(1) | ||
} | ||
|
||
err = helpers.Execute(exec.Command("gofumpt", "-l", "-w", "."), helpers.CLI_DIR) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
|
||
"github.com/GenerateNU/sac/cli/helpers" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var lintCmd = &cobra.Command{ | ||
Use: "lint", | ||
Aliases: []string{"l"}, | ||
Short: "Linting commands", | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(lintCmd) | ||
lintCmd.AddCommand(lintFrontendCmd) | ||
lintCmd.AddCommand(lintBackendCmd) | ||
lintCmd.AddCommand(lintCliCmd) | ||
|
||
lintFrontendCmd.AddCommand(lintWebCmd) | ||
lintFrontendCmd.AddCommand(lintMobileCmd) | ||
lintFrontendCmd.AddCommand(lintDashboardCmd) | ||
lintFrontendCmd.AddCommand(lintLibCmd) | ||
} | ||
|
||
var lintFrontendCmd = &cobra.Command{ | ||
Use: "frontend", | ||
Aliases: []string{"fe"}, | ||
Short: "Frontend linting commands", | ||
} | ||
|
||
var lintWebCmd = &cobra.Command{ | ||
Use: "web", | ||
Short: "Lints the frontend web", | ||
Aliases: []string{"w"}, | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := helpers.Execute(exec.Command("yarn", "run", "lint", "--fix"), helpers.WEB_DIR) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
var lintMobileCmd = &cobra.Command{ | ||
Use: "mobile", | ||
Short: "Lints the frontend mobile", | ||
Aliases: []string{"m"}, | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := helpers.Execute(exec.Command("yarn", "run", "lint", "--fix"), helpers.MOBILE_DIR) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
var lintDashboardCmd = &cobra.Command{ | ||
Use: "dashboard", | ||
Short: "Lints the frontend dashboard", | ||
Aliases: []string{"d"}, | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := helpers.Execute(exec.Command("yarn", "run", "lint", "--fix"), helpers.DASHBOARD_DIR) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
var lintLibCmd = &cobra.Command{ | ||
Use: "lib", | ||
Short: "Lints the lib directory", | ||
Aliases: []string{"l"}, | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := helpers.Execute(exec.Command("yarn", "run", "lint", "--fix"), helpers.LIB_DIR) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
var lintBackendCmd = &cobra.Command{ | ||
Use: "backend", | ||
Short: "Lints the backend", | ||
Aliases: []string{"be"}, | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
_, err := exec.LookPath("golangci-lint") | ||
if err != nil { | ||
fmt.Println("golangci-lint is not installed. Please install it by running the following command:") | ||
fmt.Println("curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.57.2") | ||
os.Exit(1) | ||
} | ||
|
||
err = helpers.Execute(exec.Command("golangci-lint", "run", "--fix"), helpers.BACKEND_DIR) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
var lintCliCmd = &cobra.Command{ | ||
Use: "cli", | ||
Short: "Lints the CLI", | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
_, err := exec.LookPath("golangci-lint") | ||
if err != nil { | ||
fmt.Println("golangci-lint is not installed. Please install it by running the following command:") | ||
fmt.Println("curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.57.2") | ||
os.Exit(1) | ||
} | ||
|
||
err = helpers.Execute(exec.Command("golangci-lint", "run", "--fix"), helpers.CLI_DIR) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
Copyright © 2024 NAME HERE <EMAIL ADDRESS> | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// rootCmd represents the base command when called without any subcommands | ||
var rootCmd = &cobra.Command{ | ||
Use: "sac", | ||
Short: "SAC manages the GenerateNU Student Activity Calendar platform", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return cmd.Help() | ||
}, | ||
} | ||
|
||
// Execute adds all child commands to the root command and sets flags appropriately. | ||
// This is called by main.main(). It only needs to happen once to the rootCmd. | ||
func Execute() { | ||
err := rootCmd.Execute() | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
} |
Oops, something went wrong.