2woongjae@gmail.com
// On macOS
electron/Electron.app/Contents/Resources/app/
├── package.json
├── main.js
└── index.html
// On Windows and Linux
electron/resources/app
├── package.json
├── main.js
└── index.html
{
"name": "electron",
"version": "1.0.0",
"description": "프로젝트 설정",
"main": "index.js",
"scripts": {
"start": "electron ."
},
"repository": {
"type": "git",
"url": "git+https://github.com/ts-korea/electron-with-typescript.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/ts-korea/electron-with-typescript/issues"
},
"homepage": "https://github.com/ts-korea/electron-with-typescript#readme",
"devDependencies": {
"electron": "^1.7.5",
"tslint": "^5.7.0",
"typescript": "^2.4.2"
}
}
Marks:electron-basic-online mark$ git clone https://github.com/electron/electron-quick-start.git
Cloning into 'electron-quick-start'...
remote: Counting objects: 255, done.
remote: Total 255 (delta 0), reused 0 (delta 0), pack-reused 255
Receiving objects: 100% (255/255), 42.55 KiB | 0 bytes/s, done.
Resolving deltas: 100% (117/117), done.
Marks:electron-basic-online mark$
Marks:electron-basic-online mark$ cd electron-quick-start/
Marks:electron-quick-start mark$
Marks:electron-quick-start mark$ npm i
> electron@1.6.6 postinstall /Users/mark/Project/electron-basic-online/electron-quick-start/node_modules/electron
> node install.js
electron-quick-start@1.0.0 /Users/mark/Project/electron-basic-online/electron-quick-start
└─┬ electron@1.6.6
├─┬ electron-download@3.3.0
│ ├─┬ debug@2.6.6
│ │ └── ms@0.7.3
│ ├─┬ fs-extra@0.30.0
│ │ ├── graceful-fs@4.1.11
│ │ ├─┬ jsonfile@2.4.0
│ │ │ └── graceful-fs@4.1.11 deduped
│ │ ├─┬ klaw@1.3.1
│ │ │ └── graceful-fs@4.1.11 deduped
│ │ ├── path-is-absolute@1.0.1
│ │ └─┬ rimraf@2.6.1
│ │ └─┬ glob@7.1.1
│ │ ├── fs.realpath@1.0.0
│ │ ├─┬ inflight@1.0.6
│ │ │ ├── once@1.4.0 deduped
│ │ │ └── wrappy@1.0.2
│ │ ├── inherits@2.0.3 deduped
│ │ ├─┬ minimatch@3.0.3
│ │ │ └─┬ brace-expansion@1.1.7
│ │ │ ├── balanced-match@0.4.2
│ │ │ └── concat-map@0.0.1
│ │ ├─┬ once@1.4.0
│ │ │ └── wrappy@1.0.2 deduped
│ │ └── path-is-absolute@1.0.1 deduped
│ ├── home-path@1.0.5
│ ├── minimist@1.2.0
│ ├─┬ nugget@2.0.1
│ │ ├── debug@2.6.6 deduped
│ │ ├── minimist@1.2.0 deduped
│ │ ├─┬ pretty-bytes@1.0.4
│ │ │ ├── get-stdin@4.0.1
│ │ │ └─┬ meow@3.7.0
│ │ │ ├─┬ camelcase-keys@2.1.0
│ │ │ │ ├── camelcase@2.1.1
│ │ │ │ └── map-obj@1.0.1 deduped
│ │ │ ├── decamelize@1.2.0
│ │ │ ├─┬ loud-rejection@1.6.0
│ │ │ │ ├─┬ currently-unhandled@0.4.1
│ │ │ │ │ └── array-find-index@1.0.2
│ │ │ │ └── signal-exit@3.0.2
│ │ │ ├── map-obj@1.0.1
│ │ │ ├── minimist@1.2.0 deduped
│ │ │ ├─┬ normalize-package-data@2.3.8
│ │ │ │ ├── hosted-git-info@2.4.2
│ │ │ │ ├─┬ is-builtin-module@1.0.0
│ │ │ │ │ └── builtin-modules@1.1.1
│ │ │ │ ├── semver@5.3.0 deduped
│ │ │ │ └─┬ validate-npm-package-license@3.0.1
│ │ │ │ ├─┬ spdx-correct@1.0.2
│ │ │ │ │ └── spdx-license-ids@1.2.2
│ │ │ │ └── spdx-expression-parse@1.0.4
│ │ │ ├── object-assign@4.1.1
│ │ │ ├─┬ read-pkg-up@1.0.1
│ │ │ │ ├─┬ find-up@1.1.2
│ │ │ │ │ ├── path-exists@2.1.0 deduped
│ │ │ │ │ └── pinkie-promise@2.0.1 deduped
│ │ │ │ └─┬ read-pkg@1.1.0
│ │ │ │ ├─┬ load-json-file@1.1.0
│ │ │ │ │ ├── graceful-fs@4.1.11 deduped
│ │ │ │ │ ├─┬ parse-json@2.2.0
│ │ │ │ │ │ └─┬ error-ex@1.3.1
│ │ │ │ │ │ └── is-arrayish@0.2.1
│ │ │ │ │ ├── pify@2.3.0
│ │ │ │ │ ├── pinkie-promise@2.0.1 deduped
│ │ │ │ │ └─┬ strip-bom@2.0.0
│ │ │ │ │ └── is-utf8@0.2.1
│ │ │ │ ├── normalize-package-data@2.3.8 deduped
│ │ │ │ └─┬ path-type@1.1.0
│ │ │ │ ├── graceful-fs@4.1.11 deduped
│ │ │ │ ├── pify@2.3.0 deduped
│ │ │ │ └── pinkie-promise@2.0.1 deduped
│ │ │ ├─┬ redent@1.0.0
│ │ │ │ ├─┬ indent-string@2.1.0
│ │ │ │ │ └─┬ repeating@2.0.1
│ │ │ │ │ └─┬ is-finite@1.0.2
│ │ │ │ │ └── number-is-nan@1.0.1 deduped
│ │ │ │ └─┬ strip-indent@1.0.1
│ │ │ │ └── get-stdin@4.0.1 deduped
│ │ │ └── trim-newlines@1.0.0
│ │ ├─┬ progress-stream@1.2.0
│ │ │ ├── speedometer@0.1.4
│ │ │ └─┬ through2@0.2.3
│ │ │ ├─┬ readable-stream@1.1.14
│ │ │ │ ├── core-util-is@1.0.2 deduped
│ │ │ │ ├── inherits@2.0.3 deduped
│ │ │ │ ├── isarray@0.0.1
│ │ │ │ └── string_decoder@0.10.31
│ │ │ └─┬ xtend@2.1.2
│ │ │ └── object-keys@0.4.0
│ │ ├─┬ request@2.81.0
│ │ │ ├── aws-sign2@0.6.0
│ │ │ ├── aws4@1.6.0
│ │ │ ├── caseless@0.12.0
│ │ │ ├─┬ combined-stream@1.0.5
│ │ │ │ └── delayed-stream@1.0.0
│ │ │ ├── extend@3.0.1
│ │ │ ├── forever-agent@0.6.1
│ │ │ ├─┬ form-data@2.1.4
│ │ │ │ ├── asynckit@0.4.0
│ │ │ │ ├── combined-stream@1.0.5 deduped
│ │ │ │ └── mime-types@2.1.15 deduped
│ │ │ ├─┬ har-validator@4.2.1
│ │ │ │ ├─┬ ajv@4.11.8
│ │ │ │ │ ├── co@4.6.0
│ │ │ │ │ └─┬ json-stable-stringify@1.0.1
│ │ │ │ │ └── jsonify@0.0.0
│ │ │ │ └── har-schema@1.0.5
│ │ │ ├─┬ hawk@3.1.3
│ │ │ │ ├─┬ boom@2.10.1
│ │ │ │ │ └── hoek@2.16.3 deduped
│ │ │ │ ├─┬ cryptiles@2.0.5
│ │ │ │ │ └── boom@2.10.1 deduped
│ │ │ │ ├── hoek@2.16.3
│ │ │ │ └─┬ sntp@1.0.9
│ │ │ │ └── hoek@2.16.3 deduped
│ │ │ ├─┬ http-signature@1.1.1
│ │ │ │ ├── assert-plus@0.2.0
│ │ │ │ ├─┬ jsprim@1.4.0
│ │ │ │ │ ├── assert-plus@1.0.0
│ │ │ │ │ ├── extsprintf@1.0.2
│ │ │ │ │ ├── json-schema@0.2.3
│ │ │ │ │ └─┬ verror@1.3.6
│ │ │ │ │ └── extsprintf@1.0.2 deduped
│ │ │ │ └─┬ sshpk@1.13.0
│ │ │ │ ├── asn1@0.2.3
│ │ │ │ ├── assert-plus@1.0.0
│ │ │ │ ├─┬ bcrypt-pbkdf@1.0.1
│ │ │ │ │ └── tweetnacl@0.14.5 deduped
│ │ │ │ ├─┬ dashdash@1.14.1
│ │ │ │ │ └── assert-plus@1.0.0
│ │ │ │ ├─┬ ecc-jsbn@0.1.1
│ │ │ │ │ └── jsbn@0.1.1 deduped
│ │ │ │ ├─┬ getpass@0.1.7
│ │ │ │ │ └── assert-plus@1.0.0
│ │ │ │ ├─┬ jodid25519@1.0.2
│ │ │ │ │ └── jsbn@0.1.1 deduped
│ │ │ │ ├── jsbn@0.1.1
│ │ │ │ └── tweetnacl@0.14.5
│ │ │ ├── is-typedarray@1.0.0
│ │ │ ├── isstream@0.1.2
│ │ │ ├── json-stringify-safe@5.0.1
│ │ │ ├─┬ mime-types@2.1.15
│ │ │ │ └── mime-db@1.27.0
│ │ │ ├── oauth-sign@0.8.2
│ │ │ ├── performance-now@0.2.0
│ │ │ ├── qs@6.4.0
│ │ │ ├── safe-buffer@5.0.1
│ │ │ ├── stringstream@0.0.5
│ │ │ ├─┬ tough-cookie@2.3.2
│ │ │ │ └── punycode@1.4.1
│ │ │ ├─┬ tunnel-agent@0.6.0
│ │ │ │ └── safe-buffer@5.0.1 deduped
│ │ │ └── uuid@3.0.1
│ │ ├─┬ single-line-log@1.1.2
│ │ │ └─┬ string-width@1.0.2
│ │ │ ├── code-point-at@1.1.0
│ │ │ ├─┬ is-fullwidth-code-point@1.0.0
│ │ │ │ └── number-is-nan@1.0.1
│ │ │ └─┬ strip-ansi@3.0.1
│ │ │ └── ansi-regex@2.1.1
│ │ └── throttleit@0.0.2
│ ├─┬ path-exists@2.1.0
│ │ └─┬ pinkie-promise@2.0.1
│ │ └── pinkie@2.0.4
│ ├─┬ rc@1.2.1
│ │ ├── deep-extend@0.4.1
│ │ ├── ini@1.3.4
│ │ ├── minimist@1.2.0 deduped
│ │ └── strip-json-comments@2.0.1
│ ├── semver@5.3.0
│ └─┬ sumchecker@1.3.1
│ ├── debug@2.6.6 deduped
│ └── es6-promise@4.1.0
└─┬ extract-zip@1.6.5
├─┬ concat-stream@1.6.0
│ ├── inherits@2.0.3
│ ├─┬ readable-stream@2.2.9
│ │ ├── buffer-shims@1.0.0
│ │ ├── core-util-is@1.0.2
│ │ ├── inherits@2.0.3 deduped
│ │ ├── isarray@1.0.0
│ │ ├── process-nextick-args@1.0.7
│ │ ├─┬ string_decoder@1.0.0
│ │ │ └── buffer-shims@1.0.0 deduped
│ │ └── util-deprecate@1.0.2
│ └── typedarray@0.0.6
├─┬ debug@2.2.0
│ └── ms@0.7.1
├─┬ mkdirp@0.5.0
│ └── minimist@0.0.8
└─┬ yauzl@2.4.1
└─┬ fd-slicer@1.0.1
└── pend@1.2.0
Marks:electron-quick-start mark$
Marks:electron-quick-start mark$ npm start
> electron-quick-start@1.0.0 start /Users/mark/Project/electron-basic-online/electron-quick-start
> electron .
{
"name": "electron-quick-start",
"version": "1.0.0",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"repository": "https://github.com/electron/electron-quick-start",
"keywords": [
"Electron",
"quick",
"start",
"tutorial",
"demo"
],
"author": "GitHub",
"license": "CC0-1.0",
"devDependencies": {
"electron": "~1.6.2"
}
}
{
"dependencies": {
"electron-download": "^3.0.1",
"extract-zip": "^1.0.3"
}
}
{
"scripts": {
"cache-clean": "rm -rf ~/.electron && rm -rf dist",
"postinstall": "node install.js",
"pretest": "npm run cache-clean && npm run postinstall",
"test": "tape test/*.js && standard"
}
}
#!/usr/bin/env node
// maintainer note - x.y.z-ab version in package.json -> x.y.z
var version = require('./package').version.replace(/-.*/, '')
var fs = require('fs')
var os = require('os')
var path = require('path')
var extract = require('extract-zip')
var download = require('electron-download')
var installedVersion = null
try {
installedVersion = fs.readFileSync(path.join(__dirname, 'dist', 'version'), 'utf-8').replace(/^v/, '')
} catch (ignored) {
// do nothing
}
var platformPath = getPlatformPath()
if (installedVersion === version && fs.existsSync(path.join(__dirname, platformPath))) {
process.exit(0)
}
// downloads if not cached
download({
cache: process.env.electron_config_cache,
version: version,
platform: process.env.npm_config_platform,
arch: process.env.npm_config_arch,
strictSSL: process.env.npm_config_strict_ssl === 'true',
quiet: ['info', 'verbose', 'silly', 'http'].indexOf(process.env.npm_config_loglevel) === -1
}, extractFile)
// unzips and makes path.txt point at the correct executable
function extractFile (err, zipPath) {
if (err) return onerror(err)
extract(zipPath, {dir: path.join(__dirname, 'dist')}, function (err) {
if (err) return onerror(err)
fs.writeFile(path.join(__dirname, 'path.txt'), platformPath, function (err) {
if (err) return onerror(err)
})
})
}
function onerror (err) {
throw err
}
function getPlatformPath () {
var platform = process.env.npm_config_platform || os.platform()
switch (platform) {
case 'darwin':
return 'dist/Electron.app/Contents/MacOS/Electron'
case 'freebsd':
case 'linux':
return 'dist/electron'
case 'win32':
return 'dist/electron.exe'
default:
throw new Error('Electron builds are not available on platform: ' + platform)
}
}
Marks:electron-quick-start mark$ ls -al node_modules/electron/dist/
total 3352
drwxr-xr-x 6 mark staff 204 May 8 01:55 .
drwxr-xr-x 16 mark staff 544 May 8 01:55 ..
drwxr-xr-x 3 mark staff 102 May 8 01:55 Electron.app
-rw-r--r-- 1 mark staff 1060 May 8 01:55 LICENSE
-rw-r--r-- 1 mark staff 1708004 May 8 01:55 LICENSES.chromium.html
-rw-r--r-- 1 mark staff 6 May 8 01:55 version
Marks:electron-quick-start mark$
dist/Electron.app/Contents/MacOS/Electron
{
"name": "electron-quick-start",
"version": "1.0.0",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"repository": "https://github.com/electron/electron-quick-start",
"keywords": [
"Electron",
"quick",
"start",
"tutorial",
"demo"
],
"author": "GitHub",
"license": "CC0-1.0",
"devDependencies": {
"electron": "~1.6.2"
}
}
{
"scripts": {
"start": "electron ."
}
}
electron . => node_modules/.bin/electron .
Marks:electron-quick-start mark$ ls -al node_modules/.bin/
total 112
drwxr-xr-x 16 mark staff 544 May 8 01:55 .
drwxr-xr-x 150 mark staff 5100 May 8 01:55 ..
lrwxr-xr-x 1 mark staff 18 May 8 01:55 electron -> ../electron/cli.js
lrwxr-xr-x 1 mark staff 33 May 8 01:55 electron-download -> ../electron-download/build/cli.js
lrwxr-xr-x 1 mark staff 21 May 8 01:55 extract-zip -> ../extract-zip/cli.js
lrwxr-xr-x 1 mark staff 20 May 8 01:55 mkdirp -> ../mkdirp/bin/cmd.js
lrwxr-xr-x 1 mark staff 16 May 8 01:55 nugget -> ../nugget/bin.js
lrwxr-xr-x 1 mark staff 22 May 8 01:55 pretty-bytes -> ../pretty-bytes/cli.js
lrwxr-xr-x 1 mark staff 14 May 8 01:55 rc -> ../rc/index.js
lrwxr-xr-x 1 mark staff 16 May 8 01:55 rimraf -> ../rimraf/bin.js
lrwxr-xr-x 1 mark staff 20 May 8 01:55 semver -> ../semver/bin/semver
lrwxr-xr-x 1 mark staff 23 May 8 01:55 sshpk-conv -> ../sshpk/bin/sshpk-conv
lrwxr-xr-x 1 mark staff 23 May 8 01:55 sshpk-sign -> ../sshpk/bin/sshpk-sign
lrwxr-xr-x 1 mark staff 25 May 8 01:55 sshpk-verify -> ../sshpk/bin/sshpk-verify
lrwxr-xr-x 1 mark staff 22 May 8 01:55 strip-indent -> ../strip-indent/cli.js
lrwxr-xr-x 1 mark staff 16 May 8 01:55 uuid -> ../uuid/bin/uuid
Marks:electron-quick-start mark$
node_modules/.bin/electron . => node_modules/electron/cli.js
#!/usr/bin/env node
var electron = require('./')
var proc = require('child_process')
var child = proc.spawn(electron, process.argv.slice(2), {stdio: 'inherit'})
child.on('close', function (code) {
process.exit(code)
})
var fs = require('fs')
var path = require('path')
var pathFile = path.join(__dirname, 'path.txt')
if (fs.existsSync(pathFile)) {
module.exports = path.join(__dirname, fs.readFileSync(pathFile, 'utf-8'))
} else {
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
}
dist/Electron.app/Contents/MacOS/Electron
{
"name": "electron-quick-start",
"version": "1.0.0",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"repository": "https://github.com/electron/electron-quick-start",
"keywords": [
"Electron",
"quick",
"start",
"tutorial",
"demo"
],
"author": "GitHub",
"license": "CC0-1.0",
"devDependencies": {
"electron": "~1.6.2"
}
}
{
"main": "main.js"
}
const electron = require('electron')
// Module to control application life.
const app = electron.app
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow
const path = require('path')
const url = require('url')
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow
function createWindow () {
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600})
// and load the index.html of the app.
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}))
// Open the DevTools.
// mainWindow.webContents.openDevTools()
// Emitted when the window is closed.
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
})
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow()
}
})
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<!-- All of the Node.js APIs are available in this renderer process. -->
We are using Node.js <script>document.write(process.versions.node)</script>,
Chromium <script>document.write(process.versions.chrome)</script>,
and Electron <script>document.write(process.versions.electron)</script>.
</body>
<script>
// You can also require other files to run in this process
require('./renderer.js')
</script>
</html>
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
// main process 생성
main.js
// main process 생성 완료 이벤트 바인딩
app.on('ready', createWindow);
// 바인딩 된 함수 실행
createWindow();
// renderer process 생성
mainWindow = new BrowserWindow({width: 800, height: 600});
// renderer process 에 로딩할 컨텐츠 삽입
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}));
// renderer process 의 script 실행
require('renderer.js');