mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-25 05:22:52 +00:00
dev: generate extension installation table (#1061)
* dev: generate extension installation table * dev: collapse style
This commit is contained in:
parent
e5f88431dd
commit
223a142931
1 changed files with 94 additions and 4 deletions
|
|
@ -17,6 +17,94 @@ const run = (command) => {
|
|||
});
|
||||
};
|
||||
|
||||
const generateExtensionInstall = (version) => {
|
||||
|
||||
/**
|
||||
* @typedef {{ file: string; displayName: string; }} PlatformAsset
|
||||
* @typedef {{ name: string; displayName: string; assets: PlatformAsset[]; }} Platform
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @returns {string}
|
||||
*/
|
||||
const binExt = (name) => {
|
||||
return (name.includes('win32') ? '.exe' : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @returns {string}
|
||||
*/
|
||||
const debugExt = (name) => {
|
||||
return (name.includes('darwin') ? '.dwarf' : (name.includes('win32') ? '.pdb' : '.debug'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {string} displayName
|
||||
* @returns {Platform}
|
||||
*/
|
||||
const platform = (name, displayName) => ({
|
||||
name,
|
||||
displayName,
|
||||
assets: [
|
||||
{ file: `tinymist-${name}${binExt(name)}`, displayName: 'Binary' },
|
||||
{ file: `tinymist-${name}${debugExt(name)}`, displayName: 'Debug Symbols' }
|
||||
]
|
||||
})
|
||||
|
||||
/**
|
||||
* @type {Platform[]}
|
||||
*/
|
||||
const platforms = [
|
||||
platform('win32-x64', 'x64 Windows'),
|
||||
platform('win32-arm64', 'ARM64 Windows'),
|
||||
platform('linux-x64', 'x64 Linux'),
|
||||
platform('linux-arm64', 'ARM64 Linux'),
|
||||
platform('linux-armhf', 'ARMv7 Linux'),
|
||||
platform('darwin-x64', 'Intel macOS'),
|
||||
platform('darwin-arm64', 'Apple Silicon macOS'),
|
||||
platform('alpine-x64', 'x64 Alpine Linux'),
|
||||
platform('alpine-arm64', 'ARM64 Alpine Linux'),
|
||||
{
|
||||
name: 'universe',
|
||||
displayName: 'Other Platforms (Universe)',
|
||||
assets: []
|
||||
}
|
||||
];
|
||||
|
||||
const urlBase = `https://github.com/Myriad-Dreamin/tinymist/releases/download/v${version}`;
|
||||
|
||||
const rows = platforms.map(platform => {
|
||||
const file = `[tinymist-${platform.name}.vsix](${urlBase}/tinymist-${platform.name}.vsix)`;
|
||||
const assets = platform.assets.map(asset => {
|
||||
return `[${asset.displayName}](${urlBase}/${asset.file})`;
|
||||
}).join(', ');
|
||||
return `| ${file} | ${platform.displayName} | ${assets} |`;
|
||||
});
|
||||
|
||||
const table = rows.join('\n');
|
||||
|
||||
|
||||
return `## Download tinymist VS Code Extension ${version}
|
||||
| File | Platform | Assets |
|
||||
|--------|----------|--------|
|
||||
${table}
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
const collapsed = (content, summary) => {
|
||||
return `<details>
|
||||
|
||||
<summary><strong>${summary}</strong></summary>
|
||||
|
||||
${content}
|
||||
|
||||
</details>`;
|
||||
}
|
||||
|
||||
const main = async () => {
|
||||
if (!versionToUpload) {
|
||||
console.error("Please provide the version to upload");
|
||||
|
|
@ -42,9 +130,9 @@ const main = async () => {
|
|||
|
||||
const distManifest = await run(DIST_CMD + ' host --steps=upload --steps=release --output-format=json');
|
||||
const distData = JSON.parse(distManifest);
|
||||
const body = distData.announcement_github_body;
|
||||
const binInstallText = distData.announcement_github_body;
|
||||
// write to file
|
||||
fs.writeFileSync('target/announcement-dist.md', body);
|
||||
fs.writeFileSync('target/announcement-dist.md', binInstallText);
|
||||
|
||||
// parse-changelog .\editors\vscode\CHANGELOG.md
|
||||
const changelogPlainRaw = await run('parse-changelog ./editors/vscode/CHANGELOG.md');
|
||||
|
|
@ -68,9 +156,11 @@ const main = async () => {
|
|||
|
||||
fs.writeFileSync('target/announcement-changelog.md', changelogPlain);
|
||||
|
||||
|
||||
const extensionInstallText = generateExtensionInstall(versionToUpload);
|
||||
// concat and generate final announcement
|
||||
const announcement = `${changelogPlain}\n\n${body}`;
|
||||
const binInstallSection = collapsed(binInstallText, `Download Binary`);
|
||||
const extensionInstallSection = collapsed(extensionInstallText, `Download VS Code Extension`);
|
||||
const announcement = [changelogPlain, binInstallSection, extensionInstallSection].join('\n\n');
|
||||
fs.writeFileSync('target/announcement.gen.md', announcement);
|
||||
|
||||
console.log("Please check the generated announcement in target/announcement.gen.md");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue