build.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env bun
  2. /**
  3. * Build script for the reconstructed Workbench CLI.
  4. *
  5. * Usage: bun build.ts
  6. */
  7. import { $ } from 'bun';
  8. const version = process.env.VERSION || '0.1.0';
  9. const buildTime = new Date().toISOString();
  10. console.log(`Building Workbench CLI v${version}...`);
  11. const result = await Bun.build({
  12. entrypoints: ['src/entrypoints/cli.tsx'],
  13. outdir: 'dist',
  14. target: 'bun',
  15. sourcemap: 'linked',
  16. define: {
  17. 'MACRO.VERSION': JSON.stringify(version),
  18. 'MACRO.BUILD_TIME': JSON.stringify(buildTime),
  19. 'MACRO.FEEDBACK_CHANNEL': JSON.stringify('#workbench-cli'),
  20. 'MACRO.ISSUES_EXPLAINER': JSON.stringify(
  21. 'report the issue in this repository issue tracker',
  22. ),
  23. 'MACRO.PACKAGE_URL': JSON.stringify('workbench-cli'),
  24. 'MACRO.NATIVE_PACKAGE_URL': JSON.stringify('workbench-cli-native'),
  25. 'MACRO.VERSION_CHANGELOG': JSON.stringify(''),
  26. },
  27. external: ['react-devtools-core', 'sharp'],
  28. });
  29. if (!result.success) {
  30. console.error('Build failed:');
  31. for (const log of result.logs) {
  32. console.error(log);
  33. }
  34. process.exit(1);
  35. }
  36. console.log(`Build succeeded: dist/cli.js (${(result.outputs[0]!.size / 1024 / 1024).toFixed(1)} MB)`);