-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-mcpb.js
More file actions
46 lines (38 loc) · 1.45 KB
/
build-mcpb.js
File metadata and controls
46 lines (38 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import fs from 'fs';
import archiver from 'archiver';
// Generate timestamp in format: YYYYMMDD-HHMMSS
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, '0');
const day = String(now.getDate()).padStart(2, '0');
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
const timestamp = `${year}${month}${day}-${hours}${minutes}${seconds}`;
// Create both timestamped and non-timestamped versions
const timestampedFilename = `hello3dmcp-server-${timestamp}.mcpb`;
const productionFilename = `hello3dmcp-server.mcpb`;
// Function to create an archive
function createArchive(filename) {
return new Promise((resolve, reject) => {
const output = fs.createWriteStream(filename);
const archive = archiver('zip', { zlib: { level: 9 } });
output.on('close', () => {
console.log(`✅ Package created: ${filename} (${archive.pointer()} bytes)`);
resolve(archive.pointer());
});
archive.on('error', err => reject(err));
archive.pipe(output);
archive.file('manifest.json', { name: 'manifest.json' });
archive.directory('dist/', 'dist');
archive.finalize();
});
}
// Create both versions
Promise.all([
createArchive(timestampedFilename),
createArchive(productionFilename)
]).catch(err => {
console.error('Error creating packages:', err);
process.exit(1);
});