Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into LL-2136
Browse files Browse the repository at this point in the history
  • Loading branch information
gre authored Jan 24, 2020
2 parents 5f69389 + f9a6c1f commit 6c7c86d
Show file tree
Hide file tree
Showing 24 changed files with 48,108 additions and 45,930 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ jobs:
yarn --frozen-lockfile
cd -
yarn ci-setup-cli
- name: Deps versions
run: |
yarn flow --version
yarn jest --version
- name: Lint
run: yarn ci-lint
- name: Run tests
Expand Down
8 changes: 5 additions & 3 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
"type": "git",
"url": "git://github.com/LedgerHQ/ledger-live-common"
},
"peerDependencies": {
"@ledgerhq/hw-transport-node-ble": "5.7.0"
},
"dependencies": {
"@ledgerhq/errors": "5.7.0",
"@ledgerhq/hw-transport-http": "5.7.0",
"@ledgerhq/hw-transport-mocker": "5.7.0",
"@ledgerhq/hw-transport-node-ble": "5.7.0",
"@ledgerhq/hw-transport-node-hid": "5.7.0",
"@ledgerhq/ledger-core": "^5.3.0",
"@ledgerhq/ledger-core": "^5.3.2",
"@ledgerhq/live-common": "^11.2.0",
"@ledgerhq/logs": "5.6.0",
"asciichart": "^1.5.9",
Expand Down Expand Up @@ -41,7 +43,7 @@
"lib"
],
"scripts": {
"prepare": "./scripts/gen.sh",
"prepare": "./scripts/gen.sh && yarn build",
"build": "babel --ignore __tests__ -s -d lib src",
"prepublishOnly": "rm -rf lib && babel --ignore __tests__ -d lib src",
"watch": "babel -wsd lib src",
Expand Down
24 changes: 16 additions & 8 deletions cli/src/live-common-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Transport from "@ledgerhq/hw-transport";
import { NotEnoughBalance } from "@ledgerhq/errors";
import { log } from "@ledgerhq/logs";
import { Observable } from "rxjs";
import { first, switchMap, map } from "rxjs/operators";
import { map, first, switchMap } from "rxjs/operators";
import createTransportHttp from "@ledgerhq/hw-transport-http";
import {
registerTransportModule,
Expand Down Expand Up @@ -44,17 +44,22 @@ if (process.env.DEVICE_PROXY_URL) {
const cacheBle = {};

if (!process.env.CI) {
const {
default: TransportNodeBle
} = require("@ledgerhq/hw-transport-node-ble");
let TransportNodeBle;
const getTransport = () => {
if (!TransportNodeBle) {
TransportNodeBle = require("@ledgerhq/hw-transport-node-ble").default;
}
return TransportNodeBle;
};

const openBleByQuery = async query => {
const m = query.match(/^ble:?(.*)/);
if (!m) throw new Error("ble regexp should match");
const [, q] = m;
if (cacheBle[query]) return cacheBle[query];
const t = await (!q
? TransportNodeBle.create()
: Observable.create(TransportNodeBle.listen)
? getTransport().create()
: Observable.create(getTransport().listen)
.pipe(
first(
e =>
Expand All @@ -77,7 +82,10 @@ if (!process.env.CI) {
return openBleByQuery(query);
}
},
discovery: Observable.create(TransportNodeBle.listen).pipe(
discovery: Observable.create(o => {
const s = getTransport().listen(o);
return () => s.unsubscribe();
}).pipe(
map(e => ({
type: e.type,
id: "ble:" + e.device.id,
Expand All @@ -87,7 +95,7 @@ if (!process.env.CI) {
disconnect: query =>
query.startsWith("ble")
? cacheBle[query]
? TransportNodeBle.disconnect(cacheBle[query].id)
? getTransport().disconnect(cacheBle[query].id)
: Promise.resolve()
: null
});
Expand Down
2 changes: 0 additions & 2 deletions cli/tests/device-appsUpdateTestAll.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ cd `mktemp -d`
git clone $GIT_REMOTE
cd ledger-live-common
yarn
yalc publish
cd cli
yalc add @ledgerhq/live-common
yarn
yarn link
yarn build
Expand Down
Loading

0 comments on commit 6c7c86d

Please sign in to comment.