#!/usr/bin/env node /** * Fmode Git 归档(Gitea + 源码入库) — 辅助脚本(零 npm 依赖,Node>=18 自带 fetch) * Copyright (c) 未来飞马 MPL-2.0 * * 用法:node index.mjs [jsonPayload] */ const BASE = "https://server.fmode.cn"; async function call(method, path, body, token) { const headers = { "content-type": "application/json" }; if (token) headers["authorization"] = "Bearer " + token; const res = await fetch(BASE + path, { method, headers, body: body ? JSON.stringify(body) : undefined, }); const text = await res.text(); // 脱敏输出:token/密钥不打印 const safe = text.replace(/(token|authorization|accessKey|secretKey|securityToken)["'\s:]+([^",}]+)/gi, "$1:***"); console.log(safe); return res; } const [action, raw] = process.argv.slice(2); let payload = {}; try { if (raw) payload = JSON.parse(raw); } catch { payload = { _raw: raw }; } // 示例端点: POST Gogs admin proxy 建用户 {token,path:/gogs/admin/proxy,params:{method:POST,path:/admin/users,...}} // 示例端点: POST 创建个人 token // 示例端点: POST 创建私有仓库