-
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
53 changed files
with
1,338 additions
and
1,055 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,62 @@ | ||
# SAC (Student Activity Calendar) CLI | ||
|
||
[![CLI](https://github.com/GenerateNU/sac/actions/workflows/cli.yml/badge.svg)](https://github.com/GenerateNU/sac/actions/workflows/cli.yml) | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/GenerateNU/sac/cli)](https://goreportcard.com/report/github.com/GenerateNU/sac/cli) | ||
[![License](https://img.shields.io/github/license/GenerateNU/sac)](https://github.com/GenerateNU/sac/blob/main/LICENSE) | ||
|
||
|
||
|
||
## Introduction | ||
The SAC CLI is a tool designed to help manage and automate tasks for the GenerateNU Student Activity Calendar platform. It provides a comprehensive suite of commands for formatting, testing, linting, running, and managing databases and other configurations essential for the SAC platform. | ||
|
||
## Table of Contents | ||
|
||
1. [Installation](#installation) | ||
2. [Usage](#usage) | ||
3. [Available Commands](#available-commands) | ||
4. [Command Aliases](#command-aliases) | ||
5. [Dependencies](#dependencies) | ||
|
||
## Installation | ||
|
||
To install the SAC CLI, clone the repository and run the following script from the root of the application: | ||
|
||
```bash | ||
./install_cli.sh | ||
``` | ||
|
||
## Usage | ||
|
||
To use the SAC CLI, you can run it with various flags or commands: | ||
|
||
```bash | ||
sac [flags] | ||
sac [command] | ||
``` | ||
|
||
## Available Commands | ||
|
||
- **completion**: Generate the autocompletion script for the specified shell. | ||
- **database**: Database management commands. | ||
- **format**: Formatting commands. | ||
- **help**: Help about any command. | ||
- **lint**: Linting commands. | ||
- **run**: Run commands for backend and frontend. | ||
- **setup**: Installs and sets up the project. (WIP) | ||
- **swagger**: Run swagger initialization for backend openapi spec. | ||
- **test**: Testing commands. | ||
|
||
For more detailed information about a command, use: | ||
|
||
```bash | ||
sac [command] --help | ||
``` | ||
|
||
## Command Aliases | ||
|
||
Several commands in the SAC CLI are equipped with short aliases to make them quicker and easier to use. For example, a command like `sac format frontend dashboard` which is pretty lengthy can be shortened to `sac f fe d`. | ||
|
||
## Dependencies | ||
|
||
- `golangci-lint`: A linter aggregator for Go, ensuring code quality. | ||
- `gofumpt`: A stricter formatter for Go code, ensuring consistency. |
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) | ||
} | ||
}, | ||
} |
Oops, something went wrong.