index.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import program from 'commander';
  2. import { execTask } from './utils/execTask';
  3. import chalk from 'chalk';
  4. import { startTask } from './tasks/core.start';
  5. import { buildTask } from './tasks/grafanaui.build';
  6. import { releaseTask } from './tasks/grafanaui.release';
  7. import { changelogTask } from './tasks/changelog';
  8. import { cherryPickTask } from './tasks/cherrypick';
  9. program.option('-d, --depreciate <scripts>', 'Inform about npm script deprecation', v => v.split(','));
  10. program
  11. .command('core:start')
  12. .option('-h, --hot', 'Run front-end with HRM enabled')
  13. .option('-t, --watchTheme', 'Watch for theme changes and regenerate variables.scss files')
  14. .description('Starts Grafana front-end in development mode with watch enabled')
  15. .action(async cmd => {
  16. await execTask(startTask)({
  17. watchThemes: cmd.watchTheme,
  18. hot: cmd.hot,
  19. });
  20. });
  21. program
  22. .command('gui:build')
  23. .description('Builds @grafana/ui package to packages/grafana-ui/dist')
  24. .action(async cmd => {
  25. await execTask(buildTask)();
  26. });
  27. program
  28. .command('gui:release')
  29. .description('Prepares @grafana/ui release (and publishes to npm on demand)')
  30. .option('-p, --publish', 'Publish @grafana/ui to npm registry')
  31. .option('-u, --usePackageJsonVersion', 'Use version specified in package.json')
  32. .action(async cmd => {
  33. await execTask(releaseTask)({
  34. publishToNpm: !!cmd.publish,
  35. usePackageJsonVersion: !!cmd.usePackageJsonVersion,
  36. });
  37. });
  38. program
  39. .command('changelog')
  40. .option('-m, --milestone <milestone>', 'Specify milestone')
  41. .description('Builds changelog markdown')
  42. .action(async cmd => {
  43. if (!cmd.milestone) {
  44. console.log('Please specify milestone, example: --m 6.0.1');
  45. return;
  46. }
  47. await execTask(changelogTask)({
  48. milestone: cmd.milestone,
  49. });
  50. });
  51. program
  52. .command('cherrypick')
  53. .description('Helps find commits to cherry pick')
  54. .action(async cmd => {
  55. await execTask(cherryPickTask)({});
  56. });
  57. program.parse(process.argv);
  58. if (program.depreciate && program.depreciate.length === 2) {
  59. console.log(
  60. chalk.yellow.bold(
  61. `[NPM script depreciation] ${program.depreciate[0]} is deprecated! Use ${program.depreciate[1]} instead!`
  62. )
  63. );
  64. }