build-plugin.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env node
  2. import fs from 'fs';
  3. import path from 'path';
  4. import process from 'process';
  5. import { fileURLToPath } from 'url';
  6. /**
  7. * Build script for the dashboard plugin
  8. * Copies package.json from plugin source to dist/plugin output directory
  9. */
  10. const __filename = fileURLToPath(import.meta.url);
  11. const __dirname = path.dirname(__filename);
  12. const sourcePackageJson = path.join(__dirname, '../plugin/package.json');
  13. const outputDir = path.join(__dirname, '../dist/plugin');
  14. const outputPackageJson = path.join(outputDir, 'package.json');
  15. try {
  16. // Ensure output directory exists
  17. if (!fs.existsSync(outputDir)) {
  18. fs.mkdirSync(outputDir, { recursive: true });
  19. console.log(`Created output directory: ${outputDir}`);
  20. }
  21. // Copy package.json
  22. if (fs.existsSync(sourcePackageJson)) {
  23. fs.copyFileSync(sourcePackageJson, outputPackageJson);
  24. console.log(`Copied package.json from ${sourcePackageJson} to ${outputPackageJson}`);
  25. } else {
  26. console.error(`Source package.json not found at: ${sourcePackageJson}`);
  27. process.exit(1);
  28. }
  29. console.log('Plugin build completed successfully');
  30. } catch (error) {
  31. console.error('Plugin build failed:', error.message);
  32. process.exit(1);
  33. }