Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Electron app setup and release workflow #403

Merged
merged 15 commits into from
Nov 27, 2024

Conversation

minai621
Copy link
Contributor

@minai621 minai621 commented Nov 5, 2024

What this PR does / why we need it:

This PR sets up the Electron application build and release workflow. It introduces a GitHub Actions workflow that automates the building and publishing of the Electron app across macOS, Windows, and Linux platforms whenever a new tag matching v* is pushed. This streamlines the release process and ensures that users can access the latest versions of the desktop application directly from GitHub Releases.

Which issue(s) this PR fixes:

Fixes #285

Special notes for your reviewer:

The workflow uses electron-builder for packaging the app.
The package.json in the native directory has been updated with build scripts and configurations for electron-builder.

Does this PR introduce a user-facing change?:

Added automated build and release workflow for the Electron application, enabling users to download pre-built installers for macOS, Windows, and Linux from GitHub Releases.

Additional documentation:

- [Usage]: Users can now download the latest version of the Electron app from the Releases page.
- [Developer Guide]: Developers can trigger a new release by pushing a tag matching `v*`.

Checklist:

  • Added relevant tests or not required
  • Didn't break anything

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new desktop application with a structured build and release process.
    • Added a configuration for TypeScript and ESLint to enhance code quality and consistency.
    • Implemented a GitHub Actions workflow to automate the release process for the desktop application.
    • Added a new script for targeting the desktop component in the project.
  • Bug Fixes

    • Improved error handling during application window creation.
  • Documentation

    • Updated .gitignore to exclude the release/ directory.
  • Chores

    • Added new scripts and workflows for building and publishing the desktop application.
    • Expanded the workspace configuration to include the desktop package.
  • Style

    • Configured Prettier for consistent code formatting across the project.

Copy link
Contributor

coderabbitai bot commented Nov 5, 2024

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce foundational configurations for the @codepair/desktop project, including a new package.json file that outlines project metadata and scripts for building and running the application. Additionally, a TypeScript configuration file (tsconfig.json) and ESLint configuration (eslint.config.mjs) are added to support TypeScript development and code quality. A GitHub Actions workflow (desktop-release.yml) is established to automate the release process, and modifications to .gitignore ensure the release/ directory is excluded from version control.

Changes

Files Change Summary
desktop/package.json New file created specifying project metadata, scripts, and build configurations for the desktop app.
desktop/src/main.ts Updated to initialize an Electron application with error handling and window management.
desktop/tsconfig.json New TypeScript configuration file added with compiler options and settings for the project.
.github/workflows/desktop-release.yml New GitHub Actions workflow for automating the release process of the desktop application.
.gitignore Modified to ignore the release/ directory.
desktop/.prettierrc New Prettier configuration file added for code formatting options.
desktop/eslint.config.mjs New ESLint configuration file added to support TypeScript linting and formatting.
package.json Updated to include a new script for targeting the desktop component.
pnpm-workspace.yaml New entry added for the desktop package in the workspace configuration.
backend/tsconfig.json Minor modification for JSON formatting in the TypeScript configuration.

Assessment against linked issues

Objective Addressed Explanation
Add support for Desktop application using Electron (#285)

Possibly related PRs

  • Update GitHub Actions to trigger when a new version is released #283: This PR updates GitHub Actions to trigger deployments specifically on new version releases, which is relevant to the new package.json file introduced in the main PR that specifies project metadata and scripts for building and releasing the application.
  • Introduce mono repo #361: This PR introduces a mono repo structure and standardizes package management to pnpm, which aligns with the changes in the main PR that also involve the introduction of a package.json file for the @codepair/desktop project, indicating a shift towards a more organized project structure.

Suggested labels

enhancement 🌟

Suggested reviewers

  • devleejb

Poem

In a world where code takes flight,
A desktop app shines bright,
With scripts and builds, it starts to play,
Electron's magic leads the way.
From code to release, all in a hop,
Hooray for changes, let the fun not stop! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@minai621 minai621 self-assigned this Nov 5, 2024
@minai621 minai621 requested a review from devleejb November 5, 2024 06:32
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (3)
native/src/main.ts (2)

18-24: Improve application lifecycle management

The application lifecycle handling could be more robust. Consider adding proper cleanup and error handling.

Here's a suggested improvement:

+let mainWindow: BrowserWindow | null = null;
+
 function createWindow() {
   const win = new BrowserWindow({...});
+  mainWindow = win;
+  
+  win.on('closed', () => {
+    mainWindow = null;
+  });
   // ... rest of createWindow function
 }

-app.whenReady().then(createWindow);
+app.whenReady().then(() => {
+  createWindow();
+  
+  process.on('uncaughtException', (error) => {
+    console.error('Uncaught exception:', error);
+  });
+});

 app.on("window-all-closed", () => {
+  // Perform any cleanup tasks here
   if (process.platform !== "darwin") {
     app.quit();
   }
 });

26-30: Add window state persistence

Consider adding window state management to preserve the window's position and size between sessions.

I recommend using electron-window-state package. Here's how to implement it:

+import * as windowStateKeeper from 'electron-window-state';

 function createWindow() {
+  const windowState = windowStateKeeper({
+    defaultWidth: 800,
+    defaultHeight: 600
+  });
+
   const win = new BrowserWindow({
-    width: 800,
-    height: 600,
+    x: windowState.x,
+    y: windowState.y,
+    width: windowState.width,
+    height: windowState.height,
     // ... rest of options
   });
+
+  windowState.manage(win);
 }
native/package.json (1)

27-62: Enhance build configuration for security and optimization

Several improvements are recommended for the build configuration:

  1. Consider optimizing the included files to reduce package size
  2. Add code signing configuration for macOS distribution
  3. Consider adding auto-update configuration
   "build": {
     "publish": {
       "provider": "github"
     },
     "appId": "com.example.codepair",
     "productName": "codepair",
     "files": [
       "dist/**/*",
-      "node_modules/**/*",
+      "!node_modules/**/{CHANGELOG.md,README.md,README,readme.md,readme}",
+      "!node_modules/**/{test,__tests__,tests,powered-test,example,examples}",
       "package.json",
       "!node_modules/**/*.{ts,map}"
     ],
     "mac": {
-      "target": "dmg"
+      "target": "dmg",
+      "hardenedRuntime": true,
+      "gatekeeperAssess": false,
+      "entitlements": "build/entitlements.mac.plist",
+      "entitlementsInherit": "build/entitlements.mac.plist"
     },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 516394e and 01aa595.

📒 Files selected for processing (4)
  • .github/workflows/app-release.yml (1 hunks)
  • native/package.json (1 hunks)
  • native/src/main.ts (1 hunks)
  • native/tsconfig.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • native/tsconfig.json
🔇 Additional comments (5)
native/src/main.ts (1)

11-15: Verify development and production URLs

Please ensure that:

  1. The development server is configured to run on port 5173
  2. The production URL is correct and accessible
.github/workflows/app-release.yml (3)

1-6: LGTM! Workflow trigger configuration is appropriate.

The workflow name and trigger configuration are well-defined for release automation.


43-53: Verify electron-builder configuration and release artifacts.

The workflow should verify the electron-builder configuration and ensure all platform-specific artifacts are included.

#!/bin/bash
# Description: Verify electron-builder configuration and build scripts
# Expected: Configuration exists with correct build targets

# Check electron-builder configuration
echo "Checking electron-builder configuration:"
rg -A 10 "build|electron-builder" native/package.json

# Check if all platform targets are configured
echo "Checking platform targets:"
rg -A 5 "mac|win|linux" native/electron-builder.*

7-18: Consider using Node.js 20.x for longer-term support.

Node.js 18.x will reach EOL in April 2025. Consider upgrading to Node.js 20.x (LTS) for longer-term support.

-        node-version: [18.x]
+        node-version: [20.x]

Verify the working directory exists.

The workflow assumes the existence of a ./native directory.

✅ Verification successful

The ./native directory exists with proper electron-builder configuration

The directory exists and contains all necessary files including package.json with complete electron-builder configuration for all platforms (Windows, macOS, and Linux). The build configuration is properly set up in the package.json file.

Regarding Node.js version upgrade suggestion:

The package.json doesn't specify Node.js engine requirements, and the project is using modern dependencies including Electron v33 and TypeScript 5.3.3. Since these are compatible with Node.js 20.x, the suggestion to upgrade from Node.js 18.x to 20.x is valid and beneficial for longer-term support.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the native directory and required files
# Expected: Directory exists with package.json and electron-builder configuration

# Check if native directory exists
if ! [ -d "native" ]; then
  echo "Error: native directory not found"
  exit 1
fi

# Check for essential files
echo "Checking for essential files in native directory:"
ls -la native/package.json native/electron-builder.* 2>/dev/null || echo "Warning: Missing essential configuration files"

Length of output: 1337


Script:

#!/bin/bash
# Let's verify if the native directory has the electron-builder configuration in package.json
rg -A 20 '"build":\s*{' native/package.json

# Also check the contents of the native directory to see if electron-builder config exists with different extensions
ls -la native/ | grep -iE 'electron-builder|builder'

# Check package.json for Node.js engine requirements
rg '"engines"' -A 3 native/package.json

Length of output: 230


Script:

#!/bin/bash
# Let's try with simpler patterns to check the configuration
echo "Checking native directory contents:"
ls -la native/

echo -e "\nChecking package.json content:"
cat native/package.json

echo -e "\nChecking for Node.js version requirements:"
rg '"node":' native/package.json

Length of output: 2191

native/package.json (1)

20-26: Review dependency versions for compatibility and security

The dependency versions need attention:

  1. [email protected] is outdated compared to the latest Electron version
  2. Consider using caret ranges for minor version updates
#!/bin/bash
# Check latest versions of key dependencies
pnpm view electron-builder version
pnpm view electron version
   "devDependencies": {
-    "@types/node": "^22.7.6",
+    "@types/node": "^20.0.0",
     "cross-env": "^7.0.3",
     "electron": "^33.0.1",
-    "electron-builder": "^25.1.8",
+    "electron-builder": "^24.0.0",
     "typescript": "^5.3.3"
   },

native/src/main.ts Outdated Show resolved Hide resolved
native/src/main.ts Outdated Show resolved Hide resolved
.github/workflows/app-release.yml Outdated Show resolved Hide resolved
.github/workflows/app-release.yml Outdated Show resolved Hide resolved
native/package.json Outdated Show resolved Hide resolved
native/package.json Outdated Show resolved Hide resolved
@devleejb
Copy link
Member

devleejb commented Nov 5, 2024

Thanks for the PR! It seems to be working well on my device.

I’ll review it soon, though it may take some time since I’m not familiar with Electron.

image

Copy link
Member

@devleejb devleejb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR.

I have a few comments:

  1. How about changing native to desktop?
  2. We need to add native (or desktop) to pnpm-workspace.yaml to use it in the monorepo.
  3. We should support the following common commands in package.json:
    "lint": "pnpm run --parallel lint",
    "lint:check": "pnpm run --parallel lint:check",
    "format": "pnpm run --parallel format",
    "format:check": "pnpm run --parallel format:check"
    
  4. We also need to change README.md and add desktop/README.md.

.github/workflows/app-release.yml Outdated Show resolved Hide resolved
native/package.json Outdated Show resolved Hide resolved
native/package.json Outdated Show resolved Hide resolved
native/package.json Outdated Show resolved Hide resolved
native/src/main.ts Outdated Show resolved Hide resolved
native/src/main.ts Outdated Show resolved Hide resolved
native/src/main.ts Outdated Show resolved Hide resolved
native/src/main.ts Outdated Show resolved Hide resolved
native/package.json Outdated Show resolved Hide resolved
native/package.json Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (2)
desktop/src/main.ts (2)

27-43: Add window state management and crash handling.

The current lifecycle management is basic. Consider adding window state persistence and crash reporting for a better user experience.

+import windowStateKeeper from 'electron-window-state';
+
+let mainWindow: BrowserWindow | null = null;
+
 function createWindow() {
   try {
+    // Load the previous state
+    const mainWindowState = windowStateKeeper({
+      defaultWidth: 1000,
+      defaultHeight: 800
+    });
+
     const win = new BrowserWindow({
       maximizable: true,
+      x: mainWindowState.x,
+      y: mainWindowState.y,
+      width: mainWindowState.width,
+      height: mainWindowState.height,
       webPreferences: {
         nodeIntegration: false,
         contextIsolation: true,
         sandbox: true
       }
     });
+    
+    // Let us register listeners on the window, so we can update the state
+    mainWindowState.manage(win);
+    mainWindow = win;

Also, consider adding crash reporting:

+app.on('render-process-gone', (event, webContents, details) => {
+  console.error('Render process crashed:', details.reason);
+  // Implement your crash reporting logic here
+});
+
+app.on('child-process-gone', (event, details) => {
+  console.error('Child process crashed:', details.type, details.reason);
+  // Implement your crash reporting logic here
+});

32-36: Consider adding graceful shutdown handling.

The current window closing behavior could be enhanced to handle unsaved changes or ongoing operations.

-app.on("window-all-closed", () => {
-  if (process.platform !== "darwin") {
-    app.quit();
-  }
-});
+app.on("window-all-closed", async () => {
+  // Check for unsaved changes or ongoing operations
+  if (mainWindow) {
+    const response = await mainWindow.webContents.executeJavaScript(
+      'window.onbeforeunload && window.onbeforeunload()'
+    );
+    if (response) {
+      // Handle cleanup or show confirmation dialog
+    }
+  }
+  
+  if (process.platform !== "darwin") {
+    app.quit();
+  }
+});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 01aa595 and 0818881.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • .github/workflows/app-release.yml (1 hunks)
  • desktop/.env.development (1 hunks)
  • desktop/.env.production (1 hunks)
  • desktop/package.json (1 hunks)
  • desktop/src/main.ts (1 hunks)
  • desktop/tsconfig.json (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • desktop/.env.development
  • desktop/.env.production
  • desktop/package.json
  • desktop/tsconfig.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/app-release.yml

desktop/src/main.ts Outdated Show resolved Hide resolved
desktop/src/main.ts Outdated Show resolved Hide resolved
desktop/src/main.ts Outdated Show resolved Hide resolved
Copy link
Member

@devleejb devleejb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve left a few comments on this document.
Let’s collaborate on Zoom!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (4)
package.json (1)

Line range hint 1-32: Consider adding release documentation

Since this PR introduces Electron app releases, consider adding relevant documentation fields to package.json.

Add these fields to improve documentation:

 {
   "name": "codepair",
   "version": "0.1.23",
   "description": "Build your own AI-powered collaborative markdown editor in just 5 minutes",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/your-org/codepair.git"
+  },
+  "homepage": "https://github.com/your-org/codepair#readme",
+  "bugs": {
+    "url": "https://github.com/your-org/codepair/issues"
+  },
   ...
desktop/src/main.ts (1)

21-37: Add graceful shutdown and system event handling.

The application should handle system events and perform cleanup during shutdown.

+// Handle system events
+app.on('before-quit', (event) => {
+  // Perform cleanup tasks here
+  console.log('Performing cleanup before quit...');
+});
+
+// Handle system sleep/resume
+app.on('suspend', () => {
+  console.log('System is going to sleep');
+  // Save application state if needed
+});
+
+app.on('resume', () => {
+  console.log('System resumed');
+  // Restore connections if needed
+});
+
 app.on("window-all-closed", () => {
   if (process.platform !== "darwin") {
     app.quit();
   }
 });
.github/workflows/desktop-release.yml (2)

1-4: Consider adding support for pre-releases

The workflow currently only runs on published releases. Consider adding support for pre-releases to enable testing of the release process before official releases.

 on:
   release:
-    types: [published]
+    types: [published, prereleased]

8-16: Add fail-fast strategy to optimize CI runtime

Consider adding a fail-fast strategy to stop all matrix jobs if one fails, saving CI minutes.

 strategy:
+      fail-fast: true
       matrix:
         os: [macos-latest, ubuntu-latest, windows-latest]
         node-version: [18.x]
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4a51f76 and 7f57c38.

⛔ Files ignored due to path filters (2)
  • desktop/build/icon.png is excluded by !**/*.png
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • .github/workflows/desktop-release.yml (1 hunks)
  • .gitignore (1 hunks)
  • backend/tsconfig.json (1 hunks)
  • desktop/.env.development (1 hunks)
  • desktop/.env.production (1 hunks)
  • desktop/.prettierrc (1 hunks)
  • desktop/eslint.config.mjs (1 hunks)
  • desktop/package.json (1 hunks)
  • desktop/src/main.ts (1 hunks)
  • desktop/tsconfig.json (1 hunks)
  • package.json (1 hunks)
  • pnpm-workspace.yaml (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • .gitignore
  • backend/tsconfig.json
  • desktop/.prettierrc
  • desktop/eslint.config.mjs
🚧 Files skipped from review as they are similar to previous changes (4)
  • desktop/.env.development
  • desktop/.env.production
  • desktop/package.json
  • desktop/tsconfig.json
🔇 Additional comments (5)
pnpm-workspace.yaml (2)

4-4: LGTM! Workspace configuration aligns with project structure.

The addition of the "desktop" package to the workspace configuration is appropriate for managing the new Electron application alongside existing frontend and backend packages.


4-4: Verify desktop package setup

Let's ensure the desktop package is properly configured in the workspace.

✅ Verification successful

Let me gather more information about the package.json content to properly verify the desktop package setup.


Desktop package is properly configured and set up

The desktop package is correctly configured with:

  • Essential Electron setup in package.json with proper build configurations for multiple platforms
  • Required dependencies (electron, electron-builder) and scripts for development and production
  • Correct main entry point (dist/main.js) with corresponding TypeScript source (src/main.ts)
  • Proper Electron application code with window management and platform-specific behaviors
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the desktop package setup and configuration

# Check if desktop directory exists and has required files
echo "Checking desktop package structure..."
fd -t f . desktop -x echo "Found: {}"

# Verify package.json exists and contains required Electron configuration
echo -e "\nChecking desktop package.json configuration..."
if [ -f "desktop/package.json" ]; then
    cat desktop/package.json | jq '{
        name: .name,
        main: .main,
        dependencies: (.dependencies | keys),
        devDependencies: (.devDependencies | keys),
        scripts: (.scripts | keys)
    }'
fi

# Check for essential Electron files
echo -e "\nChecking for essential Electron files..."
fd -t f . desktop/src -x echo "Found source file: {}"

Length of output: 874


Script:

#!/bin/bash
# Get the full content of package.json to verify Electron configuration
echo "Desktop package.json content:"
cat desktop/package.json

# Check for Electron-related dependencies in root package.json
echo -e "\nChecking root package.json for Electron dependencies:"
if [ -f "package.json" ]; then
    cat package.json | jq '.dependencies,.devDependencies' | grep -i electron || echo "No Electron dependencies found in root package.json"
fi

# Check main.ts content for Electron imports and setup
echo -e "\nChecking main.ts content:"
cat desktop/src/main.ts

Length of output: 2998

package.json (1)

13-13: LGTM! Verify desktop package setup

The new desktop script follows the established monorepo pattern correctly.

Let's verify the desktop package setup:

✅ Verification successful

Desktop package is properly configured in the monorepo

The verification confirms:

  • Desktop package exists with package.json
  • Electron is correctly added as a devDependency (v33.0.1)
  • Desktop workspace is properly configured in pnpm-workspace.yaml
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify desktop package configuration exists and contains required Electron setup

# Check if desktop package.json exists and contains electron
if fd -t f "package.json" desktop/; then
  cat desktop/package.json | jq -r '.dependencies.electron, .devDependencies.electron'
fi

# Verify desktop workspace is properly configured in pnpm-workspace.yaml
if [ -f "pnpm-workspace.yaml" ]; then
  cat pnpm-workspace.yaml
fi

Length of output: 264

desktop/src/main.ts (1)

12-12: Verify service URL configuration across environments.

Ensure that the DESKTOP_CODEPAIR_URL is properly configured in both development and production environments.

.github/workflows/desktop-release.yml (1)

39-49: 🛠️ Refactor suggestion

Optimize release asset upload configuration

Several improvements can be made to the upload step:

  1. Remove duplicate GITHUB_TOKEN environment variable
  2. Add condition to skip upload on build failure
  3. Verify release patterns match electron-builder output
       - name: Upload Release Assets
         uses: softprops/action-gh-release@v1
+        if: success()
         with:
           files: |
             ./release/**/*.exe
             ./release/**/*.dmg
             ./release/**/*.AppImage
             ./release/**/*.yml
             ./release/latest*.yml
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
✅ Verification successful

Release asset upload patterns match electron-builder configuration

The release patterns in the workflow match the electron-builder configuration:

  • ./release/**/*.exe matches Windows NSIS output
  • ./release/**/*.dmg matches Mac DMG output
  • ./release/**/*.AppImage matches Linux AppImage output
  • ./release/**/*.yml and ./release/latest*.yml match auto-update metadata files

The suggested improvements to remove the duplicate token and add failure condition are valid optimizations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that the release patterns match electron-builder output configuration
cd desktop
if [ -f "electron-builder.yml" ]; then
  echo "Checking electron-builder configuration..."
  cat electron-builder.yml
elif [ -f "package.json" ]; then
  echo "Checking package.json build configuration..."
  jq '.build' package.json
fi

Length of output: 792

desktop/src/main.ts Outdated Show resolved Hide resolved
desktop/src/main.ts Outdated Show resolved Hide resolved
desktop/src/main.ts Outdated Show resolved Hide resolved
.github/workflows/desktop-release.yml Show resolved Hide resolved
.github/workflows/desktop-release.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (1)
.github/workflows/desktop-release.yml (1)

9-12: Enhance matrix configuration with fail-fast and error handling

The matrix strategy could benefit from additional configuration:

     strategy:
+      fail-fast: false
+      max-parallel: 3
       matrix:
         os: [macos-latest, ubuntu-latest, windows-latest]
         node-version: [18.x]
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 05a9ae2 and 1f1ad33.

📒 Files selected for processing (2)
  • .github/workflows/desktop-release.yml (1 hunks)
  • desktop/src/main.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • desktop/src/main.ts
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/desktop-release.yml

40-40: the runner of "softprops/action-gh-release@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (2)
.github/workflows/desktop-release.yml (2)

19-31: Action versions and caching configuration need improvement

The environment setup steps still need the improvements suggested in the previous review.


33-38: 🛠️ Refactor suggestion

Add error handling and timeout to build step

The build step needs improved reliability:

       - name: Build and publish
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: |
+          set -eo pipefail
           pnpm run release
+        timeout-minutes: 30

Likely invalid or redundant comment.

.github/workflows/desktop-release.yml Show resolved Hide resolved
.github/workflows/desktop-release.yml Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1f1ad33 and 9056ff9.

⛔ Files ignored due to path filters (2)
  • desktop/build/icon.png is excluded by !**/*.png
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • .github/workflows/desktop-release.yml (1 hunks)
  • .gitignore (1 hunks)
  • backend/tsconfig.json (1 hunks)
  • desktop/.prettierrc (1 hunks)
  • desktop/eslint.config.mjs (1 hunks)
  • desktop/package.json (1 hunks)
  • desktop/src/main.ts (1 hunks)
  • desktop/tsconfig.json (1 hunks)
  • package.json (1 hunks)
  • pnpm-workspace.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (9)
  • .gitignore
  • backend/tsconfig.json
  • desktop/.prettierrc
  • desktop/eslint.config.mjs
  • desktop/package.json
  • desktop/src/main.ts
  • desktop/tsconfig.json
  • package.json
  • pnpm-workspace.yaml
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/desktop-release.yml

40-40: the runner of "softprops/action-gh-release@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (1)
.github/workflows/desktop-release.yml (1)

14-16: Verify desktop directory existence

The workflow assumes the existence of a ./desktop directory. Add a verification step to ensure the directory exists before proceeding with the build.

✅ Verification successful

Desktop directory exists and is properly configured

The verification confirms that the ./desktop directory exists at the repository root, validating the working directory configuration in the workflow file.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the desktop directory exists in the repository
if ! fd -t d "^desktop$" --max-depth 1; then
  echo "Warning: desktop directory not found at repository root"
fi

Length of output: 44

.github/workflows/desktop-release.yml Show resolved Hide resolved
.github/workflows/desktop-release.yml Show resolved Hide resolved
Copy link
Member

@devleejb devleejb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After merging this PR, we need to complete the following tasks:

  • Set up build tools (e.g., Webpack, Vite)
  • Configure CI
  • Update README.md

I’ll create the corresponding issues after the merge.

desktop/package.json Outdated Show resolved Hide resolved
desktop/package.json Outdated Show resolved Hide resolved
backend/tsconfig.json Outdated Show resolved Hide resolved
Copy link
Member

@devleejb devleejb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution.

@devleejb devleejb merged commit 373d154 into yorkie-team:main Nov 27, 2024
1 check passed
devleejb pushed a commit that referenced this pull request Nov 27, 2024
* Add Electron app setup and release workflow

* Improve error handling in Electron window creation

* Update package.json to set module type and adjust versioning

* remove property httpHeaders in loadURL

* Add environment configuration for development and production URLs

* Rename native directory to desktop and update related configurations

* Refactor configuration files for improved clarity and organization

* Add desktop configuration and update environment variables

* Fix setup default value for serviceUrl

* Remove development and production environment variable files for desktop configuration

* Add Improve error handling in main application window creation

* Fix pnpm install command to use frozen lockfile

* Update pnpm-lock.yaml

* Update version to 0.1.25 in desktop package.json

* Refactor clean up tsconfig.json formatting
@coderabbitai coderabbitai bot mentioned this pull request Dec 15, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add support for Desktop application using Electron
2 participants