Commit 10ff3db1 by Torkel Ödegaard

Added first iteration/poc of changelog task

parent 3fc24fa9
......@@ -73,6 +73,7 @@
"html-webpack-plugin": "^3.2.0",
"husky": "^1.3.1",
"inquirer": "^6.2.2",
"issue-regex": "^3.0.0",
"jest": "^23.6.0",
"jest-date-mock": "^1.0.6",
"lint-staged": "^8.1.3",
......@@ -140,7 +141,8 @@
"gui:releasePrepare": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/index.ts gui:release",
"gui:publish": "cd packages/grafana-ui/dist && npm publish --access public",
"gui:release": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/index.ts gui:release -p",
"cli:help": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/index.ts --help"
"cli:help": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/index.ts --help",
"cli:changelog": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/index.ts core:changelog"
},
"husky": {
"hooks": {
......
......@@ -4,6 +4,7 @@ import chalk from 'chalk';
import { startTask } from './tasks/core.start';
import { buildTask } from './tasks/grafanaui.build';
import { releaseTask } from './tasks/grafanaui.release';
import { changelogTask } from './tasks/changelog';
program.option('-d, --depreciate <scripts>', 'Inform about npm script deprecation', v => v.split(','));
......@@ -38,6 +39,13 @@ program
});
});
program
.command('core:changelog')
.description('Builds changelog markdown')
.action(async cmd => {
await execTask(changelogTask)({});
});
program.parse(process.argv);
if (program.depreciate && program.depreciate.length === 2) {
......
import { Task, TaskRunner } from './task';
import axios from 'axios';
import issueRegex from 'issue-regex';
const githubGrafanaUrl = 'https://github.com/grafana/grafana';
interface ChangelogOptions {}
const changelogTaskRunner: TaskRunner<ChangelogOptions> = async () => {
let client = axios.create({
baseURL: 'https://api.github.com/repos/grafana/grafana',
timeout: 10000,
});
const res = await client.get('/issues?state=closed&labels=' + encodeURIComponent('add to changelog'));
let markdown = '';
for (const item of res.data) {
markdown += '* ' + item.title;
markdown += ` [#${item.number}](${githubGrafanaUrl}/issues/${item.number})`;
for (const issue of item.body.match(issueRegex())) {
markdown += ` [#${issue}](${githubGrafanaUrl}/issues/${issue})`;
}
markdown += '\n';
}
console.log(markdown);
};
export const changelogTask = new Task<ChangelogOptions>();
changelogTask.setName('Changelog generator task');
changelogTask.setRunner(changelogTaskRunner);
......@@ -9929,6 +9929,11 @@ isstream@~0.1.2:
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=
issue-regex@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/issue-regex/-/issue-regex-3.0.0.tgz#275c5dac460e7827819f749747baf686109695b7"
integrity sha512-KGkx4olfVCmESgFvImfiehUcY+WXnyVZ7uHKJO1eJWQr5QaAn9MSc0ejbCqCrBjafxwDxJ3cB5+dw8tQ8KZNzg==
istanbul-api@^1.3.1:
version "1.3.7"
resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-1.3.7.tgz#a86c770d2b03e11e3f778cd7aedd82d2722092aa"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment