bfi-cli 0.1.55 → 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.
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,19 +6245,19 @@ 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);
6248
6252
  const result = await api.uploadDoc(fileBuffer, fileName);
6253
+ const doc = result.data || result;
6249
6254
  console.log(`${TEXT$4}✓ 上传成功${RESET$5}`);
6250
6255
  console.log();
6251
- if (result.id) console.log(` ${BOLD$3}ID:${RESET$5} ${TEXT$4}${result.id}${RESET$5}`);
6252
- if (result.status) console.log(` ${BOLD$3}状态:${RESET$5} ${TEXT$4}${result.status}${RESET$5}`);
6253
- if (result.fileName) console.log(` ${BOLD$3}文件:${RESET$5} ${TEXT$4}${result.fileName}${RESET$5}`);
6256
+ if (doc.id) console.log(` ${BOLD$3}ID:${RESET$5} ${TEXT$4}${doc.id}${RESET$5}`);
6257
+ if (doc.status) console.log(` ${BOLD$3}状态:${RESET$5} ${TEXT$4}${doc.status}${RESET$5}`);
6258
+ if (doc.fileName) console.log(` ${BOLD$3}文件:${RESET$5} ${TEXT$4}${doc.fileName}${RESET$5}`);
6254
6259
  console.log();
6255
- if (result.id) console.log(`${DIM$5}查看状态:bfi docs info ${result.id}${RESET$5}`);
6260
+ if (doc.id) console.log(`${DIM$5}查看状态:bfi docs info ${doc.id}${RESET$5}`);
6256
6261
  } catch (error) {
6257
6262
  console.error(`上传失败:${error.message}`);
6258
6263
  process.exit(1);
@@ -6265,25 +6270,30 @@ async function handleList(args, globalOpts) {
6265
6270
  const api = new SkillHubAPI(registry, token);
6266
6271
  try {
6267
6272
  const result = await api.listDocs(page, size);
6268
- const docs = result.data || result.docs || result.content || [];
6273
+ const data = result.data || result;
6274
+ const docs = data.items || data.content || data.docs || (Array.isArray(data) ? data : []);
6269
6275
  if (!Array.isArray(docs) || docs.length === 0) {
6270
6276
  console.log(`${DIM$5}未找到文档。${RESET$5}`);
6271
6277
  return;
6272
6278
  }
6279
+ const total = data.total || data.totalElements || result.total || result.totalElements;
6273
6280
  console.log();
6274
- console.log(`${BOLD$3}文档${RESET$5}(第 ${page} 页,共 ${docs.length} 条结果):`);
6281
+ if (total) console.log(`${BOLD$3}文档${RESET$5}(第 ${page + 1} 页,共 ${total} 条):`);
6282
+ else console.log(`${BOLD$3}文档${RESET$5}(第 ${page + 1} 页,共 ${docs.length} 条结果):`);
6275
6283
  console.log(`${DIM$5}${"─".repeat(64)}${RESET$5}`);
6276
6284
  for (const doc of docs) {
6277
6285
  const id = doc.id || "?";
6278
6286
  const fileName = doc.fileName || doc.file_name || "unknown";
6279
- const status = doc.status || "unknown";
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";
6280
6291
  const createdAt = doc.createdAt || doc.created_at;
6281
6292
  const dateStr = createdAt ? new Date(createdAt).toISOString().split("T")[0] : "N/A";
6282
6293
  console.log(` ${BOLD$3}#${id}${RESET$5} ${TEXT$4}${fileName}${RESET$5}`);
6283
- console.log(` ${DIM$5}状态:${status} | 日期:${dateStr}${RESET$5}`);
6294
+ console.log(` ${DIM$5}${sizeStr} | ${user} | ${ip} | ${dateStr}${RESET$5}`);
6284
6295
  console.log();
6285
6296
  }
6286
- const total = result.total || result.totalElements;
6287
6297
  if (total && Number(total) > (page + 1) * size) console.log(`${DIM$5}下一页:bfi docs list ${page + 1}${RESET$5}`);
6288
6298
  console.log();
6289
6299
  } catch (error) {
@@ -6311,13 +6321,20 @@ async function handleInfo(args, globalOpts) {
6311
6321
  console.log(`${DIM$5}未找到文档:${id}${RESET$5}`);
6312
6322
  process.exit(1);
6313
6323
  }
6324
+ const content = doc.content;
6325
+ const hasContent = typeof content === "string" && content.trim().length > 0;
6314
6326
  console.log();
6315
6327
  console.log(`${BOLD$3}文档 #${doc.id}${RESET$5}`);
6316
6328
  console.log(`${DIM$5}${"─".repeat(48)}${RESET$5}`);
6317
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}`);
6318
6335
  if (doc.status) {
6319
6336
  const statusColor = doc.status === "completed" || doc.status === "COMPLETED" ? "\x1B[32m" : doc.status === "failed" || doc.status === "FAILED" ? "\x1B[31m" : TEXT$4;
6320
- console.log(` ${BOLD$3}状态:${RESET$5} ${statusColor}${doc.status}${RESET$5}`);
6337
+ console.log(` ${BOLD$3}状态:${RESET$5} ${statusColor}${doc.status}${RESET$5}`);
6321
6338
  }
6322
6339
  if (doc.createdAt || doc.created_at) {
6323
6340
  const date = new Date(doc.createdAt || doc.created_at).toISOString().replace("T", " ").slice(0, 19);
@@ -6327,17 +6344,18 @@ async function handleInfo(args, globalOpts) {
6327
6344
  const date = new Date(doc.updatedAt || doc.updated_at).toISOString().replace("T", " ").slice(0, 19);
6328
6345
  console.log(` ${BOLD$3}更新时间:${RESET$5} ${TEXT$4}${date}${RESET$5}`);
6329
6346
  }
6330
- if (doc.result) {
6331
- console.log();
6332
- console.log(` ${BOLD$3}结果:${RESET$5}`);
6333
- const resultStr = typeof doc.result === "string" ? doc.result : JSON.stringify(doc.result, null, 4);
6334
- for (const line of resultStr.split("\n")) console.log(` ${DIM$5}${line}${RESET$5}`);
6335
- }
6336
6347
  if (doc.error || doc.errorMessage) {
6337
6348
  console.log();
6338
6349
  console.log(` \x1b[31m${BOLD$3}错误:${RESET$5}`);
6339
6350
  console.log(` \x1b[31m${doc.error || doc.errorMessage}${RESET$5}`);
6340
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
+ }
6341
6359
  console.log();
6342
6360
  } catch (error) {
6343
6361
  if (error.status === 404) console.error(`未找到文档:${id}`);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "bfi-cli",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
4
4
  "description": "用友大业财BFI统一命令行工具,支持技能,技能包,元数据,UI元数据等",
5
5
  "type": "module",
6
6
  "bin": {
7
- "bfi": "./bin/bfi.mjs"
7
+ "bfi": "./bin/bfi.js"
8
8
  },
9
9
  "files": [
10
10
  "dist",
File without changes