Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
72f5839
feat(tests): Added testing structure
ajfisher Dec 6, 2019
3dc708e
feat(test): Added jest test spec for firmwares
ajfisher Dec 6, 2019
dae49be
feat(tests): Removed old nodeunit tests
ajfisher Dec 6, 2019
b4563ee
feat(tests): Remove travis for build process
ajfisher Dec 6, 2019
253f9ba
chore: Added Standard version and definitions for jest
ajfisher Dec 6, 2019
8c49d60
chore: commit to bring package lock file in
ajfisher Dec 6, 2019
53ff941
chore: Added coverage to workflow
ajfisher Dec 6, 2019
1226fbb
fix: workflow bugs
ajfisher Dec 6, 2019
56a68f2
fix: workflow issues with coverage generation
ajfisher Dec 6, 2019
eb0e2b4
chore: Added coverage and clean up the workflows
ajfisher Dec 6, 2019
b1d5e5b
chore: Coverage job on PR only
ajfisher Dec 6, 2019
60cdece
chore: fixed coverage ignore pattern
ajfisher Dec 6, 2019
a0c23ce
fix: Refactor the firmware listing in cli to be testable and write tests
ajfisher Dec 7, 2019
ad8376b
chore: updated eslint definitions to 2017
ajfisher Dec 7, 2019
fb14978
fix: refactor ports command to use promises
ajfisher Dec 7, 2019
99ad915
fix: update tests and cli to use new refactored ports
ajfisher Dec 7, 2019
5fc0858
chore: tiny nits to make code more readable
ajfisher Dec 7, 2019
84dd959
chore: changed test name
ajfisher Dec 7, 2019
00712ba
fix(tests): Added tests for temp directory removal
ajfisher Dec 7, 2019
307458a
chore: placeholder for future tests
ajfisher Dec 7, 2019
901e198
feat: beginning refactoring of downloader with tests
ajfisher Dec 7, 2019
4664bcd
refactor!: Refactored the download from npm functionality tobe more a…
ajfisher Dec 8, 2019
523bfc5
chore: Added axios to the repo
ajfisher Dec 8, 2019
39459bb
test!: Getting downloader functionality working for github end to end
ajfisher Dec 9, 2019
cfd94ea
fix: refactor to return hexpath in object from npm install
ajfisher Dec 11, 2019
d02caf5
refactor: let downloader determine how to get the hex file
ajfisher Dec 11, 2019
0878504
interim: commit holder
ajfisher Dec 12, 2019
3912786
fix: made a test mode variable
ajfisher Dec 14, 2019
369a661
feat: added a new test firmware for gh master branch usage
ajfisher Dec 14, 2019
b365b6c
feat: new tests added for github downloads and refactoring to suit
ajfisher Dec 14, 2019
36dbe33
chore: Added test mode check
ajfisher Dec 14, 2019
7277c48
chore: fixed coverage script env variables
ajfisher Dec 14, 2019
370172d
chore: added ignore for a test write out
ajfisher Dec 14, 2019
7d21b95
feat: refactor out firmware requirement of manifest interpretation an…
ajfisher Dec 14, 2019
5cfa2e5
fix: starting to refactor the interchange lib to use promises and ref…
ajfisher Dec 15, 2019
cc8a74b
interim: commit with a broken test
ajfisher Dec 18, 2019
e700b35
feat: adding further tests for the interchange code
ajfisher Dec 19, 2019
15e3ef2
test: Updated tests for some of the core interchange behaviour and co…
ajfisher Dec 21, 2019
10cb9ae
tests: Added tests for the installation process
ajfisher Dec 21, 2019
5dcd1c6
feat: Added make command to set arduino back to blink
ajfisher Dec 21, 2019
e828a2f
tests: more tests for flashing and supporting refactors
ajfisher Dec 21, 2019
7886a01
test: Added scaffolding for testing the interactive CLI
ajfisher Dec 22, 2019
d95e564
test: Added tests for the questions in inquire and some small refacto…
ajfisher Dec 22, 2019
58e15e2
tests: Modified inquire constructor to be a promise and tests refacto…
ajfisher Dec 24, 2019
bed2c12
tests: Clean up of some code paths for coverage reporting
ajfisher Dec 26, 2019
51f63ce
tests: removed some console outs that are noise in tests
ajfisher Dec 26, 2019
61ceaa0
tests: building out initial tests for the interchange client
ajfisher Dec 26, 2019
17a8b83
chore: Added an unknown creator to deal with imperfect firmware respo…
ajfisher Dec 28, 2019
94a7fc2
fix: Refactored the interchange client to be more testable and moved …
ajfisher Dec 28, 2019
3d23113
fix: Tests failed and not picked up in previous commit
ajfisher Dec 28, 2019
63ba381
chore: Added husky and config to run tests before commit
ajfisher Dec 28, 2019
6b0d282
fix: Made property on ic client to determine if sp is open and tests …
ajfisher Dec 28, 2019
84879c3
tests: Tests added for get_info method on IC Client
ajfisher Dec 28, 2019
6306c4c
tests: added tests for .set_details method of interchange client
ajfisher Dec 28, 2019
b08895c
tests: Added tests to check rejection on get_info was working
ajfisher Dec 28, 2019
1825afb
chore: updated eslint config to be allowed to use spread operator. No…
ajfisher Dec 29, 2019
f89453c
tests: More tests to determine if get_firmware_info works correctly
ajfisher Dec 29, 2019
6a5e258
tests: Added tests for .set_firmware_details() scenarios
ajfisher Dec 30, 2019
34394c4
chore: changed the name of a test to reflect rest of naming convention
ajfisher Dec 30, 2019
9b73480
tests: Tests to build out coverage for set firmware details in instal…
ajfisher Dec 30, 2019
34f369c
tests: Increased coverage for npm manifest in downloader. Improves #25
ajfisher Dec 30, 2019
d467568
tests: ignored a couple of lines that are low level lib dependent only
ajfisher Dec 30, 2019
72f5ea4
tests: added test for rejection of get_ports
ajfisher Dec 30, 2019
9eb481b
tests: Further tests for the inquirer process to ensure fw is sent ba…
ajfisher Dec 30, 2019
d198e21
chore: Removed unneeded packages from modules and package file
ajfisher Dec 30, 2019
d483e7b
chore: moved changelog to more universal naming
ajfisher Dec 30, 2019
2fa2e25
chore(release): 2.0.0
ajfisher Dec 30, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"es6": true
},
"parserOptions": {
"ecmaVersion": 6,
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ jobs:
- name: Install deps
run: npm install

- name: Lint code
run: make lint

- name: Run tests
run: npm run test
run: make tests
34 changes: 34 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Coverage
on: [pull_request]

jobs:
test:
name: Build, test, coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 10

- name: Cache node modules
uses: actions/cache@v1
with:
path: node_modules
key: build-10-${{ hashFiles('**/package-lock.json') }}
restore-keys: build-10-${{ hashFiles('**/package-lock.json') }}

- name: Install deps
run: npm install

- name: Run tests with coverage
run: make test-coverage

- name: Coverage
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}

19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

46 changes: 45 additions & 1 deletion Changelog.md → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,48 @@
# Interchange Changelog
# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.0.0](https://github.com/ajfisher/nodebots-interchange/compare/v1.2.1...v2.0.0) (2019-12-30)


### ⚠ BREAKING CHANGES

* Getting downloader functionality working for github end to end
* Refactored the download from npm functionality tobe more async and testable

### Features

* added a new test firmware for gh master branch usage ([369a661](https://github.com/ajfisher/nodebots-interchange/commit/369a6613d46f212a20df6e5551dd3d4f7b1d17ae))
* Added make command to set arduino back to blink ([5dcd1c6](https://github.com/ajfisher/nodebots-interchange/commit/5dcd1c656e85f212a512784caf35b9acc3bc3c20))
* adding further tests for the interchange code ([e700b35](https://github.com/ajfisher/nodebots-interchange/commit/e700b357eb936ad430af299ce7f78121f6d51999))
* beginning refactoring of downloader with tests ([901e198](https://github.com/ajfisher/nodebots-interchange/commit/901e198febe057f330a03cc8a397dfa48d36e1cd))
* new tests added for github downloads and refactoring to suit ([b365b6c](https://github.com/ajfisher/nodebots-interchange/commit/b365b6cec9802d305360cb8b6cd2be86b19dd8ff))
* refactor out firmware requirement of manifest interpretation and tests to suit ([7d21b95](https://github.com/ajfisher/nodebots-interchange/commit/7d21b9515062df53f02aa6e3f1e9508a8e79b8f6))
* **test:** Added jest test spec for firmwares ([3dc708e](https://github.com/ajfisher/nodebots-interchange/commit/3dc708e4e4676d2772efbb52ad87109c812cd9a6))
* **tests:** Added testing structure ([72f5839](https://github.com/ajfisher/nodebots-interchange/commit/72f5839b101e38aefac482ae3cc4fadd1b9c34a8))
* **tests:** Remove travis for build process ([b4563ee](https://github.com/ajfisher/nodebots-interchange/commit/b4563ee439f155dc757bce087d1843201614d7e7))
* **tests:** Removed old nodeunit tests ([dae49be](https://github.com/ajfisher/nodebots-interchange/commit/dae49beedcb33cfb068627c7ae474491b114b0d2))


### Bug Fixes

* made a test mode variable ([3912786](https://github.com/ajfisher/nodebots-interchange/commit/3912786113139dc5d0fd4a888c546f90313a87a0))
* Made property on ic client to determine if sp is open and tests to support ([6b0d282](https://github.com/ajfisher/nodebots-interchange/commit/6b0d2821cf317432a76dd8a85d9fb96f98050993))
* refactor ports command to use promises ([fb14978](https://github.com/ajfisher/nodebots-interchange/commit/fb14978d5c8a84423729b20a9afb61deecfba422))
* Refactor the firmware listing in cli to be testable and write tests ([a0c23ce](https://github.com/ajfisher/nodebots-interchange/commit/a0c23ceb2a59c4a8d02c4b06b4a7fe49ca7f5c64))
* refactor to return hexpath in object from npm install ([cfd94ea](https://github.com/ajfisher/nodebots-interchange/commit/cfd94ea9fe446c7b62da3fc989fe2dc771e39229))
* Refactored the interchange client to be more testable and moved command line formatting to the cli tool ([94a7fc2](https://github.com/ajfisher/nodebots-interchange/commit/94a7fc27fdd56b687c079c8781d37d12641169a3))
* starting to refactor the interchange lib to use promises and refactor callbacks into await flow ([5cfa2e5](https://github.com/ajfisher/nodebots-interchange/commit/5cfa2e5b04e9adc3899d6ea85087d79141af7702))
* Tests failed and not picked up in previous commit ([3d23113](https://github.com/ajfisher/nodebots-interchange/commit/3d23113a94b5274477d63ed18a8db1580c1c2895))
* **tests:** Added tests for temp directory removal ([00712ba](https://github.com/ajfisher/nodebots-interchange/commit/00712ba5e37f63bcf4edb04dd56ccd4f8df42790))
* update tests and cli to use new refactored ports ([99ad915](https://github.com/ajfisher/nodebots-interchange/commit/99ad9150589858e9958a96fa3d0d9b6abda9ab8e))
* workflow bugs ([1226fbb](https://github.com/ajfisher/nodebots-interchange/commit/1226fbb9803ba765db0c458c50884f4b26a9942d))
* workflow issues with coverage generation ([56a68f2](https://github.com/ajfisher/nodebots-interchange/commit/56a68f223c762dc8041aa265fa338114b3bab2dd))
* **package:** update serialport to version 7.0.1 ([3de8982](https://github.com/ajfisher/nodebots-interchange/commit/3de898294dbf0b72eb33bba53ba7f19ab8b98752))


* Getting downloader functionality working for github end to end ([39459bb](https://github.com/ajfisher/nodebots-interchange/commit/39459bb820e1fe8d7e18cd0da89cccc05089ed9f))
* Refactored the download from npm functionality tobe more async and testable ([4664bcd](https://github.com/ajfisher/nodebots-interchange/commit/4664bcd46c50ed5035808833d8f2eceb21efda92))

## 1.5.0

Expand Down
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
help:
@echo "blink [board=nano|uno] Flashes blink to the board."
@echo "clean Clean up any build files etc"
@echo "install Install the appropriate packages etc"
@echo "lint Lint the code"
@echo "tests Run the tests"
@echo "test-coverage Run the tests and build coverage data"

blink:
@echo "Wiping board back to blink state"
@avrgirl-arduino flash -f node_modules/avrgirl-arduino/junk/hex/$(BOARD)/Blink.cpp.hex -a $(BOARD)
@echo "Completed"

clean:
rm -rf ./node_modules

install: clean
npm install

lint:
npm run lint

tests:
npm run test

test-coverage:
npm run coverage
54 changes: 48 additions & 6 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#! /usr/bin/env node

const _ = require('lodash');
const program = require('commander');
const version = require('../package.json').version;
const Interchange = require('../lib/interchange');
const Inquire = require('../lib/inquire');

const interchange = new Interchange();

program
Expand All @@ -12,19 +14,53 @@ program
program.command('list')
.description('Lists all of the available firmwares')
.alias('l')
.action(interchange.list_devices.bind(interchange));
.action(() => {
const list = interchange.list_devices();
let outstr = '\nFirmwares available for backpacks. (f) denotes a firmata version is available\n\n';
list.forEach((fw) => {
outstr += ` ${fw.name} ${fw.firmata ? '(f)' : ''}: ${fw.description}\n`;
});
console.info(outstr);
});

program.command('ports')
.description('Lists all of the attached boards and their ports')
.alias('p')
.option('-v, --verbose', 'List with additional information')
.action(interchange.list_ports.bind(interchange));
.action((opts) => {
// get the ports and then list them out.
interchange.get_ports()
.then((ports) => {
if (opts.verbose) {
console.info(ports);
} else {
ports.forEach((port) => {
console.info(port.path.cyan);
});
}
})
.catch(err => console.log(err));
});

program.command('read')
.description('Read firmware info from port')
.alias('r')
.option('-p, --port', 'Serial port board is attached to')
.action(interchange.get_firmware_info.bind(interchange));
.option('-p, --port <port>', 'Serial port board is attached to')
.action((opts) => {
interchange.get_firmware_info(opts.port).then(fw => {
// print out all of the info regarding firmware
console.info((fw.name + ' backpack firmware').bold);
console.info('Version %s Built %s', fw.firmware_version, fw.compile_date);
console.info('Creator ID: %s (%s @%s)', fw.creatorID, fw.creator.name, fw.creator.gh);
console.info('Device ID: %s (%s)', fw.firmwareID, fw.name);
console.info('I2C Address: 0x%s (%s)', fw.i2c_address.toString(16),
fw.use_custom_addr ? 'Using custom' : 'Using default');
console.info(fw.description);
}).catch(err => {
console.log(err.message.toString().red);
process.exit(1);
});
});

program.command('install [firmware]')
.description('Install specified firmware to board')
Expand All @@ -35,10 +71,16 @@ program.command('install [firmware]')
.option('-i, --address <address>', 'Specify I2C address, eg 0x67')
.option('--interactive', 'Interactive mode will prompt for input')
.action(function(firmware, opts) {
const {board, port, firmata, address} = opts;
const options = {board, port, firmata, address};

if (opts.interactive) {
const inquire = new Inquire(interchange.install_firmware.bind(interchange));
// Wait for the inquirer to initialise then call the prompt
new Inquire(interchange.install_firmware.bind(interchange))
.then((inquire) => inquire.prompt())
.catch(err => { throw err });
} else {
interchange.install_firmware(firmware, opts);
interchange.install_firmware(firmware, options);
}
});

Expand Down
Loading