Skip to content

Commit 331f4dc

Browse files
chore: update dev scripts (usememos#2427)
- add type-gen - remove some unused air settings - restrict air monitoring to changed go files
1 parent 055b246 commit 331f4dc

5 files changed

Lines changed: 53 additions & 15 deletions

File tree

scripts/.air-windows.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ bin = "./.air/memos.exe --mode dev"
66
cmd = "go build -o ./.air/memos.exe ./main.go"
77
delay = 1000
88
exclude_dir = [".air", "web", "build"]
9+
include_ext = ["go", "mod", "sum"]
910
exclude_file = []
1011
exclude_regex = []
11-
exclude_unchanged = false
12+
exclude_unchanged = true
1213
follow_symlink = false
13-
full_bin = ""
14-
send_interrupt = true
1514
kill_delay = 2000
15+
stop_on_error = true

scripts/.air.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ bin = "./.air/memos --mode dev"
66
cmd = "go build -o ./.air/memos ./main.go"
77
delay = 1000
88
exclude_dir = [".air", "web", "build"]
9+
include_ext = ["go", "mod", "sum"]
910
exclude_file = []
1011
exclude_regex = []
11-
exclude_unchanged = false
12+
exclude_unchanged = true
1213
follow_symlink = false
13-
full_bin = ""
1414
send_interrupt = true
1515
kill_delay = 2000
1616
stop_on_error = true

scripts/build.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ if (!$?) {
7373
Write-Host "Frontend built!" -f green
7474
}
7575

76+
Write-Host "`nGenerating buf types..." -f DarkYellow
77+
$frontendTime = Measure-Command {
78+
&pnpm type-gen | Out-Host
79+
}
80+
if (!$?) {
81+
Write-Host -BackgroundColor red -ForegroundColor white "Could not generate buf types. See above."
82+
Exit 1
83+
} else {
84+
Write-Host "buf types generated!" -f green
85+
}
86+
7687
Write-Host "`nBacking up frontend placeholder..." -f Magenta
7788
Move-Item "$repoRoot/server/dist" "$repoRoot/server/dist.bak" -Force -ErrorAction Stop
7889
if (!$?) {

scripts/build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ if [ $? -ne 0 ]; then
7474
fi
7575
echo -e "\033[32mFrontend dependencies installed!\033[0m"
7676

77+
echo -e "\n\033[33mGenerating buf types...\033[0m"
78+
pnpm type-gen
79+
if [ $? -ne 0 ]; then
80+
echo -e "\033[0;31mCould not generate buf types! Exiting.\033[0m"
81+
exit 1
82+
fi
83+
echo -e "\033[32mbuf types generated!\033[0m"
84+
7785
echo -e "\n\033[33mBuilding frontend...\033[0m"
7886
pnpm build
7987
if [ $? -ne 0 ]; then

scripts/start.ps1

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,43 @@ foreach ($dir in @(".", "../")) {
1818
$frontendPort = 3001
1919
# Tasks to run, in order
2020
$runTasks = @(
21+
@{
22+
Desc = "install frontend dependencies";
23+
Exe = "powershell.exe";
24+
Args = (
25+
"-Command",
26+
"pnpm i"
27+
);
28+
Dir = "$repoRoot/web"
29+
Wait = $true;
30+
},
31+
@{
32+
Desc = "generate buf types";
33+
Exe = "powershell.exe";
34+
Args = (
35+
"-Command",
36+
"pnpm type-gen"
37+
);
38+
Dir = "$repoRoot/web"
39+
Wait = $true;
40+
},
2141
@{
2242
Desc = "start backend with live reload";
2343
Exe = "air.exe";
24-
Args = "-c .\scripts\.air-windows.toml";
44+
Args = (
45+
"-c",
46+
".\scripts\.air-windows.toml"
47+
);
2548
Dir = "$repoRoot";
2649
Wait = $false;
2750
},
28-
@{
29-
Desc = "install frontend dependencies";
30-
Exe = "pnpm.exe";
31-
Args = "i";
32-
Dir = "$repoRoot/web"
33-
Wait = $true;
34-
}
3551
@{
3652
Desc = "start frontend with live reload";
37-
Exe = "pnpm.exe";
38-
Args = "dev";
53+
Exe = "powershell.exe";
54+
Args = (
55+
"-Command",
56+
"pnpm dev"
57+
);
3958
Dir = "$repoRoot/web";
4059
Wait = $false;
4160
}

0 commit comments

Comments
 (0)