#!/usr/bin/env node /** * Fmode 静态发布(OBS+CDN 公开 URL) — 辅助脚本(零 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 注册 Project {token,path:/fmode/project-register,params:{name,version,gitUrl}} // 示例端点: POST 取 STS {token,projectId} // 示例端点: POST CDN 刷新 {token,projectId,path}