index.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import program from 'commander';
  2. import chalk from 'chalk';
  3. import { execTask } from './utils/execTask';
  4. export type Task<T> = (options: T) => Promise<void>;
  5. // TODO: Refactor to commander commands
  6. // This will enable us to have command scoped options and limit the ifs below
  7. program
  8. .option('-h, --hot', 'Runs front-end with hot reload enabled')
  9. .option('-t, --theme', 'Watches for theme changes and regenerates variables.scss files')
  10. .option('-d, --depreciate <scripts>', 'Inform about npm script deprecation', v => v.split(','))
  11. .option('-b, --build', 'Created @grafana/ui build')
  12. .option('-r, --release', 'Releases @grafana/ui to npm')
  13. .parse(process.argv);
  14. if (program.build) {
  15. execTask('grafanaui.build');
  16. } else if (program.release) {
  17. execTask('grafanaui.release');
  18. } else {
  19. if (program.depreciate && program.depreciate.length === 2) {
  20. console.log(
  21. chalk.yellow.bold(
  22. `[NPM script depreciation] ${program.depreciate[0]} is deprecated! Use ${program.depreciate[1]} instead!`
  23. )
  24. );
  25. }
  26. execTask('core.start', {
  27. watchThemes: !!program.theme,
  28. hot: !!program.hot,
  29. });
  30. }