index.ts 1.4 KB

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