一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
67 行
1.7 KiB
TypeScript
67 行
1.7 KiB
TypeScript
import * as fs from 'fs-extra';
|
|
import markdownUtils, { MarkdownTableHeader, MarkdownTableRow } from '@joplin/lib/markdownUtils';
|
|
import { PluginManifest } from '@joplin/lib/services/plugins/utils/types';
|
|
|
|
export default async function(readmePath: string, manifests: Record<string, PluginManifest>) {
|
|
let rows: MarkdownTableRow[] = [];
|
|
|
|
for (const pluginId in manifests) {
|
|
rows.push(manifests[pluginId] as unknown as MarkdownTableRow);
|
|
}
|
|
|
|
rows = rows.map(row => {
|
|
return {
|
|
...row,
|
|
download_url: `https://github.com/joplin/plugins/raw/master/plugins/${row.id}/plugin.jpl`,
|
|
};
|
|
});
|
|
|
|
const headers: MarkdownTableHeader[] = [
|
|
{
|
|
name: 'homepage_url',
|
|
label: ' ',
|
|
filter: (value: string) => {
|
|
if (!value) return '-';
|
|
return `[🏠](${markdownUtils.escapeLinkUrl(value)})`;
|
|
},
|
|
},
|
|
{
|
|
name: 'download_url',
|
|
label: ' ',
|
|
filter: (value: string) => {
|
|
if (!value) return '-';
|
|
return `[⬇️](${markdownUtils.escapeLinkUrl(value)})`;
|
|
},
|
|
},
|
|
{
|
|
name: 'name',
|
|
label: 'Name',
|
|
},
|
|
{
|
|
name: 'version',
|
|
label: 'Version',
|
|
},
|
|
{
|
|
name: 'description',
|
|
label: 'Description',
|
|
},
|
|
{
|
|
name: 'author',
|
|
label: 'Author',
|
|
},
|
|
];
|
|
|
|
rows.sort((a, b) => {
|
|
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : +1;
|
|
});
|
|
|
|
const mdTable = markdownUtils.createMarkdownTable(headers, rows);
|
|
|
|
const tableRegex = /<!-- PLUGIN_LIST -->([^]*)<!-- PLUGIN_LIST -->/;
|
|
|
|
const content = await fs.pathExists(readmePath) ? await fs.readFile(readmePath, 'utf8') : '<!-- PLUGIN_LIST -->\n<!-- PLUGIN_LIST -->';
|
|
const newContent = content.replace(tableRegex, `<!-- PLUGIN_LIST -->\n${mdTable}\n<!-- PLUGIN_LIST -->`);
|
|
|
|
await fs.writeFile(readmePath, newContent, 'utf8');
|
|
}
|