index.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. program.option('-d, --depreciate <scripts>', 'Inform about npm script deprecation', v => v.split(','));
  9. program
  10. .command('core:start')
  11. .option('-h, --hot', 'Run front-end with HRM enabled')
  12. .option('-t, --watchTheme', 'Watch for theme changes and regenerate variables.scss files')
  13. .description('Starts Grafana front-end in development mode with watch enabled')
  14. .action(async cmd => {
  15. await execTask(startTask)({
  16. watchThemes: cmd.theme,
  17. hot: cmd.hot,
  18. });
  19. });
  20. program
  21. .command('gui:build')
  22. .description('Builds @grafana/ui package to packages/grafana-ui/dist')
  23. .action(async cmd => {
  24. await execTask(buildTask)();
  25. });
  26. program
  27. .command('gui:release')
  28. .description('Prepares @grafana/ui release (and publishes to npm on demand)')
  29. .option('-p, --publish', 'Publish @grafana/ui to npm registry')
  30. .option('-u, --usePackageJsonVersion', 'Use version specified in package.json')
  31. .action(async cmd => {
  32. await execTask(releaseTask)({
  33. publishToNpm: !!cmd.publish,
  34. usePackageJsonVersion: !!cmd.usePackageJsonVersion,
  35. });
  36. });
  37. program
  38. .command('core:changelog')
  39. .description('Builds changelog markdown')
  40. .action(async cmd => {
  41. await execTask(changelogTask)({});
  42. });
  43. program.parse(process.argv);
  44. if (program.depreciate && program.depreciate.length === 2) {
  45. console.log(
  46. chalk.yellow.bold(
  47. `[NPM script depreciation] ${program.depreciate[0]} is deprecated! Use ${program.depreciate[1]} instead!`
  48. )
  49. );
  50. }