Skip to content

Commit

Permalink
chore(app): scaffold basic electron app
Browse files Browse the repository at this point in the history
  • Loading branch information
debloper committed Dec 13, 2019
1 parent 9501203 commit 4c31249
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 89 deletions.
98 changes: 9 additions & 89 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,104 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
# Runtime
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Build
.tmp/
dist/
builds/

# Dependency directories
# Deps
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
# Misc
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
*.tgz
package-lock.json
8 changes: 8 additions & 0 deletions config/window.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"width": 1280,
"height": 720,
"autoHideMenuBar": true,
"webPreferences": {
"nodeIntegration": true
}
}
27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "exorcist",
"version": "0.0.1",
"description": "Got rogue daemons in your system?",
"main": "src/index.js",
"scripts": {
"start": "electron ."
},
"dependencies": {
"electron": "^7.1.4"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "[email protected]:debloper/exorcist.git"
},
"keywords": [
"linux",
"startup",
"daemon",
"services",
"systemd",
"optimize"
],
"author": "Soumya Deb <[email protected]>",
"license": "MIT"
}
10 changes: 10 additions & 0 deletions src/app/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
html {
font-size: 16px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
margin: auto;
padding: 2rem;
text-align: center;
}
13 changes: 13 additions & 0 deletions src/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>exorcist</title>
<link rel="stylesheet" href="index.css">
<script src="index.js"></script>
</head>
<body>
<h1 id="title">loading...</h1>
<p id="details">loading...</p>
</body>
</html>
7 changes: 7 additions & 0 deletions src/app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

const { ipcRenderer } = require('electron')

ipcRenderer.on('loaded', (event, data) => {
document.getElementById('title').innerHTML = data.appName
document.getElementById('details').innerHTML = 'built with Electron v' + data.electronVersion
})
35 changes: 35 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Application entrypoint

const { app, BrowserWindow } = require('electron');
const config = require('../config/window.json')

// Global reference of the window object
let window;

const createWindow = () => {
window = new BrowserWindow(config);

window.loadFile(`${__dirname}/app/index.html`);

// window.webContents.openDevTools()

window.webContents.on('did-finish-load', () => {
window.webContents.send('loaded', {
appName: 'exorcist',
electronVersion: process.versions.electron
})
})

// Reset the window object when closed
window.on('closed', () => {
window = null;
});
};

// Electron has finished initialization
app.on('ready', createWindow);

// Quit when all windows are closed.
app.on('window-all-closed', () => {
app.quit();
});

0 comments on commit 4c31249

Please sign in to comment.