Skip to content

Commit e9516cf

Browse files
committed
feat(scripts): generate latest release page
1 parent b31724c commit e9516cf

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed

docs/download/latest-release.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: Latest Release
3+
---
4+
5+
# v3.4.0
6+
7+
### Bug Fixes
8+
9+
- **editor:** editor height by resize window [#242](https://github.com/massCodeIO/massCode/issues/242) ([#253](https://github.com/massCodeIO/massCode/issues/253)) ([7865ff8](https://github.com/massCodeIO/massCode/commit/7865ff85023b5db0243d22f346dd6121ee639864))
10+
- **snippet:** set first fragment when creating a snippet ([#256](https://github.com/massCodeIO/massCode/issues/256)) ([d382625](https://github.com/massCodeIO/massCode/commit/d382625859a371e009be8def83839eb2791edf27))
11+
12+
### Features
13+
14+
- **i18n:** add German locales ([#244](https://github.com/massCodeIO/massCode/issues/244)) ([d842b29](https://github.com/massCodeIO/massCode/commit/d842b291670fa77b63e8083e670152a667afa369))
15+
16+
### New Contributors
17+
18+
- @Seulasslintan made their first contribution in https://github.com/massCodeIO/massCode/pull/244
19+
20+
<AssetsDownload />

docs/scripts/generate-assets.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { join } from 'path'
2-
import { writeJSONSync } from 'fs-extra'
2+
import { writeFileSync, writeJSONSync } from 'fs-extra'
33
import * as dotenv from 'dotenv'
44
import axios from 'axios'
5+
import handlebars from 'handlebars'
56

67
dotenv.config({ path: join(__dirname, '../.env') })
78

89
const BASE_URL = 'https://api.github.com'
910
const RELEASES_URL = '/repos/massCodeIO/massCode/releases'
1011
const DIST = join(__dirname, '../.vitepress/_data')
12+
const DOWNLOAD_PATH = join(__dirname, '../download/')
1113

1214
const api = axios.create({
1315
baseURL: BASE_URL,
@@ -16,6 +18,15 @@ const api = axios.create({
1618
}
1719
})
1820

21+
const templateLatestRelease = handlebars.compile(`---
22+
title: Latest Release
23+
---
24+
# v{{ version }}
25+
26+
{{ content }}
27+
28+
<AssetsDownload />`)
29+
1930
const fetch = async () => {
2031
const { data } = await api.get(RELEASES_URL)
2132

@@ -27,16 +38,21 @@ const fetch = async () => {
2738
const winAsset = `massCode.Setup.${version}.exe`
2839
const linuxAsset = `massCode_${version}_amd64.snap`
2940
const downloadUrl = `https://github.com/massCodeIO/massCode/releases/download/${tagName}`
41+
const changelog = releases[0].body
3042

3143
const assets = {
3244
version,
45+
changelog,
3346
mac: `${downloadUrl}/${macAsset}`,
3447
macM1: `${downloadUrl}/${macM1Asset}`,
3548
win: `${downloadUrl}/${winAsset}`,
3649
linux: `${downloadUrl}/${linuxAsset}`
3750
}
3851

52+
const latestReleaseMd = templateLatestRelease({ version, content: changelog })
53+
3954
writeJSONSync(join(DIST, 'assets.json'), assets)
55+
writeFileSync(join(DOWNLOAD_PATH, 'latest-release.md'), latestReleaseMd, 'utf-8')
4056
}
4157

4258
fetch()

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"eslint": "^8.22.0",
4747
"fs-extra": "^10.1.0",
4848
"gray-matter": "^4.0.3",
49+
"handlebars": "^4.7.7",
4950
"husky": "^7.0.4",
5051
"lint-staged": "^12.5.0",
5152
"npm-run-all": "^4.1.5",

pnpm-lock.yaml

+31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)