Various build and developer fixes, some optimizations (#2975)

* Various build and developer fixes, some optimizations

* Fix the linux build

* Fix afterpack

* Fix notarization variables

* Revert macos-notification-state changes from this PR

* Only build the tar for PRs

* Also ci

* Fix copy script

* Fix copy script more

* Remove @babel/cli

* Fix windows build

* Fix MAS build
This commit is contained in:
Devin Binnie 2024-03-12 10:04:11 -04:00 committed by GitHub
parent e5efa727fe
commit e56b5cdd6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 921 additions and 3761 deletions

View file

@ -17,11 +17,11 @@ runs:
- name: ci/run-i18n-check
shell: ${{ inputs.shell }}
run: |
npm run mmjstool -- i18n extract-desktop --desktop-dir .
npm run i18n-extract -- --desktop-dir .
git --no-pager diff --exit-code i18n/en.json
- name: ci/run-unit-ci
shell: ${{ inputs.shell }}
env:
ELECTRON_DISABLE_SANDBOX: "1"
run: |
npm run test:unit-ci
npm run test:unit

View file

@ -38,7 +38,7 @@ jobs:
- name: ci/build
run: |
mkdir -p ./build/linux
npm run package:linux
npm run package:linux-tar
bash -x ./scripts/patch_updater_yml.sh
bash -x ./scripts/cp_artifacts.sh release ./build/linux
- name: ci/upload-build
@ -158,8 +158,8 @@ jobs:
npm ci
- name: ci/build
env:
APPLEID: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_APPLE_ID }}
APPLEIDPASS: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_APPLE_ID_PASS }}
APPLE_ID: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_APPLE_ID_PASS }}
CSC_FOR_PULL_REQUEST: true
CSC_KEY_PASSWORD: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_CSC_KEY_PASSWORD }}
CSC_LINK: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_CSC_LINK }}

View file

@ -34,7 +34,7 @@ jobs:
- name: ci/build
run: |
mkdir -p ./build/linux
npm run package:linux
npm run package:linux-tar
bash -x ./scripts/patch_updater_yml.sh
bash -x ./scripts/cp_artifacts.sh release ./build/linux
- name: ci/upload-test-results

View file

@ -111,6 +111,7 @@ jobs:
mac-app-store-preflight:
runs-on: macos-12
env:
MAC_PROFILE: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_DMG_PROFILE }}
MAS_PROFILE: ${{ secrets.MM_DESKTOP_MAC_APP_STORE_MAS_PROFILE }}
MACOS_API_KEY_ID: ${{ secrets.MM_DESKTOP_MAC_APP_STORE_MACOS_API_KEY_ID }}
MACOS_API_KEY: ${{ secrets.MM_DESKTOP_MAC_APP_STORE_MACOS_API_KEY }}
@ -134,7 +135,9 @@ jobs:
brew install yq
npm ci
- name: nightly/copy-provisioning-profile
run: echo $MAS_PROFILE | base64 -D > ./mas.provisionprofile
run: |
echo $MAC_PROFILE | base64 -D > ./mac.provisionprofile
echo $MAS_PROFILE | base64 -D > ./mas.provisionprofile
- name: nightly/patch-version-number-for-MAS
run: ./scripts/patch_mas_version.sh
- name: nightly/test
@ -167,8 +170,8 @@ jobs:
uses: ./.github/actions/test
- name: nightly/build
env:
APPLEID: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_APPLE_ID }}
APPLEIDPASS: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_APPLE_ID_PASS }}
APPLE_ID: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_APPLE_ID_PASS }}
CSC_FOR_PULL_REQUEST: true
CSC_KEY_PASSWORD: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_CSC_KEY_PASSWORD }}
CSC_LINK: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_CSC_LINK }}

View file

@ -97,8 +97,8 @@ jobs:
uses: ./.github/actions/test
- name: nightly/build
env:
APPLEID: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_APPLE_ID }}
APPLEIDPASS: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_APPLE_ID_PASS }}
APPLE_ID: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_APPLE_ID_PASS }}
CSC_FOR_PULL_REQUEST: true
CSC_KEY_PASSWORD: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_CSC_KEY_PASSWORD }}
CSC_LINK: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_CSC_LINK }}

View file

@ -17,6 +17,7 @@ jobs:
mac-app-store-preflight:
runs-on: macos-12
env:
MAC_PROFILE: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_DMG_PROFILE }}
MAS_PROFILE: ${{ secrets.MM_DESKTOP_MAC_APP_STORE_MAS_PROFILE }}
MACOS_API_KEY_ID: ${{ secrets.MM_DESKTOP_MAC_APP_STORE_MACOS_API_KEY_ID }}
MACOS_API_KEY: ${{ secrets.MM_DESKTOP_MAC_APP_STORE_MACOS_API_KEY }}
@ -38,7 +39,9 @@ jobs:
brew install yq
npm ci
- name: release/copy-provisioning-profile
run: echo $MAS_PROFILE | base64 -D > ./mas.provisionprofile
run: |
echo $MAC_PROFILE | base64 -D > ./mac.provisionprofile
echo $MAS_PROFILE | base64 -D > ./mas.provisionprofile
- name: release/patch-version-number-for-MAS
run: ./scripts/patch_mas_version.sh
- name: release/test

View file

@ -139,8 +139,8 @@ jobs:
uses: ./.github/actions/test
- name: release/build
env:
APPLEID: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_APPLE_ID }}
APPLEIDPASS: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_APPLE_ID_PASS }}
APPLE_ID: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_APPLE_ID_PASS }}
CSC_FOR_PULL_REQUEST: true
CSC_KEY_PASSWORD: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_CSC_KEY_PASSWORD }}
CSC_LINK: ${{ secrets.MM_DESKTOP_MAC_INSTALLER_CSC_LINK }}

View file

@ -2637,26 +2637,6 @@ OTHER DEALINGS IN THE SOFTWARE.
---
## node-jq
This product contains 'node-jq' by sanack.
node-jq is a Node.js wrapper for jq - a lightweight and flexible command-line JSON processor.
* HOMEPAGE:
* https://github.com/sanack/node-jq
* LICENSE: The MIT License (MIT)
Copyright (c) David Sancho dsnxmoreno@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---
## node-loader
This product contains 'node-loader' by webpack-contrib.

View file

@ -15,8 +15,11 @@
"main": "index.js"
},
"files": [
"node_modules/bootstrap/dist/**",
"node_modules/font-awesome/{css,fonts}/**",
"!node_modules/**/*",
"node_modules/bindings/**/*",
"node_modules/file-uri-to-path/**/*",
"node_modules/macos-notification-state/**/*",
"node_modules/windows-focus-assist/**/*",
"!**/node_modules/macos-notification-state/bin/**/*",
"!**/node_modules/macos-notification-state/build/**/*",
"!**/node_modules/windows-focus-assist/bin/**/*",
@ -38,7 +41,6 @@
}
],
"afterPack": "scripts/afterpack.js",
"afterSign": "scripts/notarize.js",
"afterAllArtifactBuild": "scripts/afterbuild.js",
"deb": {
"artifactName": "${version}/${name}_${version}-1_${arch}.${ext}",
@ -99,21 +101,24 @@
],
"hardenedRuntime": true,
"gatekeeperAssess": true,
"entitlements": "./entitlements.mac.plist",
"entitlementsInherit": "./entitlements.mac.inherit.plist",
"entitlements": "./resources/mac/entitlements.mac.plist",
"entitlementsInherit": "./resources/mac/entitlements.mac.inherit.plist",
"extendInfo": {
"NSMicrophoneUsageDescription": "Microphone access may be used by Mattermost plugins, such as Jitsi video conferencing.",
"NSCameraUsageDescription": "Camera access may be used by Mattermost plugins, such as Jitsi video conferencing.",
"NSFocusStatusUsageDescription": "Focus status is used by Mattermost to determine whether to send notifications or not.",
"LSFileQuarantineEnabled": true
},
"notarize": {
"teamId": "UQ8HT4Q2XM"
},
"provisioningProfile": "./mac.provisionprofile"
},
"mas": {
"hardenedRuntime": false,
"entitlements": "./entitlements.mas.plist",
"entitlementsInherit": "./entitlements.mas.inherit.plist",
"entitlementsLoginHelper": "./entitlements.mas.inherit.plist",
"entitlements": "./resources/mac/entitlements.mas.plist",
"entitlementsInherit": "./resources/mac/entitlements.mas.inherit.plist",
"entitlementsLoginHelper": "./resources/mac/entitlements.mas.inherit.plist",
"provisioningProfile": "./mas.provisionprofile",
"extendInfo": {
"ITSAppUsesNonExemptEncryption": false

4085
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -9,7 +9,7 @@
"desktopName": "Mattermost.Desktop",
"homepage": "https://mattermost.com",
"engines": {
"node": ">=16.16.0"
"node": ">=18.0.0"
},
"repository": {
"type": "git",
@ -24,59 +24,54 @@
"build_from_source": true
},
"scripts": {
"build": "npm-run-all build:*",
"build:main": "webpack-cli --config webpack.config.main.js",
"build:renderer": "webpack-cli --config webpack.config.renderer.js",
"build-prod": "cross-env NODE_ENV=production npm-run-all check-build-config build",
"build-prod-upgrade": "cross-env NODE_ENV=production CAN_UPGRADE=true npm-run-all check-build-config build",
"build-robotjs": "cross-env CL='/std:c++17' electron-rebuild -m ./node_modules/robotjs",
"start": "electron dist/ --disable-dev-mode",
"restart": "npm run build && npm run start",
"storybook": "start-storybook -p 9001 -c src/.storybook",
"clean": "rm -rf release/ node_modules/ src/node_modules/ dist/ && find src -name '*_bundle.js' | xargs rm",
"postinstall": "patch-package && electron-builder install-app-deps",
"clean": "rm -rf release/ node_modules/ src/node_modules/ dist/",
"clean-install": "npm run clean && npm install",
"clean-dist": "rm -rf dist/",
"watch": "run-p watch:*",
"watch:main": "node scripts/watch_main_and_preload.js",
"watch:renderer": "webpack-dev-server --config webpack.config.renderer.js",
"test": "npm-run-all lint:js test:unit test:e2e",
"test:docker": "node scripts/setup_e2e_docker.js",
"test:e2e": "cross-env NODE_ENV=test npm-run-all build build-robotjs test:e2e:build test:e2e:run",
"test:e2e:performance": "cross-env NODE_ENV=test PERFORMANCE=true npm-run-all build build-robotjs test:e2e:build-performance test:e2e:run-performance",
"test:e2e:nobuild": "cross-env NODE_ENV=test npm-run-all test:e2e:build test:e2e:run",
"test:e2e:build": "webpack-cli --config webpack.config.test.js",
"test:e2e:build-performance": "webpack-cli --config webpack.config.performance.test.js",
"test:e2e:run-performance": "electron-mocha --reporter json --reporter-option output=./e2e/performance/perf-test-report.json dist/tests/e2e_bundle.js",
"test:e2e:run": "electron-mocha --reporter mochawesome dist/tests/e2e_bundle.js",
"test:e2e:send-report": "node ./e2e/save_report.js",
"test:unit": "cross-env NODE_ENV=jest jest",
"test:unit-ci": "cross-env NODE_ENV=jest jest",
"test:coverage": "jest --coverage",
"package:all": "cross-env NODE_ENV=production npm-run-all package:windows package:windows-nsis package:mac package:mac-with-universal package:linux",
"package:windows": "npm-run-all build-prod && electron-builder --win zip --x64 --ia32 --arm64 --publish=never",
"package:windows-nsis": "npm-run-all build-prod-upgrade && electron-builder --win zip nsis --x64 --ia32 --arm64 --publish=never",
"package:mac": "npm-run-all build-prod && electron-builder --mac --x64 --arm64 --publish=never",
"package:mac-with-universal": "npm-run-all build-prod && electron-builder --mac --x64 --arm64 --universal --publish=never",
"package:mas": "cross-env NODE_ENV=production IS_MAC_APP_STORE=true npm-run-all check-build-config build && electron-builder --mac mas --universal --publish=never",
"package:mas-dev": "cross-env NODE_ENV=production IS_MAC_APP_STORE=true npm-run-all check-build-config build && electron-builder --mac mas-dev --universal --publish=never",
"package:linux": "npm-run-all package:linux-all package:linux-appImage",
"package:linux-appImage": "npm-run-all build-prod-upgrade package:linux-appImage-x64 package:linux-appImage-arm64",
"package:linux-appImage-x64": "electron-builder --linux tar.gz appimage --x64 --publish=never",
"package:linux-appImage-arm64": "cross-env CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ electron-builder --linux tar.gz appimage --arm64 --publish=never",
"package:linux-all": "npm-run-all build-prod package:linux-all-x64 package:linux-all-arm64",
"package:linux-all-x64": "electron-builder --linux tar.gz deb rpm --x64 --publish=never",
"package:linux-all-arm64": "cross-env CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ electron-builder --linux tar.gz deb rpm --arm64 --publish=never",
"lint:js": "eslint --ignore-path .gitignore --ignore-pattern node_modules --ext .js --ext .jsx --ext .ts --ext .tsx .",
"lint:js-quiet": "eslint --ignore-path .gitignore --ignore-pattern node_modules --ext .js --ext .jsx --ext .ts --ext .tsx . --quiet",
"fix:js": "eslint --ignore-path .gitignore --ignore-pattern node_modules --quiet --ext .js --ext .jsx --ext .ts --ext .tsx . --fix",
"check-build-config": "npm-run-all check-build-config:build check-build-config:run",
"check-build-config:build": "babel ./src/common/config/buildConfig.ts -o ./dist/buildConfig.js",
"check-build-config:run": "node scripts/check_build_config.js",
"check": "run-p lint:js-quiet check-build-config check-types test:unit",
"check-build-config": "tsc ./src/common/config/buildConfig.ts --outDir dist --baseUrl src --skipLibCheck && node scripts/check_build_config.js",
"check-types": "tsc",
"prune": "ts-prune",
"mmjstool": "mmjstool",
"i18n-extract": "npm run mmjstool -- i18n extract-desktop",
"postinstall": "node scripts/postinstall.js && electron-builder install-app-deps"
"i18n-extract": "mmjstool -- i18n extract-desktop",
"lint:js": "eslint --ignore-path .gitignore --ignore-pattern node_modules --ext .js --ext .jsx --ext .ts --ext .tsx .",
"lint:js-quiet": "npm run lint:js -- --quiet",
"fix:js": "npm run lint:js-quiet -- --fix",
"test": "run-s lint:js test:unit test:e2e",
"test:e2e": "run-s build-all test:e2e:run",
"test:e2e:run": "electron-mocha --reporter mochawesome dist/tests/e2e_bundle.js",
"test:e2e:no-rebuild": "run-s build-test:e2e test:e2e:run",
"test:e2e:performance": "run-s build-all test:e2e:run-performance",
"test:e2e:run-performance": "electron-mocha --reporter json --reporter-option output=./e2e/performance/perf-test-report.json dist/tests/e2e_bundle.js",
"test:e2e:send-report": "node ./e2e/save_report.js",
"test:unit": "jest",
"test:unit-coverage": "jest --coverage",
"build": "run-p build:*",
"build:main": "webpack-cli --config webpack.config.main.js",
"build:preload": "webpack-cli --config webpack.config.preload.js",
"build:renderer": "webpack-cli --config webpack.config.renderer.js",
"build-prod": "cross-env NODE_ENV=production run-s check-build-config build",
"build-prod-mas": "cross-env NODE_ENV=production IS_MAC_APP_STORE=true run-s check-build-config build",
"build-prod-upgrade": "cross-env NODE_ENV=production CAN_UPGRADE=true run-s check-build-config build",
"build-test": "run-p build-test:*",
"build-test:robotjs": "cross-env CL='/std:c++17' electron-rebuild -m ./node_modules/robotjs",
"build-test:e2e": "cross-env NODE_ENV=test webpack-cli --config webpack.config.test.js",
"build-test:e2e-performance": "cross-env NODE_ENV=test webpack-cli --config webpack.config.performance.test.js",
"build-all": "run-p build build-test",
"create-linux-dev-shortcut": "node scripts/create_linux_dev_shortcut.js",
"start": "npm run create-linux-dev-shortcut && electron dist/ --disable-dev-mode",
"restart": "run-s build start",
"watch": "npm run create-linux-dev-shortcut && node scripts/watch.js",
"package": "run-s package:windows package:windows-nsis package:mac-with-universal package:mas package:linux",
"package:windows": "npm run build-prod && electron-builder --win zip --x64 --ia32 --arm64 --publish=never",
"package:windows-nsis": "npm run build-prod-upgrade && electron-builder --win zip nsis --x64 --ia32 --arm64 --publish=never",
"package:mac": "npm run build-prod && electron-builder --mac --x64 --arm64 --publish=never",
"package:mac-with-universal": "npm run package:mac -- --universal",
"package:mas": "npm run build-prod-mas && electron-builder --mac mas --universal --publish=never",
"package:mas-dev": "npm run build-prod-mas && electron-builder --mac mas-dev --universal --publish=never",
"package:linux": "run-s package:linux-*",
"package:linux-tar": "npm run build-prod && electron-builder --linux tar.gz --x64 --publish=never && cross-env CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ electron-builder --linux tar.gz --arm64 --publish=never",
"package:linux-pkg": "npm run build-prod && electron-builder --linux deb rpm --x64 --publish=never && cross-env CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ electron-builder --linux deb rpm --arm64 --publish=never",
"package:linux-appImage": "npm run build-prod-upgrade && electron-builder --linux tar.gz appimage --x64 --publish=never && cross-env CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ electron-builder --linux tar.gz appimage --arm64 --publish=never"
},
"jest": {
"clearMocks": true,
@ -135,14 +130,11 @@
"devDependencies": {
"@aws-sdk/client-s3": "3.445.0",
"@aws-sdk/lib-storage": "3.445.0",
"@babel/cli": "7.23.9",
"@babel/preset-env": "7.24.0",
"@babel/preset-react": "7.23.3",
"@babel/preset-typescript": "7.23.3",
"@electron/fuses": "1.6.0",
"@electron/notarize": "2.3.0",
"@electron/rebuild": "3.6.0",
"@mattermost/compass-icons": "0.1.32",
"@mattermost/desktop-api": "*",
"@mattermost/eslint-plugin": "1.1.0-0",
"@types/auto-launch": "5.0.5",
@ -154,54 +146,36 @@
"@types/valid-url": "1.0.7",
"@types/winreg": "1.2.36",
"7zip-bin": "5.1.1",
"auto-launch": "5.0.5",
"axios": "1.6.7",
"babel-loader": "9.1.3",
"bootstrap": "4.6.1",
"bootstrap-dark": "1.0.3",
"chai": "4.3.6",
"classnames": "2.3.1",
"copy-webpack-plugin": "10.2.4",
"cross-env": "7.0.3",
"css-loader": "6.7.1",
"electron": "29.0.0",
"electron-builder": "24.13.3",
"electron-connect": "0.6.3",
"electron-context-menu": "3.6.1",
"electron-extension-installer": "1.2.0",
"electron-is-dev": "2.0.0",
"electron-log": "5.1.1",
"electron-mocha": "12.2.0",
"electron-updater": "6.1.8",
"eslint": "8.57.0",
"eslint-import-resolver-webpack": "0.13.8",
"eslint-plugin-formatjs": "4.12.2",
"eslint-plugin-no-only-tests": "3.1.0",
"eslint-plugin-react": "7.34.0",
"eslint-plugin-react-hooks": "4.6.0",
"fs-extra": "10.0.1",
"html-webpack-plugin": "5.5.0",
"jest": "29.4.1",
"jest-junit": "13.1.0",
"joi": "17.6.0",
"mini-css-extract-plugin": "2.6.0",
"mmjstool": "github:mattermost/mattermost-utilities#3b4506b0f6b14fbb402f9f8ef932370e459e3773",
"mochawesome": "7.1.3",
"nan": "2.19.0",
"node-abi": "3.56.0",
"node-gyp": "10.0.1",
"node-jq": "4.3.1",
"node-loader": "2.0.0",
"npm-run-all": "4.1.5",
"patch-package": "8.0.0",
"playwright": "1.42.0",
"pretty-bytes": "6.0.0",
"ps-node": "0.1.6",
"react": "17.0.2",
"react-beautiful-dnd": "13.1.0",
"react-bootstrap": "1.6.4",
"react-dom": "17.0.2",
"react-intl": "6.6.2",
"react-select": "5.2.2",
"recursive-readdir": "2.2.3",
"robotjs": "0.6.0",
"sass": "1.49.11",
@ -210,17 +184,34 @@
"style-loader": "3.3.1",
"ts-prune": "0.10.3",
"typescript": "5.3.3",
"uuid": "9.0.0",
"valid-url": "1.0.9",
"webpack": "5.90.3",
"webpack-cli": "4.10.0",
"webpack-dev-server": "4.8.0",
"webpack-merge": "5.8.0",
"winreg-utf8": "0.1.1",
"yargs": "17.4.0"
"webpack-merge": "5.8.0"
},
"dependencies": {
"@mattermost/compass-icons": "0.1.43",
"auto-launch": "5.0.6",
"bootstrap": "4.6.1",
"bootstrap-dark": "1.0.3",
"classnames": "2.5.1",
"electron-context-menu": "3.6.1",
"electron-extension-installer": "1.2.0",
"electron-is-dev": "2.0.0",
"electron-log": "5.1.1",
"electron-updater": "6.1.8",
"joi": "17.12.2",
"macos-notification-state": "3.0.0",
"windows-focus-assist": "1.3.0"
"pretty-bytes": "6.1.1",
"react": "17.0.2",
"react-beautiful-dnd": "13.1.1",
"react-bootstrap": "1.6.4",
"react-dom": "17.0.2",
"react-intl": "6.6.2",
"react-select": "5.8.0",
"uuid": "9.0.1",
"valid-url": "1.0.9",
"windows-focus-assist": "1.3.0",
"winreg-utf8": "0.1.1",
"yargs": "17.7.2"
}
}

View file

@ -0,0 +1,14 @@
diff --git a/node_modules/macos-notification-state/package.json b/node_modules/macos-notification-state/package.json
index 9a863a5..2e02960 100644
--- a/node_modules/macos-notification-state/package.json
+++ b/node_modules/macos-notification-state/package.json
@@ -5,7 +5,8 @@
"main": "lib/index.js",
"scripts": {
"preinstall": "node ensure-sdk.js",
- "test": "standard && mocha ./test/test.js"
+ "test": "standard && mocha ./test/test.js",
+ "install": "node-gyp rebuild"
},
"repository": "https://github.com/felixrieseberg/macos-notification-state",
"license": "MIT",

View file

@ -1,20 +1,20 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
const {spawnSync} = require('child_process');
const path = require('path');
const {flipFuses, FuseVersion, FuseV1Options} = require('@electron/fuses');
const {spawn} = require('@electron/notarize/lib/spawn.js');
const SETUID_PERMISSIONS = '4755';
function fixSetuid(context) {
return async (target) => {
if (!['appimage', 'snap'].includes(target.name.toLowerCase())) {
const result = await spawn('chmod', [SETUID_PERMISSIONS, path.join(context.appOutDir, 'chrome-sandbox')]);
if (result.code !== 0) {
const result = await spawnSync('chmod', [SETUID_PERMISSIONS, path.join(context.appOutDir, 'chrome-sandbox')]);
if (result.error) {
throw new Error(
`Failed to set proper permissions for linux arch on ${target.name}`,
`Failed to set proper permissions for linux arch on ${target.name}: ${result.error} ${result.stderr} ${result.stdout}`,
);
}
}

View file

@ -1,7 +1,7 @@
// Copyright (c) 2015-2016 Yuya Ochiai
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
const buildConfig = require('../dist/buildConfig');
const buildConfig = require('../dist/common/config/buildConfig').default;
function validateBuildConfig(config) {
if (config.enableServerManagement === false && config.defaultServers && config.defaultServers.length === 0) {

View file

@ -80,19 +80,39 @@ fi
if [[ -f "${SRC}"/mattermost-desktop-${VERSION}-linux-x64.tar.gz ]]; then
echo -e "Copying linux\n"
cp "${SRC}"/mattermost-desktop-*-linux-x64* "${DEST}/"
cp "${SRC}"/mattermost-desktop-*-linux-x86_64* "${DEST}/"
cp "${SRC}"/mattermost-desktop_"${VERSION}"-1_amd64*.deb "${DEST}/"
SOMETHING_COPIED=$((SOMETHING_COPIED + 10))
fi
if [[ -f "${SRC}"/mattermost-desktop-${VERSION}-linux-arm64.tar.gz ]]; then
echo -e "Copying linux\n"
cp "${SRC}"/mattermost-desktop-*-linux-arm64* "${DEST}/"
cp "${SRC}"/mattermost-desktop-*-linux-aarch64* "${DEST}/"
cp "${SRC}"/mattermost-desktop_"${VERSION}"-1_arm64*.deb "${DEST}/"
SOMETHING_COPIED=$((SOMETHING_COPIED + 11))
fi
if [[ -f "${SRC}"/mattermost-desktop-*-linux-x86_64* ]]; then
echo -e "Copying linux-rpm\n"
cp "${SRC}"/mattermost-desktop-*-linux-x86_64* "${DEST}/"
SOMETHING_COPIED=$((SOMETHING_COPIED + 12))
fi
if [[ -f "${SRC}"/mattermost-desktop-*-linux-aarch64* ]]; then
echo -e "Copying linux-rpm\n"
cp "${SRC}"/mattermost-desktop-*-linux-aarch64* "${DEST}/"
SOMETHING_COPIED=$((SOMETHING_COPIED + 13))
fi
if [[ -f "${SRC}"/mattermost-desktop_${VERSION}-1_amd64*.deb ]]; then
echo -e "Copying linux-deb\n"
cp "${SRC}"/mattermost-desktop_"${VERSION}"-1_amd64*.deb "${DEST}/"
SOMETHING_COPIED=$((SOMETHING_COPIED + 14))
fi
if [[ -f "${SRC}"/mattermost-desktop_${VERSION}-1_arm64*.deb ]]; then
echo -e "Copying linux-deb\n"
cp "${SRC}"/mattermost-desktop_"${VERSION}"-1_arm64*.deb "${DEST}/"
SOMETHING_COPIED=$((SOMETHING_COPIED + 15))
fi
if [[ $SOMETHING_COPIED -eq 0 ]]; then
echo "Didn't find anything to copy, it seems like something failed"
# Bash only returns 0-255 values

View file

@ -4,19 +4,6 @@
const fs = require('fs');
const path = require('path');
const jq = require('node-jq');
// Patch the macos-notification-state library so we can build correctly
jq.run(
'.scripts.install = "node-gyp rebuild"',
'./node_modules/macos-notification-state/package.json',
).then((result) => {
fs.writeFileSync(
'./node_modules/macos-notification-state/package.json',
result,
);
});
// For linux dev, drop a desktop shortcut so deep linking works correctly
if (process.platform === 'linux') {
const xdgDir = path.resolve(process.env.HOME, '.local/share/applications');

View file

@ -1,32 +0,0 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// inspired by https://kilianvalkhof.com/2019/electron/notarizing-your-electron-application/
require('dotenv').config();
const {notarize} = require('@electron/notarize');
const config = require('../electron-builder.json');
exports.default = async function notarizing(context) {
const {electronPlatformName, appOutDir} = context;
if (electronPlatformName !== 'darwin' || process.platform !== 'darwin') {
return;
}
const appName = context.packager.appInfo.productFilename;
if (typeof process.env.APPLEID === 'undefined') {
console.log('skipping notarization, remember to setup environment variables for APPLEID and APPLEIDPASS if you want to notarize');
return;
}
await notarize({
// should we change it to appBundleId: 'com.mattermost.desktop',
appBundleId: config.appId,
appPath: `${appOutDir}/${appName}.app`,
appleId: process.env.APPLEID,
appleIdPassword: process.env.APPLEIDPASS,
teamId: 'UQ8HT4Q2XM',
tool: 'notarytool',
});
};

View file

@ -1,59 +0,0 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
const {spawn, exec} = require('child_process');
const axios = require('axios');
const mmctlPath = process.env.MMCTL_PATH || 'mmctl';
const ping = setInterval(async () => {
try {
const pingRequest = await axios.get('http://localhost:8065/api/v4/system/ping');
if (pingRequest.status === 200) {
const addUserRequest = await axios.post(
'http://localhost:8065/api/v4/users',
{
email: 'test@test.com',
username: 'admin1',
password: 'Sys@dmin123',
allow_marketing: false,
});
if (addUserRequest.status === 201) {
clearInterval(ping);
exec('echo "Sys@dmin123" > passfile', () => {
const mmctlauth = spawn(mmctlPath, ['auth', 'login', 'http://localhost:8065', '--name', 'local-server', '--username', 'admin1', '--password-file', 'passfile']);
mmctlauth.stdout.on('data', (data) => {
console.log(`${data}`);
});
mmctlauth.stderr.on('data', (data) => {
console.log(`ERROR: ${data}`);
});
mmctlauth.on('close', () => {
const sampledata = spawn(mmctlPath, ['sampledata']);
sampledata.stdout.on('data', (data) => {
console.log(`${data}`);
});
sampledata.stderr.on('data', (data) => {
console.log(`ERROR: ${data}`);
});
sampledata.on('close', () => {
exec(`${mmctlPath} config set AnnouncementSettings.UserNoticesEnabled false`, (err, stdout, stderr) => {
console.log(err, stdout, stderr);
});
});
});
});
}
} else {
console.log(`ERROR: Trying to contact server, got ${pingRequest.status}`);
}
} catch {
console.log('waiting for server to respond...');
}
}, 1000);

26
scripts/watch.js Normal file
View file

@ -0,0 +1,26 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
const electron = require('electron-connect').server.create({path: 'dist/'});
const webpack = require('webpack');
const mainConfig = require('../webpack.config.main.js');
const preloadConfig = require('../webpack.config.preload.js');
const rendererConfig = require('../webpack.config.renderer.js');
Promise.all([mainConfig, preloadConfig, rendererConfig].map((config) => {
return new Promise((resolve) => {
const compiler = webpack(config);
compiler.watch({}, (err, stats) => {
if (err) {
console.error(err);
}
process.stdout.write(stats.toString({colors: true}));
process.stdout.write('\n');
if (!stats.hasErrors()) {
electron.restart();
}
resolve();
});
});
})).then(() => electron.start());

View file

@ -1,34 +0,0 @@
// Copyright (c) 2015-2016 Yuya Ochiai
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
const electron = require('electron-connect').server.create({path: 'dist/'});
const webpack = require('webpack');
const mainConfig = require('../webpack.config.main.js');
const rendererConfig = require('../webpack.config.renderer.js');
let started = false;
const mainCompiler = webpack(mainConfig);
mainCompiler.watch({}, (err, stats) => {
if (err) {
console.error(err);
}
process.stdout.write(stats.toString({colors: true}));
process.stdout.write('\n');
if (!stats.hasErrors()) {
if (started) {
electron.restart();
} else {
electron.start();
started = true;
}
}
});
const preloadCompiler = webpack(rendererConfig);
preloadCompiler.watch({}, (err) => {
if (err) {
console.log(err);
}
});

View file

@ -309,5 +309,5 @@ function validateAgainstSchema<T>(data: T, schema: Joi.ObjectSchema<T> | Joi.Arr
log.error(`Validation failed due to: ${error}`);
return null;
}
return value;
return value as T;
}

View file

@ -41,10 +41,16 @@ jest.mock('main/i18nManager', () => ({
describe('main/CriticalErrorHandler', () => {
const criticalErrorHandler = new CriticalErrorHandler();
const env = process.env;
describe('processUncaughtExceptionHandler', () => {
beforeEach(() => {
app.isReady.mockImplementation(() => true);
process.env = {...env, NODE_ENV: 'jest'};
});
afterAll(() => {
process.env = env;
});
it('should throw error if app is not ready', () => {

View file

@ -33,7 +33,7 @@ function triageArgs(args: string[]) {
// TODO: Translations?
function parseArgs(args: string[]) {
return yargs.
return yargs().
alias('dataDir', 'd').
string('dataDir').
describe('dataDir', 'Set the path to where user data is stored.').

View file

@ -1,19 +1,20 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import fs from 'fs';
import {dialog, screen} from 'electron';
import fs from 'fs-extra';
import JsonFileManager from 'common/JsonFileManager';
import {updatePaths} from 'main/constants';
import {getDeeplinkingURL, resizeScreen, migrateMacAppStore} from './utils';
jest.mock('fs-extra', () => ({
jest.mock('fs', () => ({
readFileSync: jest.fn(),
writeFileSync: jest.fn(),
existsSync: jest.fn(),
copySync: jest.fn(),
cpSync: jest.fn(),
}));
jest.mock('electron', () => ({
@ -188,7 +189,7 @@ describe('main/app/utils', () => {
dialog.showMessageBoxSync.mockReturnValue(0);
dialog.showOpenDialogSync.mockReturnValue(['/old/data/path']);
migrateMacAppStore();
expect(fs.copySync).toHaveBeenCalledWith('/old/data/path', '/path/to/data');
expect(fs.cpSync).toHaveBeenCalledWith('/old/data/path', '/path/to/data');
expect(updatePaths).toHaveBeenCalled();
expect(migrationPrefs.setValue).toHaveBeenCalledWith('masConfigs', true);
});

View file

@ -1,12 +1,12 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import fs from 'fs';
import path from 'path';
import type {BrowserWindow, Rectangle, Session} from 'electron';
import {app, Menu, session, dialog, nativeImage, screen} from 'electron';
import isDev from 'electron-is-dev';
import fs from 'fs-extra';
import {APP_MENU_WILL_CLOSE} from 'common/communication';
import Config from 'common/config';
@ -235,7 +235,7 @@ export function migrateMacAppStore() {
}
try {
fs.copySync(result[0], app.getPath('userData'));
fs.cpSync(result[0], app.getPath('userData'));
updatePaths(true);
migrationPrefs.setValue('masConfigs', true);
} catch (e) {

View file

@ -12,13 +12,6 @@ import CallsWidgetWindow from 'main/windows/callsWidgetWindow';
import {createTemplate} from './app';
jest.mock('fs-extra', () => ({
readFileSync: jest.fn(),
writeFileSync: jest.fn(),
existsSync: jest.fn(),
copySync: jest.fn(),
}));
jest.mock('electron-extension-installer', () => {
return () => ({
REACT_DEVELOPER_TOOLS: 'react-developer-tools',

View file

@ -30,16 +30,24 @@ if (isTest) {
}
module.exports = {
// Some plugins cause errors on the app, so use few plugins.
// https://webpack.js.org/concepts/mode/#mode-production
mode: isProduction ? 'none' : 'development',
mode: isProduction ? 'production' : 'development',
bail: true,
plugins: [
new webpack.DefinePlugin(codeDefinitions),
],
module: {
rules: [{
test: /\.(js|jsx|ts|tsx)?$/,
exclude: /node_modules/,
loader: 'babel-loader',
}],
},
devtool: isProduction ? undefined : 'inline-source-map',
resolve: {
modules: [
'node_modules',
'./src',
],
alias: {
renderer: path.resolve(__dirname, 'src/renderer'),
main: path.resolve(__dirname, './src/main'),

View file

@ -14,27 +14,16 @@ const base = require('./webpack.config.base');
module.exports = merge(base, {
entry: {
index: './src/main/app/index.ts',
internalAPI: './src/main/preload/internalAPI.js',
externalAPI: './src/main/preload/externalAPI.ts',
},
externals: {
'macos-notification-state': 'require("macos-notification-state")',
'windows-focus-assist': 'require("windows-focus-assist")',
},
externalsPresets: {
electronMain: true,
},
module: {
rules: [{
test: /\.(js|ts)?$/,
use: {
loader: 'babel-loader',
options: {
include: ['@babel/plugin-proposal-class-properties'],
},
},
}, {
test: /\.mp3$/,
type: 'asset/inline',
},
{
test: /\.node$/,
loader: 'node-loader',
}],

View file

@ -5,49 +5,15 @@
/* eslint-disable import/no-commonjs */
'use strict';
const path = require('path');
const glob = require('glob');
const {merge} = require('webpack-merge');
const base = require('./webpack.config.base');
const test = require('./webpack.config.test');
const WEBSERVER_PORT = process.env.WEBSERVER_PORT ?? 9001;
module.exports = merge(base, {
module.exports = merge(test, {
entry: {
e2e: glob.sync('./e2e/performance/**/*.test.js'),
},
output: {
path: path.resolve(__dirname, 'dist/tests'),
filename: '[name]_bundle.js',
},
module: {
rules: [{
test: /\.(js|jsx|ts|tsx)?$/,
use: ['babel-loader'],
}],
},
externals: {
fs: 'require("fs")',
ws: 'require("ws")',
child_process: 'require("child_process")',
dns: 'require("dns")',
http2: 'require("http2")',
net: 'require("net")',
repl: 'require("repl")',
tls: 'require("tls")',
playwright: 'require("playwright")',
robotjs: 'require("robotjs")',
},
node: {
__filename: false,
__dirname: false,
},
devServer: {
port: WEBSERVER_PORT,
},
target: 'electron-main',
});
/* eslint-enable import/no-commonjs */

28
webpack.config.preload.js Normal file
View file

@ -0,0 +1,28 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// Copyright (c) 2015-2016 Yuya Ochiai
// This files uses CommonJS.
/* eslint-disable import/no-commonjs */
'use strict';
const {merge} = require('webpack-merge');
const base = require('./webpack.config.base');
module.exports = merge(base, {
entry: {
internalAPI: './src/main/preload/internalAPI.js',
externalAPI: './src/main/preload/externalAPI.ts',
},
externalsPresets: {
electronPreload: true,
},
node: {
__filename: true,
__dirname: true,
},
target: 'electron-preload',
});
/* eslint-enable import/no-commonjs */

View file

@ -14,8 +14,6 @@ const {merge} = require('webpack-merge');
const base = require('./webpack.config.base');
const WEBSERVER_PORT = process.env.WEBSERVER_PORT ?? 9065;
module.exports = merge(base, {
entry: {
index: './src/renderer/index.tsx',
@ -38,6 +36,11 @@ module.exports = merge(base, {
filename: '[name]_bundle.js',
assetModuleFilename: '[name].[ext]',
},
optimization: {
splitChunks: {
chunks: 'all',
},
},
plugins: [
new HtmlWebpackPlugin({
title: 'Mattermost Desktop App',
@ -131,11 +134,6 @@ module.exports = merge(base, {
],
module: {
rules: [{
test: /\.(js|jsx|ts|tsx)?$/,
use: {
loader: 'babel-loader',
},
}, {
test: /\.css$/,
exclude: /\.lazy\.css$/,
use: [
@ -175,10 +173,7 @@ module.exports = merge(base, {
__filename: false,
__dirname: false,
},
target: 'electron-renderer',
devServer: {
port: WEBSERVER_PORT,
},
target: 'web',
});
/* eslint-enable import/no-commonjs */

View file

@ -12,8 +12,6 @@ const {merge} = require('webpack-merge');
const base = require('./webpack.config.base');
const WEBSERVER_PORT = process.env.WEBSERVER_PORT ?? 9001;
module.exports = merge(base, {
entry: {
e2e: glob.sync('./e2e/specs/**/*.test.js'),
@ -22,12 +20,6 @@ module.exports = merge(base, {
path: path.resolve(__dirname, 'dist/tests'),
filename: '[name]_bundle.js',
},
module: {
rules: [{
test: /\.(js|jsx|ts|tsx)?$/,
use: ['babel-loader'],
}],
},
externals: {
fs: 'require("fs")',
ws: 'require("ws")',
@ -44,9 +36,6 @@ module.exports = merge(base, {
__filename: false,
__dirname: false,
},
devServer: {
port: WEBSERVER_PORT,
},
target: 'electron-main',
});