diff --git a/browser-runtime/scripts/package-target.mjs b/browser-runtime/scripts/package-target.mjs index f2f823a..6cb5827 100644 --- a/browser-runtime/scripts/package-target.mjs +++ b/browser-runtime/scripts/package-target.mjs @@ -21,5 +21,6 @@ export function packageTarget(args, defaults = process) { } export function executableName(platform) { + if (platform === 'darwin') return 'RuneStone-Browser.app/Contents/MacOS/RuneStone-Browser'; return platform === 'win32' ? 'RuneStone-Browser.exe' : 'RuneStone-Browser'; } diff --git a/browser-runtime/scripts/stage-runtime.mjs b/browser-runtime/scripts/stage-runtime.mjs index 8310d80..2d96c39 100644 --- a/browser-runtime/scripts/stage-runtime.mjs +++ b/browser-runtime/scripts/stage-runtime.mjs @@ -20,7 +20,7 @@ export async function stageRuntime({ project, host, platform, arch }) { let backup; let moved = false; try { - await cp(source, staged, { recursive: true }); + await cp(source, staged, { recursive: true, verbatimSymlinks: true }); // Electron Packager can leave its temporary root at 0700. Installed resources // must remain traversable after the package manager changes ownership to root. if (platform === 'linux') await chmod(staged, 0o755); diff --git a/browser-runtime/test/stage-runtime.test.mjs b/browser-runtime/test/stage-runtime.test.mjs index 43e63e3..a0b862b 100644 --- a/browser-runtime/test/stage-runtime.test.mjs +++ b/browser-runtime/test/stage-runtime.test.mjs @@ -1,6 +1,6 @@ import assert from 'node:assert/strict'; import test from 'node:test'; -import { mkdtemp, mkdir, writeFile, readFile, readdir, chmod, rm, stat } from 'node:fs/promises'; +import { mkdtemp, mkdir, writeFile, readFile, readdir, chmod, rm, stat, symlink, rename } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { stageRuntime } from '../scripts/stage-runtime.mjs'; @@ -37,6 +37,26 @@ test('missing source leaves the previous runtime intact', async t => { assert.equal(await readFile(join(options.destination, 'RuneStone-Browser.exe'), 'utf8'), 'old runtime'); }); +test('macOS staging preserves the app bundle and executable layout', async t => { + const options = await fixture(t); + const source = join(options.project, 'dist/RuneStone-Browser-darwin-arm64'); + const executable = 'RuneStone-Browser.app/Contents/MacOS/RuneStone-Browser'; + await mkdir(join(source, 'RuneStone-Browser.app/Contents/MacOS'), { recursive: true }); + await writeFile(join(source, executable), 'macOS fixture', { mode: 0o755 }); + await writeFile(join(source, 'RuneStone-Browser.app/Contents/Info.plist'), 'bundle metadata'); + if (process.platform !== 'win32') { + await symlink('../Info.plist', join(source, 'RuneStone-Browser.app/Contents/MacOS/metadata')); + } + const result = await stageRuntime({ ...options, platform: 'darwin', arch: 'arm64' }); + await rename(source, `${source}-moved`); + assert.equal(await readFile(join(result.destination, executable), 'utf8'), 'macOS fixture'); + assert.equal(await readFile(join(result.destination, 'RuneStone-Browser.app/Contents/Info.plist'), 'utf8'), 'bundle metadata'); + assert.equal(await readFile(join(result.backup, 'RuneStone-Browser.exe'), 'utf8'), 'old runtime'); + if (process.platform !== 'win32') { + assert.equal(await readFile(join(result.destination, 'RuneStone-Browser.app/Contents/MacOS/metadata'), 'utf8'), 'bundle metadata'); + } +}); + test('Linux staging rejects a non-executable runtime before replacing the old tree', { skip: process.platform === 'win32' }, async t => { const options = await fixture(t); await chmod(join(options.source, 'RuneStone-Browser'), 0o644); diff --git a/package.json b/package.json index 4cc0df8..4b551aa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "runestone", - "version": "0.1.41", + "version": "0.1.42", "description": "Desktop editor for a local workspace", "type": "module", "scripts": { diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 8aeaf46..acf8d68 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -3130,7 +3130,7 @@ dependencies = [ [[package]] name = "runestone" -version = "0.1.41" +version = "0.1.42" dependencies = [ "base64 0.23.1", "dunce", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index b9fdccd..ae13519 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runestone" -version = "0.1.41" +version = "0.1.42" description = "Writing workspace plus script editor" authors = ["you"] edition = "2021" @@ -44,4 +44,4 @@ panic = "abort" strip = true [package.metadata.runestone] -version = "0.1.41" +version = "0.1.42" diff --git a/src-tauri/src/browser.rs b/src-tauri/src/browser.rs index ab99427..14c3a2b 100644 --- a/src-tauri/src/browser.rs +++ b/src-tauri/src/browser.rs @@ -111,6 +111,8 @@ fn root(app: &AppHandle) -> Result { fn executable(app: &AppHandle) -> Result { let name = if cfg!(windows) { "RuneStone-Browser.exe" + } else if cfg!(target_os = "macos") { + "RuneStone-Browser.app/Contents/MacOS/RuneStone-Browser" } else { "RuneStone-Browser" }; diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 54bf0c6..00656e5 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "RuneStone", - "version": "0.1.41", + "version": "0.1.42", "identifier": "com.runestone.app", "build": { "beforeDevCommand": "pnpm dev",