generator-electron

This commit is contained in:
szTheory 2019-12-05 00:07:43 -05:00
commit d36f1c8699
14 changed files with 749 additions and 0 deletions

1
.gitattributes vendored Normal file
View file

@ -0,0 +1 @@
* text=auto eol=lf

281
.gitignore vendored Normal file
View file

@ -0,0 +1,281 @@
# ELECTRON/NODE
node_modules
yarn.lock
/dist
# MORE ELECTRON
.DS_Store
.env
.gclient_done
**/.npmrc
.tags*
.vs/
.vscode/
*.log
*.pyc
*.sln
*.swp
*.VC.db
*.VC.VC.opendb
*.vcxproj
*.vcxproj.filters
*.vcxproj.user
*.xcodeproj
/.idea/
/dist/
/external_binaries/
/out/
/vendor/.gclient
/vendor/debian_jessie_mips64-sysroot/
/vendor/debian_stretch_amd64-sysroot/
/vendor/debian_stretch_arm-sysroot/
/vendor/debian_stretch_arm64-sysroot/
/vendor/debian_stretch_i386-sysroot/
/vendor/gcc-4.8.3-d197-n64-loongson/
/vendor/readme-gcc483-loongson.txt
/vendor/download/
/vendor/llvm-build/
/vendor/llvm/
/vendor/npm/
/vendor/python_26/
/vendor/native_mksnapshot
/vendor/LICENSES.chromium.html
/vendor/pyyaml
node_modules/
SHASUMS256.txt
**/package-lock.json
compile_commands.json
.envrc
# npm package
/npm/dist
/npm/path.txt
.npmrc
# Generated API definitions
electron-api.json
electron.d.ts
# Spec hash calculation
spec/.hash
# Eslint Cache
.eslintcache
# Generated native addon files
/spec-main/fixtures/native-addon/echo/build/
# If someone runs tsc this is where stuff will end up
ts-gen
# Used to accelerate CI builds
.depshash
.depshash-target
#LINUX
#
# NOTE! Don't add files that are generated in specific
# subdirectories here. Add them in the ".gitignore" file
# in that subdirectory instead.
#
# NOTE! Please use 'git ls-files -i --exclude-standard'
# command after changing this file, to see if there are
# any tracked files which get ignored after the change.
#
# Normal rules (sorted alphabetically)
#
.*
*.a
*.asn1.[ch]
*.bin
*.bz2
*.c.[012]*.*
*.dt.yaml
*.dtb
*.dtb.S
*.dwo
*.elf
*.gcno
*.gz
*.i
*.ko
*.lex.c
*.ll
*.lst
*.lz4
*.lzma
*.lzo
*.mod
*.mod.c
*.o
*.o.*
*.patch
*.s
*.so
*.so.dbg
*.su
*.symtypes
*.tab.[ch]
*.tar
*.xz
Module.symvers
modules.builtin
modules.order
#
# Top-level generic files
#
/tags
/TAGS
/linux
/vmlinux
/vmlinux.32
/vmlinux-gdb.py
/vmlinuz
/System.map
/Module.markers
/modules.builtin.modinfo
/modules.nsdeps
#
# RPM spec file (make rpm-pkg)
#
/*.spec
#
# Debian directory (make deb-pkg)
#
/debian/
#
# Snap directory (make snap-pkg)
#
/snap/
#
# tar directory (make tar*-pkg)
#
/tar-install/
#
# We don't want to ignore the following even if they are dot-files
#
!.clang-format
!.cocciconfig
!.get_maintainer.ignore
!.gitattributes
!.gitignore
!.mailmap
#
# Generated include files
#
/include/config/
/include/generated/
/include/ksym/
/arch/*/include/generated/
# stgit generated dirs
patches-*
# quilt's files
patches
series
# cscope files
cscope.*
ncscope.*
# gnu global files
GPATH
GRTAGS
GSYMS
GTAGS
# id-utils files
ID
*.orig
*~
\#*#
#
# Leavings from module signing
#
extra_certificates
signing_key.pem
signing_key.priv
signing_key.x509
x509.genkey
# Kconfig presets
/all.config
/alldef.config
/allmod.config
/allno.config
/allrandom.config
/allyes.config
# Kdevelop4
*.kdev4
# Clang's compilation database file
/compile_commands.json
# WINDOWS
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# MAC
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

BIN
build/background.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 914 B

BIN
build/background@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

BIN
build/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 KiB

8
config.js Normal file
View file

@ -0,0 +1,8 @@
'use strict';
const Store = require('electron-store');
module.exports = new Store({
defaults: {
favoriteAnimal: '🦄'
}
});

43
index.css Normal file
View file

@ -0,0 +1,43 @@
html,
body {
padding: 0;
margin: 0;
background: transparent;
}
/* Use OS default fonts */
body {
font-family: -apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen-Sans,
Ubuntu,
Cantarell,
'Helvetica Neue',
sans-serif,
'Apple Color Emoji',
'Segoe UI Emoji',
'Segoe UI Symbol';
text-rendering: optimizeLegibility;
font-feature-settings: 'liga', 'clig', 'kern';
}
header {
position: absolute;
width: 500px;
height: 250px;
top: 50%;
left: 50%;
margin-top: -125px;
margin-left: -250px;
text-align: center;
}
header h1 {
font-size: 60px;
font-weight: 200;
margin: 0;
padding: 0;
opacity: 0.7;
}

18
index.html Normal file
View file

@ -0,0 +1,18 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>exifcleaner</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<div class="container">
<header>
<h1>exifcleaner</h1>
<p></p>
</header>
<section class="main"></section>
<footer></footer>
</div>
</body>
</html>

90
index.js Normal file
View file

@ -0,0 +1,90 @@
'use strict';
const path = require('path');
const {app, BrowserWindow, Menu} = require('electron');
/// const {autoUpdater} = require('electron-updater');
const {is} = require('electron-util');
const unhandled = require('electron-unhandled');
const debug = require('electron-debug');
const contextMenu = require('electron-context-menu');
const config = require('./config');
const menu = require('./menu');
const packageJson = require('./package.json');
unhandled();
debug();
contextMenu();
app.setAppUserModelId(packageJson.build.appId);
// Uncomment this before publishing your first version.
// It's commented out as it throws an error if there are no published versions.
// if (!is.development) {
// const FOUR_HOURS = 1000 * 60 * 60 * 4;
// setInterval(() => {
// autoUpdater.checkForUpdates();
// }, FOUR_HOURS);
//
// autoUpdater.checkForUpdates();
// }
// Prevent window from being garbage collected
let mainWindow;
const createMainWindow = async () => {
const win = new BrowserWindow({
title: app.name,
show: false,
width: 600,
height: 400
});
win.on('ready-to-show', () => {
win.show();
});
win.on('closed', () => {
// Dereference the window
// For multiple windows store them in an array
mainWindow = undefined;
});
await win.loadFile(path.join(__dirname, 'index.html'));
return win;
};
// Prevent multiple instances of the app
if (!app.requestSingleInstanceLock()) {
app.quit();
}
app.on('second-instance', () => {
if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore();
}
mainWindow.show();
}
});
app.on('window-all-closed', () => {
if (!is.macos) {
app.quit();
}
});
app.on('activate', () => {
if (!mainWindow) {
mainWindow = createMainWindow();
}
});
(async () => {
await app.whenReady();
Menu.setApplicationMenu(menu);
mainWindow = await createMainWindow();
const favoriteAnimal = config.get('favoriteAnimal');
mainWindow.webContents.executeJavaScript(`document.querySelector('header p').textContent = 'Your favorite animal is ${favoriteAnimal}'`);
})();

9
license Normal file
View file

@ -0,0 +1,9 @@
MIT License
Copyright (c) szTheory (http://exifcleaner.app)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

179
menu.js Normal file
View file

@ -0,0 +1,179 @@
'use strict';
const path = require('path');
const { app, Menu, shell } = require('electron');
const {
is,
appMenu,
aboutMenuItem,
openUrlMenuItem,
openNewGitHubIssue,
debugInfo
} = require('electron-util');
const config = require('./config');
const showPreferences = () => {
// Show the app's preferences here
};
const helpSubmenu = [
openUrlMenuItem({
label: 'Website',
url: 'https://github.com/szTheory/exifcleaner'
}),
openUrlMenuItem({
label: 'Source Code',
url: 'https://github.com/szTheory/exifcleaner'
}),
{
label: 'Report an Issue…',
click() {
const body = `
<!-- Please succinctly describe your issue and steps to reproduce it. -->
---
${debugInfo()}`;
openNewGitHubIssue({
user: 'szTheory',
repo: 'exifcleaner',
body
});
}
}
];
if (!is.macos) {
helpSubmenu.push(
{
type: 'separator'
},
aboutMenuItem({
icon: path.join(__dirname, 'static', 'icon.png'),
text: 'Created by szTheory'
})
);
}
const debugSubmenu = [
{
label: 'Show Settings',
click() {
config.openInEditor();
}
},
{
label: 'Show App Data',
click() {
shell.openItem(app.getPath('userData'));
}
},
{
type: 'separator'
},
{
label: 'Delete Settings',
click() {
config.clear();
app.relaunch();
app.quit();
}
},
{
label: 'Delete App Data',
click() {
shell.moveItemToTrash(app.getPath('userData'));
app.relaunch();
app.quit();
}
}
];
const macosTemplate = [
appMenu([
{
label: 'Preferences…',
accelerator: 'Command+,',
click() {
showPreferences();
}
}
]),
{
role: 'fileMenu',
submenu: [
{
label: 'Custom'
},
{
type: 'separator'
},
{
role: 'close'
}
]
},
{
role: 'editMenu'
},
{
role: 'viewMenu'
},
{
role: 'windowMenu'
},
{
role: 'help',
submenu: helpSubmenu
}
];
// Linux and Windows
const otherTemplate = [
{
role: 'fileMenu',
submenu: [
{
label: 'Custom'
},
{
type: 'separator'
},
{
label: 'Settings',
accelerator: 'Control+,',
click() {
showPreferences();
}
},
{
type: 'separator'
},
{
role: 'quit'
}
]
},
{
role: 'editMenu'
},
{
role: 'viewMenu'
},
{
role: 'help',
submenu: helpSubmenu
}
];
const template = process.platform === 'darwin' ? macosTemplate : otherTemplate;
if (is.development) {
template.push({
label: 'Debug',
submenu: debugSubmenu
});
}
module.exports = Menu.buildFromTemplate(template);

75
package.json Normal file
View file

@ -0,0 +1,75 @@
{
"name": "exifcleaner",
"productName": "exifcleaner",
"version": "0.0.0",
"description": "My kryptonian app",
"license": "MIT",
"repository": "szTheory/exifcleaner",
"author": {
"name": "szTheory",
"email": "szTheory@users.noreply.github.com",
"url": "exifcleaner.app"
},
"scripts": {
"postinstall": "electron-builder install-app-deps",
"lint": "xo",
"test": "npm run lint",
"start": "electron .",
"pack": "electron-builder --dir",
"dist": "electron-builder --macos --linux --windows",
"release": "np"
},
"dependencies": {
"electron-context-menu": "^0.15.0",
"electron-debug": "^3.0.0",
"electron-store": "^5.1.0",
"electron-unhandled": "^3.0.0",
"electron-updater": "^4.0.6",
"electron-util": "^0.13.0"
},
"devDependencies": {
"electron": "^7.1.1",
"electron-builder": "^21.2.0",
"np": "^5.0.3",
"xo": "^0.25.3"
},
"xo": {
"envs": [
"node",
"browser"
]
},
"np": {
"publish": false,
"releaseDraft": false
},
"build": {
"appId": "com.szTheory.exifcleaner",
"mac": {
"category": "public.app-category.social-networking",
"darkModeSupport": true
},
"dmg": {
"iconSize": 160,
"contents": [
{
"x": 180,
"y": 170
},
{
"x": 480,
"y": 170,
"type": "link",
"path": "/Applications"
}
]
},
"linux": {
"target": [
"AppImage",
"deb"
],
"category": "Network;Chat"
}
}
}

45
readme.md Normal file
View file

@ -0,0 +1,45 @@
# exifcleaner
> My kryptonian app
## Install
*macOS 10.10+, Linux, and Windows 7+ are supported (64-bit only).*
**macOS**
[**Download**](https://github.com/szTheory/exifcleaner/releases/latest) the `.dmg` file.
**Linux**
[**Download**](https://github.com/szTheory/exifcleaner/releases/latest) the `.AppImage` or `.deb` file.
*The AppImage needs to be [made executable](http://discourse.appimage.org/t/how-to-make-an-appimage-executable/80) after download.*
**Windows**
[**Download**](https://github.com/szTheory/exifcleaner/releases/latest) the `.exe` file.
---
## Dev
Built with [Electron](https://electronjs.org).
### Run
```
$ npm install
$ npm start
```
### Publish
```
$ npm run release
```
After Travis finishes building your app, open the release draft it created and click "Publish".

BIN
static/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 KiB