Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ci checks #6

Merged
merged 6 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Check PR

on:
pull_request:
workflow_dispatch:

jobs:
check-pr:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup node and deps
uses: actions/setup-node@v3
with:
node-version: "20"
cache: npm
cache-dependency-path: package-lock.json

- run: npm i

- run: npm run lint

- run: npm run format

- run: npm run build
2 changes: 2 additions & 0 deletions .github/workflows/deploy-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: "20"
cache: npm
cache-dependency-path: package-lock.json

- run: npm i

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"start": "vite",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"format": "prettier --check src",
"format:fix": "prettier --write src",
"test": "jest",
"test:coverage": "jest --coverage",
"typecheck": "tsc --noEmit",
Expand Down
32 changes: 16 additions & 16 deletions src/apis/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
return request({
method: 'POST',
url: `/v1/captchas`,
...configs
...configs,
});
};

Expand All @@ -23,7 +23,7 @@
/** 获取验证邮件 */
const getConfirmEmailVCode = ({
data,
configs
configs,
}: {
data: GetConfirmEmailVCodeData;
configs?: AxiosRequestConfig;
Expand All @@ -32,7 +32,7 @@
method: 'POST',
url: `/v1/confirm-email-codes`,
data: toUnderScoreCase(data),
...configs
...configs,
});
};

Expand All @@ -45,7 +45,7 @@
/** 获取验证邮件 */
const getResetPasswordVCode = ({
data,
configs
configs,
}: {
data: GetResetPasswordVCodeData;
configs?: AxiosRequestConfig;
Expand All @@ -54,20 +54,20 @@
method: 'POST',
url: `/v1/reset-password-codes`,
data: toUnderScoreCase(data),
...configs
...configs,
});
};

/** 获取验证邮件 */
const getResetEmailVCode = ({
configs
configs,
}: {
configs?: AxiosRequestConfig;
} = {}) => {
return request({
method: 'POST',
url: `/v1/reset-email-codes`,
...configs
...configs,
});
};

Expand All @@ -81,7 +81,7 @@
/** 注册 */
const register = ({
data,
configs
configs,
}: {
data: RegisterData;
configs?: AxiosRequestConfig;
Expand All @@ -90,7 +90,7 @@
method: 'POST',
url: `/v1/users`,
data: toUnderScoreCase(data),
...configs
...configs,
});
};

Expand All @@ -103,7 +103,7 @@
/** 获取验证邮件 */
const resetPassword = ({
data,
configs
configs,
}: {
data: ResetPasswordData;
configs?: AxiosRequestConfig;
Expand All @@ -112,7 +112,7 @@
method: 'DELETE',
url: `/v1/user/password`,
data: toUnderScoreCase(data),
...configs
...configs,
});
};

Expand All @@ -126,7 +126,7 @@
/** 获取验证邮件 */
const login = ({
data,
configs
configs,
}: {
data: LoginData;
configs?: AxiosRequestConfig;
Expand All @@ -135,7 +135,7 @@
method: 'POST',
url: `/v1/user/token`,
data: toUnderScoreCase(data),
...configs
...configs,
});
};

Expand All @@ -145,16 +145,16 @@
}
/** 获取用户信息 */
const getUserInfo = ({
data,

Check warning on line 148 in src/apis/auth.ts

View workflow job for this annotation

GitHub Actions / check-pr

'data' is assigned a value but never used
configs
configs,
}: {
data?: GetUserInfoData;
configs?: AxiosRequestConfig;
} = {}) => {
return request({
method: 'GET',
url: `/v1/user/info`,
...configs
...configs,
});
};

Expand All @@ -166,5 +166,5 @@
resetPassword,
register,
login,
getUserInfo
getUserInfo,
};
2 changes: 1 addition & 1 deletion src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@
};

/** 成功的响应 */
export interface BasicSuccessResult<T = any> {

Check warning on line 64 in src/apis/index.ts

View workflow job for this annotation

GitHub Actions / check-pr

Unexpected any. Specify a different type
type: typeof resultTypes.SUCCESS;
data: T;
headers: any;

Check warning on line 67 in src/apis/index.ts

View workflow job for this annotation

GitHub Actions / check-pr

Unexpected any. Specify a different type
}

/** 基础错误响应结果的数据 */
Expand Down Expand Up @@ -125,7 +125,7 @@
| CancelFailureResult
| OtherFailureResult;

export const request = <T = any>(axiosConfig: AxiosRequestConfig) => {

Check warning on line 128 in src/apis/index.ts

View workflow job for this annotation

GitHub Actions / check-pr

Unexpected any. Specify a different type
return instance({
// param=value1&param=value2,去除 query 中数组的 [] 结尾
paramsSerializer: function (params) {
Expand All @@ -150,7 +150,7 @@
if (error.response.data.code === 2) {
// 将 message 中的字段名转为小驼峰
error.response.data.message = toLowerCamelCase(
error.response.data.message
error.response.data.message,
);
// 验证错误
const result: ValidationFailureResult = {
Expand Down
2 changes: 1 addition & 1 deletion src/apis/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,5 @@ export default {
getTeam,
createTeam,
editTeam,
deleteTeam
deleteTeam,
};
8 changes: 4 additions & 4 deletions src/apis/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ interface GetSystemRolesData {
}
/** 获取系统角色 */
const getTypes = (
{ typeName, groupType, params, configs } = {} as GetSystemRolesData
{ typeName, groupType, params, configs } = {} as GetSystemRolesData,
) => {
return request({
method: 'GET',
url: `/v1/types/${toHyphenCase(typeName)}`,
params: {
group_type: groupType,
...toUnderScoreCase(params)
...toUnderScoreCase(params),
},
...configs
...configs,
});
};

export default {
getTypes
getTypes,
};
8 changes: 4 additions & 4 deletions src/components/AdminSiteSetting.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css } from '@emotion/core';
import { Button, Form as AntdForm, Input, message, Spin, Switch } from 'antd';

Check warning on line 2 in src/components/AdminSiteSetting.tsx

View workflow job for this annotation

GitHub Actions / check-pr

'Input' is defined but never used
import TextArea from 'antd/lib/input/TextArea';
import classNames from 'classnames';
import React, { useEffect, useState } from 'react';
Expand All @@ -19,8 +19,8 @@
textarea
.split('\n')
.map((item) => item.trim())
.filter((item) => item !== '')
)
.filter((item) => item !== ''),
),
);
}

Expand Down Expand Up @@ -75,7 +75,7 @@
error.data.message.whitelistEmails = [
formatMessage(
{ id: 'site.setting.whitelistEmailsError' },
{ line }
{ line },
),
];
}
Expand All @@ -86,7 +86,7 @@
error.data.message.autoJoinTeamIDs = [
formatMessage(
{ id: 'site.setting.autoJoinTeamIDsError' },
{ line }
{ line },
),
];
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ApplicationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const ApplicationList: FC<ApplicationListProps> = ({
// 弹出框
const [spinningIDs, setSpinningIDs] = useState<string[]>([]); // 删除请求中
const relatedApplicationsCount = useSelector(
(state: AppState) => state.site.relatedApplicationsCount
(state: AppState) => state.site.relatedApplicationsCount,
);

/** 处理申请 */
Expand Down Expand Up @@ -334,7 +334,7 @@ export const ApplicationList: FC<ApplicationListProps> = ({
<strong>
{formatMessage(
{ id: 'site.join.request' },
{ groupType: formatGroupType(item.groupType) }
{ groupType: formatGroupType(item.groupType) },
) + ': '}
</strong>
{item.groupType === 'project'
Expand Down
4 changes: 2 additions & 2 deletions src/components/AvatarUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ export const AvatarUpload: FC<AvatarUploadProps> = ({
setUserInfo({
avatar: info.file.response.avatar,
hasAvatar: true,
})
}),
);
} else if (type === 'team') {
dispatch(
setCurrentTeamInfo({
avatar: info.file.response.avatar,
hasAvatar: true,
})
}),
);
}
}
Expand Down
19 changes: 9 additions & 10 deletions src/components/CAPTCHAInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import style from '../style';
import { getCancelToken } from '../utils/api';
import { clickEffect, imageClickEffect } from '../utils/style';


/** 用于 Form.Item 校验验证码,rules={[{validator: checkCAPTCHA}]} */
export const checkCAPTCHA = (rule: any, captcha: CAPTCHAInputValue) => {
const intl = getIntl();
Expand All @@ -20,7 +19,7 @@ export const checkCAPTCHA = (rule: any, captcha: CAPTCHAInputValue) => {
}
if (captcha.value.length !== 4) {
return Promise.reject(
intl.formatMessage({ id: 'form.stringLen' }, { len: 4 })
intl.formatMessage({ id: 'form.stringLen' }, { len: 4 }),
);
}
return Promise.resolve();
Expand Down Expand Up @@ -70,7 +69,7 @@ const CAPTCHAInputWithoutRef: React.ForwardRefRenderFunction<
useImperativeHandle(ref, () => {
const imperatives = {
...inputRef.current,
refresh: getCAPTCHA
refresh: getCAPTCHA,
};
return imperatives as CAPTCHAInputRef;
});
Expand All @@ -84,16 +83,16 @@ const CAPTCHAInputWithoutRef: React.ForwardRefRenderFunction<

/** 获取验证码 */
const getCAPTCHA = (
{ focus = true, cancelToken, onFinish } = {} as GetCAPTCHAParams
{ focus = true, cancelToken, onFinish } = {} as GetCAPTCHAParams,
) => {
setCaptchaLoading(true);
api
.getCAPTCHA({
configs: {
cancelToken
}
cancelToken,
},
})
.then(result => {
.then((result) => {
setCaptchaValue(''); // 清空当前值
setCaptchaInfo(result.data.info);
setCaptchaImage(result.data.image);
Expand All @@ -104,15 +103,15 @@ const CAPTCHAInputWithoutRef: React.ForwardRefRenderFunction<
if (onChange) {
onChange({
value: '',
info: result.data.info
info: result.data.info,
});
}
setCaptchaLoading(false);
if (onFinish) {
onFinish();
}
})
.catch(result => {
.catch((result) => {
result.default();
});
};
Expand All @@ -129,7 +128,7 @@ const CAPTCHAInputWithoutRef: React.ForwardRefRenderFunction<
if (onChange) {
onChange({
value: e.target.value,
info: captchaInfo
info: captchaInfo,
});
}
};
Expand Down
7 changes: 3 additions & 4 deletions src/components/CAPTCHAModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ export const CAPTCHAModal: FC<CAPTCHAModalProps> = ({
value: '',
info: '',
};
const [captcha, setCAPTCHA] = useState<CAPTCHAInputValue>(
defaultCAPTCHAValue
);
const [captcha, setCAPTCHA] =
useState<CAPTCHAInputValue>(defaultCAPTCHAValue);
const inputRef = useRef<CAPTCHAInputRef>(null);

// 按钮默认值
Expand Down Expand Up @@ -146,7 +145,7 @@ export const CAPTCHAModal: FC<CAPTCHAModalProps> = ({
.captcha-form-close-icon {
color: ${style.primaryColorDarker};
}
`
`,
)}
.captcha-form-close-icon {
color: ${style.primaryColor};
Expand Down
Loading
Loading