grafana/scripts/cli/index.ts
gotjosh bc94f85dee
Improvement: Grafana release process minor improvements (#17661)
* Don't display changelog category title when no items

The output of the changelog is meant to be copy/pasted with ease. When a
changelog category does not contain items is better to not display title
at all thus avoiding having the manually modify the output as we include
it in the steps of the process.

* Introduce a CLI task to close milestones whilst doing a Grafana release

As part of a Grafana release, we need to eventually close the GitHub
milestone to indicate is done and remove all the cherry-pick labels from
issues/prs within the milestone to avoid our cherry-pick CLI command to
pick them up on the next release.

* Abstract the GitHub client into a module

* Introduce `GitHubClient` to all CLI tasks
2019-06-24 16:00:01 +01:00

109 lines
3.3 KiB
TypeScript

import program from 'commander';
import { execTask } from './utils/execTask';
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';
import { cherryPickTask } from './tasks/cherrypick';
import { closeMilestoneTask } from './tasks/closeMilestone';
import { precommitTask } from './tasks/precommit';
import { searchTestDataSetupTask } from './tasks/searchTestDataSetup';
program.option('-d, --depreciate <scripts>', 'Inform about npm script deprecation', v => v.split(','));
program
.command('core:start')
.option('-h, --hot', 'Run front-end with HRM enabled')
.option('-t, --watchTheme', 'Watch for theme changes and regenerate variables.scss files')
.description('Starts Grafana front-end in development mode with watch enabled')
.action(async cmd => {
await execTask(startTask)({
watchThemes: cmd.watchTheme,
hot: cmd.hot,
});
});
program
.command('gui:build')
.description('Builds @grafana/ui package to packages/grafana-ui/dist')
.action(async cmd => {
await execTask(buildTask)();
});
program
.command('gui:release')
.description('Prepares @grafana/ui release (and publishes to npm on demand)')
.option('-p, --publish', 'Publish @grafana/ui to npm registry')
.option('-u, --usePackageJsonVersion', 'Use version specified in package.json')
.option('--createVersionCommit', 'Create and push version commit')
.action(async cmd => {
await execTask(releaseTask)({
publishToNpm: !!cmd.publish,
usePackageJsonVersion: !!cmd.usePackageJsonVersion,
createVersionCommit: !!cmd.createVersionCommit,
});
});
program
.command('changelog')
.option('-m, --milestone <milestone>', 'Specify milestone')
.description('Builds changelog markdown')
.action(async cmd => {
if (!cmd.milestone) {
console.log('Please specify milestone, example: -m <milestone id from github milestone URL>');
return;
}
await execTask(changelogTask)({
milestone: cmd.milestone,
});
});
program
.command('cherrypick')
.description('Helps find commits to cherry pick')
.action(async cmd => {
await execTask(cherryPickTask)({});
});
program
.command('close-milestone')
.option('-m, --milestone <milestone>', 'Specify milestone')
.description('Helps ends a milestone by removing the cherry-pick label and closing it')
.action(async cmd => {
if (!cmd.milestone) {
console.log('Please specify milestone, example: -m <milestone id from github milestone URL>');
return;
}
await execTask(closeMilestoneTask)({
milestone: cmd.milestone,
});
});
program
.command('precommit')
.description('Executes checks')
.action(async cmd => {
await execTask(precommitTask)({});
});
program
.command('searchTestData')
.option('-c, --count <number_of_dashboards>', 'Specify number of dashboards')
.description('Setup test data for search')
.action(async cmd => {
await execTask(searchTestDataSetupTask)({ count: cmd.count });
});
program.parse(process.argv);
if (program.depreciate && program.depreciate.length === 2) {
console.log(
chalk.yellow.bold(
`[NPM script depreciation] ${program.depreciate[0]} is deprecated! Use ${program.depreciate[1]} instead!`
)
);
}