bfi-cli 0.1.56 → 0.1.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.mjs +26 -11
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -6195,6 +6195,11 @@ const RESET$5 = "\x1B[0m";
6195
6195
  const BOLD$3 = "\x1B[1m";
6196
6196
  const DIM$5 = "\x1B[38;5;102m";
6197
6197
  const TEXT$4 = "\x1B[38;5;145m";
6198
+ function formatFileSize(bytes) {
6199
+ if (bytes < 1024) return `${bytes} B`;
6200
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
6201
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
6202
+ }
6198
6203
  async function runDocs(args, globalOpts) {
6199
6204
  switch (args[0]) {
6200
6205
  case "upload":
@@ -6240,8 +6245,7 @@ async function handleUpload(args, globalOpts) {
6240
6245
  const { registry, token } = resolveConfig(globalOpts);
6241
6246
  const api = new SkillHubAPI(registry, token);
6242
6247
  const fileName = path$1.basename(resolvedPath);
6243
- const fileSize = stats.size;
6244
- const fileSizeStr = fileSize < 1024 ? `${fileSize} B` : fileSize < 1024 * 1024 ? `${(fileSize / 1024).toFixed(1)} KB` : `${(fileSize / (1024 * 1024)).toFixed(1)} MB`;
6248
+ const fileSizeStr = formatFileSize(stats.size);
6245
6249
  console.log(`${DIM$5}正在上传 ${fileName} (${fileSizeStr})...${RESET$5}`);
6246
6250
  try {
6247
6251
  const fileBuffer = fs.readFileSync(resolvedPath);
@@ -6280,11 +6284,14 @@ async function handleList(args, globalOpts) {
6280
6284
  for (const doc of docs) {
6281
6285
  const id = doc.id || "?";
6282
6286
  const fileName = doc.fileName || doc.file_name || "unknown";
6283
- const status = doc.status || "N/A";
6287
+ const fileSize = doc.fileSize || doc.file_size;
6288
+ const sizeStr = fileSize ? formatFileSize(Number(fileSize)) : "N/A";
6289
+ const user = doc.userDisplayName || doc.userId || "N/A";
6290
+ const ip = doc.clientIp || "N/A";
6284
6291
  const createdAt = doc.createdAt || doc.created_at;
6285
6292
  const dateStr = createdAt ? new Date(createdAt).toISOString().split("T")[0] : "N/A";
6286
6293
  console.log(` ${BOLD$3}#${id}${RESET$5} ${TEXT$4}${fileName}${RESET$5}`);
6287
- console.log(` ${DIM$5}状态:${status} | 日期:${dateStr}${RESET$5}`);
6294
+ console.log(` ${DIM$5}${sizeStr} | ${user} | ${ip} | ${dateStr}${RESET$5}`);
6288
6295
  console.log();
6289
6296
  }
6290
6297
  if (total && Number(total) > (page + 1) * size) console.log(`${DIM$5}下一页:bfi docs list ${page + 1}${RESET$5}`);
@@ -6314,13 +6321,20 @@ async function handleInfo(args, globalOpts) {
6314
6321
  console.log(`${DIM$5}未找到文档:${id}${RESET$5}`);
6315
6322
  process.exit(1);
6316
6323
  }
6324
+ const content = doc.content;
6325
+ const hasContent = typeof content === "string" && content.trim().length > 0;
6317
6326
  console.log();
6318
6327
  console.log(`${BOLD$3}文档 #${doc.id}${RESET$5}`);
6319
6328
  console.log(`${DIM$5}${"─".repeat(48)}${RESET$5}`);
6320
6329
  if (doc.fileName || doc.file_name) console.log(` ${BOLD$3}文件:${RESET$5} ${TEXT$4}${doc.fileName || doc.file_name}${RESET$5}`);
6330
+ const fileSize = doc.fileSize || doc.file_size;
6331
+ if (fileSize) console.log(` ${BOLD$3}大小:${RESET$5} ${TEXT$4}${formatFileSize(Number(fileSize))}${RESET$5}`);
6332
+ const user = doc.userDisplayName || doc.userId;
6333
+ if (user) console.log(` ${BOLD$3}上传者:${RESET$5} ${TEXT$4}${user}${RESET$5}`);
6334
+ if (doc.clientIp) console.log(` ${BOLD$3}IP:${RESET$5} ${TEXT$4}${doc.clientIp}${RESET$5}`);
6321
6335
  if (doc.status) {
6322
6336
  const statusColor = doc.status === "completed" || doc.status === "COMPLETED" ? "\x1B[32m" : doc.status === "failed" || doc.status === "FAILED" ? "\x1B[31m" : TEXT$4;
6323
- console.log(` ${BOLD$3}状态:${RESET$5} ${statusColor}${doc.status}${RESET$5}`);
6337
+ console.log(` ${BOLD$3}状态:${RESET$5} ${statusColor}${doc.status}${RESET$5}`);
6324
6338
  }
6325
6339
  if (doc.createdAt || doc.created_at) {
6326
6340
  const date = new Date(doc.createdAt || doc.created_at).toISOString().replace("T", " ").slice(0, 19);
@@ -6330,17 +6344,18 @@ async function handleInfo(args, globalOpts) {
6330
6344
  const date = new Date(doc.updatedAt || doc.updated_at).toISOString().replace("T", " ").slice(0, 19);
6331
6345
  console.log(` ${BOLD$3}更新时间:${RESET$5} ${TEXT$4}${date}${RESET$5}`);
6332
6346
  }
6333
- if (doc.result) {
6334
- console.log();
6335
- console.log(` ${BOLD$3}结果:${RESET$5}`);
6336
- const resultStr = typeof doc.result === "string" ? doc.result : JSON.stringify(doc.result, null, 4);
6337
- for (const line of resultStr.split("\n")) console.log(` ${DIM$5}${line}${RESET$5}`);
6338
- }
6339
6347
  if (doc.error || doc.errorMessage) {
6340
6348
  console.log();
6341
6349
  console.log(` \x1b[31m${BOLD$3}错误:${RESET$5}`);
6342
6350
  console.log(` \x1b[31m${doc.error || doc.errorMessage}${RESET$5}`);
6343
6351
  }
6352
+ if (hasContent) {
6353
+ console.log();
6354
+ console.log(` ${BOLD$3}内容:${RESET$5}`);
6355
+ console.log(`${DIM$5}${"─".repeat(48)}${RESET$5}`);
6356
+ for (const line of content.split("\n")) console.log(` ${TEXT$4}${line}${RESET$5}`);
6357
+ console.log(`${DIM$5}${"─".repeat(48)}${RESET$5}`);
6358
+ }
6344
6359
  console.log();
6345
6360
  } catch (error) {
6346
6361
  if (error.status === 404) console.error(`未找到文档:${id}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bfi-cli",
3
- "version": "0.1.56",
3
+ "version": "0.1.57",
4
4
  "description": "用友大业财BFI统一命令行工具,支持技能,技能包,元数据,UI元数据等",
5
5
  "type": "module",
6
6
  "bin": {