From d4b6c0d4f61927c53026c7430bc8ed57e17401d6 Mon Sep 17 00:00:00 2001 From: Isaac GC Date: Tue, 6 Feb 2024 20:17:04 -0800 Subject: [PATCH] Build config changed from .ts to .mjs to fix contents not being used properly --- build/scripts/build.mjs | 9 ++++---- ...-builder.ts => electron-builder-config.mjs | 22 +++++++++++++++---- 2 files changed, 22 insertions(+), 9 deletions(-) rename electron-builder.ts => electron-builder-config.mjs (69%) diff --git a/build/scripts/build.mjs b/build/scripts/build.mjs index 779456d6..826e6430 100644 --- a/build/scripts/build.mjs +++ b/build/scripts/build.mjs @@ -8,6 +8,7 @@ import * as vite from 'vite'; import { getMainProcessCommonConfig } from './helpers.mjs'; import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; +import frappeBooksConfig from '../../electron-builder-config.mjs'; const dirname = path.dirname(fileURLToPath(import.meta.url)); const root = path.join(dirname, '..', '..'); @@ -153,12 +154,10 @@ async function packageApp() { delete builderArgs[opt]; } + + let buildOptions = { - config: { - directories: { output: packageDirPath, app: buildDirPath }, - files: ['**'], - extends: null, - }, + config: frappeBooksConfig, ...builderArgs, }; diff --git a/electron-builder.ts b/electron-builder-config.mjs similarity index 69% rename from electron-builder.ts rename to electron-builder-config.mjs index eae60934..6c24afe7 100644 --- a/electron-builder.ts +++ b/electron-builder-config.mjs @@ -1,4 +1,6 @@ -import type { Configuration } from 'electron-builder'; +// App is tagged with a .mjs extension to allow +import path from 'path'; +import { fileURLToPath } from 'url'; /** * electron-builder doesn't look for the APPLE_TEAM_ID environment variable for some reason. @@ -6,7 +8,13 @@ import type { Configuration } from 'electron-builder'; * collection. See: https://github.com/electron-userland/electron-builder/issues/7812 */ -const config: Configuration = { +const dirname = path.dirname(fileURLToPath(import.meta.url)); +// const root = path.join(dirname, '..', '..'); +const root = dirname; // redundant, but is meant to keep with the previous line +const buildDirPath = path.join(root, 'dist_electron', 'build'); +const packageDirPath = path.join(root, 'dist_electron', 'bundled'); + +const frappeBooksConfig = { productName: 'Frappe Books', appId: 'io.frappe.books', asarUnpack: '**/*.node', @@ -15,6 +23,12 @@ const config: Configuration = { { from: 'translations', to: '../translations' }, { from: 'templates', to: '../templates' }, ], + files: '**', + extends: null, + directories: { + output: packageDirPath, + app: buildDirPath, + }, mac: { type: 'distribution', category: 'public.app-category.finance', @@ -34,7 +48,7 @@ const config: Configuration = { signDlls: true, icon: 'build/icon.ico', publish: ['github'], - target: ['portable', 'nsis'], + target: ['nsis', 'portable'], }, nsis: { oneClick: false, @@ -52,4 +66,4 @@ const config: Configuration = { }, }; -export default config; +export default frappeBooksConfig; \ No newline at end of file