Skip to content

Commit fcca09d

Browse files
committed
chore: update client generation workflow and enhance admin dependencies
1 parent 30581cf commit fcca09d

File tree

9 files changed

+56
-47
lines changed

9 files changed

+56
-47
lines changed

.github/workflows/generate-client.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ jobs:
5656
- name: Install Frontend Dependencies
5757
run: pnpm install
5858
working-directory: frontend
59+
60+
- name: Install Admin Dependencies
61+
run: pnpm install
62+
working-directory: admin
5963

6064
# 安装所有后端依赖项
6165
- name: Install Backend Dependencies
@@ -94,7 +98,9 @@ jobs:
9498
9599
# 6. Stage Generated Files
96100
- name: Stage Generated Client Files
97-
run: git add frontend/src/client # Adjust path if needed
101+
run: |
102+
git add frontend/app/openapi-client
103+
git add admin/src/client
98104
99105
# 7. Handle Changes for Same-Repo Events (Push/PR from same repo)
100106
- name: Commit and Push Changes (Same Repo)

admin/src/client/sdk.gen.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
import type { CancelablePromise } from './core/CancelablePromise';
44
import { OpenAPI } from './core/OpenAPI';
55
import { request as __request } from './core/request';
6-
import type { GoogleOauthGoogleCallbackApiData, GoogleOauthGoogleCallbackApiResponse, GoogleOauthGoogleLoginResponse, GoogleOauthGoogleCallbackData, GoogleOauthGoogleCallbackResponse, HealthGetHealthRootResponse, HealthGetHealthApiResponse, ItemsReadItemsData, ItemsReadItemsResponse, ItemsCreateItemData, ItemsCreateItemResponse, ItemsReadItemData, ItemsReadItemResponse, ItemsUpdateItemData, ItemsUpdateItemResponse, ItemsDeleteItemData, ItemsDeleteItemResponse, LoginLoginAccessTokenData, LoginLoginAccessTokenResponse, LoginTestTokenResponse, LoginLogoutResponse, LoginRecoverPasswordData, LoginRecoverPasswordResponse, LoginResetPasswordData, LoginResetPasswordResponse, LoginRecoverPasswordHtmlContentData, LoginRecoverPasswordHtmlContentResponse, PrivateCreateUserData, PrivateCreateUserResponse, UsersReadUsersData, UsersReadUsersResponse, UsersCreateUserData, UsersCreateUserResponse, UsersReadUserMeResponse, UsersDeleteUserMeResponse, UsersUpdateUserMeData, UsersUpdateUserMeResponse, UsersUpdatePasswordMeData, UsersUpdatePasswordMeResponse, UsersRegisterUserData, UsersRegisterUserResponse, UsersReadUserByIdData, UsersReadUserByIdResponse, UsersUpdateUserData, UsersUpdateUserResponse, UsersDeleteUserData, UsersDeleteUserResponse, UtilsTestEmailData, UtilsTestEmailResponse, UtilsHealthCheckResponse } from './types.gen';
6+
import type { GoogleOauthGoogleCallbackApiData, GoogleOauthGoogleCallbackApiResponse, GoogleOauthGoogleLoginResponse, GoogleOauthGoogleCallbackData, GoogleOauthGoogleCallbackResponse, HealthGetHealthApiResponse, ItemsReadItemsData, ItemsReadItemsResponse, ItemsCreateItemData, ItemsCreateItemResponse, ItemsReadItemData, ItemsReadItemResponse, ItemsUpdateItemData, ItemsUpdateItemResponse, ItemsDeleteItemData, ItemsDeleteItemResponse, LoginLoginAccessTokenData, LoginLoginAccessTokenResponse, LoginTestTokenResponse, LoginLogoutResponse, LoginRecoverPasswordData, LoginRecoverPasswordResponse, LoginResetPasswordData, LoginResetPasswordResponse, LoginRecoverPasswordHtmlContentData, LoginRecoverPasswordHtmlContentResponse, PrivateCreateUserData, PrivateCreateUserResponse, UsersReadUsersData, UsersReadUsersResponse, UsersCreateUserData, UsersCreateUserResponse, UsersReadUserMeResponse, UsersDeleteUserMeResponse, UsersUpdateUserMeData, UsersUpdateUserMeResponse, UsersUpdatePasswordMeData, UsersUpdatePasswordMeResponse, UsersRegisterUserData, UsersRegisterUserResponse, UsersReadUserByIdData, UsersReadUserByIdResponse, UsersUpdateUserData, UsersUpdateUserResponse, UsersDeleteUserData, UsersDeleteUserResponse, UtilsTestEmailData, UtilsTestEmailResponse, UtilsHealthCheckResponse } from './types.gen';
77

88
export class GoogleOauthService {
99
/**
1010
* Google Callback Api
1111
* Handle Google OAuth callback from frontend
12+
* This is maintained for backward compatibility but not used in the new flow
1213
* @param data The data for the request.
1314
* @param data.requestBody
1415
* @returns unknown Successful Response
@@ -29,6 +30,7 @@ export class GoogleOauthService {
2930
/**
3031
* Google Login
3132
* Initiate Google OAuth2 authentication flow
33+
* This endpoint redirects to Google's login page
3234
* @returns unknown Successful Response
3335
* @throws ApiError
3436
*/
@@ -42,6 +44,7 @@ export class GoogleOauthService {
4244
/**
4345
* Google Callback
4446
* Handle the callback from Google OAuth
47+
* This endpoint is called by Google after the user has logged in
4548
* @param data The data for the request.
4649
* @param data.code
4750
* @param data.state
@@ -67,22 +70,8 @@ export class GoogleOauthService {
6770
}
6871

6972
export class HealthService {
70-
/**
71-
* Get Health Root
72-
* 兼容前端的根级别健康检查路由
73-
* @returns unknown Successful Response
74-
* @throws ApiError
75-
*/
76-
public static getHealthRoot(): CancelablePromise<HealthGetHealthRootResponse> {
77-
return __request(OpenAPI, {
78-
method: 'GET',
79-
url: '/health'
80-
});
81-
}
82-
8373
/**
8474
* Get Health Api
85-
* 兼容前端的API级别健康检查路由
8675
* @returns unknown Successful Response
8776
* @throws ApiError
8877
*/

admin/src/client/types.gen.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ export type GoogleOauthGoogleCallbackData = {
142142

143143
export type GoogleOauthGoogleCallbackResponse = (unknown);
144144

145-
export type HealthGetHealthRootResponse = (unknown);
146-
147145
export type HealthGetHealthApiResponse = (unknown);
148146

149147
export type ItemsReadItemsData = {

frontend/Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@ COPY package*.json ./
1212
# Install dependencies as root (or myappuser, depending on your structure)
1313
RUN pnpm install
1414

15-
## Switch to the non-root user
16-
USER node
17-
1815
# Copy the rest of your application code
1916
COPY . .
2017

18+
# Make start.sh executable
19+
RUN chmod +x start.sh
20+
21+
# Ensure watcher.js is executable
22+
RUN chmod +x watcher.js
23+
24+
# Use non-root user for security
25+
USER node
26+
2127
EXPOSE 3000
2228

2329
# Start the application

frontend/app/openapi-client/sdk.gen.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import {
77
urlSearchParamsBodySerializer,
88
} from "@hey-api/client-axios";
99
import type {
10-
HealthGetHealthRootError,
11-
HealthGetHealthRootResponse,
1210
HealthGetHealthApiError,
1311
HealthGetHealthApiResponse,
1412
LoginLoginAccessTokenData,
@@ -90,26 +88,8 @@ import type {
9088

9189
export const client = createClient(createConfig());
9290

93-
/**
94-
* Get Health Root
95-
* 兼容前端的根级别健康检查路由
96-
*/
97-
export const healthGetHealthRoot = <ThrowOnError extends boolean = false>(
98-
options?: OptionsLegacyParser<unknown, ThrowOnError>,
99-
) => {
100-
return (options?.client ?? client).get<
101-
HealthGetHealthRootResponse,
102-
HealthGetHealthRootError,
103-
ThrowOnError
104-
>({
105-
...options,
106-
url: "/health",
107-
});
108-
};
109-
11091
/**
11192
* Get Health Api
112-
* 兼容前端的API级别健康检查路由
11393
*/
11494
export const healthGetHealthApi = <ThrowOnError extends boolean = false>(
11595
options?: OptionsLegacyParser<unknown, ThrowOnError>,
@@ -530,6 +510,7 @@ export const itemsDeleteItem = <ThrowOnError extends boolean = false>(
530510
/**
531511
* Google Callback Api
532512
* Handle Google OAuth callback from frontend
513+
* This is maintained for backward compatibility but not used in the new flow
533514
*/
534515
export const googleOauthGoogleCallbackApi = <
535516
ThrowOnError extends boolean = false,
@@ -549,6 +530,7 @@ export const googleOauthGoogleCallbackApi = <
549530
/**
550531
* Google Login
551532
* Initiate Google OAuth2 authentication flow
533+
* This endpoint redirects to Google's login page
552534
*/
553535
export const googleOauthGoogleLogin = <ThrowOnError extends boolean = false>(
554536
options?: OptionsLegacyParser<unknown, ThrowOnError>,
@@ -566,6 +548,7 @@ export const googleOauthGoogleLogin = <ThrowOnError extends boolean = false>(
566548
/**
567549
* Google Callback
568550
* Handle the callback from Google OAuth
551+
* This endpoint is called by Google after the user has logged in
569552
*/
570553
export const googleOauthGoogleCallback = <ThrowOnError extends boolean = false>(
571554
options?: OptionsLegacyParser<GoogleOauthGoogleCallbackData, ThrowOnError>,

frontend/app/openapi-client/types.gen.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,6 @@ export type ValidationError = {
126126
type: string;
127127
};
128128

129-
export type HealthGetHealthRootResponse = unknown;
130-
131-
export type HealthGetHealthRootError = unknown;
132-
133129
export type HealthGetHealthApiResponse = unknown;
134130

135131
export type HealthGetHealthApiError = unknown;

frontend/openapi.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

frontend/start.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
#!/bin/bash
22

3+
# 确保脚本具有可执行权限
4+
if [ ! -x "$0" ]; then
5+
echo "Setting executable permission on script"
6+
chmod +x "$0"
7+
fi
8+
9+
# 确保watcher脚本有可执行权限
10+
if [ -f "./watcher.js" ] && [ ! -x "./watcher.js" ]; then
11+
echo "Setting executable permission on watcher.js"
12+
chmod +x "./watcher.js"
13+
fi
14+
15+
# 启动Next.js应用
16+
echo "Starting Next.js application..."
317
pnpm run dev &
418

19+
# 启动watcher脚本监视OpenAPI文件变化
20+
echo "Starting watcher..."
521
node watcher.js
622

723
wait

scripts/generate-admin-client.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,22 @@ fi
3131

3232
cd admin
3333
echo "Generating TypeScript client from schema"
34-
pnpm run generate-client
34+
35+
# 检查node_modules目录是否存在,如果不存在则安装依赖
36+
if [ ! -d "node_modules" ]; then
37+
echo "⚠️ node_modules directory not found in admin directory"
38+
echo "📦 Installing dependencies..."
39+
pnpm install || {
40+
echo "❌ Failed to install dependencies with pnpm"
41+
exit 1
42+
}
43+
echo "✅ Dependencies installed successfully"
44+
fi
45+
46+
pnpm run generate-client || {
47+
echo "❌ Failed to generate client"
48+
exit 1
49+
}
3550

3651
echo "🧹 Formatting generated client code..."
3752
pnpm exec biome format --write ./src/client || {

0 commit comments

Comments
 (0)