Skip to content

Commit

Permalink
chore: remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmclin2 committed Dec 17, 2023
1 parent 914e336 commit 6970339
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 77 deletions.
14 changes: 0 additions & 14 deletions scripts/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,7 @@ export const publicAgentDir = resolve(root, "./public/agents");

export const agents = readdirSync(agentsDir, { withFileTypes: true });

export const templatePath = resolve(root, "agent-template.json");
export const templateFullPath = resolve(root, "agent-template-full.json");

export const indexPath = resolve(publicDir, "index.json");

export const indexCnPath = resolve(publicDir, "index.zh-CN.json");

export const readmePath = resolve(root, "README.md");

export const readmeCnPath = resolve(root, "README.zh-CN.md");

export const metaPath = resolve(root, "meta.json");
export const meta = readJSONSync(metaPath);

export const host = "https://chat-agents.lobehub.com";
export const githubHomepage = "https://github.com/lobehub/lobe-chat-agents";

export const readmeSplit = "<!-- AWESOME PROMPTS -->";
62 changes: 0 additions & 62 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { consola } from "consola";
import { colors } from "consola/utils";
import { Dirent, existsSync, mkdirSync, writeFileSync } from "node:fs";

import { readmeSplit } from "./const";

export const writeJSON = (filePath, data, format = true) => {
const jsonStr = format ? JSON.stringify(data, null, 2) : JSON.stringify(data);
writeFileSync(filePath, jsonStr, "utf8");
Expand All @@ -15,61 +11,3 @@ export const checkDir = (dirpath) => {

export const checkJSON = (file: Dirent) =>
file.isFile() && file.name?.endsWith(".json");

export const split = (name) => {
consola.log("");
consola.log(
colors.gray(
`========================== ${name} ==============================`
)
);
};

export const findDuplicates = (arr: string[]): string[] => {
const duplicates: { [key: string]: number } = {};

// 统计每个项目出现的次数
for (const item of arr) {
if (duplicates[item]) {
duplicates[item]++;
} else {
duplicates[item] = 1;
}
}

// 挑出重复出现 3 次以上的项目
const COUNT = 3;

const result = Object.keys(duplicates).filter(
(item) => duplicates[item] >= COUNT
);

// 按重复次数从多到少排序
result.sort((a, b) => duplicates[b] - duplicates[a]);

return result;
};

export const updateAwesomeReadme = (md: string, prompts: string): string => {
const mds = md.split(readmeSplit);
mds[1] = [" ", prompts, " "].join("\n\n");

return mds.join(readmeSplit);
};

export const checkHeader = (line: string) => {
const header = [
"### systemRole",
"### identifier",
"### avatar",
"### title",
"### description",
"### tags",
"### locale",
];
let check = false;
header.forEach((item) => {
if (line.startsWith(item)) check = true;
});
return check;
};
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"module": "ESNext",
"target": "es2017",
"noEmit": true,
"moduleResolution": "npmdler"
"moduleResolution": "bundler"
},
"include": ["scripts"]
}

0 comments on commit 6970339

Please sign in to comment.