2025-05-22 13:15:40 +02:00
|
|
|
const fs = require('fs-extra');
|
|
|
|
|
const path = require('path');
|
|
|
|
|
const { execSync } = require('child_process');
|
|
|
|
|
const packageJson = require('../package.json');
|
|
|
|
|
const rootPath = path.resolve(__dirname, '..');
|
2023-04-24 19:42:49 +00:00
|
|
|
const distFolderPath = path.resolve(rootPath, 'dist');
|
|
|
|
|
|
2025-05-22 13:15:40 +02:00
|
|
|
function addPortableToPortableExecutableFileName() {
|
2023-04-24 19:42:49 +00:00
|
|
|
const files = fs.readdirSync(distFolderPath);
|
|
|
|
|
for (const file of files) {
|
|
|
|
|
if (file.endsWith('.exe') && !file.match('Setup')) {
|
|
|
|
|
const filePath = path.resolve(distFolderPath, file);
|
2025-10-17 23:30:35 +02:00
|
|
|
const renamedFilePath = path.resolve(distFolderPath, file.replace('5chan', '5chan Portable'));
|
2023-04-24 19:42:49 +00:00
|
|
|
fs.moveSync(filePath, renamedFilePath);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-05-22 13:15:40 +02:00
|
|
|
}
|
2023-04-24 19:42:49 +00:00
|
|
|
|
2025-05-22 13:15:40 +02:00
|
|
|
function createHtmlArchive() {
|
2023-04-24 19:42:49 +00:00
|
|
|
if (process.platform !== 'linux') {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const zipBinPath = path.resolve(rootPath, 'node_modules', '7zip-bin', 'linux', 'x64', '7za');
|
2025-10-18 23:06:21 +02:00
|
|
|
const fivechanHtmlFolderName = `5chan-html-${packageJson.version}`;
|
|
|
|
|
const outputFile = path.resolve(distFolderPath, `${fivechanHtmlFolderName}.zip`);
|
2023-04-24 19:42:49 +00:00
|
|
|
const inputFolder = path.resolve(rootPath, 'build');
|
|
|
|
|
try {
|
|
|
|
|
execSync(`${zipBinPath} a ${outputFile} ${inputFolder}`);
|
2025-10-18 23:06:21 +02:00
|
|
|
execSync(`${zipBinPath} rn -r ${outputFile} build ${fivechanHtmlFolderName}`);
|
2023-04-24 19:42:49 +00:00
|
|
|
} catch (e) {
|
2025-05-22 13:15:40 +02:00
|
|
|
console.error('electron build createHtmlArchive error:', e);
|
2023-04-24 19:42:49 +00:00
|
|
|
}
|
2025-05-22 13:15:40 +02:00
|
|
|
}
|
2023-04-24 19:42:49 +00:00
|
|
|
|
2025-05-22 13:15:40 +02:00
|
|
|
module.exports = async function afterAllArtifactBuild(buildResult) {
|
2023-04-24 19:42:49 +00:00
|
|
|
addPortableToPortableExecutableFileName();
|
|
|
|
|
createHtmlArchive();
|
2025-05-22 13:15:40 +02:00
|
|
|
};
|