π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Check web deps before desktop renderer commands
Manav Rathia25a50c82ecb
diff --git a/desktop/README.md b/desktop/README.mdindex 056dfa4075..84c612ae7e 100644--- a/desktop/README.md+++ b/desktop/README.md@@ -8,16 +8,22 @@ To know more about Ente, see [our main README](../README.md) or visit [ente.com]## Building from source-Clone this repository and change to this directory+Clone this repository```shgit clone https://github.com/ente-io/ente-cd ente/desktop+cd ente```-Install dependencies:+Install the web dependencies+```sh+cd web+npm ci+```+Install the desktop dependencies```sh+cd ../desktopnpm ci```diff --git a/desktop/docs/README.md b/desktop/docs/README.mdindex f2dc659127..e25676cd08 100644--- a/desktop/docs/README.md+++ b/desktop/docs/README.md@@ -1,9 +1,10 @@# Developer docs-If you just want to run the Ente Photos desktop app locally or develop it, you can do:+If you just want to run the Ente Photos desktop app locally or develop it, from the repository root you can do:```sh-npm ci+cd web && npm ci && cd ..+cd desktop && npm cinpm run dev```diff --git a/desktop/docs/dev.md b/desktop/docs/dev.mdindex e8fe4760c7..a34a81cb65 100644--- a/desktop/docs/dev.md+++ b/desktop/docs/dev.md@@ -6,6 +6,15 @@Use `npm ci` when installing dependencies since it uses the lockfile. Use plain `npm install` only when you are intentionally updating dependencies and reviewing the resulting `package-lock.json` changes.+The desktop app embeds the Photos web app, so local development also requires installing dependencies in `../web`:++```sh+cd ../web+npm ci+cd ../desktop+npm ci+```+### npm run devLaunch the app in development mode:@@ -14,6 +23,8 @@ Launch the app in development mode:- Runs a development server for the renderer, with hot module reload.+The renderer scripts check that `../web` dependencies have been installed. If they are missing or stale, run `cd ../web && npm ci`.+### npm run buildBuild a binary for your current platform.diff --git a/desktop/package.json b/desktop/package.jsonindex 9554bf7428..a1bac7a277 100644--- a/desktop/package.json+++ b/desktop/package.json@@ -10,12 +10,14 @@"build": "npm run build-renderer && npm run build-main","build-main": "tsc && electron-builder","build-main:quick": "tsc && electron-builder --dir --config.compression=store --config.mac.identity=null",- "build-renderer": "cross-env-shell _ENTE_IS_DESKTOP=1 \"cd ../web && npm ci && npm run build:photos && cd ../desktop && shx rm -rf out && shx cp -r ../web/apps/photos/out out\"",- "build:ci": "npm run build-renderer && tsc",+ "build-renderer": "npm run check-web-deps && cross-env-shell _ENTE_IS_DESKTOP=1 \"cd ../web && npm run build:photos && cd ../desktop && shx rm -rf out && shx cp -r ../web/apps/photos/out out\"",+ "build-renderer:ci": "cross-env-shell _ENTE_IS_DESKTOP=1 \"cd ../web && npm ci && npm run build:photos && cd ../desktop && shx rm -rf out && shx cp -r ../web/apps/photos/out out\"",+ "build:ci": "npm run build-renderer:ci && tsc","build:quick": "npm run build-renderer && npm run build-main:quick",+ "check-web-deps": "node ../web/scripts/check-deps.mjs","dev": "concurrently --kill-others --success first --names 'main,rndr' \"npm run dev-main\" \"npm run dev-renderer\"","dev-main": "tsc && electron .",- "dev-renderer": "cross-env-shell _ENTE_IS_DESKTOP=1 \"cd ../web && npm ci && npm exec --workspace photos -- next dev -p 3008\"",+ "dev-renderer": "npm run check-web-deps && cross-env-shell _ENTE_IS_DESKTOP=1 \"cd ../web && npm exec --workspace photos -- next dev -p 3008\"","postinstall": "electron-builder install-app-deps","lint": "prettier --check --log-level warn . && eslint && tsc","lint:fix": "prettier --write --log-level warn . && eslint && tsc",diff --git a/rust/apps/ensu/scripts/tauri-build-web.mjs b/rust/apps/ensu/scripts/tauri-build-web.mjsindex 62c191572c..2b168451a5 100644--- a/rust/apps/ensu/scripts/tauri-build-web.mjs+++ b/rust/apps/ensu/scripts/tauri-build-web.mjs@@ -1,4 +1,4 @@-import { spawn } from "node:child_process";+import { spawn, spawnSync } from "node:child_process";import fs from "node:fs";import path from "node:path";import { fileURLToPath } from "node:url";@@ -8,6 +8,7 @@ const __dirname = path.dirname(__filename);const rootDir = path.resolve(__dirname, "..");const webDir = path.resolve(rootDir, "..", "..", "..", "web");+const checkWebDepsPath = path.join(webDir, "scripts", "check-deps.mjs");const tauriConfigPath = path.join(rootDir, "src-tauri", "tauri.conf.json");const desktopVersion = JSON.parse(fs.readFileSync(tauriConfigPath, "utf8"),@@ -15,6 +16,10 @@ const desktopVersion = JSON.parse(if (!desktopVersion) throw new Error("Missing Ensu desktop version");const npmBin = process.platform === "win32" ? "npm.cmd" : "npm";+const check = spawnSync(process.execPath, [checkWebDepsPath], {+ stdio: "inherit",+});+if (check.status !== 0) process.exit(check.status ?? 1);const child = spawn(npmBin, ["run", "build:ensu"], {cwd: webDir,diff --git a/rust/apps/ensu/scripts/tauri-dev.mjs b/rust/apps/ensu/scripts/tauri-dev.mjsindex c550b3230c..69aa8d168c 100644--- a/rust/apps/ensu/scripts/tauri-dev.mjs+++ b/rust/apps/ensu/scripts/tauri-dev.mjs@@ -18,8 +18,7 @@ const desktopVersion = config.version;if (!desktopVersion) throw new Error("Missing Ensu desktop version");config.build = config.build || {};-config.build.beforeDevCommand =- `cd ../../../web && npm run build:wasm && NEXT_PUBLIC_ENSU_DESKTOP_VERSION=${desktopVersion} npm exec --workspace ensu -- next dev -p ${port}`;+config.build.beforeDevCommand = `node ../../../web/scripts/check-deps.mjs && cd ../../../web && npm run build:wasm && NEXT_PUBLIC_ENSU_DESKTOP_VERSION=${desktopVersion} npm exec --workspace ensu -- next dev -p ${port}`;config.build.devUrl = `http://localhost:${port}`;await fs.writeFile(devConfigPath, JSON.stringify(config, null, 2));diff --git a/rust/apps/ensu/src-tauri/tauri.conf.json b/rust/apps/ensu/src-tauri/tauri.conf.jsonindex e30abcf543..e7c3f1fafd 100644--- a/rust/apps/ensu/src-tauri/tauri.conf.json+++ b/rust/apps/ensu/src-tauri/tauri.conf.json@@ -5,7 +5,7 @@"identifier": "io.ente.ensu","mainBinaryName": "Ensu","build": {- "beforeDevCommand": "cd ../../../web && npm run build:wasm && npm exec --workspace ensu -- next dev -p 3010",+ "beforeDevCommand": "node ../../../web/scripts/check-deps.mjs && cd ../../../web && npm run build:wasm && npm exec --workspace ensu -- next dev -p 3010","beforeBuildCommand": "node scripts/tauri-build-web.mjs","devUrl": "http://localhost:3010","frontendDist": "../../../../web/apps/ensu/out"diff --git a/web/scripts/check-deps.mjs b/web/scripts/check-deps.mjsnew file mode 100644index 0000000000..d371cf2618--- /dev/null+++ b/web/scripts/check-deps.mjs@@ -0,0 +1,17 @@+import { existsSync, statSync } from "node:fs";++const lock = new URL("../package-lock.json", import.meta.url);+const installed = new URL(+ "../node_modules/.package-lock.json",+ import.meta.url,+);++if (+ !existsSync(installed) ||+ statSync(installed).mtimeMs < statSync(lock).mtimeMs+) {+ console.error("Error: web dependencies are missing or stale.");+ console.error("Run:");+ console.error(" cd web && npm ci");+ process.exit(1);+}