Files
actual/packages/desktop-electron/beforePackHook.ts
T
Matiss Janis AboltinsandCursor Agent 32bc254040 Lint: port react and import rules from eslint to oxc (#6312)
* Enforce JSX file extensions for React components

- Update eslint config to enforce .jsx/.tsx extensions for files containing JSX
- Convert docs package JS files to JSX where they contain React code
- Fix unstable nested components in CrossoverGraph and NetWorthGraph
- Update oxlint configuration
- Update e2e fixtures

* Fix: Rename react-hooks/exhaustive-deps to react/exhaustive-deps

Co-authored-by: matiss <[email protected]>

* Enhance ESLint configuration and update import rules

* Refactor ESLint configuration to enhance import order rules and add eslint-plugin-import

* Fix ESLint directive comments in API files to use correct syntax

* Fix

* Fix ESLint directive comments and update import/extensions rule in configuration

* Refactor ESLint configuration to enforce JSX extension rules and improve code clarity

* Update ESLint configuration: disable 'import/no-unresolved' rule and remove obsolete .oxlintrc.json file

---------

Co-authored-by: Cursor Agent <[email protected]>
2025-12-12 22:40:38 +00:00

48 lines
1.5 KiB
TypeScript

import { rebuild } from '@electron/rebuild';
import copyFiles from 'copyfiles';
import { Arch, AfterPackContext } from 'electron-builder';
/* The beforePackHook runs before packing the Electron app for an architecture
We hook in here to build anything architecture dependent - such as beter-sqlite3
To build, we call @electron/rebuild on the better-sqlite3 module */
const beforePackHook = async (context: AfterPackContext) => {
const arch: string = Arch[context.arch];
const buildPath = context.packager.projectDir;
const projectRootPath = buildPath + '/../../';
const electronVersion = context.packager.config.electronVersion;
if (!electronVersion) {
console.error('beforePackHook: Unable to find electron version.');
process.exit(); // End the process - electron version is required
}
try {
await rebuild({
arch,
buildPath,
electronVersion,
force: true,
projectRootPath,
onlyModules: ['better-sqlite3', 'bcrypt'],
});
console.info(`Rebuilt better-sqlite3 and bcrypt with ${arch}!`);
if (context.packager.platform.name === 'windows') {
console.info(`Windows build - copying appx files...`);
await new Promise(resolve =>
copyFiles(['./appx/**/*', './build'], { error: true }, resolve),
);
console.info(`Copied appx files!`);
}
} catch (err) {
console.error('beforePackHook:', err);
process.exit(); // End the process - unsuccessful build
}
};
// oxlint-disable-next-line import/no-default-export
export default beforePackHook;