From 331f4dcc1ba023caad58163e1eb25c5d9c243910 Mon Sep 17 00:00:00 2001 From: Lincoln Nogueira Date: Sun, 22 Oct 2023 11:09:25 -0300 Subject: [PATCH] chore: update dev scripts (#2427) - add type-gen - remove some unused air settings - restrict air monitoring to changed go files --- scripts/.air-windows.toml | 6 +++--- scripts/.air.toml | 4 ++-- scripts/build.ps1 | 11 +++++++++++ scripts/build.sh | 8 ++++++++ scripts/start.ps1 | 39 +++++++++++++++++++++++++++++---------- 5 files changed, 53 insertions(+), 15 deletions(-) diff --git a/scripts/.air-windows.toml b/scripts/.air-windows.toml index 7c1e7f69..dcdd7799 100644 --- a/scripts/.air-windows.toml +++ b/scripts/.air-windows.toml @@ -6,10 +6,10 @@ bin = "./.air/memos.exe --mode dev" cmd = "go build -o ./.air/memos.exe ./main.go" delay = 1000 exclude_dir = [".air", "web", "build"] +include_ext = ["go", "mod", "sum"] exclude_file = [] exclude_regex = [] -exclude_unchanged = false +exclude_unchanged = true follow_symlink = false -full_bin = "" -send_interrupt = true kill_delay = 2000 +stop_on_error = true diff --git a/scripts/.air.toml b/scripts/.air.toml index 232b10d0..9a39fb39 100644 --- a/scripts/.air.toml +++ b/scripts/.air.toml @@ -6,11 +6,11 @@ bin = "./.air/memos --mode dev" cmd = "go build -o ./.air/memos ./main.go" delay = 1000 exclude_dir = [".air", "web", "build"] +include_ext = ["go", "mod", "sum"] exclude_file = [] exclude_regex = [] -exclude_unchanged = false +exclude_unchanged = true follow_symlink = false -full_bin = "" send_interrupt = true kill_delay = 2000 stop_on_error = true diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 7e171ae8..59991c55 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -73,6 +73,17 @@ if (!$?) { Write-Host "Frontend built!" -f green } +Write-Host "`nGenerating buf types..." -f DarkYellow +$frontendTime = Measure-Command { + &pnpm type-gen | Out-Host +} +if (!$?) { + Write-Host -BackgroundColor red -ForegroundColor white "Could not generate buf types. See above." + Exit 1 +} else { + Write-Host "buf types generated!" -f green +} + Write-Host "`nBacking up frontend placeholder..." -f Magenta Move-Item "$repoRoot/server/dist" "$repoRoot/server/dist.bak" -Force -ErrorAction Stop if (!$?) { diff --git a/scripts/build.sh b/scripts/build.sh index eeb1434c..91c76843 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -74,6 +74,14 @@ if [ $? -ne 0 ]; then fi echo -e "\033[32mFrontend dependencies installed!\033[0m" +echo -e "\n\033[33mGenerating buf types...\033[0m" +pnpm type-gen +if [ $? -ne 0 ]; then + echo -e "\033[0;31mCould not generate buf types! Exiting.\033[0m" + exit 1 +fi +echo -e "\033[32mbuf types generated!\033[0m" + echo -e "\n\033[33mBuilding frontend...\033[0m" pnpm build if [ $? -ne 0 ]; then diff --git a/scripts/start.ps1 b/scripts/start.ps1 index a1c8f423..f03b5942 100644 --- a/scripts/start.ps1 +++ b/scripts/start.ps1 @@ -18,24 +18,43 @@ foreach ($dir in @(".", "../")) { $frontendPort = 3001 # Tasks to run, in order $runTasks = @( + @{ + Desc = "install frontend dependencies"; + Exe = "powershell.exe"; + Args = ( + "-Command", + "pnpm i" + ); + Dir = "$repoRoot/web" + Wait = $true; + }, + @{ + Desc = "generate buf types"; + Exe = "powershell.exe"; + Args = ( + "-Command", + "pnpm type-gen" + ); + Dir = "$repoRoot/web" + Wait = $true; + }, @{ Desc = "start backend with live reload"; Exe = "air.exe"; - Args = "-c .\scripts\.air-windows.toml"; + Args = ( + "-c", + ".\scripts\.air-windows.toml" + ); Dir = "$repoRoot"; Wait = $false; }, - @{ - Desc = "install frontend dependencies"; - Exe = "pnpm.exe"; - Args = "i"; - Dir = "$repoRoot/web" - Wait = $true; - } @{ Desc = "start frontend with live reload"; - Exe = "pnpm.exe"; - Args = "dev"; + Exe = "powershell.exe"; + Args = ( + "-Command", + "pnpm dev" + ); Dir = "$repoRoot/web"; Wait = $false; }