Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electron builder #193

Merged
merged 25 commits into from
May 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
11f8a1a
Create .ico file, refactor resource folders
May 12, 2016
8539dee
Add build and directories settings to package.json
May 12, 2016
c4000ca
Make electron-builder a little happier
May 13, 2016
9408f07
Merge branch 'fix-electron-1.0.1' into electron-builder
May 13, 2016
b790209
Remove unnecessary option and properly set output directory
May 13, 2016
a415a1f
Add 'background' item for electron-builder
May 13, 2016
9f0af30
Apparently `background` isn't based off of `buildResources`
May 13, 2016
cf829d9
Cool, nothing is based off of `buildResources`. I'm not really sure w…
May 13, 2016
99dead8
Output should be to binaries
May 13, 2016
e3eb03b
Don't need electron-packager directly anymore
May 14, 2016
7cc7681
Put development version into app version
May 14, 2016
28e5ba5
Put 'name' back in app package.json
May 14, 2016
fea0b69
Set up CI servers
May 14, 2016
53c8127
Remove version from app package.json
May 14, 2016
190f467
Put version back
May 14, 2016
af04094
Attempt to play nice with squirrel startup/upgrade/etc events
May 14, 2016
d484b1b
Merge branch 'master' into electron-builder
May 14, 2016
3385972
Installer is being run properly for Windows
May 14, 2016
100d6da
Put eslint back
May 14, 2016
a133bf5
Fix lint errors
May 14, 2016
f288eec
Don't use `builder` in gulp
May 14, 2016
23a801c
Use pre* in npm scripts
May 14, 2016
6f64d44
Make dummy build for pull request demonstration
May 14, 2016
7246bd9
Add documentation, put version back, reuse a variable properly
May 14, 2016
845b3e9
Merge branch 'master' into electron-builder
May 17, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ package
node_modules
binaries
root-ca.crt.pem
root-ca.key.pem
root-ca.key.pem
npm-debug.log
39 changes: 17 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
sudo: required
dist: trusty
matrix:
include:
- os: osx
language: node_js
node_js:
- '5.1'
- '5.1'
addons:
apt:
packages:
- wine
- icnsutils
- graphicsmagick
script:
- npm --depth Infinity update
- npm run test-ci
before_deploy:
- npm run zip-binaries
deploy:
provider: releases
api_key:
secure: KEDggFkivi1iJbO/G4hicXznWk+bGA7sDuKSd36fBB9pIN/JSr08HlasrmqLmRva/rkHinbEdu+f75k/xh/m0UKll5jXUhmJVgbvNjPWQDtRSeeRM8UjveCL9wTZopkM4bLLxmWD2klyCC8qde5mMOJ1gRi+aPboGBgxEmtD69Bdhq1k3Dd2HTFnqQEh+8al2//+ayhne512Mo+lgwR1+4pLbhE/xK0iV7gQllRzTT2/ifbn5an8vbUkwfmm2NivNhSJTaPD2NndLvOVBKKQVcbIx+37gXO1Hn6F7Wr0MMHeh/ypJzGygxPQ2xZHtCKABw8jFetpFaFzm4xFcbyHsqclQlDLCv9J1e5DMvWk2ay29L9qWXT5dc7tnjaIVFPMEw4ViwIC30ThO44HHm6m+/tQAp3cDAD37uunp83wDAImbyCzZ3UoNLcmWHc39fxaD1s4Fzan3/++QbqSgdB+p4dXraxlRyqFcmKW+O5S+oGFolmdLuRbxPaaeIMMGm9AN7+fmGJgmiRzPU5k3/ao6eHoycXVPcIiuFV+2ZxvJS4ewqT+HiH6cNOFeeHEXx2O0fjEuj7mZG5Jey5GNsOdcq7loPnipcGbDnIHs+wRyqPCQ5aZ+94gQAemjBdtVnDTKd7RSjKHWmbo3Xx260XnwAEsTDtVuUJmyVjpIdCdNAs=
file:
- binaries/James-darwin-x64.zip
- binaries/James-linux-ia32.zip
- binaries/James-linux-x64.zip
- binaries/James-win32-ia32.zip
- binaries/James-win32-x64.zip
skip_cleanup: true
on:
repo: james-proxy/james
tags: true
- npm prune
- npm --depth Infinity update
- npm run test-ci
- npm run dist
cache:
apt: true
directories:
- node_modules
- $HOME/.electron
- node_modules
- "$HOME/.electron"
env:
global:
secure: JGVJJ2FeysfDzsh6sLiZZ4djQPKLA81SpBsph1cvo+FHB9E9fXiLNbIIqVALsq2b3nNgtUD/LFgYOTvfJbHr5P6ZP9oHJzh2Fv3O5WR+bPaaqVkSJKRuY7w1SBTxD0NG2+sZwR6/E0mEk6+TW27FSRccmAYCBjqBcLbpCw7wDBZXmmJ4kB2ziwFKyw7bwRrmW+pTQqYIun08sTCTlu7me4ucVEjqLTOVrYlbNIpmcKKzZs7jK+9SHtFjN2DeSnX8tu2go20M8TitkqESlQF8ztNGjkbdyC+mjRyCnfWvN8tv2SbV5EI62RPswd+bY4jIPM8aqrsMZ+pHc+nNIEc/nELhVfywPx2jfcYf6Egv36AIkVu3LJRUdhny/54cDDn2g7WT3BesX8gy0/rF59SNExdmNJHs8X3/of6ZLn8x9XvTmiKNbTYDjgc+ks3UvSRk//ToqtbziG2FKJ1wTZjKbnxyv7Ll3Z9PyAIc/7qlxvweloV5phTkL1DjU/9wHcn5BW07GXN5AH+FH7h5PyJurmJtBuC4Y9goRX+P78UuBT5rpAD5MXDeg82yb0DLZDKxaaXbzJpelqYGOZ6qUzEwTMZfvfi4YIy3BybU1L4K4j65vF+leve2JHV2poeRDLkOz5zCv596r0WlwE86sdqtO/obXwuwrDJieACkZvhfN3w=
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It is an open-source alternative to the popular developer tool [Charles](http://

James is build with [hoxy](https://github.com/greim/hoxy), [electron](https://github.com/atom/electron) and [react](https://facebook.github.io/react/index.html)

![](resource/screenshot-1.png)
![](resource-compile/screenshot-1.png)

## Installing
Download the correct version for your OS and run
Expand Down
24 changes: 24 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '{build}'

platform:
- x64

cache:
- node_modules
- '%USERPROFILE%\.electron'

install:
- ps: Install-Product node 5 x64
- npm install
- npm prune
- npm --depth Infinity update

build_script:
- npm run test-ci
- npm run dist:win64

environment:
GH_TOKEN:
secure: HnT2ViVK97gtyZrlPH1C9zM/m3YErp8kY9FtO7wUhcoLG8TZiR1oLiBx+27eCWrX

test: off
80 changes: 38 additions & 42 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ const changed = require('gulp-changed');
const sass = require('gulp-sass');
const sourcemaps = require('gulp-sourcemaps');
const autoprefixer = require('gulp-autoprefixer');
const electron = require('electron-packager');
const useref = require('gulp-useref');
const electronConnect = require('electron-connect').server;
const gulpif = require('gulp-if');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const jeditor = require('gulp-json-editor');
const version = require('./package.json').version;

gulp.task('default', ['js', 'css', 'resources']);
gulp.task('dist-prep', ['dist-resources', 'browserify']);

gulp.task('clean', () => {
return del.sync(['build', 'package', 'binaries']);
Expand All @@ -41,30 +43,44 @@ gulp.task('css', () => {
.pipe(gulp.dest('build'));
});

// There's two separate `resource-*` directories.
// `resource-runtime` contains actual files which will exist in the same
// directory as James at runtime, in production (e.g. the browser images).
// `resource-compile` has resources that we don't necessarily want taking space with James, because they're compiled
// in in a special way (e.g. icons), they're not used in the build (e.g. the screenshot) or aren't just directly
// copied, and are modified along the way
gulp.task('resources', () => {
const dest = 'build';

return es.merge([
gulp.src('node_modules/font-awesome/fonts/**').pipe(gulp.dest('build/fonts')),
gulp.src('package.json').pipe(gulp.dest('build')),
gulp.src('resource/**')
.pipe(changed('build'))
.pipe(gulp.dest('build'))
gulp.src('node_modules/font-awesome/fonts/**').pipe(gulp.dest(`${dest}/fonts`)),
gulp.src('resource-runtime/**')
.pipe(changed(dest))
.pipe(gulp.dest(dest)),
gulp.src('resource-compile/package.json')
.pipe(jeditor({ version }))
.pipe(gulp.dest(dest))
]);
});

gulp.task('package-resources', ['default'], () => {
gulp.task('dist-resources', ['css'], () => {
const dest = 'package';

return es.merge([
gulp.src('node_modules/font-awesome/fonts/**').pipe(gulp.dest('package/fonts')),
gulp.src('build/james.css').pipe(gulp.dest('package')),
gulp.src('package.json').pipe(gulp.dest('package')),
gulp.src('resource/**')
gulp.src('node_modules/font-awesome/fonts/**').pipe(gulp.dest(`${dest}/fonts`)),
gulp.src('build/james.css').pipe(gulp.dest(dest)),
gulp.src('resource-runtime/**')
.pipe(gulpif('*.html', useref()))
.pipe(gulp.dest('package'))
.pipe(gulp.dest(dest)),
gulp.src('resource-compile/package.json')
.pipe(jeditor({ version }))
.pipe(gulp.dest(dest))
]);
});

function gulpBrowserify(entry) {
gulp.task('browserify', ['js'], () => {
process.env.NODE_ENV = 'production';
return browserify(entry, {
const opts = {
builtins: false,
commondir: false,
browserField: false,
Expand All @@ -81,51 +97,31 @@ function gulpBrowserify(entry) {
transform: [
'envify'
]
}).bundle();
}
};

gulp.task('package-render', ['default'], () => {
gulpBrowserify('build/index.js')
browserify('build/index.js', opts)
.bundle()
.pipe(source('index.js'))
.pipe(gulp.dest('./package'));
});

gulp.task('package-main', ['default'], () => {
gulpBrowserify('build/electron-app.js')
browserify('build/electron-app.js', opts)
.bundle()
.pipe(source('electron-app.js'))
.pipe(gulp.dest('./package'));
});

gulp.task('package', ['package-resources', 'package-render', 'package-main'], (done) => {
const appVersion = require('./package.json').version;
const electronVersion = require('electron-prebuilt/package.json').version;
console.log(`Packaging James v${appVersion}...`);

electron({
all: true,
dir: 'package',
platform: 'all',
name: 'James',
overwrite: true,
icon: 'resource/icon.icns',
'app-version': appVersion,
version: electronVersion,
out: 'binaries'
}, (err) => done(err));
});

gulp.task('watch', ['default'], () => {
gulp.watch('src/**', ['js']);
gulp.watch('style/**', ['css']);
gulp.watch('resource/**', ['resources']);
gulp.watch('resource-runtime/**', ['resources']);
});

gulp.task('livereload', ['default'], () => {
var server = electronConnect.create({path: './build'});
const server = electronConnect.create({path: './build'});
server.start();
const reload = () => server.reload();

gulp.watch('src/**', ['js', reload]);
gulp.watch('style/**', ['css', reload]);
gulp.watch('resource/**', ['resources', reload]);
gulp.watch('resource-runtime/**', ['resources', reload]);
});
49 changes: 37 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
{
"name": "james",
"version": "1.4.5",
"description": "",
"description": "HTTP/HTTPS proxy built in Electron and React",
"author": "Julian Hollmann <[email protected]>",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/james-proxy/james.git"
},
"main": "electron-app.js",
"scripts": {
"build": "gulp",
"start": "electron ./build",
"watch": "gulp watch",
"development": "gulp livereload",
"package": "gulp clean package",
"zip-binaries": "cd binaries; rm *.zip; for i in *; do zip --symlinks -r \"${i%/}.zip\" \"$i\"; done",
"start": "electron ./build",
"lint": "eslint ./src ./test",
"test": "mocha --reporter dot --recursive -r setup-referee-sinon/globals test/unit --compilers js:babel-core/register",
"test-ci": "npm run lint && npm run test && npm run package"
},
"author": "Julian Hollmann <[email protected]>",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/james-proxy/james.git"
"test-ci": "npm run lint && npm run test",
"package": "npm run dist",
"predist": "gulp clean dist-prep",
"predist:win64": "gulp clean dist-prep",
"dist": "build --arch all",
"dist:win64": "build --platform win32 --arch x64"
},
"dependencies": {
"electron-squirrel-startup": "^0.1.4",
"hoxy": "^3.2.0",
"james-browser-launcher": "^1.2.1",
"materialize-css": "^0.97.5",
Expand All @@ -39,9 +43,9 @@
"babel-preset-react": "^6.3.13",
"browserify": "^13.0.0",
"del": "^2.2.0",
"electron-builder": "^3.17.1",
"electron-connect": "^0.4.0",
"electron-localshortcut": "^0.6.0",
"electron-packager": "7.0.1",
"electron-prebuilt": "1.1.0",
"envify": "^3.4.0",
"eslint": "^2.2.0",
Expand All @@ -53,6 +57,7 @@
"gulp-babel": "^6.1.1",
"gulp-changed": "^1.3.0",
"gulp-if": "^2.0.0",
"gulp-json-editor": "^2.2.1",
"gulp-rename": "^1.2.2",
"gulp-sass": "^2.1.1",
"gulp-sourcemaps": "^1.6.0",
Expand All @@ -75,5 +80,25 @@
"plugins": [
"transform-object-rest-spread"
]
},
"build": {
"app-bundle-id": "com.jamesproxy.james",
"app-category-type": "public.app-category.productivity",
"productName": "James",
"osx": {
"icon": "resource-compile/icon.icns",
"background": "resource-compile/icon.png"
},
"win": {
"iconUrl": "https://github.com/mitchhentges/james/blob/electron-builder/resource-compile/icon.ico?raw=true"
},
"linux": {
"synopsis": "Web proxy"
}
},
"directories": {
"buildResources": "resource-compile",
"output": "binaries",
"app": "./package"
}
}
File renamed without changes.
Binary file added resource-compile/icon.ico
Binary file not shown.
File renamed without changes
11 changes: 11 additions & 0 deletions resource-compile/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "james",
"description": "HTTP/HTTPS proxy built in Electron and React",
"main": "electron-app.js",
"author": "Julian Hollmann <[email protected]>",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/james-proxy/james.git"
}
}
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions src/electron-app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import squirrelStartup from 'electron-squirrel-startup';

import { BrowserWindow, app, ipcMain as ipc } from 'electron'; // app controls application life.
import localShortcut from 'electron-localshortcut';

if (squirrelStartup) {
process.exit(0); // Don't run James if it's just being installed/updated/etc
}
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
let mainWindow = null;
Expand Down