Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 31 additions & 12 deletions forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = {
console.log('Running afterCopyExtraResources hook...');
console.log({ arch, buildPath, electronVersion, platform });

const chromiumDir = path.join(
const localBrowsersDir = path.join(
buildPath,
'Loadmill.app',
'Contents',
Expand All @@ -57,22 +57,41 @@ module.exports = {
'.local-browsers',
);

console.log({ chromiumDir });
console.log({ localBrowsersDir });

try {
const matches = glob.sync(
path.join(chromiumDir, '**/gpu_shader_cache.bin'),
{ nodir: true },
);
console.log('Attempting to remove .tbd files from .local-browsers...');
// Check if the localBrowsers directory exists
if (fs.existsSync(localBrowsersDir)) {
console.log('.local-browsers directory found, searching for .tbd files...');

matches.forEach(file => {
console.log(`Changing permissions for: ${file}`);
fs.chmodSync(file, 0o644);
});
// Find all .tbd files recursively in the .local-browsers directory
const tbdFiles = glob.sync('**/*.tbd', {
absolute: true,
cwd: localBrowsersDir,
});

console.log('Permissions changed successfully.');
console.log(`Found ${tbdFiles.length} .tbd files:`, tbdFiles);

let removedCount = 0;
tbdFiles.forEach(tbdFile => {
try {
console.log(`Removing... ${tbdFile}`);
fs.unlinkSync(tbdFile);
console.log(`Removed: ${tbdFile}`);
removedCount++;
} catch (unlinkErr) {
console.warn(`Failed to remove ${tbdFile}:`, unlinkErr.message);
}
});

console.log('Finished removing .tbd files');
console.log(`Total .tbd files removed: ${removedCount}`);
} else {
console.log('.local-browsers directory not found, skipping .tbd file removal');
}
} catch (err) {
console.warn('Permission fix failed (may be fine if files don’t exist):', err.message);
console.warn('Removing .tbd files failed', err.message);
}

callback();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "desktop-app",
"productName": "Loadmill",
"version": "3.7.4",
"version": "3.7.4-safari.1",
"description": "The Loadmill desktop app",
"author": {
"name": "Loadmill Ltd.",
Expand Down
20 changes: 7 additions & 13 deletions scripts/prepare-standalone-playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,11 @@ const verifyStructure = (): boolean => {
const browsersPath = path.join(TARGET_DIR, 'node_modules', 'playwright-core', '.local-browsers');
const browserDirs = fs.readdirSync(browsersPath);

const hasChromium = browserDirs.some(dir => dir.startsWith('chromium-'));
const hasFfmpeg = browserDirs.some(dir => dir.startsWith('ffmpeg'));
const hasWebkit = browserDirs.some(dir => dir.startsWith('webkit-'));
const hasLinks = browserDirs.includes('.links');

if (!hasChromium) {
logError('Chromium browser not found in .local-browsers');
return false;
}

if (!hasFfmpeg) {
logError('FFmpeg not found in .local-browsers');
if (!hasWebkit) {
logError('WebKit browser not found in .local-browsers');
return false;
}

Expand Down Expand Up @@ -173,10 +167,10 @@ const installPlaywright = (): void => {
};

const installBrowsers = (): void => {
logInfo('Installing Chromium browser with dependencies...');
logInfo('Installing Safari browser with dependencies...');

try {
const command = 'npx playwright install --with-deps --no-shell chromium';
const command = 'npx playwright install --with-deps --no-shell webkit';
logInfo('Running', { command });
execSync(command, {
cwd: TARGET_DIR,
Expand All @@ -187,9 +181,9 @@ const installBrowsers = (): void => {
stdio: 'inherit',
});

logInfo('✅ Chromium browser installed');
logInfo('✅ Safari browser installed');
} catch (error) {
logError('❌ Failed to install Chromium browser:', error);
logError('❌ Failed to install Safari browser:', error);
throw error;
}
};
Expand Down
1 change: 1 addition & 0 deletions src/main-process/agent-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const createAgentProcess = (): ChildProcessWithoutNullStreams => {
LOADMILL_AGENT_VERBOSE,
NODE_OPTIONS,
NODE_TLS_REJECT_UNAUTHORIZED,
PLAYWRIGHT_BROWSER: 'Safari',
PLAYWRIGHT_BROWSERS_PATH: '0',
PLAYWRIGHT_TEST_PACKAGE_CLI_PATH,
UI_TESTS_ENABLED,
Expand Down
18 changes: 16 additions & 2 deletions src/main-process/standalone-playwright/symlink-playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import fs from 'fs';
import path from 'path';

import log from '../../log';
import {
STANDALONE_PLAYWRIGHT_DIR_PATH,
USER_DATA_PATH,
Expand All @@ -11,20 +12,30 @@ import {
* Creates a link in user data path pointing to @playwright package directory
*/
export const symlinkPlaywright = (): void => {
_removePlaywrightPackageIfExists();
_createSymlink();
log.info('Starting to set up Playwright package in user data path...');
try {
_removePlaywrightPackageIfExists();
_createSymlink();
} catch (error) {
log.error('Failed to set up Playwright package in user data path:', error);
return;
}
log.info('Finished setting up Playwright package in user data path.');
};

const _removePlaywrightPackageIfExists = (): void => {
log.info('Removing existing Playwright package if exists...');
const userDataPath = USER_DATA_PATH;
const nodeModulesPath = path.join(userDataPath, 'node_modules');
const packageJsonPath = path.join(userDataPath, 'package.json');
const packageLockPath = path.join(userDataPath, 'package-lock.json');

const pathsToRemove = [nodeModulesPath, packageJsonPath, packageLockPath];
log.info('Paths to remove if they exist:', pathsToRemove);

for (const p of pathsToRemove) {
if (fs.existsSync(p)) {
log.info(`Removing existing path: ${p}`);
fs.rmSync(p, { force: true, recursive: true });
}
}
Expand All @@ -34,11 +45,14 @@ const _createSymlink = (): void => {
const userDataPath = USER_DATA_PATH;
const src = path.join(STANDALONE_PLAYWRIGHT_DIR_PATH, 'node_modules');
const dest = path.join(userDataPath, 'node_modules');

if (fs.existsSync(dest)) {
fs.rmSync(dest, { force: true, recursive: true });
}

fs.mkdirSync(path.dirname(dest), { recursive: true });

fs.symlinkSync(src, dest, 'dir');

log.info('Symlink created successfully', { dest, src });
};