GithubHelp home page GithubHelp logo

handtrix / electron-boilerplate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from szwacz/electron-boilerplate

0.0 2.0 0.0 5.23 MB

Boilerplate application for Electron runtime

License: MIT License

HTML 3.87% JavaScript 92.74% Shell 1.83% CSS 1.57%

electron-boilerplate's Introduction

electron-boilerplate

Build Status Build status

A minimalistic yet comprehensive boilerplate application for Electron runtime. 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. 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
cd electron-boilerplate
npm install
npm start

... and boom! You have a running desktop application on your screen.

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:

"devDependencies": {
  "electron": "1.3.3"
}

Note: Electron authors advise 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).

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

The build process compiles all stuff 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.

Treat src and app folders like two halves of one bigger thing.

The drawback of this design is that app folder contains some files which should be git-ignored and some which shouldn't (see .gitignore file). But thanks to this two-folders split development builds are much (much!) faster.

Development

Installation

npm install

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

Starting the app

npm start

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

Working with modules

Thanks to 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.

Use ES6 syntax in the src folder like this:

import myStuff from './my_lib/my_stuff';

But use CommonJS syntax in app folder. So the code from above should look as follows:

var myStuff = require('./my_lib/my_stuff');

Testing

Unit tests

Using electron-mocha test runner with the chai 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

Using mocha test runner and spectron. Run with command:

npm run e2e

This task searches for all files in e2e directory which respect pattern *.e2e.js.

Code coverage

Using 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

Electron can be plugged into CI systems. Here two CIs are preconfigured for you. Travis CI covers testing on OSX and Linux and App Veyor on Windows.

Making a release

To package your app into an installer use command:

npm run 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 OSX. So to generate all three installers you need all three operating systems.

All packaging actions are handled by electron-builder. See docs of this tool if you want to customize something.

Note: There are various icons and bitmap files in resources directory. Those are used in installers and intended to be replaced by your own graphics.

License

Released under the MIT license.

electron-boilerplate's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.