This repository has been archived by the owner on Dec 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
294 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
module.exports = { | ||
"extends": "standard", | ||
"env": { | ||
"browser": true, | ||
"mocha": true, | ||
"node": true | ||
}, | ||
"rules": { | ||
"react/jsx-uses-react": 2, | ||
"react/jsx-uses-vars": 2, | ||
"react/react-in-jsx-scope": 2, | ||
"react/sort-comp": 0, | ||
"react/no-multi-comp": 0, | ||
"comma-dangle": 0, | ||
"id-length": 0, | ||
"new-cap": 0, | ||
"eol-last": 0, | ||
"jsx-quotes": 0, | ||
"consistent-return": 0 | ||
}, | ||
"plugins": [ | ||
"standard", | ||
"react" | ||
] | ||
// "parser": "babel-eslint", | ||
"extends": "standard", | ||
"env": { | ||
"browser": true, | ||
"mocha": true, | ||
"node": true | ||
}, | ||
"rules": { | ||
"react/jsx-uses-react": 2, | ||
"react/jsx-uses-vars": 2, | ||
"react/react-in-jsx-scope": 2, | ||
"react/sort-comp": 0, | ||
"react/no-multi-comp": 0, | ||
"comma-dangle": 0, | ||
"id-length": 0, | ||
"new-cap": 0, | ||
"eol-last": 0, | ||
"jsx-quotes": 0, | ||
"consistent-return": 0 | ||
}, | ||
"plugins": [ | ||
"standard", | ||
"react" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,33 @@ | ||
.DS_Store | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
!/app/node_modules | ||
npm-debug.log | ||
*.test | ||
|
||
# OSX | ||
.DS_Store | ||
|
||
# App packaged | ||
dist | ||
release | ||
main.js | ||
main.js.map |
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict' | ||
|
||
import { app, BrowserWindow } from 'electron' | ||
|
||
let mainWindow = null | ||
|
||
app.on('window-all-closed', () => { | ||
app.quit() | ||
}) | ||
|
||
let winProps = { | ||
width: 1000, | ||
height: 800 | ||
} | ||
|
||
if (process.env.NODE_ENV !== 'development') { | ||
winProps = { | ||
width: 800, | ||
height: 350, | ||
frame: true, | ||
resizeable: false | ||
} | ||
} | ||
|
||
app.on('ready', () => { | ||
mainWindow = new BrowserWindow(winProps) | ||
|
||
// mainWindow.loadURL('http://douban.fm') | ||
|
||
mainWindow.loadURL(`file://${__dirname}/index.html`) | ||
|
||
// if (process.env.NODE_ENV === 'development') { | ||
mainWindow.webContents.openDevTools() | ||
// } | ||
|
||
mainWindow.on('closed', () => { | ||
mainWindow = null | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
'use strict' | ||
|
||
import os from 'os' | ||
import webpack from 'webpack' | ||
import packager from 'electron-packager' | ||
import del from 'del' | ||
import { exec } from 'child_process' | ||
import parseArgs from 'minimist' | ||
|
||
import electronCfg from './webpack.config.electron' | ||
import proCfg from './webpack.config.pro' | ||
import pkg from './package' | ||
|
||
const argv = parseArgs(process.argv.slice(2)) | ||
|
||
// const deps = Object.keys(pkg.dependencies) | ||
// const devDeps = Object.keys(pkg.devDependencies) | ||
|
||
const appName = argv.name || argv.n || pkg.productName | ||
const shouldUseAsar = argv.asar || argv.a || false | ||
const shouldBuildAll = argv.all || false | ||
|
||
const DEFAULT_OPTS = { | ||
dir: './', | ||
name: appName, | ||
asar: shouldUseAsar, | ||
ignore: [ | ||
'/test($|/)', | ||
'/tools($|/)', | ||
'/release($|/)', | ||
'/main.dev.js', | ||
'webpack.config.*', | ||
'screen.png', | ||
'/node_modules/', | ||
'/app/' | ||
] | ||
// .concat(devDeps.map((name) => `/node_modules/${name}($|/)`)) | ||
// .concat( | ||
// deps.filter((name) => !electronCfg.externals.includes(name)) | ||
// .map((name) => `/node_modules/${name}($|/)`) | ||
// ) | ||
} | ||
|
||
const icon = argv.icon || argv.i || 'icons/logo' | ||
|
||
if (icon) { | ||
DEFAULT_OPTS.icon = icon | ||
} | ||
|
||
const version = argv.version || argv.v | ||
|
||
if (version) { | ||
DEFAULT_OPTS.version = version | ||
startPack() | ||
} else { | ||
// use the same version as the currently-installed electron-prebuilt | ||
exec('npm list electron-prebuilt --dev', (err, stdout) => { | ||
if (err) { | ||
DEFAULT_OPTS.version = '0.37.6' | ||
} else { | ||
DEFAULT_OPTS.version = stdout.split('electron-prebuilt@')[1].replace(/\s/g, '') | ||
} | ||
startPack() | ||
}) | ||
} | ||
|
||
function build (cfg) { | ||
return new Promise((resolve, reject) => { | ||
webpack(cfg, (err, stats) => { | ||
if (err) return reject(err) | ||
resolve(stats) | ||
}) | ||
}) | ||
} | ||
|
||
function startPack () { | ||
console.log('start pack...') | ||
build(electronCfg) | ||
.then(() => build(proCfg)) | ||
.then(() => del('release/**', { force: true })) | ||
.then((paths) => { | ||
if (shouldBuildAll) { | ||
// build for all platforms | ||
const archs = ['ia32', 'x64'] | ||
const platforms = ['linux', 'win32', 'darwin'] | ||
|
||
platforms.forEach((plat) => { | ||
archs.forEach((arch) => { | ||
pack(plat, arch, log(plat, arch)) | ||
}) | ||
}) | ||
} else { | ||
// build for current platform only | ||
pack(os.platform(), os.arch(), log(os.platform(), os.arch())) | ||
} | ||
}) | ||
.catch((err) => { | ||
console.error(err) | ||
}) | ||
} | ||
|
||
function pack (plat, arch, cb) { | ||
// there is no darwin ia32 electron | ||
if (plat === 'darwin' && arch === 'ia32') return | ||
|
||
const iconObj = { | ||
icon: DEFAULT_OPTS.icon + (() => { | ||
let extension = '.png' | ||
if (plat === 'darwin') { | ||
extension = '.icns' | ||
} else if (plat === 'win32') { | ||
extension = '.ico' | ||
} | ||
return extension | ||
})() | ||
} | ||
|
||
const opts = Object.assign({}, DEFAULT_OPTS, iconObj, { | ||
platform: plat, | ||
arch, | ||
prune: true, | ||
'app-version': pkg.version || DEFAULT_OPTS.version, | ||
out: `release/${plat}-${arch}` | ||
}) | ||
|
||
packager(opts, cb) | ||
} | ||
|
||
function log (plat, arch) { | ||
return (err, filepath) => { | ||
if (err) return console.error(err) | ||
console.log(`${plat}-${arch} finished!`) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.