Swich over to a real markdown format Changelog, get rid of the old icky json style one

pull/2/head
BakedPVP 4 years ago
parent e664e31975
commit 2735703914

@ -0,0 +1,84 @@
# This Changelog is just a placeholder for now...
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project attempts to loosely adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [1.1.0] - 2019-02-15
Added {added marginTop}
======================
- Danish translation from [@frederikspang](https://github.com/frederikspang).
- Georgian translation from [@tatocaster ](https://github.com/tatocaster).
- Changelog inconsistency section in Bad Practices
Changed {fixed}
======================
- Fixed typos in Italian translation from [@lorenzo-arena](https://github.com/lorenzo-arena).
- Fixed typos in Indonesian translation from [@ekojs](https://github.com/ekojs).
## [1.0.0] - 2017-06-20
Added
======================
- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
- Version navigation.
- Links to latest released version in previous versions.
- "Why keep a changelog?" section.
- "Who needs a changelog?" section.
- "How do I make a changelog?" section.
- "Frequently Asked Questions" section.
- New "Guiding Principles" sub-section to "How do I make a changelog?".
- Simplified and Traditional Chinese translations from [@tianshuo](https://github.com/tianshuo).
- German translation from [@mpbzh](https://github.com/mpbzh) & [@Art4](https://github.com/Art4).
- Italian translation from [@azkidenz](https://github.com/azkidenz).
- Swedish translation from [@magol](https://github.com/magol).
- Turkish translation from [@karalamalar](https://github.com/karalamalar).
- French translation from [@zapashcanon](https://github.com/zapashcanon).
- Brazilian Portuguese translation from [@Webysther](https://github.com/Webysther).
- Polish translation from [@amielucha](https://github.com/amielucha) & [@m-aciek](https://github.com/m-aciek).
- Russian translation from [@aishek](https://github.com/aishek).
- Czech translation from [@h4vry](https://github.com/h4vry).
- Slovak translation from [@jkostolansky](https://github.com/jkostolansky).
- Korean translation from [@pierceh89](https://github.com/pierceh89).
- Croatian translation from [@porx](https://github.com/porx).
- Persian translation from [@Hameds](https://github.com/Hameds).
- Ukrainian translation from [@osadchyi-s](https://github.com/osadchyi-s).
Changed
======================
- Start using "changelog" over "change log" since it's the common usage.
- Start versioning based on the current English version at 0.3.0 to help
translation authors keep things up-to-date.
- Rewrite "What makes unicorns cry?" section.
- Rewrite "Ignoring Deprecations" sub-section to clarify the ideal
scenario.
- Improve "Commit log diffs" sub-section to further argument against
them.
- Merge "Why cant people just use a git log diff?" with "Commit log
diffs"
- Fix typos in Simplified Chinese and Traditional Chinese translations.
- Fix typos in Brazilian Portuguese translation.
- Fix typos in Turkish translation.
- Fix typos in Czech translation.
- Fix typos in Swedish translation.
- Improve phrasing in French translation.
- Fix phrasing and spelling in German translation.
Removed
======================
- Section about "changelog" vs "CHANGELOG".
[unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.1.0...HEAD
[1.1.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.0.0...v1.1.0
[1.0.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.3.0...v1.0.0

@ -190,7 +190,7 @@ class UpdaterSettings extends React.PureComponent {
<ButtonItem
note={Messages.VIZALITY_UPDATES_OPTS_CHANGE_LOGS_DESC}
button={Messages.VIZALITY_UPDATES_OPTS_CHANGE_LOGS}
onClick={() => this.plugin.openChangeLogs()}
onClick={() => this.plugin.openChangelogs()}
>
{Messages.VIZALITY_UPDATES_OPTS_CHANGE_LOGS}
</ButtonItem>

@ -1,20 +1,26 @@
const { React, getModule, getModuleByDisplayName, i18n: { Messages } } = require('@webpack');
const { open: openModal, close: closeModal } = require('vizality/modal');
const changelog = require('@root/changelogs.json');
const { DIR: { ROOT_DIR } } = require('@constants');
const { Confirm } = require('@components/modal');
const { Plugin } = require('@entities');
const { promises: { readFile } } = require('fs');
const { promisify } = require('util');
const cp = require('child_process');
const { join } = require('path');
const exec = promisify(cp.exec);
const Settings = require('./components/Settings');
const Changelog = join(ROOT_DIR, 'CHANGELOG.md');
module.exports = class Updater extends Plugin {
class Updater extends Plugin {
constructor () {
super();
this.changelog = {
image: 'https://www.talkwalker.com/images/2020/blog-headers/image-analysis.png',
footer: 'Missed an update? [Check out our previous change logs](https://google.com)'
};
this.checking = false;
this.cwd = { cwd: ROOT_DIR };
}
@ -41,9 +47,12 @@ module.exports = class Updater extends Plugin {
this.checkForUpdates();
const lastChangelog = this.settings.get('last_changelog', '');
if (changelog.id !== lastChangelog) {
this.openChangeLogs();
if (this.changelog.id !== lastChangelog) {
this.openChangelogs();
}
this.openChangelogs();
}
onStop () {
@ -267,10 +276,11 @@ module.exports = class Updater extends Plugin {
}
// Change Log
async openChangeLogs () {
async openChangelogs () {
const changelogObject = await this.formatChangelog();
const ChangeLog = await this._getChangeLogsComponent();
openModal(() => React.createElement(ChangeLog, {
changeLog: this.formatChangeLog(changelog)
changeLog: changelogObject
}));
}
@ -297,29 +307,26 @@ module.exports = class Updater extends Plugin {
}
renderVideo () {
if (!changelog.image) {
if (!_this.changelog.image) {
return null;
}
return React.createElement('img', {
src: changelog.image,
src: _this.changelog.image,
className: video,
alt: ''
});
}
renderFooter () {
const { markdownToReact } = getModule('markdownToReact');
const footer = super.renderFooter();
footer.props.children = React.createElement('span', {
dangerouslySetInnerHTML: {
__html: changelog.footer
}
});
footer.props.children = markdownToReact(_this.changelog.footer, { inline: true });
return footer;
}
componentWillUnmount () {
_this.settings.set('last_changelog', changelog.id);
_this.settings.set('last_changelog', `updates-${_this.changelog.id}`);
}
}
@ -328,33 +335,23 @@ module.exports = class Updater extends Plugin {
return this._ChangeLog;
}
formatChangeLog (json) {
let body = '';
const colorToClass = {
GREEN: 'added',
ORANGE: 'progress',
RED: 'fixed',
BLURPLE: 'improved'
};
json.contents.forEach(item => {
if (item.type === 'HEADER') {
body += `${item.text.toUpperCase()} {${colorToClass[item.color]}${item.noMargin ? ' marginTop' : ''}}\n======================\n\n`;
} else {
if (item.text) {
body += item.text;
body += '\n\n';
}
if (item.list) {
body += ` * ${item.list.join('\n\n * ')}`;
body += '\n\n';
}
}
});
async formatChangelog () {
const log = await readFile(Changelog, 'utf-8');
const dateRegex = /([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/g;
const date = log.match(dateRegex)[0];
const previousDate = log.match(dateRegex)[1];
const body = log.slice(log.search(date) + 11, log.search(previousDate) - 13).trim();
return {
date: json.date,
id: `updates-${date}`,
date,
locale: 'en-us',
revision: 1,
body
};
}
};
}
module.exports = Updater;

@ -1,17 +0,0 @@
{
"id": "updates-2020-6-24",
"date": "2020-06-24",
"contents": [
{
"type": "HEADER",
"color": "GREEN",
"text": "Vizality super private closed pre-alpha!",
"noMargin": true
},
{
"type": "CONTENTS",
"text": "Vizality is now entering its super private closed pre-alpha stage. Let's get this party started."
}
],
"footer": "This is just a test."
}
Loading…
Cancel
Save