Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/frontend/web/next-14…
Browse files Browse the repository at this point in the history
….2.3
  • Loading branch information
garrettladley authored Apr 26, 2024
2 parents adc73ad + 0683f69 commit 0b733cf
Show file tree
Hide file tree
Showing 30 changed files with 383 additions and 243 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/frontend_lib.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Frontend Lib

permissions: read-all

on:
push:
paths:
- frontend/lib/**
- .github/workflows/frontend_lib.yml
pull_request:
types: opened
paths:
- frontend/lib/**
- .github/workflows/frontend_lib.yml

jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn
cache-dependency-path: frontend/lib/yarn.lock
- name: Install dependencies
run: |
cd frontend/lib
yarn install
- name: Format
run: |
cd frontend/lib
yarn format
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn
cache-dependency-path: frontend/lib/yarn.lock
- name: Install dependencies
run: |
cd frontend/lib
yarn install
- name: Lint
run: |
cd frontend/lib
echo "Woah there, we have no we're not linting the lib as of right now. Let's just say we're passing." && exit 0
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn
cache-dependency-path: frontend/lib/yarn.lock
- name: Install dependencies
run: |
cd frontend/lib
yarn install
- name: Test
run: |
cd frontend/lib
yarn test
41 changes: 41 additions & 0 deletions .github/workflows/frontend_lib_codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Frontend Lib CodeQL

on:
push:
paths:
- "frontend/lib/**"
- ".github/workflows/frontend_lib_codeql.yml"
pull_request:
types: [opened]
paths:
- "frontend/lib/**"
- ".github/workflows/frontend_lib_codeql.yml"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
security-events: write
strategy:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: javascript-typescript
queries: security-and-quality
- name: Autobuild
uses: github/codeql-action/autobuild@v3
with:
working-directory: frontend/lib
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: lib
2 changes: 1 addition & 1 deletion backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22.2

require (
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/aws/aws-sdk-go v1.51.25
github.com/aws/aws-sdk-go v1.51.30
github.com/garrettladley/mattress v0.4.0
github.com/go-playground/validator/v10 v10.19.0
github.com/goccy/go-json v0.10.2
Expand Down
4 changes: 2 additions & 2 deletions backend/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ github.com/awnumar/memcall v0.2.0 h1:sRaogqExTOOkkNwO9pzJsL8jrOV29UuUW7teRMfbqtI
github.com/awnumar/memcall v0.2.0/go.mod h1:S911igBPR9CThzd/hYQQmTc9SWNu3ZHIlCGaWsWsoJo=
github.com/awnumar/memguard v0.22.5 h1:PH7sbUVERS5DdXh3+mLo8FDcl1eIeVjJVYMnyuYpvuI=
github.com/awnumar/memguard v0.22.5/go.mod h1:+APmZGThMBWjnMlKiSM1X7MVpbIVewen2MTkqWkA/zE=
github.com/aws/aws-sdk-go v1.51.25 h1:DjTT8mtmsachhV6yrXR8+yhnG6120dazr720nopRsls=
github.com/aws/aws-sdk-go v1.51.25/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go v1.51.30 h1:RVFkjn9P0JMwnuZCVH0TlV5k9zepHzlbc4943eZMhGw=
github.com/aws/aws-sdk-go v1.51.30/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
Expand Down
28 changes: 22 additions & 6 deletions cli/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,26 @@ import (
)

var (
ROOT_DIR, _ = utils.GetRootDir()
FRONTEND_DIR = filepath.Join(ROOT_DIR, "/frontend")
BACKEND_DIR = filepath.Join(ROOT_DIR, "/backend")
CONFIG = filepath.Join(ROOT_DIR, "/config")
MIGRATIONS = filepath.Join(BACKEND_DIR, "/migrations")
MOCK_FILE = filepath.Join(BACKEND_DIR, "/mock/data.sql")
ROOT_DIR, _ = utils.GetRootDir()
FRONTEND_DIR = filepath.Join(ROOT_DIR, "/frontend")
MOBILE_DIR = filepath.Join(FRONTEND_DIR, "/mobile")
DASHBOARD_DIR = filepath.Join(FRONTEND_DIR, "/dashboard")
LIB_DIR = filepath.Join(FRONTEND_DIR, "/lib")
WEB_DIR = filepath.Join(FRONTEND_DIR, "/web")
BACKEND_DIR = filepath.Join(ROOT_DIR, "/backend")
CONFIG = filepath.Join(ROOT_DIR, "/config")
MIGRATIONS = filepath.Join(BACKEND_DIR, "/migrations")
MOCK_FILE = filepath.Join(BACKEND_DIR, "/mock/data.sql")
)

var (
FRONTEND_RUN_TARGETS = []string{"web", "mobile", "dashboard"}
FRONTEND_CI_TARGETS = []string{"web", "mobile", "dashboard", "lib"}
)

var TARGET_DIRS = map[string]string{
"web": WEB_DIR,
"mobile": MOBILE_DIR,
"dashboard": DASHBOARD_DIR,
"lib": LIB_DIR,
}
48 changes: 20 additions & 28 deletions cli/commands/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"os/exec"
"slices"

"github.com/urfave/cli/v2"
)
Expand Down Expand Up @@ -33,8 +34,8 @@ func FormatCommand() *cli.Command {
}

target := c.String("target")
if target != "web" && target != "mobile" {
return cli.Exit("Invalid frontend type: must be 'web' or 'mobile'", 1)
if !slices.Contains(FRONTEND_CI_TARGETS, target) {
return cli.Exit("Invalid frontend type: must be 'web', 'mobile', 'dashboard', or 'lib'", 1)
}

err := FormatFrontend(target)
Expand Down Expand Up @@ -69,14 +70,24 @@ func FormatCommand() *cli.Command {
}

func FormatFrontend(target string) error {
switch target {
case "web":
return FormatWeb()
case "mobile":
return FormatMobile()
default:
return FormatMobile()
dir, ok := TARGET_DIRS[target]
if !ok {
return cli.Exit("Invalid frontend type", 1)
}

cmd := exec.Command("yarn", "run", "format")

cmd.Dir = dir

cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin

if err := cmd.Run(); err != nil {
return err
}

return nil
}

func FormatBackend() error {
Expand All @@ -93,22 +104,3 @@ func FormatBackend() error {
fmt.Println("Backend formatted")
return nil
}

func FormatWeb() error {
return nil
}

func FormatMobile() error {
mobileCmd := exec.Command("yarn", "run", "format")
mobileCmd.Dir = FRONTEND_DIR + "/mobile"

mobileCmd.Stdout = os.Stdout
mobileCmd.Stderr = os.Stderr
mobileCmd.Stdin = os.Stdin

if err := mobileCmd.Run(); err != nil {
return err
}

return nil
}
36 changes: 32 additions & 4 deletions cli/commands/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package commands
import (
"os"
"os/exec"
"slices"

"github.com/urfave/cli/v2"
)
Expand Down Expand Up @@ -31,9 +32,8 @@ func FrontendCommand() *cli.Command {
return cli.Exit("Invalid arguments", 1)
}

target := c.String("target")
if target != "web" && target != "mobile" {
return cli.Exit("Invalid frontend type: must be 'web' or 'mobile'", 1)
if !slices.Contains(FRONTEND_RUN_TARGETS, c.String("target")) {
return cli.Exit("Invalid frontend type: must be 'web', 'mobile', or 'dashboard'", 1)
}

err := RunFE(c.String("type"), c.String("platform"))
Expand All @@ -54,14 +54,16 @@ func RunFE(feType string, platform string) error {
return RunMobileFE(platform)
case "web":
return RunWebFE()
case "dashboard":
return RunDashboardFE()
default:
return RunMobileFE(platform)
}
}

func RunMobileFE(platform string) error {
mobileCmd := exec.Command("yarn", "run", platform)
mobileCmd.Dir = FRONTEND_DIR + "/mobile"
mobileCmd.Dir = MOBILE_DIR

mobileCmd.Stdout = os.Stdout
mobileCmd.Stderr = os.Stderr
Expand All @@ -75,5 +77,31 @@ func RunMobileFE(platform string) error {
}

func RunWebFE() error {
webCmd := exec.Command("yarn", "run")
webCmd.Dir = WEB_DIR

webCmd.Stdout = os.Stdout
webCmd.Stderr = os.Stderr
webCmd.Stdin = os.Stdin

if err := webCmd.Run(); err != nil {
return err
}

return nil
}

func RunDashboardFE() error {
dashboardCmd := exec.Command("yarn", "run")
dashboardCmd.Dir = DASHBOARD_DIR

dashboardCmd.Stdout = os.Stdout
dashboardCmd.Stderr = os.Stderr
dashboardCmd.Stdin = os.Stdin

if err := dashboardCmd.Run(); err != nil {
return err
}

return nil
}
Loading

0 comments on commit 0b733cf

Please sign in to comment.