Prepare electron releases

This commit is contained in:
Thomas Nordquist
2019-01-01 23:48:35 +01:00
parent b2badfd43f
commit 5697b2daea
19 changed files with 10823 additions and 880 deletions

4
.gitignore vendored
View File

@@ -1,7 +1,7 @@
node_modules
coverage
backend/coverage
backend/.nyc_output
build
.nyc_output
.DS_Store
test.dot
test.png

993
app/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,20 +4,20 @@
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack --mode production"
"build": "webpack --mode production",
"postinstall": "npm run build"
},
"author": "",
"license": "ISC",
"devDependencies": {
"devDependencies": {},
"dependencies": {
"@types/node": "^10.12.18",
"awesome-typescript-loader": "^5.2.1",
"source-map-loader": "^0.2.4",
"typescript": "^3.2.2",
"webpack": "^4.28.2",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.14"
},
"dependencies": {
"webpack-dev-server": "^3.1.14",
"@material-ui/core": "^3.7.1",
"@types/react": "^16.7.18",
"@types/react-dom": "^16.0.11",

View File

@@ -4,6 +4,11 @@ module.exports = {
filename: "bundle.js",
path: __dirname + "/build"
},
optimization: {
removeAvailableModules: false,
removeEmptyChunks: false,
splitChunks: false,
},
mode: 'production',

3748
backend/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,15 @@
{
"name": "mqtt-explorer",
"name": "mqtt-explorer-backend",
"version": "1.0.0",
"description": "",
"main": "src/index.ts",
"main": "build/index.js",
"scripts": {
"test": "mocha",
"build": "tsc",
"test-inspect": "mocha --inspect-brk",
"coverage": "nyc mocha",
"debug": "ts-node --inspect ./src/index.ts"
"debug": "ts-node --inspect ./src/index.ts",
"postinstall": "npm run build"
},
"author": "",
"license": "ISC",
@@ -34,23 +36,23 @@
"instrument": true
},
"dependencies": {
"@types/sha1": "^1.1.1",
"@types/socket.io": "^2.1.2",
"mqtt": "^2.18.8",
"sha1": "^1.1.1",
"socket.io": "^2.2.0",
"tslint": "^5.12.0",
"typescript": "^3.2.2"
"socket.io": "^2.2.0"
},
"devDependencies": {
"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.5",
"@types/node": "^10.12.18",
"@types/sha1": "^1.1.1",
"@types/socket.io": "^2.1.2",
"chai": "^4.2.0",
"mocha": "^5.2.0",
"nyc": "^13.1.0",
"source-map-support": "^0.5.9",
"ts-node": "^7.0.1",
"tslint-strict-null-checks": "^1.0.1"
"tslint": "^5.12.0",
"tslint-strict-null-checks": "^1.0.1",
"typescript": "^3.2.2"
}
}

View File

@@ -1,10 +1,10 @@
import { DataSourceState } from './'
import { DataSourceStateMachine } from './'
type MessageCallback = (topic: string, payload: Buffer) => void
// A DataSource should automatically reconnect if connection was broken
interface DataSource<DataSourceOptions> {
connect(options: DataSourceOptions): DataSourceState
connect(options: DataSourceOptions): DataSourceStateMachine
disconnect(): void
onMessage(messageCallback: MessageCallback): void
topicSeparator: string

View File

@@ -1,11 +1,13 @@
interface InternalState {
import { EventEmitter } from 'events'
export interface DataSourceState {
connecting: boolean
connected: boolean
error?: Error
}
export class DataSourceState {
private state: InternalState = {
export class DataSourceStateMachine extends EventEmitter {
private state: DataSourceState = {
error: undefined,
connected: false,
connecting: false

View File

@@ -1,5 +1,5 @@
import { Client, connect as mqttConnect } from 'mqtt'
import { DataSource, DataSourceState } from './'
import { DataSource, DataSourceStateMachine } from './'
export interface MqttOptions {
url: string
@@ -15,8 +15,8 @@ export class MqttSource implements DataSource<MqttOptions> {
this.messageCallback = messageCallback
}
public connect(options: MqttOptions): DataSourceState {
const state = new DataSourceState()
public connect(options: MqttOptions): DataSourceStateMachine {
const state = new DataSourceStateMachine()
const client = mqttConnect(options.url, {
resubscribe: false

View File

@@ -1,10 +1,11 @@
import { DataSource } from './DataSource'
import { DataSourceState } from './DataSourceState'
import { DataSourceState, DataSourceStateMachine } from './DataSourceState'
import { MqttOptions, MqttSource } from './MqttSource'
export {
DataSource,
DataSourceState,
DataSourceStateMachine,
MqttOptions,
MqttSource,
}

View File

@@ -1,61 +0,0 @@
import { Tree, TreeNode } from './Model'
export class DotExport {
public static renderNodeInformation(node: TreeNode): string {
return `\t${node.sourceEdge.hash()} [label=${this.renderLabel(node.value)}]`
}
public static toDot(tree: Tree): string {
let i = 1
let leaveEdges = Object.values(tree.edges)
.map(e => e.node)
.map(node => node.leafes())
.reduce((a, b) => a.concat(b), [])
.map(leave => leave.branch())
const allEdges: Array<string> = []
const nodeInformation: {[s: string]: string} = {}
leaveEdges.map(edges => edges.reduce( (prev, current) => {
let currentHash = current.sourceEdge.hash()
nodeInformation[currentHash] = this.renderNodeInformation(current)
if (current && prev) {
allEdges.push(`\t${prev.sourceEdge.hash()} -> ${currentHash} [label=${this.renderLabel(current.sourceEdge.name)}]`)
}
return current
}))
return `strict digraph ethane {
${
[this.renderNodeInformation(tree)]
.concat(Object.values(nodeInformation))
.concat(allEdges)
.join('\n')
}
}`;
}
private static renderLabel(value: any): string {
let str;
if(!isNaN(value)) {
str = value
} else {
str = JSON.stringify(value)
if(str && str.length > 0) {
str = str.slice(1, -1)
}
}
if (!str) {
return '""'
}
if(str.length > 20) {
str = str.slice(0, 20)+'…'
}
if (str[0] !== '"') {
str = `"${str}"`
}
return str
}
}

View File

@@ -3,15 +3,13 @@ import { MqttSource, DataSource } from './DataSource'
import * as socketIO from 'socket.io'
const server = require('http').createServer();
let tree = new Tree()
const http = require('http')
let options = {url: 'mqtt://nodered'}
let dataSource = new MqttSource()
let count = 200
const a: Array<any> = []
const server = http.createServer()
const io = socketIO(server)
io.on('connection', client => {
console.log('connection')

33
build.ts Normal file
View File

@@ -0,0 +1,33 @@
import * as builder from 'electron-builder'
var linux: builder.CliOptions = {
x64: true,
ia32: true,
armv7l: true,
arm64: true,
linux: ['snap', 'AppImage', 'deb', 'pacman'],
};
var win: builder.CliOptions = {
x64: true,
ia32: true,
armv7l: false,
arm64: false,
win: ['portable'],
};
var mac: builder.CliOptions = {
x64: true,
ia32: true,
armv7l: false,
arm64: false,
mac: ['dmg'],
};
async function buildAll() {
await builder.build(linux)
await builder.build(mac)
await builder.build(win)
}
buildAll()

View File

@@ -1,13 +1,13 @@
// Modules to control application life and create native browser window
const {app, BrowserWindow} = require('electron')
require('mqtt-explorer-backend')
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow
function createWindow () {
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600})
mainWindow = new BrowserWindow({width: 1024, height: 600})
// and load the index.html of the app.
mainWindow.loadFile('app/index.html')

6742
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +1,38 @@
{
"name": "mqtt-explorer-electron",
"version": "1.0.0",
"description": "",
"name": "MQ(TT)-Explorer",
"version": "0.0.1",
"description": "Explore your message queues",
"main": "electron.js",
"scripts": {
"start": "electron .",
"build-app": "cd app && npm run build",
"build-backend": "cd backend && tsc",
"build": "npm run build-app && npm run build-backend"
"release": "./release.sh"
},
"author": "",
"build": {
"appId": "mq-explorer",
"mac": {
"category": "de.t7n.apps.mq-explorer"
},
"linux": {
"category": "Development",
"maintainer": "Thomas Nordquist"
},
"directories": {
"app": "./",
"buildResources": "res",
"output": "build"
}
},
"author": "Thomas Nordquist",
"email": "xxnerowingerxx@gmail.com",
"homepage": "https://github.com",
"license": "ISC",
"devDependencies": {
"electron": "^4.0.0"
"electron": "^4.0.0",
"electron-builder": "^20.38.4",
"ts-node": "^7.0.1",
"typescript": "^3.2.2"
},
"dependencies": {
"mqtt-explorer-backend": "file:backend"
}
}

8
release.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
docker run --rm -ti \
--env ELECTRON_CACHE="/root/.cache/electron" \
--env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \
-v ${PWD}:/project \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder:wine node_modules/.bin/ts-node build.ts

BIN
res/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

11
tsconfig.json Normal file
View File

@@ -0,0 +1,11 @@
{
"compileOnSave": true,
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true,
"outDir": "./build",
"strict": true,
"lib": ["es2017"],
"sourceMap": true
}
}