Skip to content

Commit

Permalink
feat: support electron applcation
Browse files Browse the repository at this point in the history
  • Loading branch information
minai621 committed Oct 17, 2024
1 parent bc5c353 commit 0262bd5
Show file tree
Hide file tree
Showing 7 changed files with 8,342 additions and 8,224 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/electron-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: electron-build
on: push
jobs:
release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
node-version: [18.x]

steps:
- name: Check out Git repository
uses: actions/checkout@v4

- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"

- name: Build/release Electron app
uses: samuelmeuli/action-electron-builder@v1
with:
package_root: native
build_script_name: build:app
# GitHub token, automatically provided to the action
# (No need to define this secret in the repo settings)
github_token: ${{ secrets.github_token }}

# If the commit is tagged with a version (e.g. "v1.0.0"),
# release the app after building
release: ${{ startsWith(github.ref, 'refs/tags/v') }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ dist-ssr/
# Tests
coverage/
.nyc_output/

# native
native/frontend
native/release
43 changes: 43 additions & 0 deletions native/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "@codepair/native",
"version": "1.0.0",
"main": "dist/main.js",
"description": "Codepair Native",
"author": "yorkie-team",
"license": "Apache-2.0",
"scripts": {
"build": "tsc src/main.ts --outDir dist",
"start": "pnpm run build && cross-env NODE_ENV=production pnpx electron dist/main.js",
"start:dev": "pnpm run start:codepair:dev && pnpm run build && cross-env NODE_ENV=development bunx electron dist/main.js",
"start:codepair:dev": "cd ../frontend && bun run dev & ",
"build:app": "pnpm run build && electron-builder"
},
"devDependencies": {
"@types/node": "^22.7.6",
"cross-env": "^7.0.3",
"electron": "^33.0.1",
"electron-builder": "^25.1.8",
"typescript": "^5.3.3"
},
"build": {
"appId": "com.example.codepair",
"productName": "codepair",
"files": [
"dist/**/*",
"node_modules/**/*",
"package.json"
],
"directories": {
"output": "release"
},
"mac": {
"target": "dmg"
},
"win": {
"target": "nsis"
},
"linux": {
"target": "AppImage"
}
}
}
30 changes: 30 additions & 0 deletions native/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { app, BrowserWindow } from "electron";

function createWindow() {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
},
});
if (process.env.NODE_ENV === "development") {
win.loadURL("http://localhost:5173");
} else {
win.loadURL("https://codepair.yorkie.dev");
}
}

app.whenReady().then(createWindow);

app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});

app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
18 changes: 18 additions & 0 deletions native/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"outDir": "dist",
"esModuleInterop": true,
"skipLibCheck": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],

/* Bundler mode */
"moduleResolution": "bundler",

/* Linting */
"strict": true
},
"include": ["src"],
"exclude": ["dist"]
}
Loading

0 comments on commit 0262bd5

Please sign in to comment.