diff options
| author | Tobias Järvelöv <tobias.jarvelov@mullvad.net> | 2026-04-23 09:40:33 +0200 |
|---|---|---|
| committer | Tobias Järvelöv <tobias.jarvelov@mullvad.net> | 2026-04-23 09:40:33 +0200 |
| commit | a94a89a6ec526961e90e2fd3fd4e71b9cc80215d (patch) | |
| tree | 08a31f15852e0f929c278b8806e423b68d636522 | |
| parent | 8ccdcafd4ce312f75ffabafc4ae93f8ef5bad736 (diff) | |
| parent | 765cf12e4512de39e1a611b3212dcb2d4ba3a266 (diff) | |
| download | mullvadvpn-a94a89a6ec526961e90e2fd3fd4e71b9cc80215d.tar.xz mullvadvpn-a94a89a6ec526961e90e2fd3fd4e71b9cc80215d.zip | |
Merge branch 'disable-npm-lifecycle-scripts-des-2809'
| -rw-r--r-- | .github/workflows/frontend.yml | 2 | ||||
| -rw-r--r-- | .github/workflows/translations.yml | 2 | ||||
| -rw-r--r-- | BuildInstructions.md | 2 | ||||
| -rwxr-xr-x | build.sh | 2 | ||||
| -rw-r--r-- | desktop/.npmrc | 3 | ||||
| -rw-r--r-- | desktop/package-lock.json | 1 | ||||
| -rw-r--r-- | desktop/package.json | 2 | ||||
| -rwxr-xr-x | desktop/scripts/install-scripts.sh | 57 |
8 files changed, 67 insertions, 4 deletions
diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index c6bd51e2f8..f0d5c23d39 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -32,7 +32,7 @@ jobs: - name: Install dependencies working-directory: desktop shell: bash - run: npm ci + run: npm run ci - name: Check formatting if: matrix.os == 'ubuntu-latest' diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml index ee5eafb27a..0aa99fcdab 100644 --- a/.github/workflows/translations.yml +++ b/.github/workflows/translations.yml @@ -30,7 +30,7 @@ jobs: - name: Install JS dependencies working-directory: desktop shell: bash - run: npm ci + run: npm run ci - name: Verify translations shell: bash diff --git a/BuildInstructions.md b/BuildInstructions.md index 9bf2f2eda9..18eba2977c 100644 --- a/BuildInstructions.md +++ b/BuildInstructions.md @@ -329,7 +329,7 @@ This section is for building the desktop app individually. 1. Install all the JavaScript dependencies by running: ```bash - npm install -w mullvad-vpn + npm run install ``` 1. Start the Electron app in development mode by running: @@ -462,7 +462,7 @@ if [[ "$DAEMON_ONLY" == "false" ]]; then log_header "Installing JavaScript dependencies" pushd desktop - npm ci --no-audit --no-fund + npm run ci pushd packages/mullvad-vpn diff --git a/desktop/.npmrc b/desktop/.npmrc new file mode 100644 index 0000000000..bf735bdb32 --- /dev/null +++ b/desktop/.npmrc @@ -0,0 +1,3 @@ +ignore-scripts=true # disable preinstall/postinstall life cycle hooks +min-release-age=1 # 1 day +allow-git=none diff --git a/desktop/package-lock.json b/desktop/package-lock.json index 2a74d992cb..419a1a21ad 100644 --- a/desktop/package-lock.json +++ b/desktop/package-lock.json @@ -7,6 +7,7 @@ "": { "name": "desktop", "version": "0.0.0", + "hasInstallScript": true, "license": "GPL-3.0-or-later", "workspaces": [ "packages/*" diff --git a/desktop/package.json b/desktop/package.json index 6fdb56cbed..aa78647557 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -13,6 +13,8 @@ "license": "GPL-3.0-or-later", "scripts": { "lint": "eslint --ignore-pattern packages/ . && npm run lint --workspaces --if-present", + "ci": "bash ./scripts/install-scripts.sh ci", + "install": "bash ./scripts/install-scripts.sh install", "lint-fix": "eslint --fix --ignore-pattern packages/ . && npm run lint-fix --workspaces --if-present", "test": "npm run test --workspaces --if-present" }, diff --git a/desktop/scripts/install-scripts.sh b/desktop/scripts/install-scripts.sh new file mode 100755 index 0000000000..b827f55aa3 --- /dev/null +++ b/desktop/scripts/install-scripts.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +set -eu + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +DESKTOP_DIR="$( cd "$SCRIPT_DIR/.." && pwd )" +REPO_DIR="$( cd "$SCRIPT_DIR/../.." && pwd )" + +source "$REPO_DIR/scripts/utils/log" + +function desktop_ci() { + desktop_pre_install + pushd "$DESKTOP_DIR" + npm ci --no-audit --no-fund + popd + desktop_post_install +} + +function desktop_install() { + desktop_pre_install + pushd "$DESKTOP_DIR" + npm install + popd + desktop_post_install +} + + +function desktop_post_install() { + # Setup electron after install + pushd "$DESKTOP_DIR/node_modules/electron" + npm run postinstall + popd + + # Run postinstall in our own packages + pushd "$DESKTOP_DIR" + npm run postinstall --if-present --ws + popd +} + +function desktop_pre_install() { + # Run preinstall in our own packages + pushd "$DESKTOP_DIR" + npm run preinstall --if-present --ws + popd +} + +case ${1-:""} in + ci) + desktop_ci + ;; + install) + desktop_install + ;; + *) + log_error "Invalid argument. Specify 'ci' or 'install' as the first argument." + exit 1 +esac + |
