fix: remove TS overloads incompatible with --experimental-strip-types, fix 204 response, fix retention-days
- lib/github.ts: Remove getEnv overload signatures (Node.js experimental-strip-types does not support TS function overloads, causes SyntaxError at parse time) - lib/github.ts: Handle 204 No Content in request<T> (DELETE returns 204, calling response.json() on empty body throws) - build-pr.yml: retention-days 7->5 (repo max is 5)
This commit is contained in:
2 files changed
+9
-5
No files matched your search
@@ -71,6 +71,11 @@ export class GitHubAPI {
|
|||||||
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
|
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 204 No Content(DELETE 等)不解析 body
|
||||||
|
if (response.status === 204) {
|
||||||
|
return undefined as T;
|
||||||
|
}
|
||||||
|
|
||||||
return response.json() as Promise<T>;
|
return response.json() as Promise<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,8 +283,7 @@ export function setMultilineOutput (name: string, value: string): void {
|
|||||||
|
|
||||||
// ============== 环境变量工具 ==============
|
// ============== 环境变量工具 ==============
|
||||||
|
|
||||||
export function getEnv (name: string, required: true): string;
|
// Note: 不使用函数重载——Node.js --experimental-strip-types 不支持 TS overload signatures
|
||||||
export function getEnv (name: string, required?: false): string | undefined;
|
|
||||||
export function getEnv (name: string, required = false): string | undefined {
|
export function getEnv (name: string, required = false): string | undefined {
|
||||||
const value = process.env[name];
|
const value = process.env[name];
|
||||||
if (required && !value) {
|
if (required && !value) {
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: NapCat.Framework
|
name: NapCat.Framework
|
||||||
path: workspace/framework-dist
|
path: workspace/framework-dist
|
||||||
retention-days: 7 # 保留 7 天
|
retention-days: 5 # 保留 5 天(仓库上限)
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Job 4: 构建 Shell 包
|
# Job 4: 构建 Shell 包
|
||||||
@@ -263,7 +263,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: NapCat.Shell
|
name: NapCat.Shell
|
||||||
path: workspace/shell-dist
|
path: workspace/shell-dist
|
||||||
retention-days: 7 # 保留 7 天
|
retention-days: 5 # 保留 5 天(仓库上限)
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Job 5: 更新评论为构建结果
|
# Job 5: 更新评论为构建结果
|
||||||
@@ -370,7 +370,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: install-script
|
name: install-script
|
||||||
path: ./release-assets/install.sh
|
path: ./release-assets/install.sh
|
||||||
retention-days: 7
|
retention-days: 5
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in new issue
Block a user