2019-02-13 07:47:59 -06:00
|
|
|
import program from 'commander';
|
2019-02-21 03:58:28 -06:00
|
|
|
import { execTask } from './utils/execTask';
|
2019-03-05 01:56:29 -06:00
|
|
|
import chalk from 'chalk';
|
|
|
|
import { startTask } from './tasks/core.start';
|
|
|
|
import { buildTask } from './tasks/grafanaui.build';
|
|
|
|
import { releaseTask } from './tasks/grafanaui.release';
|
2019-03-05 08:53:25 -06:00
|
|
|
import { changelogTask } from './tasks/changelog';
|
2019-03-06 06:18:13 -06:00
|
|
|
import { cherryPickTask } from './tasks/cherrypick';
|
2019-02-13 07:47:59 -06:00
|
|
|
|
2019-03-05 01:56:29 -06:00
|
|
|
program.option('-d, --depreciate <scripts>', 'Inform about npm script deprecation', v => v.split(','));
|
2019-02-21 03:58:28 -06:00
|
|
|
|
2019-02-13 07:47:59 -06:00
|
|
|
program
|
2019-03-05 01:56:29 -06:00
|
|
|
.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)({
|
2019-03-07 06:12:10 -06:00
|
|
|
watchThemes: cmd.watchTheme,
|
2019-03-05 01:56:29 -06:00
|
|
|
hot: cmd.hot,
|
|
|
|
});
|
|
|
|
});
|
2019-02-13 07:47:59 -06:00
|
|
|
|
2019-03-05 01:56:29 -06:00
|
|
|
program
|
|
|
|
.command('gui:build')
|
|
|
|
.description('Builds @grafana/ui package to packages/grafana-ui/dist')
|
|
|
|
.action(async cmd => {
|
|
|
|
await execTask(buildTask)();
|
2019-02-21 03:58:28 -06:00
|
|
|
});
|
2019-03-05 01:56:29 -06:00
|
|
|
|
|
|
|
program
|
|
|
|
.command('gui:release')
|
|
|
|
.description('Prepares @grafana/ui release (and publishes to npm on demand)')
|
|
|
|
.option('-p, --publish', 'Publish @grafana/ui to npm registry')
|
2019-03-06 02:52:31 -06:00
|
|
|
.option('-u, --usePackageJsonVersion', 'Use version specified in package.json')
|
2019-03-08 07:42:19 -06:00
|
|
|
.option('--createVersionCommit', 'Create and push version commit')
|
2019-03-05 01:56:29 -06:00
|
|
|
.action(async cmd => {
|
|
|
|
await execTask(releaseTask)({
|
|
|
|
publishToNpm: !!cmd.publish,
|
2019-03-06 02:52:31 -06:00
|
|
|
usePackageJsonVersion: !!cmd.usePackageJsonVersion,
|
2019-03-08 07:42:19 -06:00
|
|
|
createVersionCommit: !!cmd.createVersionCommit,
|
2019-03-05 01:56:29 -06:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-03-05 08:53:25 -06:00
|
|
|
program
|
2019-03-06 06:18:13 -06:00
|
|
|
.command('changelog')
|
2019-03-06 05:28:07 -06:00
|
|
|
.option('-m, --milestone <milestone>', 'Specify milestone')
|
2019-03-05 08:53:25 -06:00
|
|
|
.description('Builds changelog markdown')
|
|
|
|
.action(async cmd => {
|
2019-03-06 05:28:07 -06:00
|
|
|
if (!cmd.milestone) {
|
|
|
|
console.log('Please specify milestone, example: --m 6.0.1');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
await execTask(changelogTask)({
|
|
|
|
milestone: cmd.milestone,
|
|
|
|
});
|
2019-03-05 08:53:25 -06:00
|
|
|
});
|
|
|
|
|
2019-03-06 06:18:13 -06:00
|
|
|
program
|
|
|
|
.command('cherrypick')
|
|
|
|
.description('Helps find commits to cherry pick')
|
|
|
|
.action(async cmd => {
|
|
|
|
await execTask(cherryPickTask)({});
|
|
|
|
});
|
|
|
|
|
2019-03-05 01:56:29 -06:00
|
|
|
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!`
|
|
|
|
)
|
|
|
|
);
|
2019-02-13 07:47:59 -06:00
|
|
|
}
|