Skip to content

Commit

Permalink
Heroku hosting just UI (#24)
Browse files Browse the repository at this point in the history
* Remove keytar

* optional dependency

* Heroku build

* yarn

* try web directory

* static routes

* Try CDN

* Just trying things now

* proxies

* EDGE_URL

* cacheDirectories

* edge off

* EDGE_URL/web

* try EDGE_URL again

* Maybe it's a CSS thing

* Restore stylesheets

* Fix index.js

* CDN

* Fix buildiong

* end /

* Update server URL

* legacy url fix

* Remove update-server script

* Remove local env setup stuff in favour of just UI

* Remove git modules

* Remove gems and procfile stuff

* Don't use static.json any more

* Automatic github bump
  • Loading branch information
elliottkember authored Apr 6, 2021
1 parent 1c27b33 commit 22cd3ff
Show file tree
Hide file tree
Showing 15 changed files with 265 additions and 107 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ name: Build/release

on:
push:
tags:
- "v*"
branches:
- "master"

jobs:
release:
Expand All @@ -29,6 +29,14 @@ jobs:
- name: Check out Git repository
uses: actions/checkout@v2

- name: "Automated Version Bump"
id: version-bump
uses: "phips28/gh-action-bump-version@master"
with:
tag-prefix: 'v'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/setup-python@v2
with:
python-version: "3.x" # Version range or exact version of a Python version to use, using SemVer's version range syntax
Expand Down
12 changes: 0 additions & 12 deletions .gitmodules

This file was deleted.

9 changes: 0 additions & 9 deletions Gemfile

This file was deleted.

14 changes: 0 additions & 14 deletions Gemfile.lock

This file was deleted.

5 changes: 1 addition & 4 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
ide: yarn; LOCAL=true yarn start
server: cd services/soulmate-server && bundle install --quiet && PORT=3001 bundle exec rails s -p3001
firmware: cd services/soulmate-builder-server && yarn --quiet && PORT=8081 yarn start
emulator: cd services/wokwi-server && yarn --quiet && PORT=8080 yarn start
web: node index.js
26 changes: 1 addition & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,4 @@

### Dev environment

`$ foreman start`

This command runs four processes (Procfile)

```
ide: yarn; LOCAL=true yarn start
server: cd services/soulmate-server && bundle install --quiet && PORT=3001 bundle exec rails s -p3001
firmware: cd services/soulmate-builder-server && yarn --quiet && PORT=8081 yarn start
emulator: cd services/wokwi-server && yarn --quiet && PORT=8080 yarn start
```

- IDE: The local IDE electron app
- server: The Rails app that stores patterns
- firmware: Firmware builder server
- emulator: Wokwi-based arduino emulator hex builder

If something goes wrong and Foreman crashes, use this command to show all running processes:

`lsof -nP -iTCP:3000 -iTCP:3001 -iTCP:8080 -iTCP:8081 |grep -v homed`

This is the best way to run the whole ecosystem at once. You won't get any previews or thumbnails of your local patterns, but that's on the list of things to do. Changes you make to the firmware (soulmate-builder-server/soulmate-core) will be used the next time you flash.

Recursively commit and push everything by running

`./commit-all.sh "Commit all repos at once"`
`$ yarn start`
14 changes: 14 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const fs = require('fs');
const express = require('express')
const path = require('path')
const PORT = process.env.PORT || 5000
const EDGE_URL = process.env.EDGE_URL || '/';

var html = fs.readFileSync("./build/_index.html").toString()
html = html.replaceAll("/src", `${ EDGE_URL}/src`);

express()
.use(express.static(path.join(__dirname, 'build')))
.get('/(*)', (req, res) => res.send(html))
.listen(PORT, () => console.log(`Listening on ${ PORT }`))

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
"electron-log": "^4.3.0",
"electron-root-path": "^1.0.16",
"electron-updater": "^4.3.8",
"keytar": "^7.4.0",
"express": "^4.17.1",
"react-use": "^17.1.1",
"react-user": "^0.1.4",
"serialport": "9.0.2"
},
"optionalDependencies": {
"keytar": "^7.4.0"
},
"devDependencies": {
"@auth0/auth0-spa-js": "^1.13.6",
"@babel/core": "^7.12.10",
Expand Down Expand Up @@ -117,13 +120,13 @@
"@auth0/auth0-spa-js": "./node_modules/@auth0/auth0-spa-js/dist/lib/auth0-spa-js.cjs.js",
"react-dom": "@hot-loader/react-dom"
},
"cacheDirectories": [
".cache"
],
"scripts": {
"react-start": "parcel -p 3000 index.html",
"react-build": "yarn build-worker && parcel build index.html --out-dir build --public-url / --no-source-maps",
"start-servers": "concurrently \"yarn --cwd services/build-server start\" \"docker run -p 8080:8080 -d elliottkember/wokwi-hexi\"",
"start": "concurrently \"cross-env BROWSER=none yarn react-start\" \"wait-on http://localhost:3000 && electron . \" \"yarn build-worker-dev\"",
"start-local": "concurrently \"yarn start-servers\" \"yarn start-app-local\"",
"start-app-local": "concurrently \"cross-env local=true BROWSER=none yarn react-start\" \"wait-on http://localhost:3000 && electron . \" \"yarn build-worker-dev\"",
"rebuild-electron": "yarn node-gyp clean && yarn electron-rebuild",
"build": "yarn build-worker && parcel build index.html --out-dir build --public-url . --no-source-maps",
"// build-app": "Use this for building the app locally to test out a production build",
Expand All @@ -140,10 +143,8 @@
"install-arm": "npm_config_arch=$(uname -m) yarn",
"build-with-dependencies-from-source": "yarn run electron-builder --config.buildDependenciesFromSource=true -mwl",
"web": "NODE_ENV=development parcel index.html --open -p 3000",
"update-server": "(cd services/soulmate-server && ./update-ui.sh) && git add services/soulmate-server && git commit -m 'New server'",
"bump": "yarn version --patch && git push && git push --tags",
"prepare": "husky install",
"heroku-postbuild" : "yarn react-build"
"heroku-postbuild": "yarn build-worker && parcel build index.html --out-dir build --no-source-maps && mv build/index.html build/_index.html"
},
"build": {
"afterSign": "electron-builder-notarize",
Expand Down
1 change: 0 additions & 1 deletion services/soulmate-builder-server
Submodule soulmate-builder-server deleted from 4b12c1
1 change: 0 additions & 1 deletion services/soulmate-server
Submodule soulmate-server deleted from 5d23c0
1 change: 0 additions & 1 deletion services/wokwi-server
Submodule wokwi-server deleted from f182c2
13 changes: 6 additions & 7 deletions src/main/containers/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ let initialSimulatorUrl =
let initialFirmwareUrl =
localStorage.firmwareUrl || "https://firmware.soulmatelights.com:8083/build";

let initialAppServerUrl =
localStorage.appServerUrl || "https://editor.soulmatelights.com/";

if (process.env.LOCAL) {
initialSimulatorUrl = "http://localhost:8081";
initialFirmwareUrl = "http://localhost:8080/build";
initialAppServerUrl = "http://localhost:3001/build";
// Legacy URL
if (localStorage.appServerUrl === "https://editor.soulmatelights.com/") {
localStorage.appServerUrl = "https://server.soulmatelights.com/";
}

let initialAppServerUrl =
localStorage.appServerUrl || "https://server.soulmatelights.com/";

function Config() {
// TODO: Rename to simualtorUrl, firmwareUrl, appServerUrl
const [simulator, setSimulator] = useState(initialSimulatorUrl);
Expand Down
5 changes: 0 additions & 5 deletions static.json

This file was deleted.

4 changes: 0 additions & 4 deletions update-server.sh

This file was deleted.

Loading

0 comments on commit 22cd3ff

Please sign in to comment.