init: 虚拟公司架构设计——治理、流水线、中台、token 经济与演进路径

This commit is contained in:
HIsheR
2026-10-23 16:09:45 +08:00
commit 26b18a167f
14 changed files with 529 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
/*** 作用:Gitea REST API 调用包装器,用法 node scripts/gitea-api.mjs <METHOD> <path不带前导斜杠> [jsonBody],令牌读自 .gitea-token ***/
import { readFileSync } from 'node:fs';
// 仓库与令牌
const base = 'https://gitea.yinyuanjingling.icu/api/v1';
const token = readFileSync(new URL('../.gitea-token', import.meta.url), 'utf8').trim();
const [method = 'GET', path = '', body = ''] = process.argv.slice(2);
// 卫语句:缺参数退出
if (!method || !path) { console.error('用法: node scripts/gitea-api.mjs <METHOD> <path> [jsonBody]'); process.exit(2); }
// 发起请求并输出结果(path 不带前导斜杠,规避 Git Bash MSYS 路径转换篡改)
const res = await fetch(`${base}/${path.replace(/^\//, '')}`, {
method: method.toUpperCase(),
headers: { 'Authorization': `token ${token}`, 'Content-Type': 'application/json' },
body: body || undefined,
});
const text = await res.text();
console.log(`HTTP ${res.status}\n${text}`);
process.exit(res.ok ? 0 : 1);
+18
View File
@@ -0,0 +1,18 @@
/*** 作用:Gitea 认证 git 包装器,从 .gitea-token 读取令牌注入 Authorization 头,避免令牌出现在命令行 ***/
import { readFileSync } from 'node:fs';
import { spawnSync } from 'node:child_process';
// 令牌文件路径(不入库)
const tokenFile = new URL('../.gitea-token', import.meta.url);
// git 子命令参数(如 push origin main)
const args = process.argv.slice(2);
// 卫语句:无参数直接退出
if (args.length === 0) { console.error('用法: node scripts/gitea.mjs <git参数...>'); process.exit(2); }
let token = '';
try { token = readFileSync(tokenFile, 'utf8').trim(); } catch { console.error('缺少 .gitea-token 文件'); process.exit(2); }
if (!token) { console.error('.gitea-token 为空'); process.exit(2); }
// 注入认证头执行 git
const result = spawnSync('git', ['-c', `http.extraheader=Authorization: token ${token}`, ...args], { stdio: 'inherit' });
process.exit(result.status ?? 1);