Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
szwacz committed Nov 25, 2016
1 parent 52f58db commit ffcefa6
Showing 1 changed file with 21 additions and 48 deletions.
69 changes: 21 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
electron-boilerplate
==============

[![Build Status](https://travis-ci.org/szwacz/electron-boilerplate.svg?branch=master)](https://travis-ci.org/szwacz/electron-boilerplate) [![Build status](https://ci.appveyor.com/api/projects/status/s9htc1k5ojkn08fr?svg=true)](https://ci.appveyor.com/project/szwacz/electron-boilerplate)
# electron-boilerplate [![Build Status](https://travis-ci.org/szwacz/electron-boilerplate.svg?branch=master)](https://travis-ci.org/szwacz/electron-boilerplate) [![Build status](https://ci.appveyor.com/api/projects/status/s9htc1k5ojkn08fr?svg=true)](https://ci.appveyor.com/project/szwacz/electron-boilerplate)

A minimalistic yet comprehensive boilerplate application for [Electron runtime](http://electron.atom.io). Tested on OSX, Windows and Linux.

This project does not impose on you any framework (like Angular or React). Instead, it tries to give you only the 'electron' part of technology stack so you can pick your favorite tools for the rest.

# Quick start
The only development dependency of this project is [Node.js](https://nodejs.org). So just make sure you have it installed.

The only development dependency of this project is [Node.js](https://nodejs.org), so just make sure you have it installed.
Then type few commands known to every Node developer...
```
git clone https://github.com/szwacz/electron-boilerplate.git
Expand All @@ -20,33 +18,9 @@ npm start

# Structure of the project

## Declaring dependencies

There are **two** `package.json` files:

#### 1. `package.json` for development
Sits on path: `electron-boilerplate/package.json`. This is where you should declare dependencies for your development environment and build scripts. **This file is not distributed with real application!**

It's also the place to specify the Electron runtime version you want to use:
```json
"devDependencies": {
"electron": "1.4.7"
}
```
Note: [Electron authors advise](http://electron.atom.io/docs/tutorial/electron-versioning/) to use fixed version here.

#### 2. `package.json` for your application
Sits on path: `electron-boilerplate/app/package.json`. This is **real** manifest of your application. Declare your app dependencies here.

#### OMG, but seriously why there are two `package.json`?
1. Native npm modules (those written in C, not JavaScript) need to be compiled, and here we have two different compilation targets for them. Those used in application need to be compiled against electron runtime, and all `devDependencies` need to be compiled against your locally installed node.js. Thanks to having two files this is trivial.
2. When you package the app for distribution there is no need to add up to size of the app with your `devDependencies`. Here those are always not included (reside outside the `app` directory).

## Folders for application code

The application is split between two main folders...

`src` - this folder is intended for files which need to be transpiled or compiled (files which can't be used directly by electron).
`src` - this folder is intended for files which need to be transpiled or compiled (files which can't be used directly by Electron).

`app` - contains all static assets (put here images, css, html etc.) which don't need any pre-processing.

Expand All @@ -58,30 +32,29 @@ The drawback of this design is that `app` folder contains some files which shoul

# Development

### Installation
## Starting the app

```
npm install
npm start
```
It will also download Electron runtime and install dependencies for the second `package.json` file inside the `app` folder.

### Starting the app
## Upgrading Electron version

The version of Electron runtime your app is using is declared in `package.json`:
```json
"devDependencies": {
"electron": "1.4.7"
}
```
npm start
```
Side note: [Electron authors advise](http://electron.atom.io/docs/tutorial/electron-versioning/) to use fixed version here.

### Adding npm modules to your app
## Adding npm modules to your app

Remember to add your dependencies to `app/package.json` file:
```
cd app
npm install name_of_npm_module --save
```
Remember to respect the split between `dependencies` and `devDependencies` in `package.json` file. Only modules listed in `dependencies` will be included in app installers.

**Note:** if the module you want to install is a native one (not pure JavaScript but compiled C code or something) you should run `npm run postinstall` command **after** `npm install name_of_npm_module` 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`.
Pro tip: 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 run first `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 postinstall script will fire automatically with every `npm install`.

### Working with modules
## Working with modules

Thanks to [rollup](https://github.com/rollup/rollup) you can (and should) use ES6 modules for all code in `src` folder. But because ES6 modules still aren't natively supported you can't use them in the `app` folder.

Expand All @@ -97,31 +70,31 @@ var myStuff = require('./my_lib/my_stuff');

# Testing

### Unit tests
## Unit tests

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

### End to end tests
## End to end tests

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

### Code coverage
## Code coverage

Using [istanbul](http://gotwarlost.github.io/istanbul/) code coverage tool. Run with command:
```
npm run coverage
```
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`).

### Continuous integration
## Continuous integration

Electron [can be plugged](https://github.com/atom/electron/blob/master/docs/tutorial/testing-on-headless-ci.md) into CI systems. Here two CIs are preconfigured for you. [Travis CI](https://travis-ci.org/) covers testing on OSX and Linux and [App Veyor](https://www.appveyor.com) on Windows.

Expand Down

0 comments on commit ffcefa6

Please sign in to comment.