forked from eyra/feldspar
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathrelease.js
More file actions
59 lines (46 loc) · 1.51 KB
/
Copy pathrelease.js
File metadata and controls
59 lines (46 loc) · 1.51 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env node
const shell = require('shelljs');
const archiver = require('archiver');
const fs = require('fs');
const path = require('path');
// Set environment
process.env.NODE_ENV = 'production';
// Get project name from current directory
const name = path.basename(process.cwd());
// Get branch name, sanitize slashes
const { execFileSync } = require('child_process');
let branch;
try {
branch = execFileSync('git', ['branch', '--show-current'], { encoding: 'utf8' }).trim();
} catch {
branch = 'unknown';
}
branch = branch.replace(/\//g, '-');
// Create releases directory if it doesn't exist
shell.mkdir('-p', 'releases');
// Get timestamp
const timestamp = new Date().toISOString().split('T')[0]; // YYYY-MM-DD format
console.log('Building all-platform release...');
if (shell.exec('pnpm run build').code !== 0) {
shell.echo('Error: Build failed');
shell.exit(1);
}
// Create zip file
const distPath = path.join('packages', 'data-collector', 'dist');
const zipFileName = `${name}_all_${branch}_${timestamp}.zip`;
const zipPath = path.join('releases', zipFileName);
console.log(`Creating release: ${zipFileName}`);
const output = fs.createWriteStream(zipPath);
const archive = archiver('zip', {
zlib: { level: 9 } // Maximum compression
});
output.on('close', () => {
console.log(`Release created successfully: ${zipPath}`);
console.log(`Total bytes: ${archive.pointer()}`);
});
archive.on('error', (err) => {
throw err;
});
archive.pipe(output);
archive.directory(distPath, false);
archive.finalize();