bfi-cli 0.1.40 → 0.1.41
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 +24 -14
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -5846,14 +5846,14 @@ async function runSearch(args, globalOpts) {
|
|
|
5846
5846
|
const query = parseSearchQuery(args);
|
|
5847
5847
|
const namespace = args.includes("--namespace") ? getOptionValue$2(args, "--namespace") : void 0;
|
|
5848
5848
|
const json = args.includes("--json");
|
|
5849
|
-
if (!query) {
|
|
5850
|
-
console.log(
|
|
5849
|
+
if (!query || query.trim() === "") {
|
|
5850
|
+
console.log(`${BOLD$5}bfi skills search <关键词> [选项]${RESET$8}`);
|
|
5851
5851
|
console.log();
|
|
5852
|
-
console.log(
|
|
5853
|
-
console.log(
|
|
5854
|
-
console.log(
|
|
5855
|
-
console.log(
|
|
5856
|
-
console.log(
|
|
5852
|
+
console.log(`${DIM$8}常用命令:${RESET$8}`);
|
|
5853
|
+
console.log(` bfi skills search react ${DIM$8}搜索 SkillHub${RESET$8}`);
|
|
5854
|
+
console.log(` bfi skills search react --marketplace ${DIM$8}搜索 skills.sh${RESET$8}`);
|
|
5855
|
+
console.log(` bfi skills search react --all ${DIM$8}搜索全部${RESET$8}`);
|
|
5856
|
+
console.log(` bfi skills search react --json ${DIM$8}JSON 输出${RESET$8}`);
|
|
5857
5857
|
return;
|
|
5858
5858
|
}
|
|
5859
5859
|
const useMarketplace = args.includes("--marketplace");
|
|
@@ -6913,9 +6913,8 @@ async function handleSearch(args, api, globalOpts) {
|
|
|
6913
6913
|
}
|
|
6914
6914
|
const allPackages = [];
|
|
6915
6915
|
for (const ns of nsList) try {
|
|
6916
|
-
const
|
|
6917
|
-
|
|
6918
|
-
allPackages.push(...pkgs.map((p) => ({
|
|
6916
|
+
const pkgs = await api.listPackages(ns);
|
|
6917
|
+
if (Array.isArray(pkgs)) allPackages.push(...pkgs.map((p) => ({
|
|
6919
6918
|
...p,
|
|
6920
6919
|
_namespace: ns
|
|
6921
6920
|
})));
|
|
@@ -6928,12 +6927,23 @@ async function handleSearch(args, api, globalOpts) {
|
|
|
6928
6927
|
console.log("未找到任何技能包。");
|
|
6929
6928
|
return;
|
|
6930
6929
|
}
|
|
6930
|
+
const dw = (s) => {
|
|
6931
|
+
let w = 0;
|
|
6932
|
+
for (const ch of s) w += /[一-鿿]/.test(ch) ? 2 : 1;
|
|
6933
|
+
return w;
|
|
6934
|
+
};
|
|
6935
|
+
const pad = (s, w) => {
|
|
6936
|
+
let r = s;
|
|
6937
|
+
while (dw(r) < w) r += " ";
|
|
6938
|
+
return r;
|
|
6939
|
+
};
|
|
6940
|
+
const maxName = Math.max(...allPackages.map((p) => dw(p.displayName || p.name || p.slug || "")), 4);
|
|
6941
|
+
const maxSlug = Math.max(...allPackages.map((p) => dw(`@${p._namespace}/${p.slug}`)), 4);
|
|
6931
6942
|
console.log(`\n${BOLD$1}所有技能包(${allPackages.length} 个):${RESET$3}\n`);
|
|
6932
6943
|
for (const pkg of allPackages) {
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
console.log();
|
|
6944
|
+
const name = pad(pkg.displayName || pkg.name || pkg.slug || "", maxName);
|
|
6945
|
+
const ref = pad(`@${pkg._namespace}/${pkg.slug}`, maxSlug);
|
|
6946
|
+
console.log(` ${BOLD$1}${name}${RESET$3} ${DIM$3}${ref} ${pkg.visibility === "PUBLIC" ? "公开" : "私有"}${RESET$3}`);
|
|
6937
6947
|
}
|
|
6938
6948
|
}
|
|
6939
6949
|
}
|