Commit 2ba72e02 authored by Jakub Szwacz's avatar Jakub Szwacz

Initial commit

parents
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.json]
indent_size = 2
[*.md]
trim_trailing_whitespace = false
node_modules
bower_components
*.log
.DS_Store
Thumbs.db
/build/
/releases/
/tmp/
// -----------------------------------------------------
// Here is the starting point for your own code.
// All stuff below is just to show you how it works.
// -----------------------------------------------------
// Browser modules are imported through new ES6 syntax.
import { greet } from './hello_world/hello_world';
// Node modules are required the same way as always.
var os = require('os');
var greetElement = document.getElementById('greet');
greetElement.innerHTML = greet();
var platform = document.getElementById('platform-info');
platform.innerHTML = os.platform();
var greet = function () {
return 'Hello Universe!'
};
export default greet;
// Default imports test
import greet from './hello_universe';
describe("hello universe", function () {
it("greets better than hello world", function () {
expect(greet()).toBe('Hello Universe!');
});
});
export var greet = function () {
return 'Hello World!';
};
export var bye = function () {
return 'See ya!';
};
// Named imports test
import { greet, bye } from './hello_world';
describe("hello world", function () {
it("greets", function () {
expect(greet()).toBe('Hello World!');
});
it("says goodbye", function () {
expect(bye()).toBe('See ya!');
});
});
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link href="./stylesheets/main.css" rel="stylesheet" type="text/css">
<script src="vendor/require.js"></script>
<script>
requirejs(['app'], function (app) {});
</script>
</head>
<body>
<div class="container">
<h1 id="greet"></h1>
<p class="subtitle">
Welcome to <a href="http://electron.atom.io" class="js-external-link">Electron</a> app running on this magnificent <strong id="platform-info"></strong> machine.
</p>
</div>
</body>
</html>
'use strict';
var app = require('app');
var BrowserWindow = require('browser-window');
var jetpack = require('fs-jetpack');
// Must keep references to opened windows,
// otherwise Garbage Collector will kick in.
var mainWindow = null;
// Atom-shell is ready, we can start with our stuff.
app.on('ready', function () {
var appCodeDir = jetpack.cwd(__dirname);
var manifest = appCodeDir.read('package.json', 'json');
mainWindow = new BrowserWindow({ width: 800, height: 600 });
mainWindow.loadUrl('file://' + __dirname + '/index.html');
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
});
// Quit when all windows are closed.
app.on('window-all-closed', function () {
if (process.platform != 'darwin') {
app.quit();
}
});
{
"name": "electron-boilerplate",
"productName": "Electron Boilerplate",
"description": "Starter for your Electron application. Out of the box ready for serious stuff.",
"version": "0.1.0",
"author": "Mr Gumby <gumby@sillywalks.com>",
"main": "main.js",
"config": {
"target": "development"
},
"dependencies": {
"fs-jetpack": "^0.6.4"
}
}
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
body {
display: flex;
justify-content: center;
align-items: center;
font-family: sans-serif;
}
a {
text-decoration: none;
}
.container {
text-align: center;
}
.subtitle {
color: gray;
}
\ No newline at end of file
This diff is collapsed.
'use strict';
require('./tasks/build');
{
"devDependencies": {
"electron-prebuilt": "^0.24.0",
"esperanto": "^0.6.17",
"fs-jetpack": "^0.6.4",
"gulp": "^3.8.8",
"gulp-less": "^1.3.6",
"gulp-util": "^3.0.1",
"q": "^1.0.1",
"vinyl-map": "^1.0.1",
"yargs": "^1.3.1"
},
"optionalDependencies": {
"appdmg": "^0.3.1"
},
"scripts": {
"postinstall": "cd ./app && npm install",
"build": "./node_modules/.bin/gulp build",
"release": "./node_modules/.bin/gulp release --target=release",
"start": "node ./tasks/start",
"test": "node ./tasks/start --target=test"
}
}
'use strict';
var gulp = require('gulp');
var less = require('gulp-less');
var esperanto = require('esperanto');
var map = require('vinyl-map');
var jetpack = require('fs-jetpack');
var utils = require('./utils');
var projectDir = jetpack;
var srcDir = projectDir.cwd('./app');
var destDir = projectDir.cwd('./build');
var paths = {
jsCodeToTranspile: [
'app/**/*.js',
'!app/main.js',
'!app/node_modules/**',
'!app/bower_components/**',
'!app/vendor/**'
],
toCopy: [
'app/main.js',
'app/node_modules/**',
'app/bower_components/**',
'app/vendor/**',
'*.html'
],
}
// -------------------------------------
// Tasks
// -------------------------------------
gulp.task('clean', function(callback) {
return destDir.dirAsync('.', { empty: true });
});
var copyTask = function () {
return projectDir.copyAsync('app', destDir.path(), {
overwrite: true,
matching: paths.toCopy
});
};
gulp.task('copy', ['clean'], copyTask);
gulp.task('copy-watch', copyTask);
var transpileTask = function () {
return gulp.src(paths.jsCodeToTranspile)
.pipe(map(function(code, filename) {
var transpiled = esperanto.toAmd(code.toString(), { strict: true });
return transpiled.code;
}))
.pipe(gulp.dest(destDir.path()));
};
gulp.task('transpile', ['clean'], transpileTask);
gulp.task('transpile-watch', transpileTask);
var lessTask = function () {
return gulp.src('app/stylesheets/main.less')
.pipe(less())
.pipe(gulp.dest(destDir.path('stylesheets')));
};
gulp.task('less', ['clean'], lessTask);
gulp.task('less-watch', lessTask);
// Add and customize OS-specyfic and target-specyfic stuff.
gulp.task('finalize', ['clean'], function () {
var manifest = srcDir.read('package.json', 'json');
switch (utils.getBuildTarget()) {
case 'development':
// Add "-dev" suffix to name, so Electron will write all
// data like cookies and localStorage into separate place.
manifest.name += '-dev';
break;
}
destDir.write('package.json', manifest);
});
gulp.task('watch', function () {
gulp.watch(paths.jsCodeToTranspile, ['transpile-watch']);
gulp.watch(paths.toCopy, ['copy-watch']);
gulp.watch('*.less', ['less-watch']);
});
gulp.task('build', ['transpile', 'less', 'copy', 'finalize']);
'use strict';
var Q = require('q');
var electron = require('electron-prebuilt');
var pathUtil = require('path');
var childProcess = require('child_process');
var utils = require('./utils');
var gulpPath = pathUtil.resolve('./node_modules/.bin/gulp');
if (process.platform === 'win32') {
gulpPath += '.cmd';
}
var runBuild = function () {
var deferred = Q.defer();
var build = childProcess.spawn(gulpPath, [
'build',
'--target=' + utils.getBuildTarget(),
'--color'
]);
build.stdout.pipe(process.stdout);
build.stderr.pipe(process.stderr);
build.on('close', function (code) {
deferred.resolve();
});
return deferred.promise;
};
var runGulpWatch = function () {
var watch = childProcess.spawn(gulpPath, [
'watch',
'--target=' + utils.getBuildTarget(),
'--color'
]);
watch.stdout.pipe(process.stdout);
watch.stderr.pipe(process.stderr);
watch.on('close', function (code) {
// Gulp watch exits when error occured during build.
// Just respawn it then.
runGulpWatch();
});
};
var runApp = function () {
var app = childProcess.spawn(electron, ['./build']);
app.stdout.pipe(process.stdout);
app.stderr.pipe(process.stderr);
app.on('close', function (code) {
// User closed the app. Kill the host process.
process.exit();
});
};
runBuild()
.then(function () {
runGulpWatch();
runApp();
});
'use strict';
var argv = require('yargs').argv;
var os = require('os');
module.exports.os = function () {
switch (os.platform()) {
case 'darwin':
return 'osx';
case 'linux':
return 'linux';
case 'win32':
return 'windows';
}
return 'unsupported';
};
module.exports.replace = function (str, patterns) {
Object.keys(patterns).forEach(function (pattern) {
var matcher = new RegExp('{{' + pattern + '}}', 'g');
str = str.replace(matcher, patterns[pattern]);
});
return str;
};
module.exports.getBuildTarget = function () {
return argv.target || 'development';
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment