siluzan-cso-cli 1.1.8-beta.2 → 1.1.8-beta.4
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/README.md +1 -1
- package/dist/index.js +151 -76
- package/dist/skill/_meta.json +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ siluzan-cso init -d /path/to/skills # 写入自定义目录
|
|
|
20
20
|
siluzan-cso init --force # 强制覆盖已存在文件
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
> **注意**:当前为测试版(1.1.8-beta.
|
|
23
|
+
> **注意**:当前为测试版(1.1.8-beta.4),供内部测试使用。正式发布后安装命令将改为 `npm install -g siluzan-cso-cli`。
|
|
24
24
|
|
|
25
25
|
| 助手 | 建议 `--ai` |
|
|
26
26
|
|------|-------------|
|
package/dist/index.js
CHANGED
|
@@ -2340,7 +2340,8 @@ async function ensureSentryInitialized(requestUrl) {
|
|
|
2340
2340
|
if (!flushHookRegistered) {
|
|
2341
2341
|
flushHookRegistered = true;
|
|
2342
2342
|
process.once("beforeExit", () => {
|
|
2343
|
-
void Sentry.flush(2e3)
|
|
2343
|
+
void Sentry.flush(2e3).catch(() => {
|
|
2344
|
+
});
|
|
2344
2345
|
});
|
|
2345
2346
|
}
|
|
2346
2347
|
sentryReady = true;
|
|
@@ -4760,55 +4761,161 @@ async function getWithQuery(runtime, endpoint, query) {
|
|
|
4760
4761
|
}
|
|
4761
4762
|
return res.data;
|
|
4762
4763
|
}
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4764
|
+
var MODULE_TITLES = {
|
|
4765
|
+
"total-fans": "\u603B\u7C89\u4E1D\u6570",
|
|
4766
|
+
"fans-analysis": "\u7C89\u4E1D\u5206\u6790",
|
|
4767
|
+
"hot-topic": "\u70ED\u95E8\u8BDD\u9898",
|
|
4768
|
+
"hot-comment-word": "\u70ED\u95E8\u8BC4\u8BBA\u8BCD",
|
|
4769
|
+
"comment-top10": "\u8BC4\u8BBA Top10",
|
|
4770
|
+
"video-duration": "\u89C6\u9891\u65F6\u957F\u5206\u5E03",
|
|
4771
|
+
"video-distribution": "\u89C6\u9891\u5206\u5E03",
|
|
4772
|
+
"comment-trend": "\u8BC4\u8BBA\u8D8B\u52BF",
|
|
4773
|
+
"fans-trend": "\u7C89\u4E1D\u8D8B\u52BF",
|
|
4774
|
+
"new-fans-trend": "\u65B0\u589E\u7C89\u4E1D\u8D8B\u52BF",
|
|
4775
|
+
"homepage-visit": "\u4E3B\u9875\u8BBF\u95EE\u8D8B\u52BF"
|
|
4776
|
+
};
|
|
4777
|
+
function renderMarkdownArrayOfObjects(rows) {
|
|
4778
|
+
if (rows.length === 0) {
|
|
4766
4779
|
return;
|
|
4767
4780
|
}
|
|
4768
|
-
const
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
value: item.value === null || item.value === void 0 ? "-" : String(item.value),
|
|
4776
|
-
incrementRate: item.incrementRate === null || item.incrementRate === void 0 ? "-" : String(item.incrementRate)
|
|
4777
|
-
}));
|
|
4778
|
-
const tableOptions2 = unicode ? { plain: false } : void 0;
|
|
4779
|
-
printCliTable(rows, columns, tableOptions2);
|
|
4781
|
+
const keys = Object.keys(rows[0]);
|
|
4782
|
+
console.log("| " + keys.join(" | ") + " |");
|
|
4783
|
+
console.log("| " + keys.map(() => "---").join(" | ") + " |");
|
|
4784
|
+
for (const row of rows) {
|
|
4785
|
+
console.log("| " + keys.map((k) => String(row[k] ?? "-")).join(" | ") + " |");
|
|
4786
|
+
}
|
|
4787
|
+
console.log();
|
|
4780
4788
|
}
|
|
4781
|
-
function
|
|
4782
|
-
if (
|
|
4783
|
-
|
|
4789
|
+
function isTimeSeries(arr) {
|
|
4790
|
+
if (arr.length === 0) return false;
|
|
4791
|
+
const first = arr[0];
|
|
4792
|
+
if ("date" in first && "count" in first) return true;
|
|
4793
|
+
if ("name" in first && "value" in first) {
|
|
4794
|
+
const name = first.name;
|
|
4795
|
+
return typeof name === "number" || typeof name === "string" && /^\d{4}-\d{2}-\d{2}/.test(name);
|
|
4796
|
+
}
|
|
4797
|
+
return false;
|
|
4798
|
+
}
|
|
4799
|
+
function renderTimeSeries(arr) {
|
|
4800
|
+
const keyField = "date" in arr[0] ? "date" : "name";
|
|
4801
|
+
const valField = "count" in arr[0] ? "count" : "value";
|
|
4802
|
+
const nonZero = arr.filter((item) => {
|
|
4803
|
+
const v = item[valField];
|
|
4804
|
+
return v !== null && v !== void 0 && Number(v) !== 0;
|
|
4805
|
+
});
|
|
4806
|
+
if (nonZero.length === 0) {
|
|
4807
|
+
console.log(`_\uFF08${arr.length}\u6761\u5747\u4E3A0\uFF09_
|
|
4808
|
+
`);
|
|
4784
4809
|
return;
|
|
4785
4810
|
}
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
{
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
rank: String(index + 1),
|
|
4795
|
-
title: String(item.title ?? item.name ?? "-"),
|
|
4796
|
-
play: String(item.play ?? item.playCount ?? "-"),
|
|
4797
|
-
digg: String(item.digg ?? item.likeCount ?? "-"),
|
|
4798
|
-
comment: String(item.comment ?? item.commentCount ?? "-")
|
|
4799
|
-
}));
|
|
4800
|
-
const tableOptions2 = unicode ? { plain: false } : void 0;
|
|
4801
|
-
printCliTable(rows, columns, tableOptions2);
|
|
4811
|
+
if (nonZero.length <= 6) {
|
|
4812
|
+
const pairs = nonZero.map((item) => `${item[keyField]}:${item[valField]}`).join(", ");
|
|
4813
|
+
const zeroCount = arr.length - nonZero.length;
|
|
4814
|
+
console.log(`${pairs}${zeroCount > 0 ? `\uFF08\u5176\u4F59${zeroCount}\u6761\u4E3A0\uFF09` : ""}
|
|
4815
|
+
`);
|
|
4816
|
+
return;
|
|
4817
|
+
}
|
|
4818
|
+
renderMarkdownArrayOfObjects(arr);
|
|
4802
4819
|
}
|
|
4803
|
-
function
|
|
4820
|
+
function renderMarkdownValue(data) {
|
|
4821
|
+
if (data === null || data === void 0) return;
|
|
4822
|
+
if (Array.isArray(data)) {
|
|
4823
|
+
if (data.length === 0) return;
|
|
4824
|
+
if (typeof data[0] === "object" && data[0] !== null) {
|
|
4825
|
+
const rows = data;
|
|
4826
|
+
if (isTimeSeries(rows)) {
|
|
4827
|
+
renderTimeSeries(rows);
|
|
4828
|
+
} else {
|
|
4829
|
+
renderMarkdownArrayOfObjects(rows);
|
|
4830
|
+
}
|
|
4831
|
+
} else {
|
|
4832
|
+
for (const item of data) console.log(`- ${String(item)}`);
|
|
4833
|
+
console.log();
|
|
4834
|
+
}
|
|
4835
|
+
return;
|
|
4836
|
+
}
|
|
4837
|
+
if (typeof data === "object") {
|
|
4838
|
+
const obj = data;
|
|
4839
|
+
const keys = Object.keys(obj);
|
|
4840
|
+
if (keys.length === 0) return;
|
|
4841
|
+
const summaryParts = [];
|
|
4842
|
+
for (const key of keys) {
|
|
4843
|
+
const val = obj[key];
|
|
4844
|
+
if (Array.isArray(val) && val.length > 0 && typeof val[0] === "object") {
|
|
4845
|
+
if (summaryParts.length > 0) {
|
|
4846
|
+
console.log(summaryParts.join(" | ") + "\n");
|
|
4847
|
+
summaryParts.length = 0;
|
|
4848
|
+
}
|
|
4849
|
+
console.log(`**${key}**`);
|
|
4850
|
+
renderMarkdownValue(val);
|
|
4851
|
+
} else if (!Array.isArray(val)) {
|
|
4852
|
+
summaryParts.push(`${key}: ${JSON.stringify(val)}`);
|
|
4853
|
+
}
|
|
4854
|
+
}
|
|
4855
|
+
if (summaryParts.length > 0) console.log(summaryParts.join(" | ") + "\n");
|
|
4856
|
+
return;
|
|
4857
|
+
}
|
|
4858
|
+
console.log(String(data) + "\n");
|
|
4859
|
+
}
|
|
4860
|
+
function printMarkdownFetch(runtime, includeModules, sections) {
|
|
4804
4861
|
const accountScope = runtime.baseQuery.mediaCustomerIds.length > 0 ? runtime.baseQuery.mediaCustomerIds.join(", ") : "\u5168\u90E8\u8D26\u53F7";
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
console.log(
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4862
|
+
const startDay = runtime.baseQuery.startDate.slice(0, 10);
|
|
4863
|
+
const endDay = runtime.baseQuery.endDate.slice(0, 10);
|
|
4864
|
+
console.log(`# \u8FD0\u8425\u62A5\u8868\uFF5C${runtime.baseQuery.mediaTypes.join(",")}\uFF5C${accountScope}\uFF5C${startDay}~${endDay}\uFF5C${runtime.method}
|
|
4865
|
+
`);
|
|
4866
|
+
if (sections.operation && typeof sections.operation === "object") {
|
|
4867
|
+
const op = sections.operation;
|
|
4868
|
+
const core = Array.isArray(op.coreData) ? [...op.coreData] : [];
|
|
4869
|
+
if (typeof sections["total-fans"] === "number") {
|
|
4870
|
+
if (!core.some((item) => item.name === "TotalFans")) {
|
|
4871
|
+
core.push({ name: "TotalFans", value: sections["total-fans"], incrementRate: null });
|
|
4872
|
+
}
|
|
4873
|
+
}
|
|
4874
|
+
console.log("## \u6838\u5FC3\u6307\u6807\n");
|
|
4875
|
+
if (core.length > 0) {
|
|
4876
|
+
console.log("| \u6307\u6807 | \u5F53\u524D\u503C | \u73AF\u6BD4(%) |");
|
|
4877
|
+
console.log("| --- | --- | --- |");
|
|
4878
|
+
for (const item of core) {
|
|
4879
|
+
const val = item.value === null || item.value === void 0 ? "-" : String(item.value);
|
|
4880
|
+
const rate = item.incrementRate === null || item.incrementRate === void 0 ? "-" : String(item.incrementRate);
|
|
4881
|
+
console.log(`| ${item.name} | ${val} | ${rate} |`);
|
|
4882
|
+
}
|
|
4883
|
+
console.log();
|
|
4884
|
+
} else {
|
|
4885
|
+
console.log("_\uFF08\u65E0\u6838\u5FC3\u6307\u6807\u6570\u636E\uFF09_\n");
|
|
4886
|
+
}
|
|
4887
|
+
}
|
|
4888
|
+
if (Array.isArray(sections.works)) {
|
|
4889
|
+
const works = sections.works;
|
|
4890
|
+
console.log("## \u89C6\u9891\u660E\u7EC6\n");
|
|
4891
|
+
if (works.length > 0) {
|
|
4892
|
+
console.log("| \u6392\u540D | \u6807\u9898 | \u64AD\u653E | \u70B9\u8D5E | \u8BC4\u8BBA |");
|
|
4893
|
+
console.log("| --- | --- | --- | --- | --- |");
|
|
4894
|
+
works.forEach((item, idx) => {
|
|
4895
|
+
const title = String(item.title ?? item.name ?? "-");
|
|
4896
|
+
const play = String(item.play ?? item.playCount ?? "-");
|
|
4897
|
+
const digg = String(item.digg ?? item.likeCount ?? "-");
|
|
4898
|
+
const comment = String(item.comment ?? item.commentCount ?? "-");
|
|
4899
|
+
console.log(`| ${idx + 1} | ${title} | ${play} | ${digg} | ${comment} |`);
|
|
4900
|
+
});
|
|
4901
|
+
console.log();
|
|
4902
|
+
} else {
|
|
4903
|
+
console.log("_\uFF08\u65E0\u89C6\u9891\u6570\u636E\uFF09_\n");
|
|
4904
|
+
}
|
|
4905
|
+
}
|
|
4906
|
+
const otherModules = includeModules.filter(
|
|
4907
|
+
(m) => m !== "operation" && m !== "works" && m !== "total-fans"
|
|
4908
|
+
);
|
|
4909
|
+
for (const moduleName of otherModules) {
|
|
4910
|
+
const data = sections[moduleName];
|
|
4911
|
+
if (data === null || data === void 0) continue;
|
|
4912
|
+
if (Array.isArray(data) && data.length === 0) continue;
|
|
4913
|
+
if (typeof data === "object" && !Array.isArray(data) && Object.keys(data).length === 0) continue;
|
|
4914
|
+
const title = MODULE_TITLES[moduleName] ?? moduleName;
|
|
4915
|
+
console.log(`## ${title}
|
|
4916
|
+
`);
|
|
4917
|
+
renderMarkdownValue(data);
|
|
4918
|
+
}
|
|
4812
4919
|
}
|
|
4813
4920
|
async function runReportFetch(options) {
|
|
4814
4921
|
const runtime = buildRuntime(options);
|
|
@@ -4901,39 +5008,7 @@ async function runReportFetch(options) {
|
|
|
4901
5008
|
console.log(JSON.stringify(payload, null, 2));
|
|
4902
5009
|
return;
|
|
4903
5010
|
}
|
|
4904
|
-
|
|
4905
|
-
if (sections.operation && typeof sections.operation === "object") {
|
|
4906
|
-
const op = sections.operation;
|
|
4907
|
-
const core = Array.isArray(op.coreData) ? [...op.coreData] : [];
|
|
4908
|
-
if (typeof sections["total-fans"] === "number") {
|
|
4909
|
-
const exists = core.some((item) => item.name === "TotalFans");
|
|
4910
|
-
if (!exists) {
|
|
4911
|
-
core.push({ name: "TotalFans", value: sections["total-fans"], incrementRate: null });
|
|
4912
|
-
}
|
|
4913
|
-
}
|
|
4914
|
-
console.log("\n\u6838\u5FC3\u6307\u6807\uFF1A");
|
|
4915
|
-
renderCoreData(core, options.unicode);
|
|
4916
|
-
}
|
|
4917
|
-
if (Array.isArray(sections.works)) {
|
|
4918
|
-
console.log("\n\u89C6\u9891\u660E\u7EC6\uFF08\u6700\u591A\u5C55\u793A\u524D 10 \u6761\uFF09\uFF1A");
|
|
4919
|
-
renderWorksData(sections.works, options.unicode);
|
|
4920
|
-
}
|
|
4921
|
-
const hiddenModules = includeModules.filter((m) => m !== "operation" && m !== "works");
|
|
4922
|
-
if (hiddenModules.length > 0) {
|
|
4923
|
-
console.log("\n\u5176\u4ED6\u6A21\u5757\u5DF2\u83B7\u53D6\uFF1A");
|
|
4924
|
-
for (const m of hiddenModules) {
|
|
4925
|
-
const data = sections[m];
|
|
4926
|
-
if (Array.isArray(data)) {
|
|
4927
|
-
console.log(` - ${m}: \u6570\u7EC4(${data.length})`);
|
|
4928
|
-
} else if (data && typeof data === "object") {
|
|
4929
|
-
console.log(` - ${m}: \u5BF9\u8C61`);
|
|
4930
|
-
} else {
|
|
4931
|
-
console.log(` - ${m}: ${String(data ?? "null")}`);
|
|
4932
|
-
}
|
|
4933
|
-
}
|
|
4934
|
-
console.log("\u63D0\u793A\uFF1A\u5982\u9700\u5B8C\u6574\u7ED3\u6784\uFF0C\u8BF7\u52A0 --json\u3002");
|
|
4935
|
-
}
|
|
4936
|
-
console.log();
|
|
5011
|
+
printMarkdownFetch(runtime, includeModules, sections);
|
|
4937
5012
|
}
|
|
4938
5013
|
function parsePositiveInt(value, optionName, defaultValue) {
|
|
4939
5014
|
if (!value) return defaultValue;
|
package/dist/skill/_meta.json
CHANGED
package/package.json
CHANGED