fixup build appImage sqlite3 module not found

pull/2242/head
Audric Ackermann 2 years ago
parent 0efce6ea2d
commit 851d5280e0
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -148,6 +148,7 @@ if (windowFromUserConfig) {
// import {load as loadLocale} from '../..'
import { load as loadLocale, LocaleMessagesWithNameType } from '../node/locale';
import { setLastestRelease } from '../node/latest_desktop_release';
import { getAppRootPath } from '../node/getRootPath';
// Both of these will be set after app fires the 'ready' event
let logger: Logger | null = null;
@ -267,7 +268,7 @@ async function createWindow() {
enableRemoteModule: true,
nodeIntegrationInWorker: true,
contextIsolation: false,
preload: path.join(__dirname, '..', '..', 'preload.js'),
preload: path.join(getAppRootPath(), 'preload.js'),
nativeWindowOpen: true,
spellcheck: await getSpellCheckSetting(),
},
@ -379,7 +380,7 @@ async function createWindow() {
}
});
await mainWindow.loadURL(prepareURL([__dirname, '..', '..', 'background.html']));
await mainWindow.loadURL(prepareURL([getAppRootPath(), 'background.html']));
if ((process.env.NODE_APP_INSTANCE || '').startsWith('devprod')) {
// Open the DevTools.
@ -498,7 +499,7 @@ async function showPasswordWindow() {
contextIsolation: false,
// sandbox: true,
preload: path.join(__dirname, '..', '..', 'password_preload.js'),
preload: path.join(getAppRootPath(), 'password_preload.js'),
nativeWindowOpen: true,
},
// don't setup icon, the executable one will be used by default
@ -506,7 +507,7 @@ async function showPasswordWindow() {
passwordWindow = new BrowserWindow(windowOptions);
await passwordWindow.loadURL(prepareURL([__dirname, '..', '..', 'password.html']));
await passwordWindow.loadURL(prepareURL([getAppRootPath(), 'password.html']));
captureClicks(passwordWindow);
@ -569,7 +570,7 @@ async function showAbout() {
nodeIntegration: true,
nodeIntegrationInWorker: false,
contextIsolation: false,
preload: path.join(__dirname, '..', '..', 'about_preload.js'),
preload: path.join(getAppRootPath(), 'about_preload.js'),
nativeWindowOpen: true,
},
parent: mainWindow,
@ -579,7 +580,7 @@ async function showAbout() {
captureClicks(aboutWindow);
await aboutWindow.loadURL(prepareURL([__dirname, '..', '..', 'about.html']));
await aboutWindow.loadURL(prepareURL([getAppRootPath(), 'about.html']));
aboutWindow.on('closed', () => {
aboutWindow = null;
@ -617,7 +618,7 @@ async function showDebugLogWindow() {
nodeIntegration: true,
nodeIntegrationInWorker: false,
contextIsolation: false,
preload: path.join(__dirname, '..', '..', 'debug_log_preload.js'),
preload: path.join(getAppRootPath(), 'debug_log_preload.js'),
nativeWindowOpen: true,
},
parent: mainWindow,
@ -627,7 +628,7 @@ async function showDebugLogWindow() {
captureClicks(debugLogWindow);
await debugLogWindow.loadURL(prepareURL([__dirname, '..', '..', 'debug_log.html'], { theme }));
await debugLogWindow.loadURL(prepareURL([getAppRootPath(), 'debug_log.html'], { theme }));
debugLogWindow.on('closed', () => {
debugLogWindow = null;

@ -0,0 +1,9 @@
import { join } from 'path';
/**
* This always returns the app root path, either packaged or from the source code tree
* If you move this file around, you will need to update those lines
*/
export function getAppRootPath() {
return join(__dirname, '..', '..');
}

@ -1,6 +1,7 @@
import path from 'path';
import fs from 'fs';
import _ from 'lodash';
import { getAppRootPath } from './getRootPath';
function normalizeLocaleName(locale: string) {
if (/^en-/.test(locale)) {
@ -13,7 +14,7 @@ function normalizeLocaleName(locale: string) {
function getLocaleMessages(locale: string): LocaleMessagesType {
const onDiskLocale = locale.replace('-', '_');
const targetFile = path.join(__dirname, '..', '..', '_locales', onDiskLocale, 'messages.json');
const targetFile = path.join(getAppRootPath(), '_locales', onDiskLocale, 'messages.json');
// tslint:disable-next-line: non-literal-fs-path
return JSON.parse(fs.readFileSync(targetFile, 'utf-8'));

@ -22,12 +22,19 @@ import { redactAll } from '../util/privacy'; // checked - only node
import { LocaleMessagesType } from './locale'; // checked - only node
import { PubKey } from '../session/types/PubKey'; // checked - only node
import { StorageItem } from './storage_item'; // checked - only node
import { getAppRootPath } from './getRootPath';
// tslint:disable: no-console quotemark non-literal-fs-path one-variable-per-declaration
const openDbOptions = {
// tslint:disable-next-line: no-constant-condition
verbose: false ? console.log : undefined,
nativeBinding: './node_modules/better-sqlite3/build/Release/better_sqlite3.node',
nativeBinding: path.join(
getAppRootPath(),
'node_modules',
'better-sqlite3',
'build',
'Release',
'better_sqlite3.node'
),
};
const CONVERSATIONS_TABLE = 'conversations';

@ -2,6 +2,7 @@ import path from 'path';
import { app, BrowserWindow, Menu, Tray } from 'electron';
import { LocaleMessagesType } from './locale';
import { getAppRootPath } from './getRootPath';
let trayContextMenu = null;
let tray: Tray | null = null;
@ -13,7 +14,7 @@ export function createTrayIcon(
) {
// keep the duplicated part to allow for search and find
const iconFile = process.platform === 'darwin' ? 'session_icon_16.png' : 'session_icon_32.png';
const iconNoNewMessages = path.join(__dirname, '..', 'images', 'session', iconFile);
const iconNoNewMessages = path.join(getAppRootPath(), 'images', 'session', iconFile);
tray = new Tray(iconNoNewMessages);
trayAny = tray;
trayAny.forceOnTop = (mainWindow: BrowserWindow) => {

@ -86,19 +86,9 @@ describe('Privacy', () => {
describe('Redact app path', () => {
it('removes whatever is in front of the app root path before logging', () => {
const appRootPath = path.join(__dirname, '..', '..', '..', '..', '..');
const appFolderName = path.basename(appRootPath);
expect(redactAll(appRootPath)).to.be.be.oneOf([
`[REDACTED]/${appFolderName}`,
`[REDACTED]\\${appFolderName}`,
]);
});
it('removes whatever is in front of the app root path before logging', () => {
const appRootPath = path.join(__dirname, '..', '..', '..', '..', '..');
const appFolderName = path.basename(appRootPath);
expect(redactAll(appRootPath)).to.be.be.oneOf([
`[REDACTED]/${appFolderName}`,
`[REDACTED]\\${appFolderName}`,
expect(redactAll(path.join(appRootPath, 'whatever'))).to.be.be.oneOf([
'[REDACTED]/whatever',
'[REDACTED]\\whatever',
]);
});
});

@ -1,12 +1,11 @@
/* eslint-env node */
import path from 'path';
// tslint:disable-next-line: no-submodule-imports
import { compose } from 'lodash/fp';
import { escapeRegExp, isRegExp, isString } from 'lodash';
import { getAppRootPath } from '../node/getRootPath';
const APP_ROOT_PATH = path.join(__dirname, '..', '..', '..');
const APP_ROOT_PATH = getAppRootPath();
const SESSION_ID_PATTERN = /\b((05)?[0-9a-f]{64})\b/gi;
const SNODE_PATTERN = /(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/g;
const GROUP_ID_PATTERN = /(group\()([^)]+)(\))/g;

Loading…
Cancel
Save