Skip to content

Commit

Permalink
had to fix some gulp build issues first
Browse files Browse the repository at this point in the history
  • Loading branch information
daed committed Feb 25, 2019
1 parent 60b1fba commit 39a0dab
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 10 deletions.
23 changes: 21 additions & 2 deletions electron/electron.js
Expand Up @@ -3,8 +3,21 @@ const {Menu} = require('electron'),

const windowStateKeeper = require('electron-window-state');
const {app, BrowserWindow} = require('electron');
const http = require('http');
const serveStatic = require('serve-static');
const finalHandler = require('finalhandler');

let win;

const port = 9000;
let server;
var serve = serveStatic(__dirname + '/dist', {index: ['index.html']});
server = http.createServer(function(req, res) {
var done = finalHandler(req, res);
serve(req, res, done);
});
encryptic = server.listen(port);

const menuTemplate = [
{
label : '&File',
Expand Down Expand Up @@ -68,6 +81,7 @@ const menuTemplate = [
},
];


function createWindow() {
const mainWindowState = windowStateKeeper({
defaultWidth : 1000,
Expand All @@ -89,16 +103,21 @@ function createWindow() {
process.platform === 'darwin' ? 'IconMenubarTemplate.png' : 'icon.png'
),
});

mainWindowState.manage(win);
Menu.setApplicationMenu(Menu.buildFromTemplate(menuTemplate));

win.on('closed', () => win = null);

// this kills dropbox: redirect_uri=file:///home/brad/src/encryptic/release/Encryptic-0.0.3-linux-x64/resources/app/dist/index.html
// dropbox HAS to have http
//win.loadFile('./dist/index.html');

win.loadFile('./dist/index.html');
win.loadURL('http://localhost:' + port);
}

app.on('ready', createWindow);
app.on('window-all-closed', () => {
app.quit();
});

22 changes: 21 additions & 1 deletion gulps/electron.js
Expand Up @@ -2,6 +2,7 @@
const request = require('request');
const fs = require('fs');
const unzip = require('unzip');
const path = require('path');

const opt = {
version : '4.0.4',
Expand Down Expand Up @@ -64,8 +65,11 @@ module.exports = function(gulp, plugins, pkg) {
.pipe(gulp.dest(targetDir))
.on('finish', () => {
if (plat === 'darwin-x64') {
// osx has to be hard
const path = `${releaseDir}/encryptic.app`;
rmEntireDir(path);
fs.renameSync(`${releaseDir}/Electron.app`,
`${releaseDir}/encryptic.app`);
path);
}
else if (plat === 'win32-ia32' || plat === 'win32-x64') {
fs.renameSync(`${releaseDir}/electron.exe`,
Expand All @@ -74,6 +78,7 @@ module.exports = function(gulp, plugins, pkg) {
else {
fs.renameSync(`${releaseDir}/electron`,
`${releaseDir}/encryptic`);
fs.chmodSync(`${releaseDir}/encryptic`, '0755');
}

if (!opt.package) {
Expand Down Expand Up @@ -142,4 +147,19 @@ module.exports = function(gulp, plugins, pkg) {

return Promise.all(promises);
};

function rmEntireDir(dir_path) {
if (fs.existsSync(dir_path)) {
fs.readdirSync(dir_path).forEach(function(entry) {
var entry_path = path.join(dir_path, entry);
if (fs.lstatSync(entry_path).isDirectory()) {
rmEntireDir(entry_path);
} else {
fs.unlinkSync(entry_path);
}
});
fs.rmdirSync(dir_path);
}
}

};
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -38,7 +38,7 @@
"codemirror": "^5.42.0",
"debug": "^4.1.0",
"device-detect.js": "^0.2.7",
"dropbox": "^4.0.14",
"dropbox": "^4.0.16",
"dropzone": "^5.2.0",
"es6-promise": "^4.2.2",
"fast-json-patch": "^2.0.6",
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Expand Up @@ -622,7 +622,7 @@
globals "^11.1.0"
lodash "^4.17.10"

"@babel/types@^7.0.0", "@babel/types@^7.3.2":
"@babel/types@^7.0.0":
version "7.3.2"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.3.2.tgz#424f5be4be633fff33fb83ab8d67e4a8290f5a2f"
integrity sha512-3Y6H8xlUlpbGR+XvawiH0UXehqydTmNmEpozWcXymqwcrwYAl5KMvKtQ+TF6f6E08V6Jur7v/ykdDSF+WDEIXQ==
Expand Down Expand Up @@ -3256,10 +3256,10 @@ domexception@^1.0.1:
dependencies:
webidl-conversions "^4.0.2"

dropbox@^4.0.14:
version "4.0.15"
resolved "https://registry.yarnpkg.com/dropbox/-/dropbox-4.0.15.tgz#d7d1eb6d4c78092da1886d04313dc673139f14d2"
integrity sha512-+6a0bGmdjOPMWdUS+ufve8JgOi9p8/Cp+ETStvh2gpvolSoOhq02H82yykztvKHGLsZCNhfDmqJZpfNBzptKsg==
dropbox@^4.0.16:
version "4.0.16"
resolved "https://registry.yarnpkg.com/dropbox/-/dropbox-4.0.16.tgz#be5d486b2f821db74d0394c0a862fc43500c03dd"
integrity sha512-wo0XYl9VbsR8gpDSXOPVI02ok8jxZHTZHxgtrJGd3ufB/JwtMlghOqgRAoa4vES1r76ACbNNKMi3Fuwiu9LtvQ==
dependencies:
buffer "^5.0.8"
moment "^2.19.3"
Expand Down Expand Up @@ -3505,7 +3505,7 @@ es-abstract@^1.5.1:
is-callable "^1.1.3"
is-regex "^1.0.4"

es-to-primitive@^1.2.0:
es-to-primitive@^1.1.1, es-to-primitive@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.0.tgz#edf72478033456e8dda8ef09e00ad9650707f377"
integrity sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==
Expand Down

0 comments on commit 39a0dab

Please sign in to comment.