forked from bai/curriculum-project-hub
82241afb56
内存 store 换成 gitVersionStore:init 建目录并 git init,VersionId 是
commit hash,某文件的版本取 `git log -1 -- <path>`(D16 文件级版本不因
别的文件提交而失效)。删除也是一个 commit,旧版本仍可读。决策见 ADR-0030。
git 用 execFile 调系统二进制,不引依赖。每次调用钉死 --git-dir/--work-tree
并禁 hooks、隔离全局 gitconfig:项目仓库是老师上传的数据,而 storage root
默认就在本 repo 内,不钉死会让命令落到外层仓库上。
同时:
- 单文件上限改为 HUB_FILELIB_MAX_FILE_BYTES(缺省 10MiB),前端从
/database/config 读,不再两处硬编码
- commit 身份 name=displayName、email=<userId>@filelib.paradigm-edu.net;
message 缺省为「【用户名】修改了【路径】」,调用方显式传则优先
- 上传改走弹窗,路径与 commit 信息可手填(原先 prompt 只能填路径)
BREAKING CHANGE: VersionId 由计数器(v1/v2)变为 commit hash;
CommitRequest.author 由字符串变为 { userId, displayName? }。
旧 .version-store.json 不迁移,此前建的项目报 repo_not_found。
26 lines
915 B
TypeScript
26 lines
915 B
TypeScript
/**
|
|
* 前端 bootstrap:silo org slug(拼飞书 OAuth 链接用)+ dev 一键登录开关。
|
|
*
|
|
* 打 `/database/config` 而非 `/database/api/login-info`:后者由 teacherApp.ts 在
|
|
* silo org 查找成功之后才注册,org 缺失时整条链路不存在;前者在
|
|
* databaseRoutes.ts 顶部无条件注册。两者形状相同(见 src/database/README.md)。
|
|
*
|
|
* 免鉴权 —— org slug 本就出现在 OAuth URL 里,不构成敏感信息。
|
|
*/
|
|
import { api } from "./api.js";
|
|
|
|
export interface AppConfig {
|
|
readonly orgSlug: string;
|
|
readonly devLoginEnabled: boolean;
|
|
/** 单文件上传上限(字节)。后端 `HUB_FILELIB_MAX_FILE_BYTES` 的生效值。 */
|
|
readonly maxFileBytes: number;
|
|
}
|
|
|
|
let cached: AppConfig | null = null;
|
|
|
|
export async function loadConfig(): Promise<AppConfig> {
|
|
if (cached !== null) return cached;
|
|
cached = await api<AppConfig>("/database/config");
|
|
return cached;
|
|
}
|