mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-07 08:34:15 +01:00
Revert "Building electron script in js to support different OS"
This reverts commit ae78ed36ef
.
This commit is contained in:
parent
21536f9a27
commit
5ef0de2e4d
@ -22,8 +22,7 @@
|
||||
"jest": "^29.2.0",
|
||||
"pretty-quick": "^3.1.3",
|
||||
"randomstring": "^1.2.2",
|
||||
"ts-jest": "^29.0.5",
|
||||
"fs-extra": "^11.1.1"
|
||||
"ts-jest": "^29.0.5"
|
||||
},
|
||||
"scripts": {
|
||||
"dev:web": "npm run dev --workspace=packages/bruno-app",
|
||||
@ -32,7 +31,7 @@
|
||||
"dev:electron": "npm run dev --workspace=packages/bruno-electron",
|
||||
"build:bruno-query": "npm run build --workspace=packages/bruno-query",
|
||||
"build:graphql-docs": "npm run build --workspace=packages/bruno-graphql-docs",
|
||||
"build:electron": "node ./scripts/build-electron.js",
|
||||
"build:electron": "./scripts/build-electron.sh",
|
||||
"test:e2e": "npx playwright test",
|
||||
"test:report": "npx playwright show-report",
|
||||
"prepare": "husky install"
|
||||
|
@ -10,9 +10,6 @@
|
||||
"clean": "rimraf dist",
|
||||
"dev": "electron .",
|
||||
"dist": "electron-builder --mac --config electron-builder-config.js",
|
||||
"dist-mac": "electron-builder --mac --config electron-builder-config.js",
|
||||
"dist-win": "electron-builder --win --config electron-builder-config.js",
|
||||
"dist-linux": "electron-builder --linux --config electron-builder-config.js",
|
||||
"pack": "electron-builder --dir",
|
||||
"test": "jest"
|
||||
},
|
||||
|
@ -1,98 +0,0 @@
|
||||
const os = require('os');
|
||||
const fs = require('fs-extra');
|
||||
const util = require('util');
|
||||
const exec = util.promisify(require('child_process').exec);
|
||||
|
||||
|
||||
async function deleteFileIfExists(filePath) {
|
||||
try {
|
||||
const exists = await fs.pathExists(filePath);
|
||||
if (exists) {
|
||||
await fs.remove(filePath);
|
||||
console.log(`${filePath} has been successfully deleted.`);
|
||||
} else {
|
||||
console.log(`${filePath} does not exist.`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Error while checking the existence of ${filePath}: ${err}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function copyFolderIfExists(srcPath, destPath) {
|
||||
try {
|
||||
const exists = await fs.pathExists(srcPath);
|
||||
if (exists) {
|
||||
await fs.copy(srcPath, destPath);
|
||||
console.log(`${srcPath} has been successfully copied.`);
|
||||
} else {
|
||||
console.log(`${srcPath} was not copied as it does not exist.`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Error while checking the existence of ${srcPath}: ${err}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function removeSourceMapFiles(directory) {
|
||||
try {
|
||||
const files = await fs.readdir(directory);
|
||||
for (const file of files) {
|
||||
if (file.endsWith('.map')) {
|
||||
const filePath = path.join(directory, file);
|
||||
await fs.remove(filePath);
|
||||
console.log(`${filePath} has been successfully deleted.`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error while deleting .map files: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
// Remove out directory
|
||||
await deleteFileIfExists('packages/bruno-electron/out');
|
||||
|
||||
// Remove web directory
|
||||
await deleteFileIfExists('packages/bruno-electron/web');
|
||||
|
||||
// Create a new web directory
|
||||
await fs.ensureDir('packages/bruno-electron/web');
|
||||
console.log('The directory has been created successfully!');
|
||||
|
||||
// Copy build
|
||||
await copyFolderIfExists('packages/bruno-app/out', 'packages/bruno-electron/web');
|
||||
|
||||
// Change paths in next
|
||||
const files = await fs.readdir('packages/bruno-electron/web');
|
||||
for (const file of files) {
|
||||
if (file.endsWith('.html')) {
|
||||
let content = await fs.readFile(`packages/bruno-electron/web/${file}`, 'utf8');
|
||||
content = content.replace(/\/_next\//g, '/_next/');
|
||||
await fs.writeFile(`packages/bruno-electron/web/${file}`, content);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove sourcemaps
|
||||
await removeSourceMapFiles('packages/bruno-electron/web')
|
||||
|
||||
// Run npm dist command
|
||||
console.log('Building the Electron distribution');
|
||||
|
||||
// Determine the OS and set the appropriate argument
|
||||
let osArg;
|
||||
if (os.platform() === 'win32') {
|
||||
osArg = 'win';
|
||||
} else if (os.platform() === 'darwin') {
|
||||
osArg = 'mac';
|
||||
} else {
|
||||
osArg = 'linux';
|
||||
}
|
||||
|
||||
await exec(`npm run dist-${osArg} --workspace=packages/bruno-electron`);
|
||||
|
||||
} catch (error) {
|
||||
console.error('An error occurred:', error);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
Loading…
Reference in New Issue
Block a user