feat(pdfjs-annotation-extension): update module export structure and remove unused font files
Refactored the module export structure in pdfjs-annotation-extension.js for improved compatibility across module systems. Additionally, deleted unused font files (PingFangChangAnTi-2.ttf and qiantubifengshouxieti.ttf) to streamline the extension's resources.
This commit is contained in:
65
scripts/package-dist.js
Normal file
65
scripts/package-dist.js
Normal file
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
// Get package.json to extract version
|
||||
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
||||
const version = packageJson.version;
|
||||
|
||||
console.log(`📦 Building dist folder for version ${version}...`);
|
||||
|
||||
// Run the build command
|
||||
try {
|
||||
execSync('npm run build', { stdio: 'inherit' });
|
||||
console.log('✅ Build completed successfully');
|
||||
} catch (error) {
|
||||
console.error('❌ Build failed:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Package the dist folder into a zip file
|
||||
import { createWriteStream, existsSync } from 'fs';
|
||||
import { pipeline } from 'stream';
|
||||
import { promisify } from 'util';
|
||||
import archiver from 'archiver';
|
||||
|
||||
const distDir = path.resolve('./dist');
|
||||
const zipPath = path.resolve(`./dist-${version}.zip`);
|
||||
|
||||
// Check if dist directory exists
|
||||
if (!existsSync(distDir)) {
|
||||
console.error('❌ dist directory does not exist. Please run build first.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Create a write stream for the zip file
|
||||
const output = createWriteStream(zipPath);
|
||||
const archive = archiver('zip', {
|
||||
zlib: { level: 9 } // Maximum compression
|
||||
});
|
||||
|
||||
// Event listener for when the archive is finished
|
||||
output.on('close', () => {
|
||||
console.log(`✅ Successfully created ${zipPath}. Total bytes: ${archive.pointer()}`);
|
||||
});
|
||||
|
||||
// Event listener for errors
|
||||
archive.on('error', (err) => {
|
||||
console.error('❌ Error creating zip:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
// Pipe the archive to the file
|
||||
archive.pipe(output);
|
||||
|
||||
// Append the dist directory to the archive
|
||||
archive.directory(distDir, false);
|
||||
|
||||
// Finalize the archive
|
||||
archive.finalize();
|
||||
|
||||
output.on('close', () => {
|
||||
console.log(`✅ Successfully created ${zipPath}. Total bytes: ${archive.pointer()}`);
|
||||
});
|
||||
@@ -83,16 +83,25 @@ function main() {
|
||||
// 3. Create git tag
|
||||
const tagName = createGitTag(newVersion);
|
||||
|
||||
// 4. Push everything to main
|
||||
// 4. Build and package the distribution files
|
||||
console.log(`📦 Building and packaging distribution files...`);
|
||||
execSync('npm run package', { stdio: 'inherit' });
|
||||
console.log(`📦 Distribution files packaged successfully`);
|
||||
|
||||
// 5. Push everything to main
|
||||
console.log(`📤 Pushing to main...`);
|
||||
execSync('git push origin main', { stdio: 'inherit' });
|
||||
execSync(`git push origin ${tagName}`, { stdio: 'inherit' });
|
||||
|
||||
console.log(`🎉 Release v${newVersion} complete!`);
|
||||
console.log(`📦 Docker image: bentopdf/bentopdf:${newVersion}`);
|
||||
console.log(`📦 Distribution: dist-${newVersion}.zip`);
|
||||
console.log(
|
||||
`🏷️ GitHub release: https://github.com/alam00000/bentopdf/releases/tag/${tagName}`
|
||||
);
|
||||
console.log(
|
||||
`💡 Download dist-${newVersion}.zip from the release page for self-hosting.`
|
||||
);
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
Reference in New Issue
Block a user