Skip to content

Development

Gabriel Delavald edited this page Aug 2, 2017 · 2 revisions

The Rocket.Chat Electron app is Open Source, so we encourage every type of contribution, if you want a starting point make sure to check the open issues on our repository.

Quick start

Prerequisites:

  • Git
  • Node.js version 6+ is recommended.
  • Yarn is recommended instead of npm.

node-gyp and ESLint should be installed by Yarn by default, if not, make sure to install them globally.

Now just clone and start the app:

git clone https://github.com/RocketChat/Rocket.Chat.Electron.git
cd Rocket.Chat.Electron
yarn & yarn start

This should get you running with our latest development version.

We use and encourage ES6+ adoption, but please check possible compatibility issues, mostly on code inside src/public since that is limited to what Electron/Chromium supports.

Structure of the project

The source files are located in the src folder. Everything in this folder will be built automatically when running the app with yarn start.

Stylesheets are written in less and are located in src/stylesheets. They will be built into a single main.css in the app folder.

The build process compiles all source files from the src folder and puts it into the app folder, so after the build has finished your app folder contains the full runnable application.

The build pipeline

Build process is based on gulp task runner and rollup bundler. There are two entry files for your code: src/background.js and src/app.js. Rollup will follow all import statements starting from those files and compile code of the whole dependency tree into one .js file for each entry point.

Adding node modules

Remember to respect the split between dependencies and devDependencies in package.json file. Only modules listed in dependencies will be included into distributable app.

Side note: If the module you want to use in your app is a native one (not pure JavaScript but compiled C code or something) you should first run yarn add name_of_module and then yarn postinstall to rebuild the module for Electron. This needs to be done only once when you're first time installing the module. Later on post install script will fire automatically with every yarn install.

Troubleshooting

Different platforms might face issues with the installation, if you face one of these, make sure to follow the guides:

node-gyp

Follow the installation instruction on node-gyp readme.

Ubuntu Install

You will need to install:

build-essential
libevas-dev
libxss-dev

Fedora Install

You will need to install:

libX11
libXScrnSaver-devel
gcc-c++

Windows 7

On Windows 7 you may have to follow option 2 of the node-gyp install guide and install Visual Studio. Other solution is installing the Windows Build Tools which can solve various issues with python, node-gyp and VS redistributable code.

Testing

Unit tests

yarn test

Using electron-mocha test runner with the chai assertion library. This task searches for all files in src directory which respect pattern *.spec.js.

End to end tests

yarn e2e

Using mocha test runner and spectron. This task searches for all files in e2e directory which respect pattern *.e2e.js.

Code coverage

yarn coverage

Using istanbul code coverage tool.

You can set the reporter(s) by setting ISTANBUL_REPORTERS environment variable (defaults to text-summary and html). The report directory can be set with ISTANBUL_REPORT_DIR (defaults to coverage).