Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating dependencies, refactoring code and tests #9

Merged
merged 18 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"root": true,
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
Expand All @@ -8,9 +9,12 @@
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-empty": "off",
"no-throw-literal": "warn",
"semi": "off"
}
Expand Down
31 changes: 17 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: CI
on:
push:
branches:
- "*"
- 'main'
pull_request:
branches:
- "main"
- 'main'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -20,20 +20,23 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 12.x
- run: npm install
- run: ./node_modules/.bin/electron-rebuild --version 11.2.1
- run: xvfb-run -a npm test
node-version: 18.19.0

- name: Install dependencies
run: npm ci

- run: xvfb-run -a npm run test
if: runner.os == 'Linux'
- run: npm run coverage
if: runner.os != 'Linux'

- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./out/coverage/lcov.info
- run: npm run test
if: runner.os == 'macOS'

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
if: runner.os != 'Linux'
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ node_modules
.vscode-test/
*.vsix
*.code-workspace
.nyc_output
.nyc_output
coverage
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable-pre-post-scripts = true
3 changes: 2 additions & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
v12.18.3
v18.19.0

6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 80,
"singleQuote": true,
"tabWidth": 2,
"useTabs": false
}
8 changes: 8 additions & 0 deletions .vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from '@vscode/test-cli';

export default defineConfig({
files: 'out/test/**/*.test.js',
mocha: {
ui: 'bdd',
},
});
11 changes: 6 additions & 5 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint"
]
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint",
"ms-vscode.extension-test-runner"
]
}
15 changes: 3 additions & 12 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,11 @@
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
"--trace-deprecation",
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
}
]
Expand Down
19 changes: 10 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
"typescript.tsdk": "node_modules/typescript/lib"
}
32 changes: 16 additions & 16 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
50 changes: 16 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
[![Coverage Status](https://coveralls.io/repos/github/robmosca/robotinventor-vscode/badge.svg)](https://coveralls.io/github/robmosca/robotinventor-vscode)

# VScode extension for the Robot inventor set

This is my attempt at writing a Microsoft Visual Studio Code extension to
program the LEGO® MINDSTORMS® Robot Inventor set in MicroPython.

## Known limitations
[![codecov](https://codecov.io/gh/robmosca/robotinventor-vscode/graph/badge.svg?token=CPJNM9ZTKA)](https://codecov.io/gh/robmosca/robotinventor-vscode)
[![CI](https://github.com/robmosca/robotinventor-vscode/actions/workflows/main.yml/badge.svg)](https://github.com/robmosca/robotinventor-vscode/actions/workflows/main.yml)

- I wrote and tested the extension on macOS and Raspbian. I am not sure if it
works in Windows out of the box
- The connection to the Hub only works via USB at the moment. I tried to connect
via Bluetooth and it somehow works but it's unstable and it fails from time
to time, still not sure why.
This is a Microsoft Visual Studio Code extension to
program the LEGO® MINDSTORMS® Robot Inventor set in MicroPython.

- It only works on macOS and Linux, at the moment. **Windows is not supported.**
- It only works with Hubs connected via USB.

## How to install

***Before** installing the extension, please read the disclaimer at the end of this
page.*
**\*Before** installing the extension, please read the disclaimer at the end of this
page.\*

**Prerequisites**

Expand All @@ -28,34 +23,20 @@ Also, you need the command line `code` command installed.

**Install the extension**

1. Clone or download the repository
1. Clone the repository
2. Install the dependencies

```
npm install
```

3. You need to re-compile serial IO for the specific version of node used by
VS Code

```
./node_modules/.bin/electron-rebuild --version 11.2.1
npm ci
```

4. Make sure `vsce` is installed
3. Package and install the extension

```
npm install -g vsce
npm run package
code --install-extension robotinventor-1.0.0.vsix
```

5. Compile and install the extension

```
vsce package
code --install-extension robotinventor-0.0.1.vsix
```


## How to use the extension

After installing the extension open the RI5DEV device browser:
Expand Down Expand Up @@ -91,11 +72,12 @@ Since there is no official documentation for the API, the implementation is base
on what I could discover empirically.
I also obtained information from the following repositories, based on the LEGO®
Education SPIKE™️ Prime Set:

- [gpdaniels/spike-prime](https://github.com/gpdaniels/spike-prime/blob/master/specifications/stm32f413.pdf)
- [nutki/spike-tools](https://github.com/nutki/spike-tools)
- [sanjayseshan/spikeprime-tools](https://github.com/sanjayseshan/spikeprime-tools)

I based my implementation on the excellent work of David Lechner (for EV3):
I based the implementation on the work of David Lechner (for EV3):

[ev3dev/vscode-ev3dev-browser](https://github.com/ev3dev/vscode-ev3dev-browser)

Expand All @@ -108,4 +90,4 @@ _warranty of any kind, express, implied or otherwise, including without_
_limitation, any warranty of fitness for a particular purpose. In no event shall_
_the author of this software be liable for any direct, special, incidental,_
_indirect or consequential damages of any kind arising out of or in connection_
_with the possession, use or performance of this software._
_with the possession, use or performance of this software._
Loading
Loading