index.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. .option('--createVersionCommit', 'Create and push version commit')
  33. .action(async cmd => {
  34. await execTask(releaseTask)({
  35. publishToNpm: !!cmd.publish,
  36. usePackageJsonVersion: !!cmd.usePackageJsonVersion,
  37. createVersionCommit: !!cmd.createVersionCommit,
  38. });
  39. });
  40. program
  41. .command('changelog')
  42. .option('-m, --milestone <milestone>', 'Specify milestone')
  43. .description('Builds changelog markdown')
  44. .action(async cmd => {
  45. if (!cmd.milestone) {
  46. console.log('Please specify milestone, example: -m <milestone id from github milestone URL>');
  47. return;
  48. }
  49. await execTask(changelogTask)({
  50. milestone: cmd.milestone,
  51. });
  52. });
  53. program
  54. .command('cherrypick')
  55. .description('Helps find commits to cherry pick')
  56. .action(async cmd => {
  57. await execTask(cherryPickTask)({});
  58. });
  59. program.parse(process.argv);
  60. if (program.depreciate && program.depreciate.length === 2) {
  61. console.log(
  62. chalk.yellow.bold(
  63. `[NPM script depreciation] ${program.depreciate[0]} is deprecated! Use ${program.depreciate[1]} instead!`
  64. )
  65. );
  66. }