Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
matthme committed Jan 14, 2025
2 parents 3485885 + db27c2e commit b2cd28c
Show file tree
Hide file tree
Showing 39 changed files with 2,168 additions and 652 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@ jobs:
run: |
echo ${{ github.repository }}
echo "overwriting names for release testing"
curl -f -L --output ./pouch/kando.webhapp /~https://github.com/holochain-apps/kando/releases/download/v0.10.9/kando.webhapp
curl -f -L --output ./pouch/ziptest.webhapp /~https://github.com/holochain-apps/ziptest/releases/download/ziptest-v0.0.9/ziptest.webhapp
node ./scripts/overwrite-with-test-name.js
- name: Retrieve version
run: |
yarn write:configs
echo "Retrieved App version: $(node -p -e "require('./package.json').version")"
echo "APP_VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_OUTPUT
id: version
Expand Down Expand Up @@ -142,7 +141,6 @@ jobs:
gh release upload "v${{ steps.version.outputs.APP_VERSION }}" "latest-linux.yml" --clobber
gh release upload "v${{ steps.version.outputs.APP_VERSION }}" "dist/${{ steps.appId.outputs.APP_ID }}_${{ steps.version.outputs.APP_VERSION }}_amd64.deb" --clobber
# Windows
#---------------------------------------------------------------------------------------
- name: build, sign and upload the app (Windows)
Expand Down
3 changes: 3 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
singleQuote: true
semi: true
printWidth: 100
64 changes: 50 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ This repository let's you easily convert your Holochain app into a standalone, e

**Note:** Support for non-breaking updates to happ coordinator zomes is currently not built into the kangaroo.

**Holochain Version**: Kangaroo Electron currently uses holochain 0.3.3.
# Holochain Versions

Depending on which Holochain minor version you want to use you should use the corresponding branch of this repository.

- Holochain 0.3.x (stable): [main-0.3](/~https://github.com/holochain/kangaroo-electron/tree/main-0.3)
- Holochain 0.4.x: [main](/~https://github.com/holochain/kangaroo-electron/tree/main)

# Instructions

## Setup and Testing Locally

1. Either use this repository as a template (by clicking on the green "Use this template" button) or fork it.
Using it as a template allows you to start with a clean git history and the contributors of this repository won't show up as contributors to your new repository. **Forking has the advantage of being able to relatively easily pull in updates from this parent repository at a later point in time.** If you fork it, it may be smart to work off a different branch than the main branch in your forked repository in order to be able to keep the main branch in sync with this parent repository and selectively merge into your working branch as needed.
Using it as a template allows you to start with a clean git history and the contributors of this repository won't show up as contributors to your new repository. **Forking has the advantage of being able to relatively easily pull in updates from this parent repository at a later point in time.** If you fork it, it may be smart to work off a different branch than the main branch in your forked repository in order to be able to keep the main branch in sync with this parent repository and selectively merge into your working branch as needed.

2. In your local copy of the repository, run

Expand All @@ -23,19 +28,21 @@ yarn setup

3. In the `kangaroo.config.ts` file, replace the `appId` and `productName` fields with names appropriate for your own app.

4. Choose a version number in the `version` field of `kangaroo.config.ts`. And **Read* the section [Versioning](#Versioning) below to understand the implications.
4. Choose a version number in the `version` field of `kangaroo.config.ts`. And **Read** the section [Versioning](#Versioning) below to understand the implications.

4. Paste the `.webhapp` file of your holochain app into the `pouch` folder.
**Note**: The kangaroo expects a 1024x1024 pixel `icon.png` at the root level of your webhapp's UI assets.
5. Paste the `.webhapp` file of your holochain app into the `pouch` folder.
**Note**: The kangaroo expects a 1024x1024 pixel `icon.png` at the root level of your webhapp's UI assets.

6. To test it, run

5. To test it, run
```
yarn dev
```

## Build the Distributable

### Build locally

To build the app locally for your platform, run the build command for your respecive platform:

```
Expand All @@ -47,6 +54,7 @@ yarn build:mac
# or
yarn build:windows
```

### Build on CI for all platforms

The general workflow goes as follows:
Expand All @@ -56,13 +64,15 @@ The general workflow goes as follows:
2. Merge the main branch into the release branch and push it to github to trigger the release workflow.

If you do this for the first time you will need to create the `release` branch first:

```
git checkout -b release
git merge main
git push --set-upstream origin release
```

For subsequent releases after that you can run

```
git checkout release
git merge main
Expand All @@ -74,17 +84,18 @@ git push
By default, the kangaroo is set up to check github releases for semver compatible releases by their tag name whenever the app starts up and will prompt to install and restart if one is available. This can be disabled by setting `autoUpdates` to `false` in `kangaroo.config.ts`.

> [!NOTE]
> Note that once your app is displayed, this setting can only be turned on again for newer releases and users will have to manually install new versions.
> Note that once your app is deployed, this setting can only be turned on again for newer releases and users will have to manually install new versions.
## Versioning

To allow for subsequent incompatible releases of your app (for example due to switching to a new Holochain version or introducing a breaking change in the integrity zomes of your .happ) without having to change the app's name or identifier, the kangaroo is set up such that semver incompatible versions of your app will be able to run fully independently from each other and store their data in dedicated locations on disk.
To allow for subsequent incompatible releases of your app (for example due to switching to a new Holochain version or introducing a breaking change in the integrity zomes of your .happ) without having to change the app's name or identifier, the kangaroo is set up to use semver to support incompatible versions of your app running fully independently from each other and store their data in dedicated locations on disk.

Examples:
* version 0.0.2 and 0.0.3 of your app will store their data in independent locations on disk and version 0.0.3 will not have access to any data created/obtained in version 0.0.2
* version 0.3.4 will reuse the same Holochain conductor and data as version 0.3.2
* versions 0.3.0-alpha and 0.3.0-beta will *not* share data
* versions 0.3.0-alpha.0 and 0.3.0-alpha.1 *will* share data

- version 0.0.2 and 0.0.3 of your app will store their data in independent locations on disk and version 0.0.3 will not have access to any data created/obtained in version 0.0.2
- version 0.3.4 will reuse the same Holochain conductor and data as version 0.3.2
- versions 0.3.0-alpha and 0.3.0-beta will _not_ share data
- versions 0.3.0-alpha.0 and 0.3.0-alpha.1 _will_ share data

> [!NOTE]
> It is your responsibility to make sure that if you mark two versions of your app as semver compatible they actually are compatible (e.g. that you don't try to run a new incompatible version of Holochain on existing databases).
Expand All @@ -97,27 +108,52 @@ To use code signing on macOS for your release in CI you will have to

1. Set the `macOSCodeSigning` field to `true` in `kangaroo.config.ts`
2. Add the following secrets to your github repository with the appropriate values:

- `APPLE_DEV_IDENTITY`
- `APPLE_ID_EMAIL`
- `APPLE_ID_PASSWORD`
- `APPLE_TEAM_ID`


### Windows

If you want to code sign your app with an EV certificate, you can follow [this guide](https://melatonin.dev/blog/how-to-code-sign-windows-installers-with-an-ev-cert-on-github-actions/) to get your EV certificate hosted on Azure Key Vault and then

1. Set the `windowsEVCodeSigning` field to `true` in `kangaroo.config.ts`
2. Add all the necessary secrets to the repository:

- `AZURE_KEY_VAULT_URI`
- `AZURE_CERT_NAME`
- `AZURE_TENANT_ID`
- `AZURE_CLIENT_ID`
- `AZURE_CLIENT_SECRET`


## Permissions on macOS

Access to things like camera and microphone on macOS require special permissions to be set in the .plist file. For this, uncomment the corresponding permissions in `./templates/electron-builder-template.yml` as needed.

## Run your App from the command line

If you want to customize some runtime parameters you can run your app via the terminal and pass additional options:

```
Options:
-V, --version output the version number
-p, --profile <string> Runs Holochain Kangaroo Electron (Test) with a custom profile with its own dedicated data store.
-n, --network-seed <string> If this is the first time running kangaroo with the given profile, this installs the happ with the
provided network seed.
--holochain-path <path> Runs Holochain Kangaroo Electron (Test) with the holochain binary at the provided path. Use with caution
since this may potentially corrupt your databases if the binary you use is not compatible with existing
databases.
--lair-path <path> Runs the Holochain Kangaroo Electron (Test) with the lair binary at the provided path. Use with caution
since this may potentially corrupt your databases if the binary you use is not compatible with existing
databases.
--holochain-rust-log <string> RUST_LOG value to pass to the holochain binary
--holochain-wasm-log <string> WASM_LOG value to pass to the holochain binary
--lair-rust-log <string> RUST_LOG value to pass to the lair keystore binary
-b, --bootstrap-url <url> URL of the bootstrap server to use (not persisted across restarts).
-s, --signaling-url <url> URL of the signaling server to use (not persisted across restarts).
--ice-urls <string> Comma separated string of ICE server URLs to use. Is ignored if an external holochain binary is being used
(not persisted across restarts).
--print-holochain-logs Print holochain logs directly to the terminal (they will be still written to the logfile as well)
-h, --help display help for command
```
19 changes: 11 additions & 8 deletions electron.vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { defineConfig, externalizeDepsPlugin } from "electron-vite";
import { resolve } from "path";
import { defineConfig, externalizeDepsPlugin } from 'electron-vite';
import { resolve } from 'path';

export default defineConfig({
main: {
plugins: [externalizeDepsPlugin({ exclude: ["@holochain/client", "get-port", "nanoid"] })],
plugins: [externalizeDepsPlugin({ exclude: ['@holochain/client', 'get-port', 'nanoid'] })],
},
preload: {
build: {
rollupOptions: {
input: {
happ: resolve(__dirname, "src/preload/happ.ts"),
splashscreen: resolve(__dirname, "src/preload/splashscreen.ts"),
happ: resolve(__dirname, 'src/preload/happ.ts'),
splashscreen: resolve(__dirname, 'src/preload/splashscreen.ts'),
},
},
},
Expand All @@ -19,9 +19,12 @@ export default defineConfig({
build: {
rollupOptions: {
input: {
indexNotFound: resolve(__dirname, "src/renderer/indexNotFound.html"),
indexNotFound2: resolve(__dirname, "src/renderer/indexNotFound2.html"),
splashscreen: resolve(__dirname, "src/renderer/splashscreen.html"),
indexNotFound: resolve(__dirname, 'src/renderer/indexNotFound.html'),
indexNotFound2: resolve(__dirname, 'src/renderer/indexNotFound2.html'),
loading: resolve(__dirname, 'src/renderer/loading.html'),
setupPassword: resolve(__dirname, 'src/renderer/setupPassword.html'),
setupPasswordOptional: resolve(__dirname, 'src/renderer/setupPasswordOptional.html'),
enterPassword: resolve(__dirname, 'src/renderer/enterPassword.html'),
},
},
},
Expand Down
42 changes: 20 additions & 22 deletions kangaroo.config.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
import { defineConfig } from "./src/main/defineConfig";
import { defineConfig } from './src/main/defineConfig';

export default defineConfig({
appId: "org.holochain.kangaroo-electron",
productName: "Holochain Kangaroo Electron",
version: "0.1.1",
appId: 'org.holochain.kangaroo-electron',
productName: 'Holochain Kangaroo Electron',
version: '0.1.0',
macOSCodeSigning: false,
windowsEVCodeSigning: false,
fallbackToIndexHtml: true,
autoUpdates: true,
systray: true,
passwordMode: 'password-optional',
bins: {
holochain: {
version: "0.3.3",
version: '0.4.0',
sha256: {
"x86_64-unknown-linux-gnu":
"889f517e5353287e6656b9516582ae806194eddaae86e2a546afcb8007c6adc1",
"x86_64-pc-windows-msvc.exe":
"d8702733568791e4e42afaa6bb49b9a992fc0874498fe87b818c64d5e9848e6a",
"x86_64-apple-darwin":
"b5444f43056abf545176dcea724afe43790d5531e5d1ecde4425d3ecabbcb24c",
"aarch64-apple-darwin":
"93ddcc2beb19e13dd3789b322bba5dcaa9cefd52cd60f1505a764a090673c993",
'x86_64-unknown-linux-gnu':
'f2e5d5c5c90a0c5eb85641bd8ab207396ddbbc304aaa51982dfde24037a0d0a9',
'x86_64-pc-windows-msvc.exe':
'9b893527d1f4c1e69fa3c9fbd605987065087ca15ebc72bbe598edef9ab5b27a',
'x86_64-apple-darwin': '9d8e4996dd86441ec859faf9fa90c31bdfaddd49d5079bf67492d9c93d17c503',
'aarch64-apple-darwin': '1d206d09ddf90c85b781457514df3c87d8c7e38a6dab4e53f01a8f089acfa3d1',
},
},
lair: {
version: "0.4.5",
version: '0.5.3',
sha256: {
"x86_64-unknown-linux-gnu":
"67b5a8d06575fc14c6295fec05cd2dcd338de76a051ceac6dd7b03e921ee1762",
"x86_64-pc-windows-msvc.exe":
"77cb4e51a9816048520a30293760214483a0a372ab554ad496955167e6009c99",
"x86_64-apple-darwin":
"60c81104bbaa37e69749a7f53b079d06414d07418a1514a3c676503ce2861c4a",
"aarch64-apple-darwin":
"f6e427557271d13ab32bdd8672f0408b8b248117840adc64c858d55a6ae56583",
'x86_64-unknown-linux-gnu':
'96a28b9b37c73ef46d8b5c56b9d799d558fd2fe77b41c577e2bcb37685a46396',
'x86_64-pc-windows-msvc.exe':
'68b6453a19921072aac04dae52a4e94e725e7482005d2f54f907aec680e078de',
'x86_64-apple-darwin': 'a53bfb8e501431870b99243cbac24f6103d67f8be094930f174829bb249f34c4',
'aarch64-apple-darwin': '6b15d977408847ac977c2e060c7aab84a69e6e90c79390098dd40a6b75256e50',
},
},
},
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "org.holochain.kangaroo-electron2",
"name": "org.holochain.kangaroo-electron",
"version": "0.1.0",
"license": "CAL-1.0",
"main": "./out/main/index.js",
Expand All @@ -23,13 +23,14 @@
"dependencies": {
"@electron-toolkit/preload": "^3.0.1",
"@electron-toolkit/utils": "^3.0.0",
"@holochain/client": "0.17.1",
"@holochain/hc-spin-rust-utils": "0.300.1",
"@lightningrodlabs/we-rust-utils": "0.300.2",
"@holochain/client": "0.18.0-rc.1",
"@holochain/hc-spin-rust-utils": "0.400.0",
"@lightningrodlabs/we-rust-utils": "0.400.1",
"@matthme/electron-updater": "6.3.0-alpha.1",
"@msgpack/msgpack": "^2.8.0",
"adm-zip": "0.5.14",
"bufferutil": "4.0.8",
"commander": "12.1.0",
"electron-context-menu": "3.6.1",
"get-port": "7.0.0",
"nanoid": "5.0.4",
Expand All @@ -49,6 +50,7 @@
"electron-vite": "^2.3.0",
"eslint": "^8.0.1",
"eslint-plugin-import": "^2.25.0",
"jimp": "^1.6.0",
"js-yaml": "4.1.0",
"make-dir-cli": "^3.1.0",
"ncp": "^2.0.0",
Expand Down
58 changes: 36 additions & 22 deletions scripts/create-icons.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require("fs");
const path = require("path");
const png2icons = require("png2icons");
const fs = require('fs');
const path = require('path');
const png2icons = require('png2icons');
const jimp = require('jimp');

generateIcons();

function generateIcons() {
const uiDir = path.join("resources", "ui");
async function generateIcons() {
const uiDir = path.join('resources', 'ui');
const buildDir = 'build';

const pngPath = path.join(uiDir, "icon.png");
const icoPath = path.join(uiDir, "icon.ico");
const icnsPath = path.join(uiDir, "icon.icns");
const pngPath = path.join(uiDir, 'icon.png');
const icoPath = path.join(uiDir, 'icon.ico');
const icnsPath = path.join(uiDir, 'icon.icns');


const pngOutPath = path.join(buildDir, "icon.png");
const icoOutPath = path.join(buildDir, "icon.ico");
const icnsOutPath = path.join(buildDir, "icon.icns");
const pngOutPath = path.join(buildDir, 'icon.png');
const icoOutPath = path.join(buildDir, 'icon.ico');
const icnsOutPath = path.join(buildDir, 'icon.icns');

if (!fs.existsSync(pngPath)) {
console.warn("WARNING: No icon.png found in your webhapp's UI assets.");
console.warn("WARNING: No icon.png found. If you're using the systray option, an icon.png (256x256 pixel) is required to be provided at the root level of your webhapp's UI assets.");
return;
}

Expand All @@ -28,20 +28,34 @@ function generateIcons() {
const pngBuffer = fs.readFileSync(pngPath);

if (!fs.existsSync(icoPath)) {
console.log("Generating icon.ico");
const icoIcon = png2icons.createICO(
pngBuffer,
png2icons.BICUBIC2,
0,
false,
true
);
console.log('Generating icon.ico');
const icoIcon = png2icons.createICO(pngBuffer, png2icons.BICUBIC2, 0, false, true);
fs.writeFileSync(icoOutPath, icoIcon);
} else {
fs.cpSync(icoPath, icoOutPath);
}

if (!fs.existsSync(icnsPath)) {
console.log("Generating icon.icns");
console.log('Generating icon.icns');
const icnsIcon = png2icons.createICNS(pngBuffer, png2icons.BILINEAR, 0);
fs.writeFileSync(icnsOutPath, icnsIcon);
} else {
fs.cpSync(icnsPath, icnsOutPath);
}

// Generate the systray icon
console.log('Generating systray icon');
const systrayIcon = await jimp.Jimp.fromBuffer(pngBuffer);
systrayIcon.resize({ w: 64, h: 64});
const iconsDir = path.join('resources', 'icons');
if (!fs.existsSync(iconsDir)) {
fs.mkdirSync(iconsDir);
}
systrayIcon.write(path.join(iconsDir, '32x32@2.png'));

// Generate the icon for OS notifications
console.log('Generating notifications icon');
const icon128x128 = await jimp.Jimp.fromBuffer(pngBuffer);
icon128x128.resize({ w: 128, h: 128});
icon128x128.write(path.join(iconsDir, '128x128.png'));
}
2 changes: 1 addition & 1 deletion scripts/extend-deb-postinst.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ profile ${appId} \\"/opt/${productName}/${appId}\\" flags=(unconfined) {
fi
# SUID chrome-sandbox for Electron 5+
`,
`
);

fs.writeFileSync(posinstPath, postinstScriptModified);
Expand Down
Loading

0 comments on commit b2cd28c

Please sign in to comment.