diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 10e71a0..0000000 --- a/.eslintrc +++ /dev/null @@ -1,18 +0,0 @@ -{ - "env": { - "browser": true, - "node": true, - "es6": true - }, - "globals": { - "define": true - }, - rules: { - "semi": ["error"], - "indent": ["error", 4, { "SwitchCase": 1 }], - "no-irregular-whitespace": ["error"], - "linebreak-style": ["warn", "unix"], - "no-undef": ["warn"], - "no-unused-vars": ["warn"] - } -} diff --git a/.gitignore b/.gitignore index 9daa824..5e3a659 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,8 @@ .DS_Store +.vscode node_modules +dist +lib +types +npm-debug.log +package-lock.json diff --git a/.npmignore b/.npmignore index 59d354b..edd51b2 100644 --- a/.npmignore +++ b/.npmignore @@ -1,7 +1,9 @@ _flash firmware -.eslintrc .gitignore -bower.json circle.yml gulpfile.js +index.html +tsconfig.json +tslint.json +bower.json diff --git a/LICENSE b/LICENSE index 8e078d2..a4d0ec4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2017 Rob Moran +Copyright (c) 2018 Rob Moran Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 4e9cc12..b366c15 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ https://thegecko.github.io/web-bluetooth-dfu/ ## Prerequisites -[Node.js > v4.7.0](https://nodejs.org), which includes `npm`. +[Node.js > v4.8.0](https://nodejs.org), which includes `npm`. ## Installation diff --git a/bower.json b/bower.json index 5dec298..8611b47 100644 --- a/bower.json +++ b/bower.json @@ -23,10 +23,12 @@ "ignore": [ "_flash", "firmware", - ".eslintrc", ".gitignore", "circle.yml", "gulpfile.js", + "index.html", + "tsconfig.json", + "tslint.json", "package.json" ] -} \ No newline at end of file +} diff --git a/circle.yml b/circle.yml index 1de7916..fbfca97 100644 --- a/circle.yml +++ b/circle.yml @@ -1,11 +1,30 @@ machine: node: - version: 4.7.0 + version: 4.8.0 + environment: + LIVE_BRANCH: gh-pages -dependencies: - post: - - npm install +compile: + override: + - npm run gulp test: - override: - - npm run gulp + override: + - exit 0 + +deployment: + staging: + branch: master + commands: + - echo Syncing to $LIVE_BRANCH on GitHub... + - git config --global user.name thegecko + - git config --global user.email github@thegecko.org + - git add --force dist lib types + - git stash save + - git checkout $LIVE_BRANCH + - git merge master --no-commit + - git checkout stash -- . + - git commit --allow-empty --message "Automatic Deployment [skip ci]" + - git push + - 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc' + - npm publish || true diff --git a/examples/node.js b/examples/node.js index 387cc88..a736a23 100644 --- a/examples/node.js +++ b/examples/node.js @@ -6,7 +6,7 @@ var crc = require("crc-32"); var JSZip = require("jszip"); var progress = require("progress"); var Bluetooth = require("webbluetooth").Bluetooth; -var Dfu = require("../index"); +var secureDfu = require("../lib"); var bluetoothDevices = []; var progressBar = null; @@ -125,8 +125,8 @@ function update() { }) .then(content => { manifest = JSON.parse(content).manifest; - dfu = new Dfu(crc.buf); - dfu.addEventListener("progress", event => { + dfu = new secureDfu(crc.buf, bluetooth); + dfu.addEventListener(secureDfu.EVENT_PROGRESS, event => { if (progressBar && event.object === "firmware") { progressBar.update(event.currentBytes / event.totalBytes); } @@ -135,8 +135,7 @@ function update() { console.log("Scanning for DFU devices..."); return bluetooth.requestDevice({ acceptAllDevices: true, - optionalServices: [Dfu.SERVICE_UUID], - deviceFound: handleDeviceFound + optionalServices: [secureDfu.SERVICE_UUID] }); }) .then(device => { @@ -147,13 +146,7 @@ function update() { if (device) return device; console.log("DFU mode set"); - return bluetooth.requestDevice({ - filters: [{ services: [Dfu.SERVICE_UUID] }], - deviceFound: () => { - // Select first device found with correct service - return true; - } - }); + return dfu.requestDevice(); }) .then(selectedDevice => { device = selectedDevice; diff --git a/examples/web.html b/examples/web.html index 3e231a7..1bce0df 100644 --- a/examples/web.html +++ b/examples/web.html @@ -132,7 +132,7 @@ - +