Skip to content

Commit 1ce6ad6

Browse files
feat: electron desktop app without express server (stackblitz-labs#1136)
* feat: add electron app * refactor: using different approach * chore: update commit hash to 02621e3 * fix: working dev but prod showing not found and lint fix * fix: add icon * fix: resolve server file load issue * fix: eslint and prettier wip * fix: only load server build once * fix: forward request for other ports * fix: use cloudflare {} to avoid crash * fix: no need for appLogger * fix: forward cookie * fix: update script and update preload loading path * chore: minor update for appId * fix: store and load all cookies * refactor: split main/index.ts * refactor: group electron main files into two folders * fix: update electron build configs * fix: update auto update feat * fix: vite-plugin-node-polyfills need to be in dependencies for dmg version to work * ci: trigger build for electron branch * ci: mark draft if it's from branch commit * ci: add icons for windows and linux * fix: update icons for windows * fix: add author in package.json * ci: use softprops/action-gh-release@v2 * fix: use path to join * refactor: refactor path logic for working in both mac and windows * fix: still need vite-plugin-node-polyfills dependencies * fix: update vite-electron.config.ts * ci: sign mac app * refactor: assets folder * ci: notarization * ci: add NODE_OPTIONS * ci: window only nsis dist --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 88901f3 commit 1ce6ad6

29 files changed

+6187
-2854
lines changed

.github/workflows/electron.yml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Electron Build and Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- electron
8+
tags:
9+
- 'v*'
10+
11+
jobs:
12+
build:
13+
runs-on: ${{ matrix.os }}
14+
15+
strategy:
16+
matrix:
17+
os: [macos-latest, ubuntu-latest, windows-latest]
18+
node-version: [18.18.0]
19+
fail-fast: false
20+
21+
steps:
22+
- name: Check out Git repository
23+
uses: actions/checkout@v4
24+
25+
- name: Install Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: ${{ matrix.node-version }}
29+
30+
- name: Install pnpm
31+
uses: pnpm/action-setup@v2
32+
with:
33+
version: 9.14.4
34+
run_install: false
35+
36+
- name: Get pnpm store directory
37+
shell: bash
38+
run: |
39+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
40+
41+
- name: Setup pnpm cache
42+
uses: actions/cache@v3
43+
with:
44+
path: ${{ env.STORE_PATH }}
45+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
46+
restore-keys: |
47+
${{ runner.os }}-pnpm-store-
48+
49+
- name: Install dependencies
50+
run: pnpm install
51+
52+
# Install Linux dependencies
53+
- name: Install Linux dependencies
54+
if: matrix.os == 'ubuntu-latest'
55+
run: |
56+
sudo apt-get update
57+
sudo apt-get install -y rpm
58+
59+
# Build
60+
- name: Build Electron app
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
CSC_LINK: ${{ secrets.CSC_LINK }}
64+
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
65+
APPLE_ID: ${{ secrets.APPLE_ID }}
66+
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
67+
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
68+
NODE_OPTIONS: "--max_old_space_size=4096"
69+
run: |
70+
if [ "$RUNNER_OS" == "Windows" ]; then
71+
pnpm run electron:build:win
72+
elif [ "$RUNNER_OS" == "macOS" ]; then
73+
pnpm run electron:build:mac
74+
else
75+
pnpm run electron:build:linux
76+
fi
77+
shell: bash
78+
79+
# Create Release
80+
- name: Create Release
81+
uses: softprops/action-gh-release@v2
82+
with:
83+
draft: ${{ github.ref_type == 'branch' }}
84+
files: |
85+
dist/*.exe
86+
dist/*.dmg
87+
dist/*.deb
88+
dist/*.AppImage
89+
dist/*.zip
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

app/components/@settings/tabs/debug/DebugTab.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,9 @@ export default function DebugTab() {
13531353
</div>
13541354
<div className="text-xs text-bolt-elements-textSecondary mt-2 flex items-center gap-1.5">
13551355
<div className="i-ph:code w-3.5 h-3.5 text-purple-500" />
1356-
DOM Ready: {systemInfo ? (systemInfo.performance.timing.domReadyTime / 1000).toFixed(2) : '-'}s
1356+
DOM Ready: {systemInfo
1357+
? (systemInfo.performance.timing.domReadyTime / 1000).toFixed(2)
1358+
: '-'}s
13571359
</div>
13581360
</div>
13591361

assets/entitlements.mac.plist

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<!-- Allows Just-In-Time compilation required by V8 JavaScript engine in Electron -->
6+
<key>com.apple.security.cs.allow-jit</key>
7+
<true/>
8+
9+
<!-- This is needed for the V8 JavaScript engine to function properly -->
10+
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
11+
<true/>
12+
13+
<!-- Allows network connections -->
14+
<key>com.apple.security.network.client</key>
15+
<true/>
16+
17+
<!-- Uncomment to allow read and write access to files explicitly selected by the user through system dialogs -->
18+
<!-- <key>com.apple.security.files.user-selected.read-write</key>
19+
<true/> -->
20+
21+
<!-- Uncomment to allow read and write access to the user's Downloads directory -->
22+
<!-- <key>com.apple.security.files.downloads.read-write</key>
23+
<true/> -->
24+
</dict>
25+
</plist>

assets/icons/icon.icns

163 KB
Binary file not shown.

assets/icons/icon.ico

168 KB
Binary file not shown.

assets/icons/icon.png

18.5 KB
Loading

electron-builder.yml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
appId: com.stackblitz.bolt.diy
2+
productName: Bolt Local
3+
directories:
4+
buildResources: build
5+
output: dist
6+
files:
7+
- build/**/*
8+
- package.json
9+
- node_modules/**/*
10+
- icons/**
11+
- electron-update.yml
12+
extraMetadata:
13+
main: build/electron/main/index.mjs
14+
asarUnpack:
15+
- resources/**
16+
- build/client/**/*
17+
- build/server/**/*
18+
- electron-update.yml
19+
20+
mac:
21+
icon: assets/icons/icon.icns
22+
target:
23+
- dmg
24+
identity: "Xinzhe Wang (RDQSC33B2X)"
25+
category: "public.app-category.developer-tools"
26+
type: "distribution"
27+
hardenedRuntime: true
28+
entitlements: "assets/entitlements.mac.plist"
29+
entitlementsInherit: "assets/entitlements.mac.plist"
30+
gatekeeperAssess: false
31+
32+
win:
33+
icon: assets/icons/icon.ico
34+
target:
35+
- nsis
36+
signDlls: false
37+
artifactName: ${name}-${version}-${os}-${arch}.${ext}
38+
39+
linux:
40+
icon: assets/icons/icon.png
41+
target:
42+
- AppImage
43+
- deb
44+
artifactName: ${name}-${version}-${os}-${arch}.${ext}
45+
category: Development
46+
47+
nsis:
48+
oneClick: false
49+
allowToChangeInstallationDirectory: true
50+
createDesktopShortcut: true
51+
createStartMenuShortcut: true
52+
shortcutName: ${productName}
53+
artifactName: ${name}-${version}-${os}-${arch}-setup.${ext}
54+
55+
npmRebuild: false
56+
57+
publish:
58+
provider: github
59+
owner: Derek-X-Wang
60+
repo: bolt.local
61+
private: true
62+
releaseType: release
63+
64+
electronDownload:
65+
mirror: https://npmmirror.com/mirrors/electron/

electron-update.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
owner: stackblitz-labs
2+
repo: bolt.diy
3+
provider: github
4+
private: false

0 commit comments

Comments
 (0)