From db9449aa2d29b509f2b92e877008b8daa14d2977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=BCbleitner?= Date: Fri, 20 Sep 2019 22:39:07 +0200 Subject: [PATCH 1/3] it werks --- Index.ts | 10 +++++++++- src/Backend.ts | 10 +--------- src/Frontend.ts | 12 +----------- src/Responses.ts | 1 - src/webpack.js | 21 +++++++++++++-------- test/TestBackend.ts | 4 ++-- test/TestFrontend.ts | 10 +++++----- 7 files changed, 31 insertions(+), 37 deletions(-) diff --git a/Index.ts b/Index.ts index f307de2..5db6b50 100644 --- a/Index.ts +++ b/Index.ts @@ -1,7 +1,15 @@ import * as Back from './src/Backend'; import * as Front from './src/Frontend'; +import * as Types from './src/Types'; +import * as Utils from './src/Utils'; +import * as Interfaces from './src/Interfaces'; +import * as Responses from './src/Responses'; export { Back as Backend, - Front as Frontend + Front as Frontend, + Types, + Utils, + Interfaces, + Responses } \ No newline at end of file diff --git a/src/Backend.ts b/src/Backend.ts index 8e633c5..6d37d02 100644 --- a/src/Backend.ts +++ b/src/Backend.ts @@ -6,16 +6,8 @@ import bsock = require('bsock'); import * as T from './Types'; import * as U from './Utils'; import * as I from './Interfaces'; -import * as R from './Responses'; -export { - T as Types, - U as Utils, - I as Interfaces, - R as Responses -} - -export class Server{ +export class RPCServer{ private ws = http.createServer() private io = bsock.createServer() diff --git a/src/Frontend.ts b/src/Frontend.ts index d277257..86b1bca 100644 --- a/src/Frontend.ts +++ b/src/Frontend.ts @@ -3,24 +3,14 @@ var bsock = require('bsock') import * as T from './Types'; -import * as U from './Utils'; import * as I from './Interfaces'; -import * as R from './Responses'; - -export { - T as Types, - U as Utils, - I as Interfaces, - R as Responses -} - //fix args with defaults like "force = true" -> "force" function stripAfterEquals(str:string){ return str.split("=")[0] } -export class Client implements I.Socket{ +export class RPCSocket implements I.Socket{ private socket: I.Socket constructor(public port:number, private server: string, private tls: boolean = false){ diff --git a/src/Responses.ts b/src/Responses.ts index 7f470bf..2b44c45 100644 --- a/src/Responses.ts +++ b/src/Responses.ts @@ -1,7 +1,6 @@ export type Outcome = "Success" | "Error" -/* Responses */ export class Response{ constructor( public message?:string diff --git a/src/webpack.js b/src/webpack.js index ea871b9..58d2181 100644 --- a/src/webpack.js +++ b/src/webpack.js @@ -1,20 +1,25 @@ const path = require('path'); -const frontendConf = { +module.exports = { mode: 'production', target: "web", - entry: path.resolve(__dirname, '..', 'js', 'src', 'Frontend.js'), + entry: path.resolve(__dirname, 'Frontend.ts'), output: { - path: path.resolve(__dirname, '..', 'js', 'src'), - filename: "Frontend.js", - libraryTarget: 'commonjs', + path: path.resolve(__dirname, '../js'), + filename: 'Frontend.min.js', + libraryTarget: 'window', }, resolve: { extensions: [".ts", ".tsx", ".js"] }, + module: { + rules: [ + { test: /\.ts?$/, loader: "ts-loader" } + ] + }, optimization: { minimize: false, }, -} - -module.exports = [frontendConf] + externals: { + } +} \ No newline at end of file diff --git a/test/TestBackend.ts b/test/TestBackend.ts index b794756..c54df0b 100644 --- a/test/TestBackend.ts +++ b/test/TestBackend.ts @@ -1,6 +1,6 @@ -import { Server } from '../src/Backend' +import { RPCServer } from '../src/Backend' -new Server(20000, [{ +new RPCServer(20000, [{ name: "HelloWorldRPCGroup", publicRPCs: () => [], localRPCs: () => [{ diff --git a/test/TestFrontend.ts b/test/TestFrontend.ts index 12191e4..18ea8cc 100644 --- a/test/TestFrontend.ts +++ b/test/TestFrontend.ts @@ -1,7 +1,7 @@ -import { Client } from '../src/Frontend' +import { RPCSocket } from '../src/Frontend' -const client = new Client(20000, 'localhost') -client.connect().then(_ => { - client.info().then(console.log) - client["HelloWorldRPCGroup"].echo("x").then(console.log) +const socket = new RPCSocket(20000, 'localhost') +socket.connect().then(_ => { + socket.info().then(console.log) + socket["HelloWorldRPCGroup"].echo("x").then(console.log) }) From 6f51ee98135751f318a9c84d39199b255c5094ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=BCbleitner?= Date: Sat, 21 Sep 2019 00:10:31 +0200 Subject: [PATCH 2/3] automate the shit out of it --- .drone.yml | 22 ++++++++++++++++++++++ .gitignore | 5 ++--- src/Frontend.ts | 1 + test/index.html | 1 + 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 .drone.yml create mode 100644 test/index.html diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..5f7726e --- /dev/null +++ b/.drone.yml @@ -0,0 +1,22 @@ +kind: pipeline +name: default + +steps: +- name: npm install + image: node:12 + commands: + - npm install + +- name: npm run build + image: node:12 + commands: + - npm run build + +- name: npm publish + image: plugins/npm + settings: + username: frontwork + password: + from_secret: npm_password + email: frontwork.me@gmail.com + \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5ed8763..35162d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules +js src/**/*.js src/**/*.d.ts @@ -7,6 +8,4 @@ test/**/*.js test/**/*.d.ts *.d.ts -*.js - -lib \ No newline at end of file +*.js \ No newline at end of file diff --git a/src/Frontend.ts b/src/Frontend.ts index 86b1bca..9a1d0ff 100644 --- a/src/Frontend.ts +++ b/src/Frontend.ts @@ -14,6 +14,7 @@ export class RPCSocket implements I.Socket{ private socket: I.Socket constructor(public port:number, private server: string, private tls: boolean = false){ + Object.defineProperty(this, 'socket', {value: undefined, writable: true}) } diff --git a/test/index.html b/test/index.html new file mode 100644 index 0000000..4159903 --- /dev/null +++ b/test/index.html @@ -0,0 +1 @@ + From 38ade11a2b1a441f6cbe7d4a31a03ea159bfe026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=BCbleitner?= Date: Sat, 21 Sep 2019 00:11:02 +0200 Subject: [PATCH 3/3] version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d52c6fa..78e6790 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rpclibrary", - "version": "1.0.3", + "version": "1.0.4", "description": "", "main": "./js/Index.js", "scripts": {