super-productivity/packages/plugin-dev/boilerplate-solid-js/scripts/build-plugin.js
Johannes Millan d4d81bf511 feat(plugin-api): create foundational plugin API package
- Add @super-productivity/plugin-api package with TypeScript definitions
- Define core plugin interfaces, types, and manifest structure
- Add plugin hooks system for event-driven architecture
- Create plugin API type definitions and constants
- Add documentation and development guidelines
2025-06-27 18:13:19 +02:00

47 lines
1.3 KiB
JavaScript

import fs from 'fs';
import path from 'path';
import archiver from 'archiver';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const projectRoot = path.dirname(__dirname);
// Read manifest to get plugin name
const manifest = JSON.parse(
fs.readFileSync(path.join(projectRoot, 'src/manifest.json'), 'utf8'),
);
const outputFileName = `${manifest.id}-v${manifest.version}.zip`;
// Create output stream
const output = fs.createWriteStream(path.join(projectRoot, outputFileName));
const archive = archiver('zip', {
zlib: { level: 9 }, // Maximum compression
});
output.on('close', () => {
console.log(`Plugin packaged successfully: ${outputFileName}`);
console.log(`Total size: ${(archive.pointer() / 1024).toFixed(2)} KB`);
});
archive.on('error', (err) => {
throw err;
});
// Pipe archive data to the file
archive.pipe(output);
// Add dist files to the archive
const distPath = path.join(projectRoot, 'dist');
// Add manifest.json from src (it's copied to dist during build)
archive.file(path.join(projectRoot, 'src/manifest.json'), { name: 'manifest.json' });
// Add all files from dist
archive.glob('**/*', {
cwd: distPath,
ignore: ['manifest.json'], // We already added it from src
});
// Finalize the archive
archive.finalize();