PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 8.8.1
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v8.8.1
8.8.1 8.8.0 8.7.9 8.7.8 8.7.7 8.7.6 8.7.5 8.7.4 8.7.3 8.7.2 8.7.1 8.7.0 8.6.9 8.6.8 8.6.7 8.6.6 8.6.5 8.6.4 8.6.2 8.6.1 8.6.0 8.5.9 8.5.8 8.5.7 8.5.6 All 537 releases
chatbot / addons / automator / build-plugin.js

build-plugin.js in WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services 8.8.1, at addons/automator/build-plugin.js

70 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 const fs = require('fs-extra');
2 const path = require('path');
3 const { execSync } = require('child_process');
4 const archiver = require('archiver');
5
6 async function build() {
7 const PLUGIN_NAME = 'wpbot-automator';
8 const BUILD_DIR = 'dist';
9 const ZIP_FILE = `${PLUGIN_NAME}.zip`;
10 const PLUGIN_PATH = path.join(BUILD_DIR, PLUGIN_NAME);
11
12 try {
13 console.log(`🚀 Starting build process for ${PLUGIN_NAME}...`);
14
15 // 1. Clean up previous builds
16 console.log('🧹 Cleaning up old build files...');
17 await fs.remove(BUILD_DIR);
18 await fs.remove(ZIP_FILE);
19
20 // 2. Build assets
21 console.log('📦 Building assets...');
22 execSync('npm run build', { stdio: 'inherit' });
23
24 // 3. Create temporary structure
25 console.log('📁 Creating production structure...');
26 await fs.ensureDir(PLUGIN_PATH);
27
28 // 4. Copy necessary files
29 console.log('📂 Copying files...');
30 const filesToCopy = [
31 'includes',
32 'build',
33 'assets',
34 'wpbot-automator.php',
35 'readme.txt'
36 ];
37
38 for (const file of filesToCopy) {
39 const src = path.join(__dirname, file);
40 if (await fs.pathExists(src)) {
41 await fs.copy(src, path.join(PLUGIN_PATH, file));
42 }
43 }
44
45 // 5. Create Zip
46 console.log('🤐 Generating zip file...');
47 const output = fs.createWriteStream(ZIP_FILE);
48 const archive = archiver('zip', { zlib: { level: 9 } });
49
50 output.on('close', async () => {
51 console.log(`�
52 Success! Zip file created at: ${path.resolve(ZIP_FILE)}`);
53
54 // 6. Final Cleanup
55 console.log('🧹 Cleaning up temporary files...');
56 await fs.remove(BUILD_DIR);
57 });
58
59 archive.on('error', (err) => { throw err; });
60 archive.pipe(output);
61 archive.directory(PLUGIN_PATH, PLUGIN_NAME);
62 await archive.finalize();
63
64 } catch (err) {
65 console.error('❌ Error:', err.message);
66 process.exit(1);
67 }
68 }
69
70 build();