From a733e4c77cd3ff15ed9a9155634661e481e32f38 Mon Sep 17 00:00:00 2001 From: joelchu Date: Tue, 29 Oct 2019 11:07:23 +0800 Subject: [PATCH 1/4] setting up test.todo --- packages/@jsonql/client/README.md | 4 +++- packages/@jsonql/client/package.json | 5 ++++- packages/@jsonql/client/tests/auth.test.js | 6 ++++++ packages/@jsonql/client/tests/basic.test.js | 5 +++++ packages/@jsonql/client/tests/login.test.js | 6 ++++++ 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 packages/@jsonql/client/tests/auth.test.js create mode 100644 packages/@jsonql/client/tests/basic.test.js create mode 100644 packages/@jsonql/client/tests/login.test.js diff --git a/packages/@jsonql/client/README.md b/packages/@jsonql/client/README.md index 8f93fc36..a3ca4baf 100644 --- a/packages/@jsonql/client/README.md +++ b/packages/@jsonql/client/README.md @@ -1,6 +1,8 @@ # @jsonql/client -> This is jsonql browser client with socket client, for pure HTTP client please use @jsonql/http-client +> This is jsonql browser client comes with jsonql-client (http) and optional socket clients + + --- diff --git a/packages/@jsonql/client/package.json b/packages/@jsonql/client/package.json index 0807de53..c1cc9c94 100644 --- a/packages/@jsonql/client/package.json +++ b/packages/@jsonql/client/package.json @@ -49,7 +49,10 @@ }, "license": "MIT", "dependencies": { - + "jsonql-client": "^1.4.0" + }, + "optionalDependencies": { + "jsonql-ws-client": "^1.3.3" }, "devDependencies": { "@jsonql/koa": "^0.2.6", diff --git a/packages/@jsonql/client/tests/auth.test.js b/packages/@jsonql/client/tests/auth.test.js new file mode 100644 index 00000000..fab0ac3d --- /dev/null +++ b/packages/@jsonql/client/tests/auth.test.js @@ -0,0 +1,6 @@ +// test the basic static connection with already existed token +const test = require('ava') + +test.todo(`It should able to connect to the backend with existing token`) + +test.todo(`Socket client should able to connect to the existing backend using the same token from http client`) diff --git a/packages/@jsonql/client/tests/basic.test.js b/packages/@jsonql/client/tests/basic.test.js new file mode 100644 index 00000000..ea017ce0 --- /dev/null +++ b/packages/@jsonql/client/tests/basic.test.js @@ -0,0 +1,5 @@ +// basic test to check if the socket client get included +const test = require('ava') + + +test.todo(`The client should also have a socket client included`) diff --git a/packages/@jsonql/client/tests/login.test.js b/packages/@jsonql/client/tests/login.test.js new file mode 100644 index 00000000..4dfe0c36 --- /dev/null +++ b/packages/@jsonql/client/tests/login.test.js @@ -0,0 +1,6 @@ +// e2e test to see if we can call the login and make both client authorized +const test = require('ava') + +test.todo(`It should not able to call the private method because its not login yet`) + +test.todo(`It should able to call the login method and authorized both the http and socket client`) -- Gitee From 8ae8c7d3e0a92d16d58096e68d5110b7f84518de Mon Sep 17 00:00:00 2001 From: joelchu Date: Tue, 29 Oct 2019 12:47:20 +0800 Subject: [PATCH 2/4] setup the rest of the files --- packages/@jsonql/client/README.md | 4 ++++ packages/@jsonql/client/index.js | 1 + packages/@jsonql/client/package.json | 3 +-- packages/@jsonql/client/static.js | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 packages/@jsonql/client/index.js create mode 100644 packages/@jsonql/client/static.js diff --git a/packages/@jsonql/client/README.md b/packages/@jsonql/client/README.md index a3ca4baf..3c685fb3 100644 --- a/packages/@jsonql/client/README.md +++ b/packages/@jsonql/client/README.md @@ -2,8 +2,12 @@ > This is jsonql browser client comes with jsonql-client (http) and optional socket clients +## Example +Coming soon --- +https://jsonql.org + NEWBRAN LTD UK & T01SOURCE CN diff --git a/packages/@jsonql/client/index.js b/packages/@jsonql/client/index.js new file mode 100644 index 00000000..47cd05f4 --- /dev/null +++ b/packages/@jsonql/client/index.js @@ -0,0 +1 @@ +// this is the default export entry point diff --git a/packages/@jsonql/client/package.json b/packages/@jsonql/client/package.json index c1cc9c94..e6fa570a 100644 --- a/packages/@jsonql/client/package.json +++ b/packages/@jsonql/client/package.json @@ -2,7 +2,7 @@ "name": "@jsonql/client", "version": "0.1.0", "description": "jsonql js http client for browser with socket client, for pure Http client please use @jsonql/http-client", - "main": "dist/jsonql-client.umd.js", + "main": "dist/jsonql-client.cjs.js", "module": "index.js", "browser": "dist/jsonql-client.umd.js", "files": [ @@ -55,7 +55,6 @@ "jsonql-ws-client": "^1.3.3" }, "devDependencies": { - "@jsonql/koa": "^0.2.6", "ava": "^2.4.0", "browser-env": "^3.2.6", "debug": "^4.1.1", diff --git a/packages/@jsonql/client/static.js b/packages/@jsonql/client/static.js new file mode 100644 index 00000000..728bf310 --- /dev/null +++ b/packages/@jsonql/client/static.js @@ -0,0 +1 @@ +// this will export the static version -- Gitee From 0edb18c32d43f3348f910b502e77f863f611dffe Mon Sep 17 00:00:00 2001 From: joelchu Date: Tue, 29 Oct 2019 12:48:26 +0800 Subject: [PATCH 3/4] setup the rollup build script --- packages/@jsonql/client/rollup.config.js | 95 ++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 packages/@jsonql/client/rollup.config.js diff --git a/packages/@jsonql/client/rollup.config.js b/packages/@jsonql/client/rollup.config.js new file mode 100644 index 00000000..a73ef6dc --- /dev/null +++ b/packages/@jsonql/client/rollup.config.js @@ -0,0 +1,95 @@ +/** + * Rollup config for building the slim version + */ +import { join } from 'path' +import buble from 'rollup-plugin-buble' +import { terser } from "rollup-plugin-terser" +import replace from 'rollup-plugin-replace' +import commonjs from 'rollup-plugin-commonjs' +import nodeResolve from 'rollup-plugin-node-resolve' +import nodeGlobals from 'rollup-plugin-node-globals' +import builtins from 'rollup-plugin-node-builtins' +import size from 'rollup-plugin-bundle-size' +import async from 'rollup-plugin-async' + +import pkg from './package.json' + +const env = process.env.NODE_ENV; +const target = process.env.TARGET; // 1.4.0 add new prop to control the build + +let plugins = [ + buble({ + objectAssign: 'Object.assign' + }), + nodeResolve({ + preferBuiltins: true, + mainFields: ['module', 'browser'] + }), + commonjs({ + include: 'node_modules/**' + }), + nodeGlobals(), + builtins(), + async(), + replace({ + 'process.env.NODE_ENV': JSON.stringify('production'), + '__VERSION__': pkg.version + }) +] + +let globals = { + 'debug': 'debug', + 'promise-polyfill': 'Promise', + 'flyio': 'Fly' +} +let external = [ + 'flyio', + 'debug', + 'fetch', + 'Promise', + 'promise-polyfill', + 'superagent', + 'handlebars', + 'tty' +] +let moduleName = 'jsonqlClient' +let sourceFile = 'index.js' +let distFile = 'core.js' +switch (target) { + case 'BROWSER': + sourceFile = 'full.js' + distFile = join('dist', 'jsonql-client.umd.js') + break; + case 'STATIC': + moduleName = 'jsonqlClientStatic' + sourceFile = join('src', 'static.js') + distFile = 'static.js' + break; + case 'FULL': + moduleName = 'jsonqlClientStatic' + sourceFile = join('src', 'static-full.js') + distFile = join('dist', 'jsonql-client.static.js') + break; + default: + sourceFile = 'index.js' + +} +if (env === 'production') { + plugins.push(terser()) +} +plugins.push(size()) + +let config = { + input: join(__dirname, sourceFile), + output: { + name: moduleName, + file: join(__dirname, distFile), + format: 'umd', + sourcemap: true, + globals + }, + plugins, + external +} + +export default config -- Gitee From 0719279dd391c25e96807711f7fd40ad26f63cf4 Mon Sep 17 00:00:00 2001 From: joelchu Date: Tue, 29 Oct 2019 22:55:46 +0800 Subject: [PATCH 4/4] jsonql-client 1.4.1 module change to name export so it wont be easily crash with others --- packages/@jsonql/client/index.js | 3 ++- packages/http-client/module.js | 3 ++- packages/http-client/package.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/@jsonql/client/index.js b/packages/@jsonql/client/index.js index 47cd05f4..06189780 100644 --- a/packages/@jsonql/client/index.js +++ b/packages/@jsonql/client/index.js @@ -1 +1,2 @@ -// this is the default export entry point +// this is the default export entry point +import jsonqlClient from 'jsonql-client/module' diff --git a/packages/http-client/module.js b/packages/http-client/module.js index 396c662a..9d116f15 100644 --- a/packages/http-client/module.js +++ b/packages/http-client/module.js @@ -23,13 +23,14 @@ const initSocketClient = function(client, contract, config, socketClient) { } /** + * @1.4.1 change to name export * When pass a static contract then it return a static interface * otherwise it will become the async interface * @param {object} Fly the http engine * @param {object} config configuration * @return {object} jsonqlClient */ -export default function jsonqlClient(Fly, config) { +export function jsonqlClient(Fly, config) { // @NOTE we pass the socket client via the config, that save us the headache to try to dynamicly load the dep const { contract, socketClient, debugOn } = config; const ee = getEventEmitter(debugOn) diff --git a/packages/http-client/package.json b/packages/http-client/package.json index 03242177..e02fa970 100755 --- a/packages/http-client/package.json +++ b/packages/http-client/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-client", - "version": "1.4.0", + "version": "1.4.1", "description": "jsonql http browser client using Fly.js", "main": "core.js", "module": "index.js", -- Gitee