mattermost-desktop/scripts/postinstall.js
Devin Binnie 9b36c25e4e
[MM-52696] Upgrade and clean up Desktop App dev dependencies (#2970)
* Upgrade to ESLint v8

* Upgrade TypeScript, api-types, react-intl

* Remove unnecessary dependencies

* Update to React 17.0.2

* npm audit fixes, remove storybook

* Lock some packages

* Remove nan patch

* Remove some deprecated dependencies

* Fix lint/type/tests

* Merge'd

* Fix bad use of spawn

* Fix notarize

* Fix afterpack, switch to tsc es2020

* Fix api types

* Use @mattermost/eslint-plugin
2024-03-07 15:55:33 -05:00

54 lines
2 KiB
JavaScript

// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
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');
if (fs.existsSync(xdgDir) && !fs.existsSync(path.resolve(xdgDir, 'mattermost-desktop-dev.desktop'))) {
fs.writeFileSync(
path.resolve(xdgDir, 'mattermost-desktop-dev.desktop'),
`[Desktop Entry]
Name=Mattermost.Dev
Exec=${path.resolve(process.cwd(), 'node_modules/electron/dist/electron')} ${path.resolve(process.cwd(), 'dist')} %U
Terminal=false
Type=Application
Icon=mattermost-desktop
StartupWMClass=Mattermost
Comment=Mattermost
MimeType=x-scheme-handler/mattermost-dev;
Categories=contrib/net;
`,
);
const defaultsListPath = path.resolve(xdgDir, 'defaults.list');
if (!fs.existsSync(defaultsListPath)) {
fs.writeFileSync(defaultsListPath, '[Default Applications]\n');
}
fs.appendFileSync(defaultsListPath, 'x-scheme-handler/mattermost-dev=mattermost-desktop-dev.desktop\n');
const mimeCachePath = path.resolve(xdgDir, 'mimeinfo.cache');
if (!fs.existsSync(mimeCachePath)) {
fs.writeFileSync(mimeCachePath, '[MIME Cache]\n');
}
fs.appendFileSync(mimeCachePath, 'x-scheme-handler/mattermost-dev=mattermost-desktop-dev.desktop\n');
console.log('NOTE: You may need to log in and out of your session to ensure that deep linking works correctly.');
}
}