Ship the browser engine as its own release file
The installer no longer bundles the engine, and the installer script stops when the bundle names it or when the setup file is over 30 MB. pnpm build:browser-engine packages the engine, writes a deterministic ZIP and its record to releases/browser-engine/<version>/, and pins the ZIP in the host. The installer hooks remove the engine folder that 0.1.48 leaves behind, and uninstall removes the downloaded engine.
This commit is contained in:
@@ -26,6 +26,7 @@ The [development guide](docs/development.md#architecture) maps the source folder
|
|||||||
| `pnpm check:menus` | Menu surface inventory |
|
| `pnpm check:menus` | Menu surface inventory |
|
||||||
| `pnpm smoke [filter...]` | Browser smoke tests (`tests/smoke/`). See [Browser smoke tests](docs/development.md#browser-smoke-tests). |
|
| `pnpm smoke [filter...]` | Browser smoke tests (`tests/smoke/`). See [Browser smoke tests](docs/development.md#browser-smoke-tests). |
|
||||||
| `pnpm build:installer --version <version>` | Windows installer. See [Builds](docs/builds.md). |
|
| `pnpm build:installer --version <version>` | Windows installer. See [Builds](docs/builds.md). |
|
||||||
|
| `pnpm build:browser-engine --release-url <url> --version <version>` | Browser engine ZIP and its pin. See [Build the browser engine](docs/builds.md#build-the-browser-engine). |
|
||||||
| `pnpm package:plugin <compiled-folder> [output-folder]` | Plugin ZIP |
|
| `pnpm package:plugin <compiled-folder> [output-folder]` | Plugin ZIP |
|
||||||
| `pnpm sdk:build` | Build the plugin SDK in `packages/plugin-sdk/` |
|
| `pnpm sdk:build` | Build the plugin SDK in `packages/plugin-sdk/` |
|
||||||
| `pnpm release:sdk --version <version>` | Prepare an SDK release in the public SDK clone. It never pushes. See [SDK releases](docs/releases.md). |
|
| `pnpm release:sdk --version <version>` | Prepare an SDK release in the public SDK clone. It never pushes. See [SDK releases](docs/releases.md). |
|
||||||
@@ -74,13 +75,13 @@ Rules from the owner:
|
|||||||
|
|
||||||
- Versions use `zz.yy.xx`. A hotfix adds a lowercase letter suffix: `0.2.28a`, then `0.2.28b`.
|
- Versions use `zz.yy.xx`. A hotfix adds a lowercase letter suffix: `0.2.28a`, then `0.2.28b`.
|
||||||
- Keep the current version during source edits, fixes, documentation, and checks. Instruction-only edits never change it.
|
- Keep the current version during source edits, fixes, documentation, and checks. Instruction-only edits never change it.
|
||||||
- Set the next version only when you produce a build: a RuneStone installer or a plugin ZIP.
|
- Set the next version only when you produce a build: a RuneStone installer, a browser engine ZIP, or a plugin ZIP.
|
||||||
A regular build increases `xx` by one. A hotfix build increases only the suffix.
|
A regular build increases `xx` by one. A hotfix build increases only the suffix.
|
||||||
- If the build fails, restore the previous version fields. Failed attempts do not use up a version.
|
- If the build fails, restore the previous version fields. Failed attempts do not use up a version.
|
||||||
- Increase `yy` or `zz` only when the owner directs a release.
|
- Increase `yy` or `zz` only when the owner directs a release.
|
||||||
- Report a new version only after its artifact exists. Report the full artifact path.
|
- Report a new version only after its artifact exists. Report the full artifact path.
|
||||||
- Completed builds go in `releases/`, outside Git. Never overwrite a release with different contents.
|
- Completed builds go in `releases/`, outside Git. Never overwrite a release with different contents.
|
||||||
- Repository releases contain only installers or plugin ZIPs, with an empty description.
|
- Repository releases contain only installers, browser engine ZIPs, or plugin ZIPs, with an empty description.
|
||||||
|
|
||||||
## Windows installer
|
## Windows installer
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ This directory contains the runtime, bundled filter lists, licenses, and tests.
|
|||||||
Electron runs in its own process, with a separate dependency lock.
|
Electron runs in its own process, with a separate dependency lock.
|
||||||
|
|
||||||
Run `npm ci` in this directory to install the runtime dependencies.
|
Run `npm ci` in this directory to install the runtime dependencies.
|
||||||
Run `npm run package` and `npm run stage:host` to prepare the resource for a host installer.
|
Run `npm run package` and `npm run stage:host` to use the engine in `pnpm tauri dev`. In the host repository, `pnpm build:browser-engine` makes the release ZIP that users download.
|
||||||
No Browser plugin ZIP or sibling checkout is required.
|
No Browser plugin ZIP or sibling checkout is required.
|
||||||
|
|
||||||
## Page isolation
|
## Page isolation
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ The former Browser repository is no longer a build dependency.
|
|||||||
|
|
||||||
| Capability | State |
|
| Capability | State |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| Delivery | Built into RuneStone, with an isolated Chromium process |
|
| Delivery | A separate download that RuneStone installs on first use. It runs as an isolated Chromium process. |
|
||||||
| Interface | Editor tabs, Bookmarks, Settings, split panes, and separate windows |
|
| Interface | Editor tabs, Bookmarks, Settings, split panes, and separate windows |
|
||||||
| Profiles | Default User profile, blank profiles, and independent copies |
|
| Profiles | Default User profile, blank profiles, and independent copies |
|
||||||
| Page input | Pointer input, wheel scrolling, middle-button scrolling, text, clipboard shortcuts, and composition text |
|
| Page input | Pointer input, wheel scrolling, middle-button scrolling, text, clipboard shortcuts, and composition text |
|
||||||
|
|||||||
@@ -3,6 +3,5 @@
|
|||||||
"productName": "RuneStone Browser Test",
|
"productName": "RuneStone Browser Test",
|
||||||
"app": {
|
"app": {
|
||||||
"windows": [{ "label": "main", "title": "RuneStone browser test (isolated)", "visible": false, "width": 1400, "height": 900, "decorations": false, "dragDropEnabled": false }]
|
"windows": [{ "label": "main", "title": "RuneStone browser test (isolated)", "visible": false, "width": 1400, "height": 900, "decorations": false, "dragDropEnabled": false }]
|
||||||
},
|
}
|
||||||
"bundle": { "resources": { "browser-engine/": "browser-engine/" } }
|
|
||||||
}
|
}
|
||||||
|
|||||||
+48
-10
@@ -13,7 +13,7 @@ Use the [release policy](releases.md) to select the version, store the files, an
|
|||||||
Prerequisites:
|
Prerequisites:
|
||||||
|
|
||||||
- The source setup in [Run from source](development.md#run-from-source).
|
- The source setup in [Run from source](development.md#run-from-source).
|
||||||
- A Windows Browser runtime staged in `src-tauri/browser-engine`. See [Built-in browser runtime](development.md#built-in-browser-runtime). The installer bundles that folder.
|
- The pin of the browser engine in `src-tauri/browser-engine.json`. To build a new engine first, see [Build the browser engine](#build-the-browser-engine). The installer does not include the engine.
|
||||||
- Internet access for the first build. Tauri downloads NSIS and the WebView2 bootstrapper.
|
- Internet access for the first build. Tauri downloads NSIS and the WebView2 bootstrapper.
|
||||||
|
|
||||||
Procedure, in the RuneStone repository root:
|
Procedure, in the RuneStone repository root:
|
||||||
@@ -45,7 +45,7 @@ Source: `scripts/buildInstaller.mjs`.
|
|||||||
|
|
||||||
1. Reads the version and makes sure that all version fields match the current version.
|
1. Reads the version and makes sure that all version fields match the current version.
|
||||||
2. Makes sure that downgrade protection stays on in `tauri.conf.json` and `tauri.windows.conf.json`.
|
2. Makes sure that downgrade protection stays on in `tauri.conf.json` and `tauri.windows.conf.json`.
|
||||||
Makes sure that `tauri.windows.conf.json` names the installer hooks and that the browser runtime is staged.
|
Makes sure that `tauri.windows.conf.json` names the installer hooks and that `tauri.conf.json` does not bundle the browser engine.
|
||||||
3. Stops if the setup file or `host.json` exists in the bundle folder or in `releases/<version>/`.
|
3. Stops if the setup file or `host.json` exists in the bundle folder or in `releases/<version>/`.
|
||||||
A dry run prints the plan and stops here.
|
A dry run prints the plan and stops here.
|
||||||
4. Saves copies of the four version files as `*.before` in `output/installer-build/<version>/<time>/`, a new folder for each attempt.
|
4. Saves copies of the four version files as `*.before` in `output/installer-build/<version>/<time>/`, a new folder for each attempt.
|
||||||
@@ -55,7 +55,8 @@ Source: `scripts/buildInstaller.mjs`.
|
|||||||
Tauri gives the override to the Rust build script and to the app. Cargo keeps the previous package version, so the app must not use `CARGO_PKG_VERSION`.
|
Tauri gives the override to the Rust build script and to the app. Cargo keeps the previous package version, so the app must not use `CARGO_PKG_VERSION`.
|
||||||
6. Runs `scripts/setWindowsVersion.ps1`. It writes the release version to the `FileVersion` and `ProductVersion` strings of `runestone.exe`. Tauri can write only a SemVer version to these strings.
|
6. Runs `scripts/setWindowsVersion.ps1`. It writes the release version to the `FileVersion` and `ProductVersion` strings of `runestone.exe`. Tauri can write only a SemVer version to these strings.
|
||||||
7. Runs `tauri bundle --bundles nsis --config <override>`. Tauri uses its stock NSIS template with the [installer hooks](#installer-hooks).
|
7. Runs `tauri bundle --bundles nsis --config <override>`. Tauri uses its stock NSIS template with the [installer hooks](#installer-hooks).
|
||||||
8. Moves the setup file into `releases/<version>/`, writes `host.json`, and removes the bundle-folder copy.
|
8. Stops if the setup file is larger than 30 MB. The core installer is about 10 MB.
|
||||||
|
Moves the setup file into `releases/<version>/`, writes `host.json`, and removes the bundle-folder copy.
|
||||||
9. Writes the new version to `package.json`, `tauri.conf.json`, `Cargo.toml`, and `Cargo.lock`.
|
9. Writes the new version to `package.json`, `tauri.conf.json`, `Cargo.toml`, and `Cargo.lock`.
|
||||||
|
|
||||||
### Failure and rollback
|
### Failure and rollback
|
||||||
@@ -77,6 +78,8 @@ Keep these properties when you change the installer configuration or hooks:
|
|||||||
| Windows shows the release version in installed apps. | The hooks write the release version, such as `0.1.23a`, to `DisplayVersion`. |
|
| Windows shows the release version in installed apps. | The hooks write the release version, such as `0.1.23a`, to `DisplayVersion`. |
|
||||||
| The app identity stays the same across upgrades. | The identifier stays `com.runestone.app`. |
|
| The app identity stays the same across upgrades. | The identifier stays `com.runestone.app`. |
|
||||||
| WebView2 is available. | The installer embeds the WebView2 bootstrapper. If the runtime is missing, setup downloads it. |
|
| WebView2 is available. | The installer embeds the WebView2 bootstrapper. If the runtime is missing, setup downloads it. |
|
||||||
|
| An update removes the engine folder of releases up to 0.1.48. | `NSIS_HOOK_POSTINSTALL` removes `$INSTDIR\browser-engine`. The uninstaller of the old version does not run, so nothing else removes it. |
|
||||||
|
| Uninstall removes the downloaded browser engine. The browser profiles stay unless the user deletes the app data. | `NSIS_HOOK_POSTUNINSTALL` removes `browser-engine` in the local app data folder, except during an update. |
|
||||||
|
|
||||||
The installer uses the RuneStone icon, installs for the current Windows account, and adds a Start menu shortcut and an uninstaller.
|
The installer uses the RuneStone icon, installs for the current Windows account, and adds a Start menu shortcut and an uninstaller.
|
||||||
It does not register document types or start RuneStone when Windows starts.
|
It does not register document types or start RuneStone when Windows starts.
|
||||||
@@ -93,7 +96,8 @@ RuneStone uses the stock NSIS template of the Tauri CLI.
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `RuneStoneGuiInit`, set as `MUI_CUSTOMFUNCTION_GUIINIT` | Interactive and passive (`/P`) setup, before the first page | Stops a downgrade. Makes the maintenance page skip itself. |
|
| `RuneStoneGuiInit`, set as `MUI_CUSTOMFUNCTION_GUIINIT` | Interactive and passive (`/P`) setup, before the first page | Stops a downgrade. Makes the maintenance page skip itself. |
|
||||||
| Section `-RuneStoneVersionCheck` | All modes, before the Tauri sections | Restores the current-user context. Stops a downgrade. Silent setup shows no pages, so it needs this check. |
|
| Section `-RuneStoneVersionCheck` | All modes, before the Tauri sections | Restores the current-user context. Stops a downgrade. Silent setup shows no pages, so it needs this check. |
|
||||||
| `NSIS_HOOK_POSTINSTALL` | At the end of the Tauri `Install` section | Writes `DisplayVersion`, `RuneStoneReleaseVersion`, and `RuneStoneWindowsVersion`. |
|
| `NSIS_HOOK_POSTINSTALL` | At the end of the Tauri `Install` section | Writes `DisplayVersion`, `RuneStoneReleaseVersion`, and `RuneStoneWindowsVersion`. Removes `$INSTDIR\browser-engine`. |
|
||||||
|
| `NSIS_HOOK_POSTUNINSTALL` | At the end of the Tauri `Uninstall` section | Removes `$LOCALAPPDATA\com.runestone.app\browser-engine`, except in update mode. |
|
||||||
|
|
||||||
Tauri includes the hooks file before the template variables, pages, and sections.
|
Tauri includes the hooks file before the template variables, pages, and sections.
|
||||||
Thus only the `NSIS_HOOK_*` macros can use template symbols such as `${VERSION}`.
|
Thus only the `NSIS_HOOK_*` macros can use template symbols such as `${VERSION}`.
|
||||||
@@ -147,12 +151,15 @@ Do all checks in this table for the first installer that uses the stock template
|
|||||||
| Open RuneStone from the Start menu | The app opens without a terminal or a development server. |
|
| Open RuneStone from the Start menu | The app opens without a terminal or a development server. |
|
||||||
| Create a workspace outside the installation folder | Notes save and open again. |
|
| Create a workspace outside the installation folder | Notes save and open again. |
|
||||||
| Install the new version over 0.1.44 | Setup shows no maintenance page and does not start the uninstaller. It updates the app and keeps workspace files and settings. |
|
| Install the new version over 0.1.44 | Setup shows no maintenance page and does not start the uninstaller. It updates the app and keeps workspace files and settings. |
|
||||||
|
| Install the new version over 0.1.48 | The `browser-engine` folder in the installation folder is gone. At the first browser start, the browser profiles move from `%APPDATA%` to `%LOCALAPPDATA%`. |
|
||||||
|
| Open a browser tab, then select **Download the engine** | The download shows its progress. Then the tab opens its page. |
|
||||||
|
| Open a browser tab without internet access | The tab shows the cause, **Retry**, and **Install from file…**. Web links in documents open in the system browser. |
|
||||||
| Install the same version again | Setup shows no maintenance page and does not start the uninstaller. It keeps workspace files and settings. |
|
| Install the same version again | Setup shows no maintenance page and does not start the uninstaller. It keeps workspace files and settings. |
|
||||||
| Install an older version, for example 0.1.44 | Setup blocks the downgrade. |
|
| Install an older version, for example 0.1.44 | Setup blocks the downgrade. |
|
||||||
| Silent downgrade attempt | See the procedure below this table. Setup stops with exit code 2 and changes nothing. |
|
| Silent downgrade attempt | See the procedure below this table. Setup stops with exit code 2 and changes nothing. |
|
||||||
| Open **Settings → Apps → Installed apps** in Windows | The RuneStone entry shows the release version, such as `0.1.45` or `0.1.45a`. |
|
| Open **Settings → Apps → Installed apps** in Windows | The RuneStone entry shows the release version, such as `0.1.45` or `0.1.45a`. |
|
||||||
| Install a hotfix over its base version | Setup updates the app. |
|
| Install a hotfix over its base version | Setup updates the app. |
|
||||||
| Remove RuneStone through Windows Settings | The app and shortcuts are removed. The separate workspace stays. |
|
| Remove RuneStone through Windows Settings | The app, the shortcuts, and the downloaded browser engine are removed. The separate workspace stays. |
|
||||||
|
|
||||||
Silent downgrade attempt, in PowerShell on the test account:
|
Silent downgrade attempt, in PowerShell on the test account:
|
||||||
|
|
||||||
@@ -165,12 +172,43 @@ Silent downgrade attempt, in PowerShell on the test account:
|
|||||||
5. Run the same command with `-ArgumentList '/P'`. Setup shows a message, then stops with exit code `2`.
|
5. Run the same command with `-ArgumentList '/P'`. Setup shows a message, then stops with exit code `2`.
|
||||||
6. Restore the registry value: set `RuneStoneWindowsVersion` to the `windowsVersion` value in `host.json`.
|
6. Restore the registry value: set `RuneStoneWindowsVersion` to the `windowsVersion` value in `host.json`.
|
||||||
|
|
||||||
|
## Build the browser engine
|
||||||
|
|
||||||
|
`pnpm build:browser-engine` packages the browser engine for 64-bit Windows (x64) as a ZIP. Then it pins that ZIP in `src-tauri/browser-engine.json`. Each later host build downloads the pinned engine on first use.
|
||||||
|
Build and publish the engine before the installer that pins it. An installer needs a new engine only when the engine changes.
|
||||||
|
|
||||||
|
Prerequisites:
|
||||||
|
|
||||||
|
- Windows x64. The script stops on other systems, because no other platform has a published engine yet.
|
||||||
|
- `npm ci --prefix browser-runtime`, then `pnpm browser:check` and `pnpm browser:test`. See [Built-in browser runtime](development.md#built-in-browser-runtime).
|
||||||
|
- The public folder URL of the engine release. See [Publish a browser engine](releases.md#publish-a-browser-engine).
|
||||||
|
|
||||||
|
Procedure, in the RuneStone repository root:
|
||||||
|
|
||||||
|
1. Select the engine version with the [version policy](releases.md#versions). The engine version is in `browser-runtime/package.json`.
|
||||||
|
2. Run `pnpm build:browser-engine --release-url <folder URL> --version <version> --dry-run`. Make sure that the plan shows the correct version and URL. A dry run changes no file.
|
||||||
|
3. Run `pnpm build:browser-engine --release-url <folder URL> --version <version>`.
|
||||||
|
4. Publish the ZIP. See [Publish a browser engine](releases.md#publish-a-browser-engine).
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
| File | Contents |
|
||||||
|
| --- | --- |
|
||||||
|
| `releases/browser-engine/<version>/RuneStone-Browser_<version>_win32-x64.zip` | The engine files at the archive root, in name order, with a fixed time stamp |
|
||||||
|
| `releases/browser-engine/<version>/engine.json` | The version, the protocol, the platform key, the file name, the URL, the size in bytes, and the SHA-256 hash |
|
||||||
|
| `src-tauri/browser-engine.json` | The pin: the engine version, the protocol, and the URL, size, and SHA-256 for `windows-x86_64` |
|
||||||
|
|
||||||
|
The script prints `Engine available: <path>`, the size, the hash, and the upload URL when it completes.
|
||||||
|
The script writes the new version to `browser-runtime/package.json` and `package-lock.json` before it packages the engine, because the engine reports that version. If a step fails, the script restores these files and the pin. The backups are in `output/browser-engine-build/<version>/<time>/`.
|
||||||
|
The script reads `PROTOCOL` in `src-tauri/src/browser_engine.rs` and the protocol of the `ready` event in `browser-runtime/src/engine-main.mjs`. It stops if they differ.
|
||||||
|
|
||||||
|
Example, with Electron 44.5.1 from `browser-runtime/package.json`: the engine files are 377 MB, and the ZIP is about 160 MB.
|
||||||
|
|
||||||
## Build Linux packages
|
## Build Linux packages
|
||||||
|
|
||||||
Prerequisites:
|
Prerequisites:
|
||||||
|
|
||||||
- The [Linux development prerequisites](linux.md) on the processor architecture of the package.
|
- The [Linux development prerequisites](linux.md) on the processor architecture of the package.
|
||||||
- A Linux Browser runtime for that architecture, staged in `src-tauri/browser-engine`.
|
|
||||||
- The new version in all RuneStone version fields. No Linux script sets or restores them. See [Versions](releases.md#versions).
|
- The new version in all RuneStone version fields. No Linux script sets or restores them. See [Versions](releases.md#versions).
|
||||||
|
|
||||||
Procedure, in the RuneStone repository root. The commands use the Tauri CLI from `package.json` and the bundle settings in `src-tauri/tauri.linux.conf.json`.
|
Procedure, in the RuneStone repository root. The commands use the Tauri CLI from `package.json` and the bundle settings in `src-tauri/tauri.linux.conf.json`.
|
||||||
@@ -194,6 +232,7 @@ If the build fails, restore the previous version fields.
|
|||||||
Example, from the 0.1.44 download link in the README: the x86_64 Debian build of version `0.1.44` is `RuneStone_0.1.44_amd64.deb`.
|
Example, from the 0.1.44 download link in the README: the x86_64 Debian build of version `0.1.44` is `RuneStone_0.1.44_amd64.deb`.
|
||||||
|
|
||||||
`pnpm build:installer` does not build Linux packages. It stops on operating systems other than Windows.
|
`pnpm build:installer` does not build Linux packages. It stops on operating systems other than Windows.
|
||||||
|
Linux packages do not include the browser engine, and no Linux engine is published yet. The browser tab says that no engine is available for the platform.
|
||||||
No Linux script encodes hotfix versions, and Tauri rejects a letter suffix in `tauri.conf.json`. Report this blocker before a Linux hotfix build.
|
No Linux script encodes hotfix versions, and Tauri rejects a letter suffix in `tauri.conf.json`. Report this blocker before a Linux hotfix build.
|
||||||
|
|
||||||
The Debian package depends on `libc6 (>= 2.39)`, as set in `tauri.linux.conf.json`.
|
The Debian package depends on `libc6 (>= 2.39)`, as set in `tauri.linux.conf.json`.
|
||||||
@@ -217,7 +256,7 @@ For an example record, see the [Linux 0.1.44 validation](archive/linux-validatio
|
|||||||
|
|
||||||
macOS packages are experimental. RuneStone has no validated macOS release procedure.
|
macOS packages are experimental. RuneStone has no validated macOS release procedure.
|
||||||
|
|
||||||
Prerequisites: a Mac, the source setup, and a Browser runtime packaged and staged on that Mac.
|
Prerequisites: a Mac and the source setup.
|
||||||
|
|
||||||
In the RuneStone repository root, run:
|
In the RuneStone repository root, run:
|
||||||
|
|
||||||
@@ -227,9 +266,8 @@ pnpm tauri build --bundles app -- --locked
|
|||||||
|
|
||||||
Tauri puts the application bundle in `src-tauri/target/release/bundle/macos/`. No script sets the version fields on macOS.
|
Tauri puts the application bundle in `src-tauri/target/release/bundle/macos/`. No script sets the version fields on macOS.
|
||||||
|
|
||||||
Example, from the [macOS 0.1.44 record](archive/macos-validation-0.1.44.md): the 0.1.44 DMG used manual steps after this build.
|
macOS packages do not include the browser engine, and no macOS engine is published yet.
|
||||||
Those steps replaced the bundled Browser resources with a copy that keeps the Electron framework symbolic links.
|
The [macOS 0.1.44 record](archive/macos-validation-0.1.44.md) describes the ad hoc signatures and the DMG steps of that release.
|
||||||
Then they applied ad hoc signatures and created the DMG.
|
|
||||||
|
|
||||||
Developer ID signing, notarization, Intel builds, and desktop acceptance tests are not done for macOS.
|
Developer ID signing, notarization, Intel builds, and desktop acceptance tests are not done for macOS.
|
||||||
See [Tauri's macOS application bundle guide](https://v2.tauri.app/distribute/macos-application-bundle/).
|
See [Tauri's macOS application bundle guide](https://v2.tauri.app/distribute/macos-application-bundle/).
|
||||||
|
|||||||
+1
-1
@@ -283,7 +283,7 @@ Before you start the app, set `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-de
|
|||||||
## Built-in browser runtime
|
## Built-in browser runtime
|
||||||
|
|
||||||
The browser interface is in `src/lib/browser/`. The browser engine, its tests, and its notices are in `browser-runtime/`.
|
The browser interface is in `src/lib/browser/`. The browser engine, its tests, and its notices are in `browser-runtime/`.
|
||||||
The engine is a separate download. Users install it on first use.
|
The engine is a separate download. Users install it on first use. To build and publish it, see [Build the browser engine](builds.md#build-the-browser-engine).
|
||||||
|
|
||||||
1. Run `npm ci --prefix browser-runtime`.
|
1. Run `npm ci --prefix browser-runtime`.
|
||||||
2. Run `pnpm browser:check` and `pnpm browser:test`.
|
2. Run `pnpm browser:check` and `pnpm browser:test`.
|
||||||
|
|||||||
+3
-1
@@ -45,6 +45,8 @@ Some distributions limit user namespaces, which the sandbox can need. Test the B
|
|||||||
|
|
||||||
The native host uses WebKitGTK and the Browser uses Electron. Test both.
|
The native host uses WebKitGTK and the Browser uses Electron. Test both.
|
||||||
|
|
||||||
|
Linux packages do not include the engine, and no Linux engine download exists yet. A package says that no engine is available for the platform. `pnpm tauri dev` starts the staged engine.
|
||||||
|
|
||||||
## Checks
|
## Checks
|
||||||
|
|
||||||
Run the source checks in [Checks](development.md#checks) and the tests in [Browser smoke tests](development.md#browser-smoke-tests).
|
Run the source checks in [Checks](development.md#checks) and the tests in [Browser smoke tests](development.md#browser-smoke-tests).
|
||||||
@@ -64,7 +66,7 @@ Voice typing is not part of the Linux checks.
|
|||||||
| Launch and windows | Open from the desktop. Move, resize, minimize, maximize, and close. Unsaved edits start the close guard. |
|
| Launch and windows | Open from the desktop. Move, resize, minimize, maximize, and close. Unsaved edits start the close guard. |
|
||||||
| Files and paths | Create, save, open again, rename, copy, and delete files. Check spaces, Unicode, and distinct `Note.md` and `note.md` files. |
|
| Files and paths | Create, save, open again, rename, copy, and delete files. Check spaces, Unicode, and distinct `Note.md` and `note.md` files. |
|
||||||
| External edits | Edit a file in a different editor. RuneStone finds the change and does not silently replace conflicting edits. |
|
| External edits | Edit a file in a different editor. RuneStone finds the change and does not silently replace conflicting edits. |
|
||||||
| Built-in Browser | Open a web page, type, scroll, open and close tabs, download a file, and restart the app. Check the packaged runtime too. |
|
| Built-in Browser | In `pnpm tauri dev` with the staged engine, open a web page, type, scroll, open and close tabs, download a file, and restart the app. In a package, a browser tab says that no engine is available. |
|
||||||
| Editors | Edit Markdown, source code, tables, images, and diagrams. Check undo, keyboard shortcuts, and both themes. |
|
| Editors | Edit Markdown, source code, tables, images, and diagrams. Check undo, keyboard shortcuts, and both themes. |
|
||||||
| Clipboard and dialogs | Copy and paste text, tables, and images. Check folder selection, external links, and file reveal. |
|
| Clipboard and dialogs | Copy and paste text, tables, and images. Check folder selection, external links, and file reveal. |
|
||||||
| Plugins | Install plugin ZIPs through Settings, enable them, restart, disable them, and remove them. Check that plugin data stays. |
|
| Plugins | Install plugin ZIPs through Settings, enable them, restart, disable them, and remove them. Check that plugin data stays. |
|
||||||
|
|||||||
+24
-4
@@ -6,7 +6,7 @@ This policy sets version numbers, release file storage, and publication steps fo
|
|||||||
|
|
||||||
## Versions
|
## Versions
|
||||||
|
|
||||||
RuneStone and each plugin keep separate version numbers. Each project uses the form `zz.yy.xx`.
|
RuneStone, the browser engine, and each plugin keep separate version numbers. Each project uses the form `zz.yy.xx`.
|
||||||
|
|
||||||
| Part | Increase it for | Then reset |
|
| Part | Increase it for | Then reset |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
@@ -14,7 +14,7 @@ RuneStone and each plugin keep separate version numbers. Each project uses the f
|
|||||||
| `yy` | A deliberate release that is ready for build testing, by direction of the project owner | `xx` to zero |
|
| `yy` | A deliberate release that is ready for build testing, by direction of the project owner | `xx` to zero |
|
||||||
| `zz` | A full release, by direction of the project owner | `yy` and `xx` to zero |
|
| `zz` | A full release, by direction of the project owner | `yy` and `xx` to zero |
|
||||||
|
|
||||||
A build is a RuneStone installer or a plugin ZIP, unless the project owner asks for a different distributable.
|
A build is a RuneStone installer, a browser engine ZIP, or a plugin ZIP, unless the project owner asks for a different distributable.
|
||||||
Development servers, test runs, and intermediate compilation output are not builds.
|
Development servers, test runs, and intermediate compilation output are not builds.
|
||||||
|
|
||||||
- Keep routine implementation work in the current `zz.yy` series.
|
- Keep routine implementation work in the current `zz.yy` series.
|
||||||
@@ -29,12 +29,16 @@ Development servers, test runs, and intermediate compilation output are not buil
|
|||||||
| Project | Version fields |
|
| Project | Version fields |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| RuneStone | `package.json`, `src-tauri/tauri.conf.json`, the package version and `[package.metadata.runestone]` in `src-tauri/Cargo.toml`, and the `runestone` entry in `src-tauri/Cargo.lock` |
|
| RuneStone | `package.json`, `src-tauri/tauri.conf.json`, the package version and `[package.metadata.runestone]` in `src-tauri/Cargo.toml`, and the `runestone` entry in `src-tauri/Cargo.lock` |
|
||||||
|
| Browser engine | `version` in `browser-runtime/package.json`, and the two `version` fields of `browser-runtime/package-lock.json` |
|
||||||
| Plugin | `plugin.json`, the project `package.json`, and any build metadata |
|
| Plugin | `plugin.json`, the project `package.json`, and any build metadata |
|
||||||
| Plugin SDK | `packages/plugin-sdk/package.json`. See [SDK releases](#sdk-releases). |
|
| Plugin SDK | `packages/plugin-sdk/package.json`. See [SDK releases](#sdk-releases). |
|
||||||
|
|
||||||
On Windows, `pnpm build:installer --version <version>` sets the RuneStone fields when the installer is complete. If the build fails, the fields keep the previous version.
|
On Windows, `pnpm build:installer --version <version>` sets the RuneStone fields when the installer is complete. If the build fails, the fields keep the previous version.
|
||||||
See [Build the Windows installer](builds.md#build-the-windows-installer).
|
See [Build the Windows installer](builds.md#build-the-windows-installer).
|
||||||
|
|
||||||
|
`pnpm build:browser-engine --release-url <folder URL> --version <version>` sets the engine fields and the pin in `src-tauri/browser-engine.json` when the ZIP is complete. If the build fails, they keep their previous contents.
|
||||||
|
See [Build the browser engine](builds.md#build-the-browser-engine).
|
||||||
|
|
||||||
## Hotfix versions
|
## Hotfix versions
|
||||||
|
|
||||||
A hotfix fixes one item or a narrowly scoped problem in an existing release.
|
A hotfix fixes one item or a narrowly scoped problem in an existing release.
|
||||||
@@ -64,6 +68,7 @@ These rules apply to the main app, all existing plugins, and all new plugins.
|
|||||||
| Release | Folder |
|
| Release | Folder |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| RuneStone installer | `releases/<version>/` at the RuneStone project root |
|
| RuneStone installer | `releases/<version>/` at the RuneStone project root |
|
||||||
|
| Browser engine ZIP | `releases/browser-engine/<version>/` at the RuneStone project root |
|
||||||
| Plugin ZIP | `releases/` at the root of that plugin project |
|
| Plugin ZIP | `releases/` at the root of that plugin project |
|
||||||
|
|
||||||
- Keep release notes, checksums, and build metadata with the release they describe, in the local release folder.
|
- Keep release notes, checksums, and build metadata with the release they describe, in the local release folder.
|
||||||
@@ -77,8 +82,8 @@ These rules apply to the main app, all existing plugins, and all new plugins.
|
|||||||
- Report a filename conflict before you change a file name.
|
- Report a filename conflict before you change a file name.
|
||||||
- After each completed build, report the full path of the build file.
|
- After each completed build, report the full path of the build file.
|
||||||
|
|
||||||
`pnpm build:installer` and `pnpm package:plugin` obey these rules for their own output.
|
`pnpm build:installer`, `pnpm build:browser-engine`, and `pnpm package:plugin` obey these rules for their own output.
|
||||||
The installer script stops if the release file exists. The plugin packager reuses an identical ZIP and stops if the existing ZIP has different contents.
|
The installer and engine scripts stop if the release file exists. The plugin packager reuses an identical ZIP and stops if the existing ZIP has different contents.
|
||||||
|
|
||||||
## Publish an installer
|
## Publish an installer
|
||||||
|
|
||||||
@@ -98,6 +103,21 @@ Do not attach Markdown files, release notes, checksums, metadata, logs, or scree
|
|||||||
Put release notes, test results, and installation instructions in the repository documentation.
|
Put release notes, test results, and installation instructions in the repository documentation.
|
||||||
Keep the other build records in the local release folder.
|
Keep the other build records in the local release folder.
|
||||||
|
|
||||||
|
## Publish a browser engine
|
||||||
|
|
||||||
|
The RuneStone repository is private, so the engine ZIP needs a public download location. Each host build downloads the URL in its pin.
|
||||||
|
|
||||||
|
1. Build the engine ZIP with the URL of its public release folder. See [Build the browser engine](builds.md#build-the-browser-engine).
|
||||||
|
2. In the public download repository, create a release with the tag `browser-engine-v<version>`.
|
||||||
|
3. Attach only the engine ZIP. Leave the release description empty.
|
||||||
|
4. Upload through the LAN address of the Gitea server. Cloudflare limits a request body to 100 MB, and the ZIP is larger.
|
||||||
|
5. Make sure that the `url` in `engine.json` downloads the ZIP without a sign-in, and that its size matches.
|
||||||
|
6. Commit `src-tauri/browser-engine.json` and the engine version fields.
|
||||||
|
7. Build the installer that pins this engine.
|
||||||
|
|
||||||
|
The Gitea attachment limit (`[attachment] MAX_SIZE`) must be larger than the ZIP. The server allowed 100 MB on 2026-10-29.
|
||||||
|
Keep each published engine ZIP. Installed RuneStone versions download the engine that they pin.
|
||||||
|
|
||||||
## Publish a plugin release
|
## Publish a plugin release
|
||||||
|
|
||||||
These rules apply on all hosting services. The service stores the files. RuneStone defines the package format, the versions, and the installation checks.
|
These rules apply on all hosting services. The service stores the files. RuneStone defines the package format, the versions, and the installation checks.
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"browser:test": "npm --prefix browser-runtime test",
|
"browser:test": "npm --prefix browser-runtime test",
|
||||||
"browser:test:engine": "npm --prefix browser-runtime run test:browser",
|
"browser:test:engine": "npm --prefix browser-runtime run test:browser",
|
||||||
"browser:stage": "npm --prefix browser-runtime run stage:host",
|
"browser:stage": "npm --prefix browser-runtime run stage:host",
|
||||||
|
"build:browser-engine": "node scripts/buildBrowserEngine.mjs",
|
||||||
"package:plugin": "node scripts/packagePlugin.mjs",
|
"package:plugin": "node scripts/packagePlugin.mjs",
|
||||||
"sdk:build": "node scripts/buildSdk.mjs",
|
"sdk:build": "node scripts/buildSdk.mjs",
|
||||||
"release:sdk": "node scripts/releaseSdk.mjs"
|
"release:sdk": "node scripts/releaseSdk.mjs"
|
||||||
|
|||||||
@@ -0,0 +1,193 @@
|
|||||||
|
// Builds the browser engine ZIP and pins it in the host. See docs/builds.md#build-the-browser-engine.
|
||||||
|
// Usage: node scripts/buildBrowserEngine.mjs --release-url <folder URL> [--version <version>] [--dry-run]
|
||||||
|
import fs from 'node:fs/promises';
|
||||||
|
import path from 'node:path';
|
||||||
|
import zlib from 'node:zlib';
|
||||||
|
import { spawn } from 'node:child_process';
|
||||||
|
import { realpathSync } from 'node:fs';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
import { createHash } from 'node:crypto';
|
||||||
|
import { releaseVersion } from './releaseVersion.mjs';
|
||||||
|
|
||||||
|
const exists = file => fs.access(file).then(() => true, () => false);
|
||||||
|
export const engineFiles = ['browser-runtime/package.json', 'browser-runtime/package-lock.json', 'src-tauri/browser-engine.json'];
|
||||||
|
|
||||||
|
export function parseArguments(args) {
|
||||||
|
const options = { version: undefined, releaseUrl: undefined, dryRun: false };
|
||||||
|
for (let i = 0; i < args.length; i++) {
|
||||||
|
if (args[i] === '--dry-run') options.dryRun = true;
|
||||||
|
else if (args[i] === '--version' && args[i + 1] && !options.version) options.version = args[++i];
|
||||||
|
else if (args[i] === '--release-url' && args[i + 1] && !options.releaseUrl) options.releaseUrl = args[++i];
|
||||||
|
else throw Error('Use --release-url followed by the release folder URL, optionally --version followed by the engine version, and optionally --dry-run.');
|
||||||
|
}
|
||||||
|
if (!options.releaseUrl) throw Error('Use --release-url followed by the URL of the folder that will hold the engine ZIP.');
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The platform key of the host manifest, as `browser_engine::platform()` in Rust writes it. */
|
||||||
|
export function platformKey(platform, arch) {
|
||||||
|
const system = { win32: 'windows', linux: 'linux', darwin: 'macos' }[platform];
|
||||||
|
const processor = { x64: 'x86_64', arm64: 'aarch64' }[arch];
|
||||||
|
if (!system || !processor) throw Error(`Unsupported engine platform: ${platform}-${arch}`);
|
||||||
|
return `${system}-${processor}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reads the version fields, checks the preconditions, and returns the build plan. Changes no file.
|
||||||
|
/** @param {string} root @param {{ version?: string, releaseUrl: string }} options @param {{ platform: string, arch: string }} [target] */
|
||||||
|
export async function planEngineBuild(root, { version, releaseUrl }, target = process) {
|
||||||
|
const files = engineFiles.map(file => path.join(root, file));
|
||||||
|
const before = await Promise.all(files.map(file => fs.readFile(file, 'utf8')));
|
||||||
|
const [packageJson, lock, manifest] = before.map(text => JSON.parse(text));
|
||||||
|
const current = releaseVersion(packageJson.version).version;
|
||||||
|
const next = releaseVersion(version ?? current).version;
|
||||||
|
if (lock.version !== current || lock.packages?.['']?.version !== current) throw Error('The engine version fields do not match.');
|
||||||
|
const protocol = Number(/pub const PROTOCOL: u64 = (\d+);/.exec(await fs.readFile(path.join(root, 'src-tauri/src/browser_engine.rs'), 'utf8'))?.[1]);
|
||||||
|
const sent = Number(/event: 'ready', protocol: (\d+)/.exec(await fs.readFile(path.join(root, 'browser-runtime/src/engine-main.mjs'), 'utf8'))?.[1]);
|
||||||
|
if (!protocol || protocol !== sent) throw Error('The engine protocol in browser_engine.rs and engine-main.mjs differs.');
|
||||||
|
const folder = new URL(releaseUrl.endsWith('/') ? releaseUrl : releaseUrl + '/');
|
||||||
|
if (folder.protocol !== 'https:' || folder.username || folder.password || folder.search || folder.hash) {
|
||||||
|
throw Error('Use an HTTPS release URL without credentials, a query, or a fragment.');
|
||||||
|
}
|
||||||
|
const { platform, arch } = target;
|
||||||
|
const file = `RuneStone-Browser_${next}_${platform}-${arch}.zip`;
|
||||||
|
const releaseDir = path.join(root, 'releases', 'browser-engine', next);
|
||||||
|
const artifacts = { archive: path.join(releaseDir, file), metadata: path.join(releaseDir, 'engine.json') };
|
||||||
|
for (const artifact of Object.values(artifacts)) if (await exists(artifact)) throw Error('The release file already exists: ' + artifact);
|
||||||
|
const dist = path.join(root, 'browser-runtime', 'dist', `RuneStone-Browser-${platform}-${arch}`);
|
||||||
|
return { root, files, before, current, next, protocol, platform, arch, key: platformKey(platform, arch), file,
|
||||||
|
url: new URL(file, folder).href, dist, releaseDir, artifacts };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildCommands(plan) {
|
||||||
|
// The same script as `npm --prefix browser-runtime run package`, without a shell.
|
||||||
|
return [{ step: 'package', command: process.execPath,
|
||||||
|
args: [path.join(plan.root, 'browser-runtime/scripts/package.mjs'), `--platform=${plan.platform}`, `--arch=${plan.arch}`] }];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function describePlan(plan) {
|
||||||
|
const relative = file => path.relative(plan.root, file);
|
||||||
|
return [
|
||||||
|
`Engine version: ${plan.next} (current ${plan.current}). Protocol: ${plan.protocol}. Platform: ${plan.key}.`,
|
||||||
|
`1. Write ${plan.next} to ${engineFiles.slice(0, 2).join(' and ')}.`,
|
||||||
|
...buildCommands(plan).map((entry, index) => `${index + 2}. ${entry.step}: ${[entry.command, ...entry.args].join(' ')}`),
|
||||||
|
`3. Write ${relative(plan.artifacts.archive)} from ${relative(plan.dist)}, and ${relative(plan.artifacts.metadata)}.`,
|
||||||
|
`4. Pin ${plan.url} in ${engineFiles[2]}.`,
|
||||||
|
].join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function listFiles(folder, prefix = '') {
|
||||||
|
const result = [];
|
||||||
|
const entries = (await fs.readdir(path.join(folder, prefix), { withFileTypes: true })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
||||||
|
for (const entry of entries) {
|
||||||
|
const name = prefix ? `${prefix}/${entry.name}` : entry.name;
|
||||||
|
if (entry.isDirectory()) result.push(...await listFiles(folder, name));
|
||||||
|
else if (entry.isFile()) result.push(name);
|
||||||
|
else throw Error(`The engine folder contains a link or a special file: ${name}`);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A ZIP of the files in `folder`, at the archive root, in name order, with a fixed time. The same files give the same bytes. */
|
||||||
|
export async function zipFolder(folder) {
|
||||||
|
const chunks = [], central = [];
|
||||||
|
let offset = 0;
|
||||||
|
const names = await listFiles(folder);
|
||||||
|
if (names.length > 65535) throw Error('The engine has too many files for a ZIP without ZIP64.');
|
||||||
|
for (const name of names) {
|
||||||
|
const full = path.join(folder, ...name.split('/'));
|
||||||
|
const [data, stat] = await Promise.all([fs.readFile(full), fs.stat(full)]);
|
||||||
|
const deflated = zlib.deflateRawSync(data, { level: 9 });
|
||||||
|
const stored = deflated.length >= data.length;
|
||||||
|
const body = stored ? data : deflated;
|
||||||
|
const crc = zlib.crc32(data);
|
||||||
|
const nameBytes = Buffer.from(name, 'utf8');
|
||||||
|
if (data.length >= 0xffffffff || offset + 30 + nameBytes.length + body.length >= 0xffffffff) throw Error('The engine is too large for a ZIP without ZIP64.');
|
||||||
|
// Version 2.0, UTF-8 names, no data descriptor, and the DOS date 1980-01-01 00:00.
|
||||||
|
const local = Buffer.alloc(30);
|
||||||
|
local.writeUInt32LE(0x04034b50, 0); local.writeUInt16LE(20, 4); local.writeUInt16LE(0x0800, 6); local.writeUInt16LE(stored ? 0 : 8, 8);
|
||||||
|
local.writeUInt16LE(0, 10); local.writeUInt16LE(0x21, 12); local.writeUInt32LE(crc, 14); local.writeUInt32LE(body.length, 18);
|
||||||
|
local.writeUInt32LE(data.length, 22); local.writeUInt16LE(nameBytes.length, 26); local.writeUInt16LE(0, 28);
|
||||||
|
const mode = 0o100000 | (process.platform === 'win32' ? 0o644 : stat.mode & 0o755);
|
||||||
|
const entry = Buffer.alloc(46);
|
||||||
|
entry.writeUInt32LE(0x02014b50, 0); entry.writeUInt16LE((3 << 8) | 20, 4); entry.writeUInt16LE(20, 6); entry.writeUInt16LE(0x0800, 8);
|
||||||
|
entry.writeUInt16LE(stored ? 0 : 8, 10); entry.writeUInt16LE(0, 12); entry.writeUInt16LE(0x21, 14); entry.writeUInt32LE(crc, 16);
|
||||||
|
entry.writeUInt32LE(body.length, 20); entry.writeUInt32LE(data.length, 24); entry.writeUInt16LE(nameBytes.length, 28);
|
||||||
|
entry.writeUInt32LE(mode * 0x10000, 38); entry.writeUInt32LE(offset, 42);
|
||||||
|
chunks.push(local, nameBytes, body);
|
||||||
|
central.push(entry, nameBytes);
|
||||||
|
offset += local.length + nameBytes.length + body.length;
|
||||||
|
}
|
||||||
|
const directory = Buffer.concat(central);
|
||||||
|
const end = Buffer.alloc(22);
|
||||||
|
end.writeUInt32LE(0x06054b50, 0); end.writeUInt16LE(names.length, 8); end.writeUInt16LE(names.length, 10);
|
||||||
|
end.writeUInt32LE(directory.length, 12); end.writeUInt32LE(offset, 16);
|
||||||
|
return Buffer.concat([...chunks, directory, end]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Runs the build. run(command, args) must reject when a command fails.
|
||||||
|
// On failure, the version fields and the pin get their previous contents back.
|
||||||
|
export async function runEngineBuild(plan, run, staging) {
|
||||||
|
const { files, before, artifacts } = plan;
|
||||||
|
await fs.mkdir(staging, { recursive: true });
|
||||||
|
for (let i = 0; i < files.length; i++) await fs.writeFile(path.join(staging, path.basename(files[i]) + '.before'), before[i]);
|
||||||
|
let complete = false;
|
||||||
|
try {
|
||||||
|
// Electron reports this version with app.getVersion(), so it goes into the package first.
|
||||||
|
const packageJson = JSON.parse(before[0]);
|
||||||
|
packageJson.version = plan.next;
|
||||||
|
const lock = JSON.parse(before[1]);
|
||||||
|
lock.version = plan.next; lock.packages[''].version = plan.next;
|
||||||
|
await fs.writeFile(files[0], JSON.stringify(packageJson, null, 2) + '\n');
|
||||||
|
await fs.writeFile(files[1], JSON.stringify(lock, null, 2) + '\n');
|
||||||
|
for (const { command, args } of buildCommands(plan)) await run(command, args);
|
||||||
|
const executable = plan.platform === 'win32' ? 'RuneStone-Browser.exe' : 'RuneStone-Browser';
|
||||||
|
if (!(await exists(path.join(plan.dist, executable)))) throw Error('The packaged engine has no engine program: ' + plan.dist);
|
||||||
|
const archive = await zipFolder(plan.dist);
|
||||||
|
await fs.mkdir(plan.releaseDir, { recursive: true });
|
||||||
|
await fs.writeFile(artifacts.archive, archive, { flag: 'wx' });
|
||||||
|
const sha256 = createHash('sha256').update(archive).digest('hex');
|
||||||
|
const metadata = { version: plan.next, protocol: plan.protocol, platform: plan.key, file: plan.file, url: plan.url, bytes: archive.length, sha256 };
|
||||||
|
await fs.writeFile(artifacts.metadata, JSON.stringify(metadata, null, 2) + '\n', { flag: 'wx' });
|
||||||
|
const previous = JSON.parse(before[2]);
|
||||||
|
// The packages of other platforms stay only when they have the same engine version.
|
||||||
|
const platforms = previous.version === plan.next ? { ...previous.platforms } : {};
|
||||||
|
platforms[plan.key] = { url: plan.url, bytes: archive.length, sha256 };
|
||||||
|
await fs.writeFile(files[2], JSON.stringify({ version: plan.next, protocol: plan.protocol, platforms }, null, 2) + '\n');
|
||||||
|
complete = true;
|
||||||
|
return { archive: artifacts.archive, ...metadata };
|
||||||
|
} finally {
|
||||||
|
if (!complete) {
|
||||||
|
for (let i = 0; i < files.length; i++) {
|
||||||
|
if ((await fs.readFile(files[i], 'utf8').catch(() => null)) !== before[i]) await fs.writeFile(files[i], before[i]);
|
||||||
|
}
|
||||||
|
for (const file of Object.values(artifacts)) {
|
||||||
|
if (await exists(file)) await fs.rename(file, path.join(staging, path.basename(file) + '.failed-' + Date.now()));
|
||||||
|
}
|
||||||
|
console.error('The engine build did not complete. The version fields and the pin are restored. Backups: ' + staging);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||||
|
const options = parseArguments(process.argv.slice(2));
|
||||||
|
const plan = await planEngineBuild(root, options);
|
||||||
|
if (options.dryRun) {
|
||||||
|
console.log(describePlan(plan));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (process.platform !== 'win32') throw Error('Build the browser engine on Windows. The other platforms have no published engine yet.');
|
||||||
|
async function run(command, parameters) {
|
||||||
|
console.log(command + ' ' + parameters.join(' '));
|
||||||
|
const code = await new Promise((resolve, reject) => {
|
||||||
|
const child = spawn(command, parameters, { cwd: root, stdio: 'inherit', windowsHide: true });
|
||||||
|
child.on('error', reject); child.on('exit', resolve);
|
||||||
|
});
|
||||||
|
if (code !== 0) throw Error('The engine build command failed with exit code ' + code);
|
||||||
|
}
|
||||||
|
const staging = path.join(root, 'output/browser-engine-build', plan.next, new Date().toISOString().replaceAll(':', '-'));
|
||||||
|
const result = await runEngineBuild(plan, run, staging);
|
||||||
|
console.log(`Engine available: ${result.archive}\n${result.bytes} bytes, SHA-256 ${result.sha256}\nUpload it to ${result.url}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.argv[1] && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))) await main();
|
||||||
@@ -38,9 +38,8 @@ export async function planInstallerBuild(root, requestedVersion) {
|
|||||||
if (windowsConfig?.allowDowngrades !== false) throw Error('Downgrade protection must remain enabled.');
|
if (windowsConfig?.allowDowngrades !== false) throw Error('Downgrade protection must remain enabled.');
|
||||||
const hooks = windowsConfig?.nsis?.installerHooks;
|
const hooks = windowsConfig?.nsis?.installerHooks;
|
||||||
if (!hooks || !(await exists(path.join(root, 'src-tauri', hooks)))) throw Error('The installer hooks file is not configured. See src-tauri/tauri.windows.conf.json.');
|
if (!hooks || !(await exists(path.join(root, 'src-tauri', hooks)))) throw Error('The installer hooks file is not configured. See src-tauri/tauri.windows.conf.json.');
|
||||||
if (!(await exists(path.join(root, 'src-tauri/browser-engine/RuneStone-Browser.exe')))) {
|
// The browser engine is a separate download. See docs/builds.md#build-the-browser-engine.
|
||||||
throw Error('The browser runtime is not staged. Run pnpm browser:stage first. See docs/development.md#built-in-browser-runtime.');
|
if (JSON.stringify(config.bundle?.resources ?? {}).includes('browser-engine')) throw Error('The installer must not bundle the browser engine.');
|
||||||
}
|
|
||||||
const bundleDir = path.join(root, 'src-tauri/target/release/bundle/nsis');
|
const bundleDir = path.join(root, 'src-tauri/target/release/bundle/nsis');
|
||||||
const releaseDir = path.join(root, 'releases', next.version);
|
const releaseDir = path.join(root, 'releases', next.version);
|
||||||
const artifacts = {
|
const artifacts = {
|
||||||
@@ -63,7 +62,9 @@ export async function planInstallerBuild(root, requestedVersion) {
|
|||||||
const override = { version: next.toolchain };
|
const override = { version: next.toolchain };
|
||||||
// vite.config.js gives this version to the front end, so package.json can wait until the build completes.
|
// vite.config.js gives this version to the front end, so package.json can wait until the build completes.
|
||||||
const env = { RUNESTONE_VERSION: next.version };
|
const env = { RUNESTONE_VERSION: next.version };
|
||||||
return { root, files, before, updated, current, next, override, env, releaseDir, artifacts };
|
// The core installer is about 10 MB. A larger file means that something such as the engine got into the bundle.
|
||||||
|
const maxSetupBytes = 30 * 1024 * 1024;
|
||||||
|
return { root, files, before, updated, current, next, override, env, releaseDir, artifacts, maxSetupBytes };
|
||||||
}
|
}
|
||||||
|
|
||||||
// The commands of a build, in order. overridePath is the file with plan.override.
|
// The commands of a build, in order. overridePath is the file with plan.override.
|
||||||
@@ -102,7 +103,8 @@ export async function runInstallerBuild(plan, run, staging) {
|
|||||||
let complete = false;
|
let complete = false;
|
||||||
try {
|
try {
|
||||||
for (const { command, args } of buildCommands(plan, overridePath)) await run(command, args);
|
for (const { command, args } of buildCommands(plan, overridePath)) await run(command, args);
|
||||||
await fs.access(artifacts.bundled);
|
const size = (await fs.stat(artifacts.bundled)).size;
|
||||||
|
if (size > plan.maxSetupBytes) throw Error(`The setup file has ${size} bytes, more than the limit of ${plan.maxSetupBytes}. Make sure that the bundle does not include the browser engine.`);
|
||||||
if (artifacts.bundled !== artifacts.renamed) await fs.rename(artifacts.bundled, artifacts.renamed);
|
if (artifacts.bundled !== artifacts.renamed) await fs.rename(artifacts.bundled, artifacts.renamed);
|
||||||
await fs.mkdir(plan.releaseDir, { recursive: true });
|
await fs.mkdir(plan.releaseDir, { recursive: true });
|
||||||
await fs.copyFile(artifacts.renamed, artifacts.release, fs.constants.COPYFILE_EXCL);
|
await fs.copyFile(artifacts.renamed, artifacts.release, fs.constants.COPYFILE_EXCL);
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
// tauri-build requires every bundle resource to exist. `pnpm browser:stage` fills this
|
|
||||||
// folder for installers. An empty folder lets `cargo test` and `tauri dev` run without it.
|
|
||||||
std::fs::create_dir_all("browser-engine").expect("failed to create browser-engine");
|
|
||||||
tauri_build::try_build(
|
tauri_build::try_build(
|
||||||
tauri_build::Attributes::new().app_manifest(
|
tauri_build::Attributes::new().app_manifest(
|
||||||
tauri_build::AppManifest::new().commands(&[
|
tauri_build::AppManifest::new().commands(&[
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"bundle": {
|
|
||||||
"resources": {
|
|
||||||
"browser-engine/": "browser-engine/"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -49,9 +49,6 @@
|
|||||||
"icons/[email protected]",
|
"icons/[email protected]",
|
||||||
"icons/icon.icns",
|
"icons/icon.icns",
|
||||||
"icons/icon.ico"
|
"icons/icon.ico"
|
||||||
],
|
]
|
||||||
"resources": {
|
|
||||||
"browser-engine/": "browser-engine/"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,4 +228,18 @@ SectionEnd
|
|||||||
WriteRegStr SHCTX "${RUNESTONE_UNINSTKEY}" "RuneStoneWindowsVersion" "$0"
|
WriteRegStr SHCTX "${RUNESTONE_UNINSTKEY}" "RuneStoneWindowsVersion" "$0"
|
||||||
Pop $1
|
Pop $1
|
||||||
Pop $0
|
Pop $0
|
||||||
|
; Releases up to 0.1.48 put the browser engine in the installation folder. Setup does not start
|
||||||
|
; their uninstaller, so this hook removes that folder. The engine is now a separate download.
|
||||||
|
${If} "$INSTDIR" != ""
|
||||||
|
RMDir /r "$INSTDIR\browser-engine"
|
||||||
|
${EndIf}
|
||||||
|
!macroend
|
||||||
|
|
||||||
|
; The downloaded browser engine is a program, not user data. Uninstall removes it, also when the
|
||||||
|
; user keeps the app data. The browser profiles stay in $LOCALAPPDATA\${BUNDLEID}\browser.
|
||||||
|
!macro NSIS_HOOK_POSTUNINSTALL
|
||||||
|
${If} $UpdateMode <> 1
|
||||||
|
SetShellVarContext current
|
||||||
|
RMDir /r "$LOCALAPPDATA\${BUNDLEID}\browser-engine"
|
||||||
|
${EndIf}
|
||||||
!macroend
|
!macroend
|
||||||
|
|||||||
@@ -0,0 +1,127 @@
|
|||||||
|
import test from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { mkdtemp, mkdir, readFile, writeFile, copyFile, rm, access } from 'node:fs/promises';
|
||||||
|
import { tmpdir } from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import zlib from 'node:zlib';
|
||||||
|
import { createHash } from 'node:crypto';
|
||||||
|
import { buildCommands, describePlan, engineFiles, parseArguments, planEngineBuild, platformKey, runEngineBuild, zipFolder } from '../../../scripts/buildBrowserEngine.mjs';
|
||||||
|
|
||||||
|
const repository = path.resolve('.');
|
||||||
|
const exists = (file: string) => access(file).then(() => true, () => false);
|
||||||
|
const releaseUrl = 'https://example.com/releases/download/browser-engine';
|
||||||
|
const windows = { platform: 'win32', arch: 'x64' };
|
||||||
|
|
||||||
|
// A copy of the files that the engine script reads.
|
||||||
|
async function withFixture(body: (root: string, before: string[]) => Promise<void>) {
|
||||||
|
const root = await mkdtemp(path.join(tmpdir(), 'runestone-engine-build-'));
|
||||||
|
try {
|
||||||
|
for (const file of [...engineFiles, 'src-tauri/src/browser_engine.rs', 'browser-runtime/src/engine-main.mjs']) {
|
||||||
|
await mkdir(path.dirname(path.join(root, file)), { recursive: true });
|
||||||
|
await copyFile(path.join(repository, file), path.join(root, file));
|
||||||
|
}
|
||||||
|
await body(root, await Promise.all(engineFiles.map(file => readFile(path.join(root, file), 'utf8'))));
|
||||||
|
} finally { await rm(root, { recursive: true, force: true }); }
|
||||||
|
}
|
||||||
|
const contents = (root: string) => Promise.all(engineFiles.map(file => readFile(path.join(root, file), 'utf8')));
|
||||||
|
|
||||||
|
/** The names and contents of a ZIP, read from its central directory. */
|
||||||
|
function unzip(archive: Buffer) {
|
||||||
|
const end = archive.length - 22;
|
||||||
|
assert.equal(archive.readUInt32LE(end), 0x06054b50);
|
||||||
|
const count = archive.readUInt16LE(end + 10);
|
||||||
|
let at = archive.readUInt32LE(end + 16);
|
||||||
|
const entries: { name: string, data: Buffer, mode: number }[] = [];
|
||||||
|
for (let i = 0; i < count; i++) {
|
||||||
|
assert.equal(archive.readUInt32LE(at), 0x02014b50);
|
||||||
|
const method = archive.readUInt16LE(at + 10), crc = archive.readUInt32LE(at + 16), size = archive.readUInt32LE(at + 20);
|
||||||
|
const nameLength = archive.readUInt16LE(at + 28), mode = archive.readUInt32LE(at + 38) >>> 16, offset = archive.readUInt32LE(at + 42);
|
||||||
|
const name = archive.subarray(at + 46, at + 46 + nameLength).toString('utf8');
|
||||||
|
const start = offset + 30 + archive.readUInt16LE(offset + 26) + archive.readUInt16LE(offset + 28);
|
||||||
|
const body = archive.subarray(start, start + size);
|
||||||
|
const data = method === 8 ? zlib.inflateRawSync(body) : Buffer.from(body);
|
||||||
|
assert.equal(zlib.crc32(data), crc, name);
|
||||||
|
entries.push({ name, data, mode });
|
||||||
|
at += 46 + nameLength;
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
test('the engine script reads its options and maps platform keys', () => {
|
||||||
|
assert.deepEqual(parseArguments(['--release-url', releaseUrl]), { version: undefined, releaseUrl, dryRun: false });
|
||||||
|
assert.deepEqual(parseArguments(['--dry-run', '--version', '0.1.8', '--release-url', releaseUrl]), { version: '0.1.8', releaseUrl, dryRun: true });
|
||||||
|
for (const args of [[], ['--version', '0.1.8'], ['--release-url'], ['--release-url', releaseUrl, '--release-url', releaseUrl], ['--force']]) assert.throws(() => parseArguments(args));
|
||||||
|
assert.equal(platformKey('win32', 'x64'), 'windows-x86_64');
|
||||||
|
assert.equal(platformKey('linux', 'arm64'), 'linux-aarch64');
|
||||||
|
assert.equal(platformKey('darwin', 'arm64'), 'macos-aarch64');
|
||||||
|
assert.throws(() => platformKey('aix', 'x64'));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('planning checks the URL, the protocol, and existing releases, and changes no file', () => withFixture(async (root, before) => {
|
||||||
|
const plan = await planEngineBuild(root, { version: '0.1.8', releaseUrl }, windows);
|
||||||
|
assert.deepEqual(await contents(root), before);
|
||||||
|
assert.equal(plan.file, 'RuneStone-Browser_0.1.8_win32-x64.zip');
|
||||||
|
assert.equal(plan.url, `${releaseUrl}/RuneStone-Browser_0.1.8_win32-x64.zip`);
|
||||||
|
assert.equal(plan.key, 'windows-x86_64');
|
||||||
|
assert.match(describePlan(plan), /Pin https:\/\/example\.com\/.*0\.1\.8_win32-x64\.zip in src-tauri\/browser-engine\.json/);
|
||||||
|
assert.match(buildCommands(plan)[0].args.join(' '), /browser-runtime[\\/]scripts[\\/]package\.mjs --platform=win32 --arch=x64/);
|
||||||
|
for (const url of ['http://example.com/engine', 'https://user:[email protected]/engine', 'https://example.com/engine?token=1']) {
|
||||||
|
await assert.rejects(planEngineBuild(root, { version: '0.1.8', releaseUrl: url }, windows), /HTTPS/);
|
||||||
|
}
|
||||||
|
await assert.rejects(planEngineBuild(root, { version: '0.1', releaseUrl }, windows), /release version/);
|
||||||
|
await mkdir(path.dirname(plan.artifacts.archive), { recursive: true });
|
||||||
|
await writeFile(plan.artifacts.archive, 'old');
|
||||||
|
await assert.rejects(planEngineBuild(root, { version: '0.1.8', releaseUrl }, windows), /already exists/);
|
||||||
|
const main = path.join(root, 'browser-runtime/src/engine-main.mjs');
|
||||||
|
await writeFile(main, (await readFile(main, 'utf8')).replace("event: 'ready', protocol: 1", "event: 'ready', protocol: 2"));
|
||||||
|
await assert.rejects(planEngineBuild(root, { version: '0.1.9', releaseUrl }, windows), /protocol/);
|
||||||
|
}));
|
||||||
|
|
||||||
|
test('the engine ZIP holds the files at its root, in name order, with the same bytes each time', async () => {
|
||||||
|
const folder = await mkdtemp(path.join(tmpdir(), 'runestone-engine-zip-'));
|
||||||
|
try {
|
||||||
|
await mkdir(path.join(folder, 'locales'), { recursive: true });
|
||||||
|
await mkdir(path.join(folder, 'resources'), { recursive: true });
|
||||||
|
await writeFile(path.join(folder, 'RuneStone-Browser.exe'), Buffer.alloc(4096, 7));
|
||||||
|
await writeFile(path.join(folder, 'locales', 'en-US.pak'), 'strings '.repeat(200));
|
||||||
|
await writeFile(path.join(folder, 'resources', 'app.asar'), createHash('sha256').update('random').digest());
|
||||||
|
const first = await zipFolder(folder);
|
||||||
|
assert.deepEqual(first, await zipFolder(folder));
|
||||||
|
const entries = unzip(first);
|
||||||
|
assert.deepEqual(entries.map(entry => entry.name), ['RuneStone-Browser.exe', 'locales/en-US.pak', 'resources/app.asar']);
|
||||||
|
assert.deepEqual(entries[1].data, Buffer.from('strings '.repeat(200)));
|
||||||
|
assert.equal(entries[0].mode & 0o170000, 0o100000, 'Each entry is a regular file.');
|
||||||
|
} finally { await rm(folder, { recursive: true, force: true }); }
|
||||||
|
});
|
||||||
|
|
||||||
|
test('a completed build writes the ZIP, its record, and the pin', () => withFixture(async (root, before) => {
|
||||||
|
const plan = await planEngineBuild(root, { version: '0.1.8', releaseUrl }, windows);
|
||||||
|
const versions: string[] = [];
|
||||||
|
const result = await runEngineBuild(plan, async () => {
|
||||||
|
versions.push(JSON.parse(await readFile(path.join(root, engineFiles[0]), 'utf8')).version);
|
||||||
|
await mkdir(plan.dist, { recursive: true });
|
||||||
|
await writeFile(path.join(plan.dist, 'RuneStone-Browser.exe'), 'engine');
|
||||||
|
}, path.join(root, 'output/attempt'));
|
||||||
|
assert.deepEqual(versions, ['0.1.8'], 'The package step sees the new version.');
|
||||||
|
const archive = await readFile(plan.artifacts.archive);
|
||||||
|
const sha256 = createHash('sha256').update(archive).digest('hex');
|
||||||
|
assert.equal(result.sha256, sha256);
|
||||||
|
assert.deepEqual(JSON.parse(await readFile(plan.artifacts.metadata, 'utf8')), { version: '0.1.8', protocol: plan.protocol, platform: 'windows-x86_64', file: plan.file, url: plan.url, bytes: archive.length, sha256 });
|
||||||
|
assert.deepEqual(JSON.parse(await readFile(path.join(root, engineFiles[2]), 'utf8')), { version: '0.1.8', protocol: plan.protocol, platforms: { 'windows-x86_64': { url: plan.url, bytes: archive.length, sha256 } } });
|
||||||
|
const lock = JSON.parse(await readFile(path.join(root, engineFiles[1]), 'utf8'));
|
||||||
|
assert.equal(lock.version, '0.1.8');
|
||||||
|
assert.equal(lock.packages[''].version, '0.1.8');
|
||||||
|
assert.notDeepEqual(await contents(root), before);
|
||||||
|
}));
|
||||||
|
|
||||||
|
test('a failed build restores the version fields and the pin', () => withFixture(async (root, before) => {
|
||||||
|
const plan = await planEngineBuild(root, { version: '0.1.8', releaseUrl }, windows);
|
||||||
|
const staging = path.join(root, 'output/attempt');
|
||||||
|
await assert.rejects(runEngineBuild(plan, async () => { throw Error('packager failed'); }, staging), /packager failed/);
|
||||||
|
assert.deepEqual(await contents(root), before);
|
||||||
|
assert.equal(await exists(plan.artifacts.archive), false);
|
||||||
|
// The package step completes, but the program is missing.
|
||||||
|
await assert.rejects(runEngineBuild(plan, async () => { await mkdir(plan.dist, { recursive: true }); }, staging), /no engine program/);
|
||||||
|
assert.deepEqual(await contents(root), before);
|
||||||
|
assert.equal(await exists(plan.artifacts.metadata), false);
|
||||||
|
}));
|
||||||
@@ -9,15 +9,13 @@ import { nextHotfix, releaseVersion } from '../../../scripts/releaseVersion.mjs'
|
|||||||
const repository = path.resolve('.');
|
const repository = path.resolve('.');
|
||||||
const exists = (file: string) => access(file).then(() => true, () => false);
|
const exists = (file: string) => access(file).then(() => true, () => false);
|
||||||
|
|
||||||
// A copy of the files that the installer script reads, with a placeholder Browser runtime.
|
// A copy of the files that the installer script reads.
|
||||||
async function fixture() {
|
async function fixture() {
|
||||||
const root = await mkdtemp(path.join(tmpdir(), 'runestone-installer-build-'));
|
const root = await mkdtemp(path.join(tmpdir(), 'runestone-installer-build-'));
|
||||||
for (const file of [...versionFiles, 'src-tauri/tauri.windows.conf.json', 'src-tauri/windows/hooks.nsh']) {
|
for (const file of [...versionFiles, 'src-tauri/tauri.windows.conf.json', 'src-tauri/windows/hooks.nsh']) {
|
||||||
await mkdir(path.dirname(path.join(root, file)), { recursive: true });
|
await mkdir(path.dirname(path.join(root, file)), { recursive: true });
|
||||||
await copyFile(path.join(repository, file), path.join(root, file));
|
await copyFile(path.join(repository, file), path.join(root, file));
|
||||||
}
|
}
|
||||||
await mkdir(path.join(root, 'src-tauri/browser-engine'), { recursive: true });
|
|
||||||
await writeFile(path.join(root, 'src-tauri/browser-engine/RuneStone-Browser.exe'), '');
|
|
||||||
const before = await Promise.all(versionFiles.map(file => readFile(path.join(root, file), 'utf8')));
|
const before = await Promise.all(versionFiles.map(file => readFile(path.join(root, file), 'utf8')));
|
||||||
const current = releaseVersion(JSON.parse(before[0]).version);
|
const current = releaseVersion(JSON.parse(before[0]).version);
|
||||||
return { root, before, current, next: releaseVersion(nextHotfix(current.version)) };
|
return { root, before, current, next: releaseVersion(nextHotfix(current.version)) };
|
||||||
@@ -78,14 +76,22 @@ test('a completed build sets the version fields only after the installer exists'
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
test('a failed build leaves the version fields unchanged', () => withFixture(async ({ root, before, next }) => {
|
test('a failed build leaves the version fields unchanged', () => withFixture(async ({ root, before, next }) => {
|
||||||
for (const failure of ['compile', 'version-resource', 'bundle', 'missing setup file']) {
|
for (const failure of ['compile', 'version-resource', 'bundle', 'missing setup file', 'oversized setup file']) {
|
||||||
const plan = await planInstallerBuild(root, next.version);
|
const plan = await planInstallerBuild(root, next.version);
|
||||||
|
if (failure === 'oversized setup file') plan.maxSetupBytes = 4;
|
||||||
const staging = path.join(root, 'output', failure.replaceAll(' ', '-'));
|
const staging = path.join(root, 'output', failure.replaceAll(' ', '-'));
|
||||||
const steps = buildCommands(plan, path.join(staging, 'tauri.version.json'));
|
const steps = buildCommands(plan, path.join(staging, 'tauri.version.json'));
|
||||||
let index = 0;
|
let index = 0;
|
||||||
await assert.rejects(runInstallerBuild(plan, async () => {
|
const attempt = runInstallerBuild(plan, async () => {
|
||||||
if (steps[index++].step === failure) throw Error('The build command failed with exit code 1');
|
const step = steps[index++].step;
|
||||||
}, staging));
|
if (step === failure) throw Error('The build command failed with exit code 1');
|
||||||
|
// A setup file over the size limit, as with a bundled browser engine.
|
||||||
|
if (step === 'bundle' && failure === 'oversized setup file') {
|
||||||
|
await mkdir(path.dirname(plan.artifacts.bundled), { recursive: true });
|
||||||
|
await writeFile(plan.artifacts.bundled, 'setup');
|
||||||
|
}
|
||||||
|
}, staging);
|
||||||
|
await assert.rejects(attempt, failure === 'oversized setup file' ? /more than the limit/ : Error);
|
||||||
assert.deepEqual(await contents(root), before, 'A failure during ' + failure + ' must restore the version fields.');
|
assert.deepEqual(await contents(root), before, 'A failure during ' + failure + ' must restore the version fields.');
|
||||||
assert.equal(await exists(plan.artifacts.release), false);
|
assert.equal(await exists(plan.artifacts.release), false);
|
||||||
assert.equal(await exists(plan.artifacts.metadata), false);
|
assert.equal(await exists(plan.artifacts.metadata), false);
|
||||||
@@ -115,7 +121,11 @@ test('the plan stops before a build that breaks the release rules', () => withFi
|
|||||||
await writeFile(plan.artifacts.release, 'existing');
|
await writeFile(plan.artifacts.release, 'existing');
|
||||||
await assert.rejects(planInstallerBuild(root, next.version), /already exists/);
|
await assert.rejects(planInstallerBuild(root, next.version), /already exists/);
|
||||||
await rm(plan.releaseDir, { recursive: true });
|
await rm(plan.releaseDir, { recursive: true });
|
||||||
await rm(path.join(root, 'src-tauri/browser-engine'), { recursive: true });
|
// The browser engine is a separate download. The installer must not bundle it.
|
||||||
await assert.rejects(planInstallerBuild(root, next.version), /browser runtime is not staged/);
|
const config = JSON.parse(before[1]);
|
||||||
|
config.bundle.resources = { 'browser-engine/': 'browser-engine/' };
|
||||||
|
await writeFile(tauriConfig, JSON.stringify(config));
|
||||||
|
await assert.rejects(planInstallerBuild(root, next.version), /must not bundle the browser engine/);
|
||||||
|
await writeFile(tauriConfig, before[1]);
|
||||||
assert.deepEqual(await contents(root), before);
|
assert.deepEqual(await contents(root), before);
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import test from 'node:test';
|
import test from 'node:test';
|
||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import { mkdtemp, readFile, writeFile, copyFile, rm } from 'node:fs/promises';
|
import { mkdtemp, mkdir, readFile, writeFile, copyFile, rm } from 'node:fs/promises';
|
||||||
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
||||||
import { createRequire } from 'node:module';
|
import { createRequire } from 'node:module';
|
||||||
import { tmpdir } from 'node:os';
|
import { tmpdir } from 'node:os';
|
||||||
@@ -51,6 +51,10 @@ test('the stock Tauri template still provides what the hooks rely on', { skip: t
|
|||||||
assert.ok(index >= 0, 'The stock template no longer contains: ' + fragment);
|
assert.ok(index >= 0, 'The stock template no longer contains: ' + fragment);
|
||||||
return index;
|
return index;
|
||||||
};
|
};
|
||||||
|
// NSIS_HOOK_POSTUNINSTALL removes the downloaded engine. It needs ${BUNDLEID}, $UpdateMode, and its place after the app data step.
|
||||||
|
const removal = at('RmDir /r "$LOCALAPPDATA\\${BUNDLEID}"');
|
||||||
|
assert.ok(text.indexOf('${AndIf} $UpdateMode <> 1') < removal);
|
||||||
|
assert.ok(removal < at('!insertmacro NSIS_HOOK_POSTUNINSTALL'), 'The uninstall hook must run after the app data step.');
|
||||||
const include = at('!include "{{installer_hooks}}"');
|
const include = at('!include "{{installer_hooks}}"');
|
||||||
assert.ok(include < at('!insertmacro MUI_PAGE_WELCOME'), 'Tauri must include the hooks before the first page.');
|
assert.ok(include < at('!insertmacro MUI_PAGE_WELCOME'), 'Tauri must include the hooks before the first page.');
|
||||||
assert.ok(include < at('\nSection EarlyChecks'), 'Tauri must include the hooks before its first section.');
|
assert.ok(include < at('\nSection EarlyChecks'), 'Tauri must include the hooks before its first section.');
|
||||||
@@ -158,7 +162,7 @@ test('the hooks block downgrades in every installer mode', { skip: nsisSkip }, a
|
|||||||
RequestExecutionLevel user
|
RequestExecutionLevel user
|
||||||
Name "RuneStone hook test"
|
Name "RuneStone hook test"
|
||||||
OutFile "${executable}"
|
OutFile "${executable}"
|
||||||
InstallDir "$TEMP"
|
InstallDir "${path.join(root, 'install')}"
|
||||||
AutoCloseWindow true
|
AutoCloseWindow true
|
||||||
VIProductVersion "${windows}"
|
VIProductVersion "${windows}"
|
||||||
VIAddVersionKey "ProductName" "RuneStone hook test"
|
VIAddVersionKey "ProductName" "RuneStone hook test"
|
||||||
@@ -242,3 +246,64 @@ SectionEnd
|
|||||||
await rm(root, { recursive: true, force: true });
|
await rm(root, { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// NSIS_HOOK_POSTINSTALL removes the engine folder that releases up to 0.1.48 put in the installation folder.
|
||||||
|
// NSIS_HOOK_POSTUNINSTALL removes the downloaded engine, keeps the browser profiles, and keeps everything during an update.
|
||||||
|
test('the hooks remove old and downloaded browser engines but keep the profiles', { skip: nsisSkip }, async () => {
|
||||||
|
const root = await mkdtemp(path.join(tmpdir(), 'runestone-installer-engine-'));
|
||||||
|
const bundle = 'com.runestone.hook-test-' + path.basename(root);
|
||||||
|
const local = path.join(process.env.LOCALAPPDATA!, bundle);
|
||||||
|
const install = path.join(root, 'install');
|
||||||
|
const key = 'Software\\RuneStoneInstallerTest-' + path.basename(root);
|
||||||
|
const program = async (name: string, updateMode: number) => {
|
||||||
|
const executable = path.join(root, name + '.exe'), script = path.join(root, name + '.nsi');
|
||||||
|
const source = `Unicode true
|
||||||
|
SilentInstall silent
|
||||||
|
RequestExecutionLevel user
|
||||||
|
Name "RuneStone engine hook test"
|
||||||
|
OutFile "${executable}"
|
||||||
|
InstallDir "${install}"
|
||||||
|
VIProductVersion "0.1.49.0"
|
||||||
|
VIAddVersionKey "ProductName" "RuneStone engine hook test"
|
||||||
|
VIAddVersionKey "FileVersion" "0.1.49"
|
||||||
|
VIAddVersionKey "ProductVersion" "0.1.49"
|
||||||
|
!define RUNESTONE_UNINSTKEY "${key}"
|
||||||
|
!define BUNDLEID "${bundle}"
|
||||||
|
!include "${hooks}"
|
||||||
|
Var UpdateMode
|
||||||
|
Section Install
|
||||||
|
StrCpy $UpdateMode ${updateMode}
|
||||||
|
!insertmacro NSIS_HOOK_POSTINSTALL
|
||||||
|
!insertmacro NSIS_HOOK_POSTUNINSTALL
|
||||||
|
SectionEnd
|
||||||
|
`;
|
||||||
|
await writeFile(script, source);
|
||||||
|
compile(script, source);
|
||||||
|
return executable;
|
||||||
|
};
|
||||||
|
const seed = async () => {
|
||||||
|
await mkdir(path.join(install, 'browser-engine', 'locales'), { recursive: true });
|
||||||
|
await writeFile(path.join(install, 'browser-engine', 'RuneStone-Browser.exe'), 'old engine');
|
||||||
|
await writeFile(path.join(install, 'runestone.exe'), 'app');
|
||||||
|
await mkdir(path.join(local, 'browser-engine', '0.1.8'), { recursive: true });
|
||||||
|
await writeFile(path.join(local, 'browser-engine', '0.1.8', 'RuneStone-Browser.exe'), 'engine');
|
||||||
|
await mkdir(path.join(local, 'browser'), { recursive: true });
|
||||||
|
await writeFile(path.join(local, 'browser', 'browser.json'), '{}');
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
await seed();
|
||||||
|
assert.equal(spawnSync(await program('remove', 0), ['/S'], { windowsHide: true, timeout: 30000 }).status, 0);
|
||||||
|
assert.equal(existsSync(path.join(install, 'browser-engine')), false, 'Setup removes the old engine folder.');
|
||||||
|
assert.equal(existsSync(path.join(install, 'runestone.exe')), true);
|
||||||
|
assert.equal(existsSync(path.join(local, 'browser-engine')), false, 'Uninstall removes the downloaded engine.');
|
||||||
|
assert.equal(existsSync(path.join(local, 'browser', 'browser.json')), true, 'The profiles stay.');
|
||||||
|
await seed();
|
||||||
|
assert.equal(spawnSync(await program('update', 1), ['/S'], { windowsHide: true, timeout: 30000 }).status, 0);
|
||||||
|
assert.equal(existsSync(path.join(local, 'browser-engine', '0.1.8', 'RuneStone-Browser.exe')), true, 'An update keeps the downloaded engine.');
|
||||||
|
} finally {
|
||||||
|
spawnSync('reg', ['delete', 'HKCU\\' + key, '/f'], { windowsHide: true });
|
||||||
|
assert.equal(local.startsWith(process.env.LOCALAPPDATA!) && path.basename(local).startsWith('com.runestone.hook-test-'), true);
|
||||||
|
await rm(local, { recursive: true, force: true });
|
||||||
|
await rm(root, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user