Sfoglia il codice sorgente

[desktop] Fix desktop build (#1062)

`yarn dev` is still not working, but that is a previous issue unrelated
to the monorepo migration. Will fix that in a subsequent PR.
Manav Rathi 1 anno fa
parent
commit
ca771993ee

+ 5 - 4
desktop/.gitignore

@@ -11,10 +11,11 @@ node_modules/
 .env
 .env
 .env.*.local
 .env.*.local
 
 
-# Generated code during build
-# - tsc transpiles src/**/*.ts and emits the generated JS into build/app
-# - The out dir from the photos web app is symlinked to build/out
-build/
+# tsc transpiles src/**/*.ts and emits the generated JS into app
+app/
+
+# out is a symlink to the photos web app's dir
+out
 
 
 # electron-builder
 # electron-builder
 dist/
 dist/

+ 19 - 15
desktop/README.md

@@ -10,12 +10,6 @@ To know more about Ente, see [our main README](../README.md) or visit
 
 
 ## Building from source
 ## Building from source
 
 
-> [!CAUTION]
->
-> We moved a few things around when switching to a monorepo recently, and the
-> desktop app is not currently building with these instructions below. Hang
-> tight, we're on it, and will fix soon.
-
 Fetch submodules
 Fetch submodules
 
 
 ```sh
 ```sh
@@ -28,22 +22,32 @@ Install dependencies
 yarn install
 yarn install
 ```
 ```
 
 
-Run the app
+Create a binary for your platform
 
 
 ```sh
 ```sh
-yarn dev
+yarn build
 ```
 ```
 
 
-To recompile automatically using electron-reload, run this in a separate
-terminal:
+## Developing
 
 
-```bash
-yarn watch
+Instead of building, you can run the app in development mode
+
+```sh
+yarn dev
 ```
 ```
 
 
-`yarn dev` is handy during development, but if you wish, you can also create a
-binary for your platform by using
+> [!CAUTION]
+>
+> `yarn dev` is currently not working (we'll fix soon). If you just want to
+> build from source and use the generated binary, use `yarn build` as described
+> above.
+
+This'll launch a development server to serve the pages loaded by the renderer
+process, and will hot reload on changes.
+
+If you also want hot reload for the main process, run this in a separate
+terminal:
 
 
 ```sh
 ```sh
-yarn build
+yarn watch
 ```
 ```

+ 0 - 0
desktop/resources/entitlements.mac.plist → desktop/build/entitlements.mac.plist


+ 0 - 0
desktop/resources/error.html → desktop/build/error.html


+ 0 - 0
desktop/resources/ggmlclip-linux → desktop/build/ggmlclip-linux


+ 0 - 0
desktop/resources/ggmlclip-mac → desktop/build/ggmlclip-mac


+ 0 - 0
desktop/resources/ggmlclip-windows.exe → desktop/build/ggmlclip-windows.exe


+ 0 - 0
desktop/resources/icon.icns → desktop/build/icon.icns


+ 0 - 0
desktop/resources/icon.png → desktop/build/icon.png


+ 0 - 0
desktop/resources/image-magick → desktop/build/image-magick


+ 0 - 0
desktop/resources/msvcp140d.dll → desktop/build/msvcp140d.dll


+ 0 - 0
desktop/resources/splash.html → desktop/build/splash.html


+ 0 - 0
desktop/resources/taskbar-icon-Template.png → desktop/build/taskbar-icon-Template.png


+ 0 - 0
desktop/resources/taskbar-icon-Template@2x.png → desktop/build/taskbar-icon-Template@2x.png


+ 0 - 0
desktop/resources/taskbar-icon-Template@3x.png → desktop/build/taskbar-icon-Template@3x.png


+ 0 - 0
desktop/resources/taskbar-icon.png → desktop/build/taskbar-icon.png


+ 0 - 0
desktop/resources/taskbar-icon@2x.png → desktop/build/taskbar-icon@2x.png


+ 0 - 0
desktop/resources/taskbar-icon@3x.png → desktop/build/taskbar-icon@3x.png


+ 0 - 0
desktop/resources/ucrtbased.dll → desktop/build/ucrtbased.dll


+ 0 - 0
desktop/resources/vcruntime140_1d.dll → desktop/build/vcruntime140_1d.dll


+ 0 - 0
desktop/resources/vcruntime140d.dll → desktop/build/vcruntime140d.dll


+ 0 - 0
desktop/resources/version.html → desktop/build/version.html


+ 0 - 0
desktop/resources/window-icon.png → desktop/build/window-icon.png


+ 4 - 0
desktop/docs/dev.md

@@ -0,0 +1,4 @@
+# Development tips
+
+* `yarn build:quick` is a variant of `yarn build` that uses the
+  `--config.compression=store` flag to (slightly) speed up electron-builder.

+ 14 - 18
desktop/package.json

@@ -4,14 +4,16 @@
     "private": true,
     "private": true,
     "description": "Desktop client for Ente Photos",
     "description": "Desktop client for Ente Photos",
     "author": "Ente <code@ente.io>",
     "author": "Ente <code@ente.io>",
-    "main": "build/app/main.js",
+    "main": "app/main.js",
     "scripts": {
     "scripts": {
-        "build": "mkdir -p build && yarn build-renderer && yarn build-main",
-        "build-main": "tsc && electron-builder --config.compression=store",
-        "build-renderer": "cd ../web && yarn install && yarn build:photos && cd ../desktop/build && rm -f out && ln -sf ../../web/apps/photos/out",
+        "build": "yarn build-renderer && yarn build-main",
+        "build-main": "tsc && electron-builder",
+        "build-main:quick": "tsc && electron-builder --config.compression=store",
+        "build-renderer": "cd ../web && yarn install && yarn build:photos && cd ../desktop && rm -f out && ln -sf ../web/apps/photos/out",
+        "build:quick": "yarn build-renderer && yarn build-main:quick",
         "dev": "concurrently \"yarn dev-main\" \"yarn dev-renderer\"",
         "dev": "concurrently \"yarn dev-main\" \"yarn dev-renderer\"",
         "dev-main": "tsc && electron build/app/main.js",
         "dev-main": "tsc && electron build/app/main.js",
-        "dev-renderer": "cd ../web && yarn install && yarn dev:photos && cd ../desktop/build && rm -f out && ln -sf ../../web/apps/photos/out",
+        "dev-renderer": "cd ../web && yarn install && yarn dev:photos",
         "postinstall": "electron-builder install-app-deps",
         "postinstall": "electron-builder install-app-deps",
         "lint": "yarn prettier --check . && eslint \"src/**/*.ts\"",
         "lint": "yarn prettier --check . && eslint \"src/**/*.ts\"",
         "lint-fix": "yarn prettier --write . && eslint --fix .",
         "lint-fix": "yarn prettier --write . && eslint --fix .",
@@ -110,26 +112,20 @@
             "x64ArchFiles": "Contents/Resources/ggmlclip-mac"
             "x64ArchFiles": "Contents/Resources/ggmlclip-mac"
         },
         },
         "afterSign": "electron-builder-notarize",
         "afterSign": "electron-builder-notarize",
-        "extraFiles": [
-            {
-                "from": "resources",
-                "to": "resources",
-                "filter": [
-                    "**/*"
-                ]
-            }
-        ],
         "asarUnpack": [
         "asarUnpack": [
             "node_modules/ffmpeg-static/bin/${os}/${arch}/ffmpeg",
             "node_modules/ffmpeg-static/bin/${os}/${arch}/ffmpeg",
             "node_modules/ffmpeg-static/index.js",
             "node_modules/ffmpeg-static/index.js",
             "node_modules/ffmpeg-static/package.json"
             "node_modules/ffmpeg-static/package.json"
         ],
         ],
-        "files": [
-            "build/app/**/*",
+        "extraFiles": [
             {
             {
-                "from": "build/out",
-                "to": "out"
+                "from": "build",
+                "to": "resources"
             }
             }
+        ],
+        "files": [
+            "app/**/*",
+            "out"
         ]
         ]
     },
     },
     "productName": "ente",
     "productName": "ente",

+ 1 - 1
desktop/src/utils/createWindow.ts

@@ -1,13 +1,13 @@
 import { app, BrowserWindow, nativeImage } from "electron";
 import { app, BrowserWindow, nativeImage } from "electron";
 import ElectronLog from "electron-log";
 import ElectronLog from "electron-log";
 import * as path from "path";
 import * as path from "path";
-import { PROD_HOST_URL } from "../config";
 import { isAppQuitting } from "../main";
 import { isAppQuitting } from "../main";
 import autoLauncher from "../services/autoLauncher";
 import autoLauncher from "../services/autoLauncher";
 import { logErrorSentry } from "../services/sentry";
 import { logErrorSentry } from "../services/sentry";
 import { getHideDockIconPreference } from "../services/userPreference";
 import { getHideDockIconPreference } from "../services/userPreference";
 import { isDev } from "./common";
 import { isDev } from "./common";
 import { isPlatform } from "./common/platform";
 import { isPlatform } from "./common/platform";
+import { PROD_HOST_URL } from "./main";
 
 
 export async function createWindow(): Promise<BrowserWindow> {
 export async function createWindow(): Promise<BrowserWindow> {
     const appImgPath = isDev
     const appImgPath = isDev

+ 5 - 1
desktop/src/utils/main.ts

@@ -14,7 +14,7 @@ import { isPlatform } from "./common/platform";
 import { buildContextMenu, buildMenuBar } from "./menu";
 import { buildContextMenu, buildMenuBar } from "./menu";
 const execAsync = util.promisify(require("child_process").exec);
 const execAsync = util.promisify(require("child_process").exec);
 
 
-const PROD_HOST_URL: string = "ente://app";
+export const PROD_HOST_URL: string = "ente://app";
 const RENDERER_OUTPUT_DIR: string = "./out";
 const RENDERER_OUTPUT_DIR: string = "./out";
 
 
 export async function handleUpdates(mainWindow: BrowserWindow) {
 export async function handleUpdates(mainWindow: BrowserWindow) {
@@ -79,6 +79,10 @@ export async function setupMainMenu(mainWindow: BrowserWindow) {
 }
 }
 
 
 export function setupMainHotReload() {
 export function setupMainHotReload() {
+    // Hot reload the main process if anything changes in the source directory
+    // that we're running from. In particular, this gets triggered when `yarn
+    // watch` rebuilds JS files in the `app/` directory when we change the TS
+    // files in the `src/` directory.
     if (isDev) {
     if (isDev) {
         electronReload(__dirname, {});
         electronReload(__dirname, {});
     }
     }

+ 2 - 2
desktop/tsconfig.json

@@ -3,8 +3,8 @@
         "target": "es2021",
         "target": "es2021",
         "module": "commonjs",
         "module": "commonjs",
         "esModuleInterop": true,
         "esModuleInterop": true,
-        /* Emit the generated JS into build/app */
-        "outDir": "build/app",
+        /* Emit the generated JS into app */
+        "outDir": "app",
         "noImplicitAny": true,
         "noImplicitAny": true,
         "sourceMap": true,
         "sourceMap": true,
         "baseUrl": "src",
         "baseUrl": "src",