MCPcopy
hub / github.com/Adpro-Team/GKD_THS_List / writeReadMeMd

Function writeReadMeMd

scripts/writeFile.ts:4–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2import fs from 'node:fs/promises';
3
4export const writeReadMeMd = async() => {
5 let list = ``;
6 List.forEach((a)=>{
7 let repository = a.repo == undefined ? null : a.repo;
8 let branch = repository == null ? null : a.branch;
9 let repoUrl = repository != null && branch != null ? `https://github.com/${a.repo}/tree/${a.branch}` : null;
10 let repoText = repoUrl == null ? '无' : a.repo;
11 list += `|${a.name}|${String(a.id)}|${a.author}|`;
12 list += a.prescribedUpdateUrl == undefined || a.prescribedUpdateUrl ? '由订阅内部规定链接更新|' : '从导入链接更新|';
13 list += repoText == '无' ? `${repoText}|` : `[${repoText}](${repoUrl}) ![GitHub Repo stars](https://img.shields.io/github/stars/${repoText})|<ul>`;
14 const subUrls = a.subUrls;
15 subUrls.forEach((b)=>{
16 let index = 1;
17 const urlName = (b.hasOwnProperty('name') ? b.name : `订阅链接${String(index)}`) + (b.defaultUpdateUrl ? '(内置的更新链接)' : '');
18 let url = `https://github.com/Adpro-Team/GKD_THS_List/blob/main/importUrlsList.md#${a.name}-${urlName}`;
19 url = url.replace(/ /g,'-').replace(/[\uFF08-\uFF09]/g,'');
20 list += `<li>[${urlName}](${url})</li><br>`;
21 index++;
22 });
23 list += a.active == true ? '</ul>|仍在维护|' : '</ul>|停止维护|';
24 list +='\r';
25 });
26 const mdTemplate = await fs.readFile(process.cwd() + '/Template.md', 'utf-8');
27 const readMeMdText = mdTemplate.replace('--thirdPartySubList--', list);
28 await fs.writeFile(process.cwd() + '/README.md', readMeMdText);
29};
30
31export const writeUrlListMd = async() => {
32 let list = ``;

Callers 1

update.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected