mattermost-desktop/docs/development.md

110 lines
3.5 KiB
Markdown
Raw Normal View History

2016-09-25 03:45:52 -07:00
# Mattermost Desktop Development Guides
## Build instructions
### Prerequisites
- C++ environment which supports C++11 (e.g. VS 2015, Xcode, GCC)
- Python 2.7
2018-03-13 06:42:32 -07:00
- Node.js 8.2.0 or later
2016-09-25 03:45:52 -07:00
- Git
### Installing dependencies
2017-03-09 04:39:03 -08:00
After installation, dependencies of `src/` directory are also installed.
2016-09-25 03:45:52 -07:00
```
2019-01-07 06:22:35 -08:00
$ npm install
2016-09-25 03:45:52 -07:00
```
### Building
2017-03-09 04:39:03 -08:00
Build JavaScript codes with `webpack`.
2016-09-25 03:45:52 -07:00
```
$ npm run build
```
After building is done, you can execute the application with `npm start`.
2016-10-08 01:40:25 -07:00
### Packaging
2017-03-09 04:39:03 -08:00
Package specific files of `src/` directory as distributable formats with [`electron-builder`](https://github.com/electron-userland/electron-builder).
Files are defined in `electron-builder.json`.
2016-10-08 01:40:25 -07:00
Packages will be generated into `release/` directory.
```
$ npm run package:<all | windows | mac | linux>
```
#### Dependencies
Need to install some software required by `electron-builder` to build packages.
Please see [electron-builder wiki](https://github.com/electron-userland/electron-builder/wiki/Multi-Platform-Build) for detailed description.
**Minimum requirements for current platform:**
- Windows: Nothing.
2016-12-31 02:37:41 -08:00
- macOS: `brew install gnu-tar`
- Linux (64 bit): `icnsutils`, `graphicsmagick` and `xz-utils` if Ubuntu is used.
2016-10-08 01:40:25 -07:00
#### Code signing
Set environment variables to build trusted packages.
Please see [electron-builder wiki](https://github.com/electron-userland/electron-builder/wiki/Code-Signing) for detailed description.
**Quoted from the wiki:**
| Env name | Description |
|---|---|
| `CSC_LINK` | The HTTPS link (or base64-encoded data, or `file://` link) to certificate (`*.p12` or `*.pfx` file). |
| `CSC_KEY_PASSWORD` | The password to decrypt the certificate given in `CSC_LINK`. |
| `CSC_NAME` | *macOS-only* Name of certificate (to retrieve from login.keychain). Useful on a development machine (not on CI) if you have several identities (otherwise don't specify it). |
2016-09-25 03:45:52 -07:00
### Tests
Execute automated tests.
```
$ npm test
```
There are two steps in `npm test`.
Test functionality:
```
$ npm run test:app
```
Test coding style:
```
2016-10-27 08:47:36 -07:00
$ npm run lint:js
2016-09-25 03:45:52 -07:00
```
2018-12-02 05:07:31 -08:00
### Helper commands
2016-09-25 03:45:52 -07:00
#### `npm run watch`
Reload the application automatically when you have saved source codes.
2017-03-09 04:39:03 -08:00
When using this mode, you can use "React Developer Tools" in the Developer Tools window.
2016-09-25 03:45:52 -07:00
## Directory Structure
```
Mattermost Desktop
├── docs/ - Documentations.
├── resources/ - Resources which are used outside of the application codes, and original images of assets.
2016-09-25 03:45:52 -07:00
├── scripts/ - Helper scripts.
├── src/ - Application source code.
│   ├── assets/ - Assets which are loaded from the application codes.
2016-11-02 21:15:16 -07:00
│   ├── browser/ - Implementation of Electron's renderer process.
2016-09-25 03:45:52 -07:00
│   │   ├── components/ - React.js components.
│   │   ├── css/ - Stylesheets.
│   │   ├── js/ - Helper JavaScript modules.
│   │   └── webview/ - Injection code for Electron's <webview> tag.
│   ├── common/ - Common JavaScript modules for both Electron's processes.
│   └── main/ - Implementation of Electron's main process.
│      └── menus/ - Application menu.
2016-09-25 03:45:52 -07:00
└── test/ - Automated tests.
   ├── modules/ - Scripts which are commonly used in tests.
   └── specs/ - Test scripts.
```
### Other directories
2017-03-09 04:39:03 -08:00
- **node_modules/** - Third party Node.js modules to develop and build the application.
2016-09-25 03:45:52 -07:00
- **release/** - Packaged distributable applications.
- **src/node_modules/** - Third party Node.js modules to use in the application.