Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…lectron into bugfix/duplicate-notifications
  • Loading branch information
gdelavald committed Aug 2, 2017
2 parents 6dc6eb4 + 274a53c commit 894da03
Show file tree
Hide file tree
Showing 8 changed files with 4,225 additions and 97 deletions.
34 changes: 20 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
language: node_js
node_js: 7
cache:
yarn: true
directories:
- node_modules

matrix:
include:
- os: linux
dist: trusty
sudo: false
services:
- docker
script:
- docker run --rm -v ${PWD}:/project -e GH_TOKEN=${GH_TOKEN} -e TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST} rocketchat/electron.builder /bin/bash -l -c "npm install && npm run release -- --x64 --ia32"
addons:
apt:
packages:
- rpm
- g++-multilib
- libxss-dev:i386
- os: osx
osx_image: xcode7.3.1
language: generic
node_js:
- '6'
before_script:
- chmod +x ./scripts/travis-build.sh
script: ./scripts/travis-build.sh
cache:
directories:
- node_modules
osx_image: xcode8.3

install:
- yarn
script:
- if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then export CSC_IDENTITY_AUTO_DISCOVERY=false; fi
- yarn release -- --x64 --ia32

branches:
only:
Expand Down
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ Prerequisites:
* [Git](http://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
* [Node.js](https://nodejs.org)
* [node-gyp](https://github.com/nodejs/node-gyp#installation)
* [Yarn](http://yarnpkg.com/) is recommended instead of npm.

Now just clone and start the app:

```sh
git clone https://github.com/RocketChat/Rocket.Chat.Electron.git
cd Rocket.Chat.Electron
npm install
npm start
yarn
yarn start
```

## Structure of the project

The sources is located in the `src` folder. Everything in this folder will be built automatically when running the app with `npm start`.
The sources is 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 build into a single `main.css` in the `app` folder.

Expand All @@ -48,11 +49,11 @@ The build process compiles all stuff from the `src` folder and puts it into the
Build process is founded upon [gulp](https://github.com/gulpjs/gulp) task runner and [rollup](https://github.com/rollup/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 npm modules
## 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 `npm install name_of_npm_module --save` and then `npm run postinstall` to rebuild the module for Electron. This needs to be done only once when you're first time installing the module. Later on postinstall script will fire automatically with every `npm install`.
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 postinstall script will fire automatically with every `yarn install`.

## Working with modules

Expand Down Expand Up @@ -98,23 +99,23 @@ On Windows 7 you may have to follow option 2 of the [node-gyp install guide](htt
## Unit tests

```
npm test
yarn test
```

Using [electron-mocha](https://github.com/jprichardson/electron-mocha) test runner with the [chai](http://chaijs.com/api/assert/) assertion library. This task searches for all files in `src` directory which respect pattern `*.spec.js`.

## End to end tests

```
npm run e2e
yarn e2e
```

Using [mocha](https://mochajs.org/) test runner and [spectron](http://electron.atom.io/spectron/). This task searches for all files in `e2e` directory which respect pattern `*.e2e.js`.

## Code coverage

```
npm run coverage
yarn coverage
```

Using [istanbul](http://gotwarlost.github.io/istanbul/) code coverage tool.
Expand All @@ -126,12 +127,15 @@ You can set the reporter(s) by setting `ISTANBUL_REPORTERS` environment variable
To package your app into an installer use command:

```
npm run release
yarn release
```

It will start the packaging process for operating system you are running this command on. Ready for distribution file will be outputted to `dist` directory.

You can create Windows installer only when running on Windows, the same is true for Linux and macOS. So to generate all three installers you need all three operating systems.
Right now you can only create Windows installer when running Windows, the same is true for macOS. For Linux builds, you can use our [Docker image](https://hub.docker.com/r/rocketchat/electron.builder/) with the following commands:
```
docker run --rm -ti -v ${PWD}:/project -v ${PWD##*/}-node-modules:/project/node_modules -v ~/.electron:/root/.electron rocketchat/electron.builder /bin/bash -l -c "yarn && yarn release -- --x64 --ia32 --p never"
```

All packaging actions are handled by [electron-builder](https://github.com/electron-userland/electron-builder). It has a lot of [customization options](https://github.com/electron-userland/electron-builder/wiki/Options), which you can declare under ["build" key in package.json file](https://github.com/szwacz/electron-boilerplate/blob/master/package.json#L2).

Expand All @@ -141,13 +145,13 @@ You can bundle a `servers.json` with the install which will define what servers

If this file is found, the initial "Connect to server" screen will be skipped and it will attempt to connect to the first server in the array that has been defined and drop the user right at the login screen.

The `servers.json` file needs to be placed in the `%APPDATA%` folder for the User not the System wide one.
The `servers.json` file needs to be placed in the `%APPDATA%` folder for the User not the System wide one. The servers.json will only be checked if no other servers have already be added. It should be copied to the correct location after the install.

```
%APPDATA%/Rocket.Chat+/servers.json
```

The syntax/layout of servers.json is as follows:
The syntax/layout of servers.json is as follows:
```
{
"MyRocketChatServer": "https://my-chat-server-url.com",
Expand All @@ -160,7 +164,7 @@ On MacOS the full path of servers.json is:
/Users/<username>/Library/Application Support/Rocket.Chat+/servers.json
```

and on windows:
and on Windows:
```
C:\Users\<username>\AppData\Roaming\Rocket.Chat+\servers.json
```
Expand Down
23 changes: 16 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,31 @@ branches:

skip_tags: true

environment:
nodejs_version: "7"

cache:
- "%LOCALAPPDATA%/Yarn"
- node_modules -> package.json
- app/node_modules -> app/package.json

shallow_clone: true

clone_depth: 1

install:
- ps: Install-Product node 6 $env:platform
- npm install npm
- .\node_modules\.bin\npm install
- ps: Install-Product node $env:nodejs_version $env:platform
- set CI=true
- yarn

test_script:
- node --version
- .\node_modules\.bin\npm --version
# - .\node_modules\.bin\npm test
# - .\node_modules\.bin\npm run e2e
- yarn --version
# - yarn test
# - yarn e2e

build_script:
- npm run release -- --ia32 --x64
- yarn release -- --ia32 --x64

artifacts:
- path: 'dist\**\*.exe'
46 changes: 25 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@
"deb",
"rpm"
]
},
"publish": [
{
"provider": "github",
"owner": "RocketChat",
"repo": "Rocket.Chat.Electron",
"vPrefixedTagName": false
}
]
},
"publish": [
{
"provider": "github",
"owner": "RocketChat",
"repo": "Rocket.Chat.Electron",
"vPrefixedTagName": false
}
]
},
"scripts": {
"postinstall": "install-app-deps && electron-rebuild",
"postinstall": "electron-builder install-app-deps",
"build": "gulp build",
"prerelease": "gulp build --env=production",
"release": "build",
Expand All @@ -73,29 +73,33 @@
},
"dependencies": {
"@paulcbetts/system-idle-time": "^1.0.4",
"electron-updater": "^1.16.0",
"fs-jetpack": "^1.0.0",
"electron-updater": "^2.7.1",
"fs-jetpack": "^1.1.0",
"lodash": "^4.17.4",
"spellchecker": "^3.3.1"
"spellchecker": "^3.4.1"
},
"devDependencies": {
"chai": "^4.0.0",
"electron": "^1.6.10",
"electron-builder": "^18.0.1",
"electron-mocha": "^3.4.0",
"chai": "^4.1.0",
"electron": "^1.6.11",
"electron-builder": "^19.16.0",
"electron-mocha": "^4.0.0",
"electron-rebuild": "^1.5.11",
"gulp": "^3.9.1",
"gulp-batch": "^1.0.5",
"gulp-less": "^3.3.0",
"gulp-less": "^3.3.2",
"gulp-plumber": "^1.1.0",
"gulp-util": "^3.0.8",
"gulp-watch": "^4.3.11",
"istanbul": "^0.4.5",
"minimist": "^1.2.0",
"mocha": "^3.4.2",
"rollup": "^0.41.6",
"rollup": "^0.45.2",
"rollup-plugin-istanbul": "^1.1.0",
"source-map-support": "^0.4.15",
"spectron": "^3.7.1"
"spectron": "^3.7.2"
},
"devEngines": {
"node": ">=7.x",
"npm": ">=4.x",
"yarn": ">=0.21.3"
}
}
24 changes: 0 additions & 24 deletions scripts/travis-build.sh

This file was deleted.

6 changes: 3 additions & 3 deletions src/public/lib/SpellCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ class SpellCheck {
if (this.setEnabled(this.userLanguage)) {
return;
}
if (this.userLanguage.split('_') !== -1 && this.setEnabled(this.userLanguage.split('_')[0])) {
if (this.userLanguage.includes('_') && this.setEnabled(this.userLanguage.split('_')[0])) {
return;
}
}

let navigatorLanguage = navigator.language.replace('-', '_');
const navigatorLanguage = navigator.language.replace('-', '_');
if (this.setEnabled(navigatorLanguage)) {
return;
}

if (navigatorLanguage.split('_') !== -1 && this.setEnabled(this.navigatorLanguage.split('_')[0])) {
if (navigatorLanguage.includes('_') && this.setEnabled(navigatorLanguage.split('_')[0])) {
return;
}

Expand Down
33 changes: 18 additions & 15 deletions tasks/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,24 @@ module.exports = function (src, dest, opts) {
cache: cached[src],
plugins: opts.rollupPlugins,
})
.then(function (bundle) {
cached[src] = bundle;
.then(function (bundle) {
cached[src] = bundle;

var jsFile = path.basename(dest);
var result = bundle.generate({
format: 'cjs',
sourceMap: true,
sourceMapFile: jsFile,
var jsFile = path.basename(dest);
return bundle.generate({
format: 'cjs',
sourceMap: true,
sourceMapFile: jsFile,
});
})
.then(function (result) {
// Wrap code in self invoking function so the variables don't
// pollute the global namespace.
var isolatedCode = '(function () {' + result.code + '\n}());';
var jsFile = path.basename(dest);
return Promise.all([
jetpack.writeAsync(dest, isolatedCode + '\n//# sourceMappingURL=' + jsFile + '.map'),
jetpack.writeAsync(dest + '.map', result.map.toString()),
]);
});
// Wrap code in self invoking function so the variables don't
// pollute the global namespace.
var isolatedCode = '(function () {' + result.code + '\n}());';
return Promise.all([
jetpack.writeAsync(dest, isolatedCode + '\n//# sourceMappingURL=' + jsFile + '.map'),
jetpack.writeAsync(dest + '.map', result.map.toString()),
]);
});
};
Loading

0 comments on commit 894da03

Please sign in to comment.