From 4c42195989395b533bfbff08565110ddc852be61 Mon Sep 17 00:00:00 2001 From: Theenoro Date: Wed, 9 Aug 2017 23:00:01 +0200 Subject: [PATCH 1/2] 1.2.0 Beta --- .compilerc | 42 ++++++++++ .eslintrc | 9 +++ .gitignore | 6 +- index.js | 35 --------- package.json | 74 ++++++++++++++---- {app => src/app}/js/app.js | 0 .../libs/bootstrap/css/bootstrap-theme.css | 0 .../bootstrap/css/bootstrap-theme.css.map | 0 .../bootstrap/css/bootstrap-theme.min.css | 0 .../bootstrap/css/bootstrap-theme.min.css.map | 0 .../app}/libs/bootstrap/css/bootstrap.css | 0 .../app}/libs/bootstrap/css/bootstrap.css.map | 0 .../app}/libs/bootstrap/css/bootstrap.min.css | 0 .../libs/bootstrap/css/bootstrap.min.css.map | 0 .../fonts/glyphicons-halflings-regular.eot | Bin .../fonts/glyphicons-halflings-regular.svg | 0 .../fonts/glyphicons-halflings-regular.ttf | Bin .../fonts/glyphicons-halflings-regular.woff | Bin .../fonts/glyphicons-halflings-regular.woff2 | Bin .../app}/libs/bootstrap/js/bootstrap.js | 0 .../app}/libs/bootstrap/js/bootstrap.min.js | 0 {app => src/app}/libs/bootstrap/js/npm.js | 0 .../app}/libs/jquery/jquery-3.2.1.min.js | 0 {app => src/app}/style/progress.css | 0 {app => src/app}/view/layout.html | 0 {controller => src/controller}/youtube-dl.js | 0 src/index.html | 10 +++ src/index.js | 53 +++++++++++++ {lib => src/lib}/dummy | 0 29 files changed, 177 insertions(+), 52 deletions(-) create mode 100644 .compilerc create mode 100644 .eslintrc delete mode 100644 index.js rename {app => src/app}/js/app.js (100%) rename {app => src/app}/libs/bootstrap/css/bootstrap-theme.css (100%) rename {app => src/app}/libs/bootstrap/css/bootstrap-theme.css.map (100%) rename {app => src/app}/libs/bootstrap/css/bootstrap-theme.min.css (100%) rename {app => src/app}/libs/bootstrap/css/bootstrap-theme.min.css.map (100%) rename {app => src/app}/libs/bootstrap/css/bootstrap.css (100%) rename {app => src/app}/libs/bootstrap/css/bootstrap.css.map (100%) rename {app => src/app}/libs/bootstrap/css/bootstrap.min.css (100%) rename {app => src/app}/libs/bootstrap/css/bootstrap.min.css.map (100%) rename {app => src/app}/libs/bootstrap/fonts/glyphicons-halflings-regular.eot (100%) rename {app => src/app}/libs/bootstrap/fonts/glyphicons-halflings-regular.svg (100%) rename {app => src/app}/libs/bootstrap/fonts/glyphicons-halflings-regular.ttf (100%) rename {app => src/app}/libs/bootstrap/fonts/glyphicons-halflings-regular.woff (100%) rename {app => src/app}/libs/bootstrap/fonts/glyphicons-halflings-regular.woff2 (100%) rename {app => src/app}/libs/bootstrap/js/bootstrap.js (100%) rename {app => src/app}/libs/bootstrap/js/bootstrap.min.js (100%) rename {app => src/app}/libs/bootstrap/js/npm.js (100%) rename {app => src/app}/libs/jquery/jquery-3.2.1.min.js (100%) rename {app => src/app}/style/progress.css (100%) rename {app => src/app}/view/layout.html (100%) rename {controller => src/controller}/youtube-dl.js (100%) create mode 100644 src/index.html create mode 100644 src/index.js rename {lib => src/lib}/dummy (100%) diff --git a/.compilerc b/.compilerc new file mode 100644 index 0000000..8b5712e --- /dev/null +++ b/.compilerc @@ -0,0 +1,42 @@ +{ + "env": { + "development": { + "application/javascript": { + "presets": [ + [ + "env", + { + "targets": { + "electron": 1.6 + } + } + ], + "react" + ], + "plugins": [ + "transform-async-to-generator" + ], + "sourceMaps": "inline" + } + }, + "production": { + "application/javascript": { + "presets": [ + [ + "env", + { + "targets": { + "electron": 1.6 + } + } + ], + "react" + ], + "plugins": [ + "transform-async-to-generator" + ], + "sourceMaps": "none" + } + } + } +} \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..64f1252 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,9 @@ +{ + "extends": "eslint-config-airbnb", + "rules": { + "import/extensions": 0, + "import/no-extraneous-dependencies": 0, + "import/no-unresolved": [2, { "ignore": ["electron"] }], + "linebreak-style": 0 + } +} diff --git a/.gitignore b/.gitignore index 12b972d..eabeb50 100644 --- a/.gitignore +++ b/.gitignore @@ -61,4 +61,8 @@ typings/ ffmpeg* ffplay* ffprobe* -lib/youtube-dl* +src/lib/youtube-dl* + +node_modules +out + *.exe diff --git a/index.js b/index.js deleted file mode 100644 index 9c5a834..0000000 --- a/index.js +++ /dev/null @@ -1,35 +0,0 @@ -const path = require('path'); -global.dir = path.join(__dirname); -const { - app, - BrowserWindow, - Menu, - dialog, - ipcMain -} = require('electron'); -const fs = require('fs'); -const yt_dl = require('./controller/youtube-dl') - -var win ; - -app.getPath('documents') -app.on('ready', () => { - win = new BrowserWindow({ - width: 1010, - height: 800, - minWidth: 1010, - minHeight: 565, - show: false, - frame: true - }) - win.loadURL(`file://${__dirname}/app/view/layout.html`) - win.once('ready-to-show', () => { - win.show() - //var x = new yt_dl("https://www.youtube.com/watch?v=UbQgXeY_zi4") - //x.download(); - }) - - win.on('closed', () => { - app.quit(); - }) -}) diff --git a/package.json b/package.json index 11357df..5bb5df2 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,65 @@ { - "name": "electron-simple-youtube-downloader", + "name": "cyb3r-youtube-downloader", + "productName": "cyb3r-youtube-downloader", "version": "1.0.0", - "description": "electron-simple-youtube-downloader", - "main": "index.js", + "description": "My Electron application description", + "main": "src/index.js", + "scripts": { + "start": "electron-forge start", + "package": "electron-forge package", + "make": "electron-forge make", + "lint": "eslint src" + }, + "keywords": [], + "author": "theen", + "license": "MIT", + "config": { + "forge": { + "make_targets": { + "win32": [ + "squirrel" + ], + "darwin": [ + "zip" + ], + "linux": [ + "deb", + "rpm" + ] + }, + "electronPackagerConfig": { + "packageManager": "npm" + }, + "electronWinstallerConfig": { + "name": "cyb3r_youtube_downloader" + }, + "electronInstallerDebian": {}, + "electronInstallerRedhat": {}, + "github_repository": { + "owner": "", + "name": "" + }, + "windowsStoreConfig": { + "packageName": "", + "name": "cyb3ryoutubedownloader" + } + } + }, "dependencies": { + "electron-compile": "^6.4.1", "electron": "^1.6.11", "mkdirp": "^0.5.1", - "request": "^2.81.0", - "youtube-dl": "^1.11.1" + "request": "^2.81.0" }, - "devDependencies": {}, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "start": "electron index.js" - }, - "repository": { - "type": "git", - "url": "https://git.tooru.thee.moe/theenoro/electron-simple-youtube-downloader.git" - }, - "author": "Theenoro", - "license": "ISC" + "devDependencies": { + "babel-plugin-transform-async-to-generator": "^6.24.1", + "babel-preset-env": "^1.6.0", + "babel-preset-react": "^6.24.1", + "electron-prebuilt-compile": "1.6.11", + "eslint": "^3.19.0", + "eslint-config-airbnb": "^15.1.0", + "eslint-plugin-import": "^2.7.0", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-react": "^7.1.0" + } } diff --git a/app/js/app.js b/src/app/js/app.js similarity index 100% rename from app/js/app.js rename to src/app/js/app.js diff --git a/app/libs/bootstrap/css/bootstrap-theme.css b/src/app/libs/bootstrap/css/bootstrap-theme.css similarity index 100% rename from app/libs/bootstrap/css/bootstrap-theme.css rename to src/app/libs/bootstrap/css/bootstrap-theme.css diff --git a/app/libs/bootstrap/css/bootstrap-theme.css.map b/src/app/libs/bootstrap/css/bootstrap-theme.css.map similarity index 100% rename from app/libs/bootstrap/css/bootstrap-theme.css.map rename to src/app/libs/bootstrap/css/bootstrap-theme.css.map diff --git a/app/libs/bootstrap/css/bootstrap-theme.min.css b/src/app/libs/bootstrap/css/bootstrap-theme.min.css similarity index 100% rename from app/libs/bootstrap/css/bootstrap-theme.min.css rename to src/app/libs/bootstrap/css/bootstrap-theme.min.css diff --git a/app/libs/bootstrap/css/bootstrap-theme.min.css.map b/src/app/libs/bootstrap/css/bootstrap-theme.min.css.map similarity index 100% rename from app/libs/bootstrap/css/bootstrap-theme.min.css.map rename to src/app/libs/bootstrap/css/bootstrap-theme.min.css.map diff --git a/app/libs/bootstrap/css/bootstrap.css b/src/app/libs/bootstrap/css/bootstrap.css similarity index 100% rename from app/libs/bootstrap/css/bootstrap.css rename to src/app/libs/bootstrap/css/bootstrap.css diff --git a/app/libs/bootstrap/css/bootstrap.css.map b/src/app/libs/bootstrap/css/bootstrap.css.map similarity index 100% rename from app/libs/bootstrap/css/bootstrap.css.map rename to src/app/libs/bootstrap/css/bootstrap.css.map diff --git a/app/libs/bootstrap/css/bootstrap.min.css b/src/app/libs/bootstrap/css/bootstrap.min.css similarity index 100% rename from app/libs/bootstrap/css/bootstrap.min.css rename to src/app/libs/bootstrap/css/bootstrap.min.css diff --git a/app/libs/bootstrap/css/bootstrap.min.css.map b/src/app/libs/bootstrap/css/bootstrap.min.css.map similarity index 100% rename from app/libs/bootstrap/css/bootstrap.min.css.map rename to src/app/libs/bootstrap/css/bootstrap.min.css.map diff --git a/app/libs/bootstrap/fonts/glyphicons-halflings-regular.eot b/src/app/libs/bootstrap/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from app/libs/bootstrap/fonts/glyphicons-halflings-regular.eot rename to src/app/libs/bootstrap/fonts/glyphicons-halflings-regular.eot diff --git a/app/libs/bootstrap/fonts/glyphicons-halflings-regular.svg b/src/app/libs/bootstrap/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from app/libs/bootstrap/fonts/glyphicons-halflings-regular.svg rename to src/app/libs/bootstrap/fonts/glyphicons-halflings-regular.svg diff --git a/app/libs/bootstrap/fonts/glyphicons-halflings-regular.ttf b/src/app/libs/bootstrap/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from app/libs/bootstrap/fonts/glyphicons-halflings-regular.ttf rename to src/app/libs/bootstrap/fonts/glyphicons-halflings-regular.ttf diff --git a/app/libs/bootstrap/fonts/glyphicons-halflings-regular.woff b/src/app/libs/bootstrap/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from app/libs/bootstrap/fonts/glyphicons-halflings-regular.woff rename to src/app/libs/bootstrap/fonts/glyphicons-halflings-regular.woff diff --git a/app/libs/bootstrap/fonts/glyphicons-halflings-regular.woff2 b/src/app/libs/bootstrap/fonts/glyphicons-halflings-regular.woff2 similarity index 100% rename from app/libs/bootstrap/fonts/glyphicons-halflings-regular.woff2 rename to src/app/libs/bootstrap/fonts/glyphicons-halflings-regular.woff2 diff --git a/app/libs/bootstrap/js/bootstrap.js b/src/app/libs/bootstrap/js/bootstrap.js similarity index 100% rename from app/libs/bootstrap/js/bootstrap.js rename to src/app/libs/bootstrap/js/bootstrap.js diff --git a/app/libs/bootstrap/js/bootstrap.min.js b/src/app/libs/bootstrap/js/bootstrap.min.js similarity index 100% rename from app/libs/bootstrap/js/bootstrap.min.js rename to src/app/libs/bootstrap/js/bootstrap.min.js diff --git a/app/libs/bootstrap/js/npm.js b/src/app/libs/bootstrap/js/npm.js similarity index 100% rename from app/libs/bootstrap/js/npm.js rename to src/app/libs/bootstrap/js/npm.js diff --git a/app/libs/jquery/jquery-3.2.1.min.js b/src/app/libs/jquery/jquery-3.2.1.min.js similarity index 100% rename from app/libs/jquery/jquery-3.2.1.min.js rename to src/app/libs/jquery/jquery-3.2.1.min.js diff --git a/app/style/progress.css b/src/app/style/progress.css similarity index 100% rename from app/style/progress.css rename to src/app/style/progress.css diff --git a/app/view/layout.html b/src/app/view/layout.html similarity index 100% rename from app/view/layout.html rename to src/app/view/layout.html diff --git a/controller/youtube-dl.js b/src/controller/youtube-dl.js similarity index 100% rename from controller/youtube-dl.js rename to src/controller/youtube-dl.js diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..e11c582 --- /dev/null +++ b/src/index.html @@ -0,0 +1,10 @@ + + + + + + + + Well hey there!!! + + diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..4480a44 --- /dev/null +++ b/src/index.js @@ -0,0 +1,53 @@ +const path = require('path'); +global.dir = path.join(__dirname); +const { + app, + BrowserWindow, + Menu, + dialog, + ipcMain +} = require('electron'); +const fs = require('fs'); +const yt_dl = require('./controller/youtube-dl') + +var win ; + +app.getPath('documents') +const createWindow = () =>{ + win = new BrowserWindow({ + width: 1010, + height: 800, + minWidth: 1010, + minHeight: 565, + show: false, + frame: true + }) + win.loadURL(`file://${__dirname}/app/view/layout.html`) + win.once('ready-to-show', () => { + win.show() + //var x = new yt_dl("https://www.youtube.com/watch?v=UbQgXeY_zi4") + //x.download(); + }) + + win.on('closed', () => { + // 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. + win = null; + }); +} +app.on('ready', createWindow); +app.on('window-all-closed', () => { + // 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', () => { + // 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(); + } +}); diff --git a/lib/dummy b/src/lib/dummy similarity index 100% rename from lib/dummy rename to src/lib/dummy From 05a40748c4cbc887c20aaab576a7f9e5bdfcdc77 Mon Sep 17 00:00:00 2001 From: Theenoro Date: Sun, 13 Aug 2017 23:47:09 +0200 Subject: [PATCH 2/2] 1.3.0 --- app.ico | Bin 0 -> 32988 bytes package.json | 14 +-- src/app/view/init.html | 205 +++++++++++++++++++++++++++++++++++++ src/controller/download.js | 126 +++++++++++++++++++++++ src/index.js | 129 ++++++++++++++++------- src/main.js | 46 +++++++++ src/tmp/dummy | 0 7 files changed, 477 insertions(+), 43 deletions(-) create mode 100644 app.ico create mode 100644 src/app/view/init.html create mode 100644 src/controller/download.js create mode 100644 src/main.js create mode 100644 src/tmp/dummy diff --git a/app.ico b/app.ico new file mode 100644 index 0000000000000000000000000000000000000000..cd1b3b056d4b58086c609ead551a93016ab2f962 GIT binary patch literal 32988 zcmeHP36K=!6&~t$d$TMI>mI|p5HNpNb@lc4 z```QC``>@`du_7~vmI({Xt3cp+BP1?^K3TT=+Qf`kG0u;hI=DN?z}$2W_!HRW;+)5 zOXUx>+1|RsW*d)pP|UU*JKbj+Lx3T`5MT%}1Q-Gg0fqoWfFZyTU-i|BI)#L2NMp_X!J-~ z(`Kh+WsRb0DbjPUqth}V59yucB0D!=^F8G*zoxcPfGuc7cB`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>p<%7bhZK{f`u{PO;8Z7xG=g7-P>N{;R6Ce#g&A^HJs_%7sDwn~;mR&^NAi*M9(d zle6bNjA1VWjc@?;yJE&mxoGP#$BFoy@w}f;t_e6LZ_oGk=Gq5bfYvFa#I^3;~7!Lx3T`5MT%}1Q-Gg0fqoWfFZyT QU + + + + + + + + + + + + + + +
+
+
+
+
+
+ +
+
+
+
+
+ + + diff --git a/src/controller/download.js b/src/controller/download.js new file mode 100644 index 0000000..bc0d7bf --- /dev/null +++ b/src/controller/download.js @@ -0,0 +1,126 @@ +const request = require('request'); +const fs = require('fs') +const ipcMain = require('electron').ipcMain; +const unzip = require('unzip') + + +var libsx = { + "ffmpeg":"ffmpeg", + "ffplay":"ffplay", + "ffprobe":"ffprobe", + "youtube-dl":"youtube-dl" +} +var libs = {}; + +libs.listen = null; +libs.libs = null; +ipcMain +.on('download-lib', (event, arg)=>{ + console.log('TEST') + libs.listen = event; + console.log(`This platform is ${process.platform}`); + switch (process.platform) { + case "win32": + for (var lib in libsx) { + libsx[lib] = libsx[lib]+'.exe'; + } + break; + default: + } + for (var lib in libsx) { + if (fs.existsSync(global.dir+"/lib/"+libsx[lib])) { + + }else{ + libsx[lib] = null; + } + } + libs.libs = libsx; + if(libsx['ffmpeg'] === null || libsx['ffplay'] === null || libsx['ffprobe'] === null ){ + var z = 0; + libs.download(libs.ff(process.platform),"ffmpeg",function(data,file){ + fs.createReadStream(file) + .pipe(unzip.Parse()) + .on('entry', function (entry) { + var fileName = entry.path; + var type = entry.type; // 'Directory' or 'File' + var size = entry.size; + console.log(fileName) + if (fileName === "ffmpeg-latest-win32-static/bin/ffmpeg.exe" || fileName === "ffmpeg-latest-win32-static/bin/ffprobe.exe" || fileName === "ffmpeg-latest-win32-static/bin/ffplay.exe") { + entry.pipe(fs.createWriteStream(global.dir+'/lib/'+fileName.split('/')[2])); + console.log('TEST') + z++; + if(z == 3){ + libs.checkNext('youtube-dl'); + } + } else { + entry.autodrain(); + } + }); + }); + }else{ + libs.checkNext('youtube-dl'); + } + console.dir(libsx); +}) +libs.checkNext = (nxt)=>{ + if( libs.libs['youtube-dl'] === null ){ + libs.yt_dl(process.platform,function(){ + libs.startFull(); + }); + }else{ + libs.startFull(); + } +} +libs.startFull = ()=>{ + libs.listen.sender.send('fin-loading',{}); +} +libs.ff = (os)=>{ + var url = ""; + switch (os) { + case "win32": + url = 'http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-latest-win32-static.zip'; + break; + default: + + } + return url; +} +libs.yt_dl = (os,cb)=>{ + var url = ""; + switch (os) { + case "win32": + url = 'https://yt-dl.org/downloads/2017.08.13/youtube-dl.exe' + break; + default: + + } + libs.download(url,"youtube-dl",function(data,file){ + fs.renameSync(file,global.dir+'/lib/youtube-dl.exe'); + cb(); + }) + +} +libs.download = (url,data,cb)=>{ + var r = request(url); + var actual = 1; + var full = 100; + var perc = 0; + r.on('data', function (chunk) { + actual += chunk.length; + perc = actual / full * 100; + console.log(perc); + libs.listen.sender.send('progress',{percent :Math.floor(perc)}); + }); + + r.on('response', function (res) { + res.pipe(fs.createWriteStream(global.dir+'/tmp/' + data + '.' + res.headers['content-type'].split('/')[1])); + full = res.headers[ 'content-length' ] ; + res.on('end', function () { + cb(data,global.dir+'/tmp/' + data + '.' + res.headers['content-type'].split('/')[1]); + }) + }); +} + + + +module.exports = libs; diff --git a/src/index.js b/src/index.js index 4480a44..7c4c4f2 100644 --- a/src/index.js +++ b/src/index.js @@ -9,45 +9,100 @@ const { } = require('electron'); const fs = require('fs'); const yt_dl = require('./controller/youtube-dl') +const dl = require('./controller/download'); -var win ; +if (!fs.existsSync(global.dir+'/tmp/inst')) { + fs.writeFileSync(global.dir+'/tmp/inst',"out"); + var win; + const createWindow = () =>{ + win = new BrowserWindow({ + width: 320, + height: 500, + show: false, + frame: false + }) + win.once('ready-to-show', () => { + }) -app.getPath('documents') -const createWindow = () =>{ - win = new BrowserWindow({ - width: 1010, - height: 800, - minWidth: 1010, - minHeight: 565, - show: false, - frame: true - }) - win.loadURL(`file://${__dirname}/app/view/layout.html`) - win.once('ready-to-show', () => { - win.show() - //var x = new yt_dl("https://www.youtube.com/watch?v=UbQgXeY_zi4") - //x.download(); - }) + win.on('closed', () => { + win = null; + }); + } + app.on('ready', createWindow); + app.on('window-all-closed', () => { + if (process.platform !== 'darwin') { + app.quit(); + } + }); +}else{ + var win ; - win.on('closed', () => { - // 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. - win = null; + + app.getPath('documents') + const createWindow = () =>{ + + //dl.download(dl.ff(process.platform)); + /* + + win = new BrowserWindow({ + width: 1010, + height: 800, + minWidth: 1010, + minHeight: 565, + show: false, + frame: true + }) + */ + win = new BrowserWindow({ + width: 320, + height: 500, + show: false, + frame: false + }) + ipcMain + .on('start-full', (event, arg)=>{ + + var win2 = new BrowserWindow({ + width: 1010, + height: 800, + minWidth: 1010, + minHeight: 565, + show: true, + frame: true + }) + win.close(); + win2.loadURL(`file://${__dirname}/app/view/layout.html`) + win = win2; + }); + win.loadURL(`file://${__dirname}/app/view/init.html`) + win.once('ready-to-show', () => { + win.show() + //var x = new yt_dl("https://www.youtube.com/watch?v=UbQgXeY_zi4") + //x.download(); + }) + + win.on('closed', () => { + // 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. + win = null; + }); + } + app.on('ready', createWindow); + app.on('window-all-closed', () => { + // 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', () => { + // 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(); + } }); } -app.on('ready', createWindow); -app.on('window-all-closed', () => { - // 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', () => { - // 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(); - } -}); + +module.exports = app; diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..4b8fddb --- /dev/null +++ b/src/main.js @@ -0,0 +1,46 @@ +var app = require('./index'); + +var handleStartupEvent = function() { + if (process.platform !== 'win32') { + return false; + } + + var squirrelCommand = process.argv[1]; + console.log(squirrelCommand); + switch (squirrelCommand) { + case '--squirrel-install': + target = path.basename(process.execPath); + updateDotExe = path.resolve(path.dirname(process.execPath), '..', 'update.exe'); + var createShortcut = updateDotExe + ' --createShortcut=' + target + ' --shortcut-locations=Desktop,StartMenu' ; + console.log (createShortcut); + exec(createShortcut); + // Always quit when done + app.quit(); + return true; + + case '--squirrel-uninstall': + // Undo anything you did in the --squirrel-install and + // --squirrel-updated handlers + target = path.basename(process.execPath); + updateDotExe = path.resolve(path.dirname(process.execPath), '..', 'update.exe'); + var createShortcut = updateDotExe + ' --removeShortcut=' + target ; + console.log (createShortcut); + exec(createShortcut); + // Always quit when done + app.quit(); + return true; + case '--squirrel-obsolete': + // This is called on the outgoing version of your app before + // we update to the new version - it's the opposite of + // --squirrel-updated + app.quit(); + return true; + } +}; + +(function(){ + if (handleStartupEvent()) { + return; + } + +}) diff --git a/src/tmp/dummy b/src/tmp/dummy new file mode 100644 index 0000000..e69de29