Skip to content

Commit 2509f76

Browse files
authored
Merge branch 'main' into fix/auth-error-handling
2 parents f0989c8 + 52ce174 commit 2509f76

308 files changed

Lines changed: 7017 additions & 18569 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main-ci.yml

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
# LinaPro backend main CI workflow.
2-
# Runs on every push and pull request to main.
2+
# Runs on every push and pull request branch.
33
name: Main CI
44

55
on:
66
push:
77
branches:
8-
- main
9-
- develop
10-
- feat/**
11-
- fix/**
12-
13-
pull_request:
14-
branches:
15-
- main
16-
- develop
17-
- feat/**
18-
- fix/**
8+
- '**'
199

2010
workflow_dispatch:
2111
inputs:
@@ -34,6 +24,10 @@ env:
3424
TZ: "Asia/Shanghai"
3525

3626
jobs:
27+
windows-command-smoke:
28+
name: Windows command smoke
29+
uses: ./.github/workflows/reusable-windows-command-smoke.yml
30+
3731
backend-unit-tests:
3832
name: Go unit tests
3933
uses: ./.github/workflows/reusable-backend-unit-tests.yml
@@ -48,18 +42,18 @@ jobs:
4842

4943
steps:
5044
- name: Setup Timezone
51-
uses: szenius/set-timezone@v2.0
52-
with:
53-
timezoneLinux: "Asia/Shanghai"
45+
run: |
46+
sudo ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
47+
echo Asia/Shanghai | sudo tee /etc/timezone
5448
5549
- name: Checkout Repository
5650
uses: actions/checkout@v5
5751

5852
- name: Setup Go
59-
uses: actions/setup-go@v5
53+
uses: actions/setup-go@v6
6054
with:
6155
go-version: "1.25"
62-
cache-dependency-path: '**/go.sum'
56+
cache: false
6357

6458
- name: Run SQLite Backend Smoke
6559
run: |

.github/workflows/nightly-build.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ env:
2222
PLATFORMS: "linux/amd64,linux/arm64"
2323

2424
jobs:
25+
windows-command-smoke:
26+
name: Windows command smoke
27+
uses: ./.github/workflows/reusable-windows-command-smoke.yml
28+
2529
nightly-image:
2630
name: Build and publish nightly image
2731
runs-on: ubuntu-latest
@@ -32,13 +36,13 @@ jobs:
3236
uses: actions/checkout@v5
3337

3438
- name: Setup Go
35-
uses: actions/setup-go@v5
39+
uses: actions/setup-go@v6
3640
with:
3741
go-version: "1.25"
38-
cache-dependency-path: "**/go.sum"
42+
cache: false
3943

4044
- name: Setup pnpm
41-
uses: pnpm/action-setup@v4
45+
uses: pnpm/action-setup@v6
4246
with:
4347
version: "10.30.3"
4448
run_install: false

.github/workflows/nightly-test.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ env:
1919
TZ: "Asia/Shanghai"
2020

2121
jobs:
22+
windows-command-smoke:
23+
name: Windows command smoke
24+
uses: ./.github/workflows/reusable-windows-command-smoke.yml
25+
2226
backend-unit-tests:
2327
name: Go unit tests
2428
uses: ./.github/workflows/reusable-backend-unit-tests.yml
@@ -50,21 +54,21 @@ jobs:
5054
5155
steps:
5256
- name: Setup Timezone
53-
uses: szenius/set-timezone@v2.0
54-
with:
55-
timezoneLinux: "Asia/Shanghai"
57+
run: |
58+
sudo ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
59+
echo Asia/Shanghai | sudo tee /etc/timezone
5660
5761
- name: Checkout Repository
5862
uses: actions/checkout@v5
5963

6064
- name: Setup Go
61-
uses: actions/setup-go@v5
65+
uses: actions/setup-go@v6
6266
with:
6367
go-version: "1.25"
64-
cache-dependency-path: "**/go.sum"
68+
cache: false
6569

6670
- name: Setup pnpm
67-
uses: pnpm/action-setup@v4
71+
uses: pnpm/action-setup@v6
6872
with:
6973
version: "10.30.3"
7074
run_install: false

.github/workflows/release-build.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ env:
2020
PLATFORMS: "linux/amd64,linux/arm64"
2121

2222
jobs:
23+
windows-command-smoke:
24+
name: Windows command smoke
25+
uses: ./.github/workflows/reusable-windows-command-smoke.yml
26+
2327
release-image:
2428
name: Build and publish release image
2529
if: ${{ github.event.created == true && startsWith(github.ref, 'refs/tags/') }}
@@ -31,13 +35,13 @@ jobs:
3135
uses: actions/checkout@v5
3236

3337
- name: Setup Go
34-
uses: actions/setup-go@v5
38+
uses: actions/setup-go@v6
3539
with:
3640
go-version: "1.25"
37-
cache-dependency-path: "**/go.sum"
41+
cache: false
3842

3943
- name: Setup pnpm
40-
uses: pnpm/action-setup@v4
44+
uses: pnpm/action-setup@v6
4145
with:
4246
version: "10.30.3"
4347
run_install: false

.github/workflows/reusable-backend-unit-tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ jobs:
3434
3535
steps:
3636
- name: Setup Timezone
37-
uses: szenius/set-timezone@v2.0
38-
with:
39-
timezoneLinux: "Asia/Shanghai"
37+
run: |
38+
sudo ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
39+
echo Asia/Shanghai | sudo tee /etc/timezone
4040
4141
- name: Checkout Repository
4242
uses: actions/checkout@v5
4343

4444
- name: Setup Go
45-
uses: actions/setup-go@v5
45+
uses: actions/setup-go@v6
4646
with:
4747
go-version: "1.25"
48-
cache-dependency-path: "**/go.sum"
48+
cache: false
4949

5050
- name: Initialize Database Schema
5151
run: |

.github/workflows/reusable-frontend-unit-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ jobs:
1818

1919
steps:
2020
- name: Setup Timezone
21-
uses: szenius/set-timezone@v2.0
22-
with:
23-
timezoneLinux: "Asia/Shanghai"
21+
run: |
22+
sudo ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
23+
echo Asia/Shanghai | sudo tee /etc/timezone
2424
2525
- name: Checkout Repository
2626
uses: actions/checkout@v5
2727

2828
- name: Setup pnpm
29-
uses: pnpm/action-setup@v4
29+
uses: pnpm/action-setup@v6
3030
with:
3131
version: "10.30.3"
3232
run_install: false
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Reusable LinaPro Windows command smoke workflow.
2+
name: Reusable Windows Command Smoke
3+
4+
on:
5+
workflow_call:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
windows-command-smoke:
12+
name: Windows command smoke
13+
runs-on: windows-2025-vs2026
14+
timeout-minutes: 20
15+
16+
steps:
17+
- name: Checkout Repository
18+
uses: actions/checkout@v5
19+
20+
- name: Setup Go
21+
uses: actions/setup-go@v6
22+
with:
23+
go-version: "1.25"
24+
cache: false
25+
26+
- name: Verify linactl Basic Commands
27+
shell: pwsh
28+
run: |
29+
go run ./hack/tools/linactl help
30+
go run ./hack/tools/linactl status
31+
go run ./hack/tools/linactl prepare-packed-assets
32+
go run ./hack/tools/linactl wasm dry-run=true
33+
34+
- name: Verify make.cmd From cmd.exe
35+
shell: cmd
36+
run: |
37+
make.cmd help
38+
make.cmd status
39+
40+
- name: Verify make.cmd From PowerShell
41+
shell: pwsh
42+
run: |
43+
.\make.cmd help
44+
.\make.cmd status

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,35 @@ corepack enable
208208
cd apps/lina-vben
209209
pnpm install
210210
cd ../..
211+
go run ./hack/tools/linactl init confirm=init
212+
go run ./hack/tools/linactl mock confirm=mock
213+
go run ./hack/tools/linactl dev
214+
```
215+
216+
Linux and macOS users can keep using the compatibility `Makefile` entrypoint:
217+
218+
```bash
211219
make init confirm=init
212220
make mock confirm=mock
213221
make dev
214222
```
215223

224+
Windows users can use the cross-platform Go entrypoint above. The repository also provides a thin `make.cmd` wrapper for `cmd.exe`; because `cmd.exe` resolves executable file extensions in the current directory, the `.cmd` suffix can be omitted and the command can be written as `make`:
225+
226+
```cmd
227+
make init confirm=init
228+
make mock confirm=mock
229+
make dev
230+
```
231+
232+
In PowerShell, call the wrapper with the current-directory prefix. On default Windows environments, the `.cmd` suffix can also be omitted as `.\make`. Use `.\make.cmd` when you want to avoid ambiguity with another installed `make` command:
233+
234+
```powershell
235+
.\make init confirm=init
236+
.\make mock confirm=mock
237+
.\make dev
238+
```
239+
216240
The default backend link is:
217241

218242
```yaml
@@ -221,9 +245,9 @@ database:
221245
link: "pgsql:postgres:postgres@tcp(127.0.0.1:5432)/linapro?sslmode=disable"
222246
```
223247
224-
`make init` is an operations bootstrap command. It uses the configured database account and requires permission to connect to the system database, create and drop the target database, terminate target-database connections, create tables and indexes, write comments, and insert seed data. If those permissions are missing, initialization fails instead of falling back to a lower-privilege runtime mode.
248+
`linactl init` and `make init` are operations bootstrap commands. They use the configured database account and require permission to connect to the system database, create and drop the target database, terminate target-database connections, create tables and indexes, write comments, and insert seed data. If those permissions are missing, initialization fails instead of falling back to a lower-privilege runtime mode.
225249

226-
For external hosted `PostgreSQL`, such as `RDS` or `Aliyun PolarDB`, point `database.default.link` at the provider host and port. Use an initialization account with the permissions above for `make init`, then run the service with the same configured database unless your deployment process replaces the config with a runtime account after initialization.
250+
For external hosted `PostgreSQL`, such as `RDS` or `Aliyun PolarDB`, point `database.default.link` at the provider host and port. Use an initialization account with the permissions above for `linactl init` or `make init`, then run the service with the same configured database unless your deployment process replaces the config with a runtime account after initialization.
227251

228252
For a single-node development demo, switch the link to `SQLite`:
229253

README.zh-CN.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,35 @@ corepack enable
209209
cd apps/lina-vben
210210
pnpm install
211211
cd ../..
212+
go run ./hack/tools/linactl init confirm=init
213+
go run ./hack/tools/linactl mock confirm=mock
214+
go run ./hack/tools/linactl dev
215+
```
216+
217+
`Linux``macOS`用户可以继续使用兼容`Makefile`入口:
218+
219+
```bash
212220
make init confirm=init
213221
make mock confirm=mock
214222
make dev
215223
```
216224

225+
`Windows`用户可以使用上面的跨平台`Go`入口。仓库根目录也提供`cmd.exe`薄包装入口`make.cmd`;在`cmd.exe`中会按可执行文件扩展名查找当前目录脚本,因此可直接省略`.cmd`后缀使用`make`
226+
227+
```cmd
228+
make init confirm=init
229+
make mock confirm=mock
230+
make dev
231+
```
232+
233+
`PowerShell`中,需要使用当前目录前缀调用;默认`Windows`环境下也可以省略`.cmd`后缀写成`.\make`。如需避免与本机已安装的其他`make`命令混淆,可使用`.\make.cmd`
234+
235+
```powershell
236+
.\make init confirm=init
237+
.\make mock confirm=mock
238+
.\make dev
239+
```
240+
217241
默认后端连接为:
218242

219243
```yaml
@@ -222,9 +246,9 @@ database:
222246
link: "pgsql:postgres:postgres@tcp(127.0.0.1:5432)/linapro?sslmode=disable"
223247
```
224248
225-
`make init`是运维初始化命令,会直接使用配置中的数据库账号。该账号必须具备连接系统库、创建和删除目标数据库、终止目标库连接、建表、建索引、写入注释和写入`Seed`数据的权限。权限不足时初始化会失败,不会降级到低权限运行时模式。
249+
`linactl init`和`make init`是运维初始化命令,会直接使用配置中的数据库账号。该账号必须具备连接系统库、创建和删除目标数据库、终止目标库连接、建表、建索引、写入注释和写入`Seed`数据的权限。权限不足时初始化会失败,不会降级到低权限运行时模式。
226250

227-
使用外部托管`PostgreSQL`,例如`RDS`或阿里云`PolarDB`时,请将`database.default.link`指向供应商提供的主机和端口。执行`make init`时使用具备上述权限的初始化账号;如果部署流程需要运行时低权限账号,请在初始化完成后再替换运行配置。
251+
使用外部托管`PostgreSQL`,例如`RDS`或阿里云`PolarDB`时,请将`database.default.link`指向供应商提供的主机和端口。执行`linactl init`或`make init`时使用具备上述权限的初始化账号;如果部署流程需要运行时低权限账号,请在初始化完成后再替换运行配置。
228252

229253
如需单节点开发演示,可切换为`SQLite`链接:
230254

apps/lina-core/Makefile

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
ROOT_DIR = $(shell pwd)
21
NAMESPACE = "default"
32
DEPLOY_NAME = "template-single"
43
DOCKER_NAME = "template-single"
@@ -10,49 +9,20 @@ include ./hack/hack.mk
109
# prepare-packed-assets: 准备宿主 manifest 与插件相关嵌入资源,供后续后端构建打包使用
1110
.PHONY: prepare-packed-assets
1211
prepare-packed-assets:
13-
@../../hack/scripts/prepare-packed-assets.sh
12+
@go run ../../hack/tools/linactl prepare-packed-assets
1413

1514
# build: Prepare embedded assets, then build the host backend binary via GoFrame config
1615
# build: 先准备嵌入资源,再按 hack/config.yaml 调用 GoFrame 构建宿主后端二进制
1716
build: prepare-packed-assets
1817

19-
# Confirmation helper shared by destructive local targets.
20-
# 本地高风险目标共用的确认辅助逻辑。
21-
define require_confirm
22-
@if [ "$(confirm)" != "$(1)" ]; then \
23-
echo "✗ make $(1) requires explicit confirmation for safety"; \
24-
echo " Use: make $(1) confirm=$(1)"; \
25-
exit 1; \
26-
fi
27-
endef
28-
2918
# init: Initialize host DDL and seed data only; requires confirm=init, supports rebuild=true
3019
# init: 初始化数据库,仅执行宿主 DDL 与 Seed 数据;需 confirm=init,可追加 rebuild=true 重建数据库
3120
.PHONY: init
3221
init:
33-
$(call require_confirm,init)
34-
@echo "Initializing database..."
35-
@tmp_log="$$(mktemp)"; \
36-
if go run main.go init --confirm=$(confirm) --sql-source=local $(if $(rebuild),--rebuild=$(rebuild),) > "$$tmp_log" 2>&1; then \
37-
cat "$$tmp_log"; \
38-
rm -f "$$tmp_log"; \
39-
else \
40-
status="$$?"; \
41-
cat "$$tmp_log"; \
42-
if grep -Eqi "dial tcp|connection refused|connect: connection|failed to connect|i/o timeout|no such host" "$$tmp_log"; then \
43-
echo "PostgreSQL is not ready. Start PostgreSQL first."; \
44-
echo "Local example: docker run --name linapro-postgres -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=linapro -p 5432:5432 -d postgres:14-alpine"; \
45-
fi; \
46-
rm -f "$$tmp_log"; \
47-
exit "$$status"; \
48-
fi
49-
@echo "✓ Database initialization complete"
22+
@go run ../../hack/tools/linactl init confirm=$(confirm) $(if $(rebuild),rebuild=$(rebuild),)
5023

5124
# mock: Load mock demo/test data from manifest/sql/mock-data after init; requires confirm=mock
5225
# mock: 加载 manifest/sql/mock-data 下的 Mock 演示/测试数据;需先执行 init,并传入 confirm=mock
5326
.PHONY: mock
5427
mock:
55-
$(call require_confirm,mock)
56-
@echo "Loading mock data..."
57-
@go run main.go mock --confirm=$(confirm) --sql-source=local
58-
@echo "✓ Mock data load complete"
28+
@go run ../../hack/tools/linactl mock confirm=$(confirm)

0 commit comments

Comments
 (0)