Skip to content

Commit

Permalink
Merge branch '0.0.47'
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmflynn committed Nov 30, 2024
2 parents e787c76 + 2f1de49 commit cbecfd3
Show file tree
Hide file tree
Showing 21 changed files with 6,430 additions and 7,855 deletions.
Binary file modified .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode
.DS_Store

# Global Workspace
.commoners
Expand Down
27 changes: 8 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
# commoners-starter-kit
A cross-platform app for testing the [`commoners`](commoners.dev) build tool.
A cross-platform app built using [`commoners`](commoners.dev).

When new changes are pushed to `main`, this application will automatically be built and distributed in the following formats:
## Overview
This repository is configured to automatically build and distribute the application and its related services when new changes are pushed to `main`.

### Distribution Formats
- [x] Web — Progressive Web App (PWA)
- [x] Mac
- [x] Windows
- [x] Linux
- [ ] iOS
- [ ] Android

Related services will be hosted using [Railway](https://railway.app/), where following considerations apply:
<!-- The TypeScript service is hosted using [Railway](https://railway.app/), where following considerations apply:
> **Note:** As of November 2023, choosing your [build providers](https://docs.railway.app/deploy/builds#build-providers) is a [Priority Boarding](https://docs.railway.app/reference/priority-boarding) feature, where you'll have to link your Discord account to support this.
1. When registering each service, set the `build` command to something useless (e.g. `node -v`) and run only a single service at a time (e.g. `npm run dev --service node`)
2. For each service, generate a domain in the Networking tab. Paste this into your `commoners.config.ts` file

## Running the Application
To run the Python server, you'll need to create a `conda` environment from the `environment.yml` file.

After this, activate the `commoners-starter-kit` environment (`conda activate commoners-starter-kit`).

You can then run `npm run dev` to start the development server on your default browser—or `npm start` to begin developing for desktop!

To populate the UI with an interactive UI for the `python` service (documented with the OpenAPI specification), run `npm run share` (**desktop** only).

## Current Issues
### Railway Service Deployment
1. Cannot connect to Railway Node server because our WebSocket connection is not secure (http is fine...)
2. Selecting [build providers](https://docs.railway.app/deploy/builds#build-providers) is an premium feature, and our app auto-registers as Node only. So the Railway Python server fails with `Error: spawn python ENOENT` because there is no Python installed.
1. When registering each service, set the `build` command to something useless (e.g. `node -v`) and run only a single service at a time (e.g. `npm run build -- --service service && npm run launch -- --service service`).
2. For each service, generate a domain in the Networking tab. Paste this into the `commoners.config.ts` file -->
105 changes: 7 additions & 98 deletions commoners.config.ts
Original file line number Diff line number Diff line change
@@ -1,112 +1,21 @@
// ------------- PRODUCTION -------------
import * as bluetoothPlugin from '@commoners/bluetooth'
import * as serialPlugin from '@commoners/serial'
import localServicesPlugin from '@commoners/local-services'
// import { defineConfig } from 'commoners' // NOTE: commoners dependencies are missing in local development...

// // ------------- DEVELOPMENT -------------
// import * as bluetoothPlugin from '../commoners/packages/plugins/devices/ble/index.js'
// import * as serialPlugin from '../commoners/packages/plugins/devices/serial/index.js'
// import localServicesPlugin from '../commoners/packages/plugins/local-services/index.js'
// import { defineConfig } from '../commoners/packages/core/index' // NOTE: commoners dependencies are missing in local development...

// ------------- PACKAGE CHANGES -------------
// "commoners": "file:../commoners/packages/cli",


const defineConfig = (o) => o
// import { defineConfig } from '@commoners/solidarity/config';
const defineConfig = (o) => o

export default defineConfig({

// icon: './icon.png',
icon: './icon.png',

electron: {
splash: './splash.html',
window: {
width: 1000 // Adjust default width
}
},


plugins: {
bluetooth: bluetoothPlugin,
serial: serialPlugin,
localServices: localServicesPlugin((ip, env) => {
const isLocalIP = ip === 'localhost'
const hasAuthString = process.env.SHARE_SECRET_KEY === env.SHARE_SECRET_KEY
return hasAuthString || isLocalIP
}),

selectiveBuilds:{
isSupported: {
desktop: {
load: true
},
mobile: {
load: true
},
web: {
load: false
}
},
main: () => {
console.log(`desktop build (main)`)
},
preload: () => {
console.log(commoners.target + ' build (preload)')
},
render: () => console.log(commoners.target + ' build (render)'),

}
window: { width: 1000 }
},

services: {

// Packaged with pkg
dynamicNode: {
description: 'A simple Node.js server',
src: './src/services/node/index.js',
publish: 'https://node-production-aa81.up.railway.app/'
},

devNode: {
description: 'A development Node.js server',
src: './src/services/node/index.js',
publish: false // NOTE: Must try sending messages and checking
},

localNode: {
description: 'A local Node.js server',
src: './src/services/node/index.js',
publish: true

// {
// // local: true,
// // local: './dist/services/node/index', // NOTE: This actually doesn't change the output location...
// remote: false // Must include to remove auto-built service from remote
// }
},

// Packaged with pyinstaller
python: {
description: 'A simple Python server',
src: './src/services/python/main.py',
port: 1111,
service: {
src:'./src/service/index.ts',
publish: {
build: 'python -m PyInstaller --name flask --onedir --clean ./src/services/python/main.py --distpath ./build/python',
remote: 'https://python-production-4f11.up.railway.app',
local: {
src: 'flask',
base: './build/python/flask', // Will be copied
}
remote: 'https://node-production-aa81.up.railway.app/'
}
},

remote: 'https://jsonplaceholder.typicode.com',

dynamic: {
src: 'http://localhost:1111', // Call the python server in development
publish: 'https://jsonplaceholder.typicode.com'
}
}
})
11 changes: 0 additions & 11 deletions environment.yml

This file was deleted.

6 changes: 0 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Kanit">
<link rel="stylesheet" href="/src/frontend/styles.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Commoners Starter Kit</title>
<script type="module" src="/src/frontend/main.ts" defer></script>
<script src="https://unpkg.com/swagger-client"></script>
</head>

<body>
Expand All @@ -19,10 +17,6 @@ <h1>Commoners Starter Kit</h1>
<div id="console">
<div id="messages"></div>
</div>
<ul id="commands">
<li>Connect to Serial Device <button id="testSerialConnection">Run</button></li>
<li>Connect to Bluetooth Device <button id="testBluetoothConnection">Run</button></li>
</ul>
</main>
<footer>
<small>Built with ✊ by Garrett Flynn</small>
Expand Down
Loading

0 comments on commit cbecfd3

Please sign in to comment.