Skip to content

Commit

Permalink
Merge pull request #11 from jhk0530/main
Browse files Browse the repository at this point in the history
update
  • Loading branch information
jhk0530 authored Jan 29, 2024
2 parents 5906c26 + 5f85a3c commit 88a981c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 89 deletions.
8 changes: 1 addition & 7 deletions [fix] forge.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
module.exports = {
packagerConfig: {},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-zip'
}
]
makers: [{name: '@electron-forge/maker-zip'}]
};
17 changes: 3 additions & 14 deletions [fix] pacakge-json
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,24 @@
"version": "1.0.0",
"description": "My Electron application description",
"main": "src/index.js",
"scripts": {
"start": "electron-forge start",
"make": "electron-forge make"
},
"keywords": [],
"author": {
"name": "jhk0530",
"email": "[email protected]"
},
"license": "MIT",
"repository": {
"repository": {
"type": "git",
"url": "https://github.com/zarathucorp/shiny-electron-template-m1"
},
"dependencies": {
"axios": "0.27.2",
"electron-squirrel-startup": "^1.0.0",
"esm": "^3.2.25",
"execa": "^5.1.1"
},
"devDependencies": {
"@babel/core": "^7.22.20",
"@babel/plugin-transform-async-to-generator": "^7.22.5",
"@babel/preset-env": "^7.22.20",
"@babel/preset-react": "^7.22.15",
"@electron-forge/cli": "^7.2.0",
"@electron-forge/maker-zip": "^7.2.0",
"@electron-forge/plugin-auto-unpack-natives": "^7.2.0",
"electron": "^26.2.1",
"fs-extra": "^11.1.1"
"electron": "^26.6.7",
"fs-extra": "^11.2.0"
}
}
35 changes: 0 additions & 35 deletions src/helpers.js

This file was deleted.

22 changes: 11 additions & 11 deletions src/loading.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ 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.
*/

.spinner {
margin: 100px auto;
width: 50px;
height: 40px;
text-align: center;
font-size: 10px;
}
.spinner {
margin: 100px auto;
width: 50px;
height: 40px;
text-align: center;
font-size: 10px;
}

.spinner > div {
background-color: white;
Expand Down Expand Up @@ -72,8 +72,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}

#status {
text-align: center;
color: white;
font-size: 10px;
font-family: Arial,Helvetica Neue,Helvetica,sans-serif;
text-align: center;
color: white;
font-size: 10px;
font-family: Arial,Helvetica Neue,Helvetica,sans-serif;
}
56 changes: 34 additions & 22 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,47 @@ import {
BrowserWindow
} from 'electron'

import path from 'path'
import http from 'axios'
import os from 'os'
import execa from 'execa'
import {
randomPort,
waitFor,
getRPath
} from './helpers'

const rPath = getRPath(os.platform())
import path from 'path';
import http from 'axios';
import os from 'os';
import execa from 'execa';

let shutdown = false;
// Helpers

const rpath = path.join(app.getAppPath(), rPath)
const libPath = path.join(rpath, 'library')
const rscript = path.join(rpath, 'bin', 'R')
const shinyAppPath = path.join(app.getAppPath(), 'shiny')
const rPath = 'r-mac';

const backgroundColor = '#2c3e50';
const randomPort = (exclude) => {
let min = 3000;
let max = 8000;
let randomInt = Math.floor(Math.random() * (max - min + 1)) + min;
while (exclude.includes(randomInt)) {
randomInt = Math.floor(Math.random() * (max - min + 1)) + min;
}
return randomInt;
}

let rShinyProcess = null;
let shinyPort = randomPort(
[3659, 4045, 5060, 5061, 6000, 6566, 6665, 6666, 6667, 6668, 6669, 6697]
);
// forbiden ports at 2024-01-28
// https://chromium.googlesource.com/chromium/src.git/+/refs/heads/master/net/base/port_util.cc

if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
app.quit()
const waitFor = (milliseconds) => {
return new Promise((resolve, _reject) => {
setTimeout(resolve, milliseconds);
})
}

const rpath = path.join(app.getAppPath(), rPath);
const libPath = path.join(rpath, 'library');
const rscript = path.join(rpath, 'bin', 'R');
const shinyAppPath = path.join(app.getAppPath(), 'shiny');

const backgroundColor = '#2c3e50'; // electron

let shutdown = false;
let rShinyProcess = null;

const tryStartWebserver = async (attempt, progressCallback, onErrorStartup, onErrorLater, onSuccess) => {
if (attempt > 100) {
await progressCallback({attempt: attempt, code: 'failed'})
Expand All @@ -45,8 +59,6 @@ const tryStartWebserver = async (attempt, progressCallback, onErrorStartup, onEr
return
}

let shinyPort = randomPort()

await progressCallback({attempt: attempt, code: 'start'})

let shinyRunning = false
Expand Down

0 comments on commit 88a981c

Please sign in to comment.