The class reads a Markdown file and extracts the changelog entries. The Markdown file is expected to be formatted as follows:
- Start: The first line of the file is the title of the changelog and has to be "# CHANGELOG".
- Changelog: New Changelogs entries begin with a title which ought to have the format: "## [Title]"
- Changelog: Next comes either the version or null which ought to have the format: "### vYYYY.X.Y" where X and Y can be arbitrarily many digits
- Changelog: Next comes the date which out to have the format: "### [Date]" and the Date has to be in the format: "YYYY-MM-DD"
- Changelog: Now the description lines follow, which are either:
- Text and come in format: "[Text]"
- Bullet points and come in format: "* [Text]"
NB: at minimum one empty space is necessary between each signifier (e.g. "-", "*", "#", "##", "###", etc.) and the content.
# CHANGELOGS
## Changelog Title - Version 2.00
### v3023.23.123123
Changelog description text line 1
Changelog description text line 2
- Feature bullet 1
- Feature bullet 2
Changelog summary text line
## Changelog Title - Version 1.00
### 2021-10-10
Changelog description text line 1
- Feature bullet 1
- Feature bullet 2
- Feature bullet 3
Changelog summary text line 1
Changelog summary text line 2
=>
const expectedChangeLogs: ChangeLog[] = [
new ChangeLog(
'Changelog Title - Version 2.00',
"v3023.23.123123",
null,
[
new Line('Changelog description text line 1 Changelog description text line 2', LineStateType.DESCRIPTION_TEXT ),
new Line('Feature bullet 1', LineStateType.DESCRIPTION_BULLET ),
new Line('Feature bullet 2', LineStateType.DESCRIPTION_BULLET ),
new Line('Changelog summary text line', LineStateType.DESCRIPTION_TEXT)
]),
new ChangeLog(
'Changelog Title - Version 1.00',
null,
new Date('2021-10-10'),
[
new Line( 'Changelog description text line 1', LineStateType.DESCRIPTION_TEXT ),
new Line( 'Feature bullet 1', LineStateType.DESCRIPTION_BULLET),
new Line( 'Feature bullet 2', LineStateType.DESCRIPTION_BULLET),
new Line( 'Feature bullet 3', LineStateType.DESCRIPTION_BULLET),
new Line( 'Changelog summary text line 1 Changelog summary text line 2', LineStateType.DESCRIPTION_TEXT),
],
)];
Put:
Add "markdown_changelog_parser": "^1.0.22" (or a more current version) to your package.json dependencies section.
const changeLogParser = new ChangeLogParser(fileContent);
changeLogParser.parse();
const changelogs = changeLogParser.changeLogs;
console.log(changelogs);
In VueJS you need to install raw-loader:
Add "raw-loader": "^4.0.2" (or a more current version) to your package.json dependencies section. Also add:
configureWebpack: {
module: {
rules: [
{
test: /\.md$/i,
loader: "raw-loader",
}
]
}
}
as an entry into your vue.config.js file.
Now you can use somethin like:
const fileContent = require(`@/assets/changelogs/${changeLogFileName}`);
in your code.
> npm install
Run once on start and every time you change any non-typescript/non-javascript files. See package.json => scripts => build for more details.
> npm run build
I you allow in your Webstorm Config in Preferences => Framework => TypeScript: you can check recompile on changes. this will recompile all typescript files in /scr to javascript in /build, but NOT any asset file. Asset file changes need to be compiled separatly using: npm run build.
> npm run test
> npm run test