forked from Jerrylum/v5-serial-protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from LemLib/main
Put actual package contents on npm
- Loading branch information
Showing
32 changed files
with
27,058 additions
and
10,771 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": ["@commitlint/config-conventional"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": [ | ||
"plugin:@typescript-eslint/recommended", | ||
"standard-with-typescript", | ||
"prettier" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint"], | ||
"rules": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
name: Bug Report | ||
about: Report a bug in the project | ||
title: "[BUG]" | ||
labels: "needs confirmation" | ||
assignees: "" | ||
--- | ||
|
||
#### Expected Behavior | ||
|
||
<!-- Concisely describe the behavior you expected --> | ||
|
||
#### Observed Behavior | ||
|
||
<!-- Concisely describe the behavior you observed --> | ||
|
||
#### Steps to Reproduce | ||
|
||
<!-- Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. Include code to reproduce, if relevant --> | ||
|
||
#### Environment | ||
|
||
<!-- Please provide the following information --> | ||
|
||
- LemLink Version: <!-- (e.g. 0.4.5) --> | ||
|
||
#### Additional Information | ||
|
||
<!-- Add any other relevant information about the problem here --> | ||
<!-- This includes screenshots, code snippets, videos, anything you think is relevant --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
name: Feature Request | ||
about: Suggest an idea for the project | ||
title: "[FEATURE]" | ||
labels: "enhancement" | ||
assignees: "" | ||
--- | ||
|
||
#### Requested Feature | ||
|
||
<!-- Concisely describe the behavior you are requesting here --> | ||
|
||
<!-- Describe any details in point form here --> | ||
|
||
- a | ||
- b | ||
- c | ||
|
||
#### Current Implementation | ||
|
||
<!-- Describe the current implementation here --> | ||
|
||
#### Motivation | ||
|
||
<!-- Explain why this feature would benefit users and/or maintainers --> | ||
|
||
#### (Optional) Possible Implementations and Alternatives | ||
|
||
<!-- Describe any possible implementations or alternatives you have considered --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "npm" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: ci | ||
on: | ||
pull_request: | ||
branches: "*" | ||
push: | ||
branches: "*" | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Copy repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: "npm" | ||
|
||
- name: Install dependencies | ||
run: npm i | ||
|
||
- name: Lint | ||
run: npm run check-lint | ||
|
||
- name: Check formatting | ||
run: npm run check-format | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Test | ||
run: npm test | ||
release_and_publish: | ||
if: github.ref == 'refs/heads/pre-release' || github.ref == 'refs/heads/stable' | ||
runs-on: ubuntu-latest | ||
environment: npm_publish_env | ||
needs: build | ||
permissions: | ||
contents: write # to be able to publish a GitHub release | ||
issues: write # to be able to comment on released issues | ||
pull-requests: write # to be able to comment on released pull requests | ||
id-token: write # to enable use of OIDC for npm provenance | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: "npm" | ||
registry-url: "https://registry.npmjs.org" | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Build project | ||
run: npm run build | ||
|
||
- name: Run Semantic Release | ||
run: npx semantic-release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_RELEASR_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx --no -- commitlint --edit ${1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npm run pre-commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
module.exports = { | ||
presets: [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
targets: { "node": true } | ||
}, | ||
"@babel/preset-typescript" | ||
] | ||
] | ||
} | ||
presets: [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
targets: { node: true }, | ||
}, | ||
"@babel/preset-typescript", | ||
], | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { serial } from "node-web-serial-ponyfill"; | ||
import { V5SerialDevice } from "../src"; | ||
|
||
(async function() { | ||
let device = new V5SerialDevice(serial); | ||
void (async function () { | ||
const device = new V5SerialDevice(serial); | ||
|
||
await device.connect(); | ||
await device.connect(); | ||
|
||
console.log(device.brain.systemVersion); | ||
})(); | ||
console.log(device.brain.systemVersion); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,25 @@ | ||
{ | ||
"compilerOptions": { | ||
// | ||
"allowSyntheticDefaultImports": true, | ||
"experimentalDecorators": true, | ||
// | ||
"isolatedModules": false, | ||
"module": "commonjs", | ||
// | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"noUnusedLocals": false, // it is ok for the example | ||
"noUnusedParameters": false, | ||
"removeComments": true, | ||
"preserveConstEnums": true, | ||
// | ||
"moduleResolution": "node", | ||
"emitDecoratorMetadata": true, | ||
"esModuleInterop": true, // testing | ||
"sourceMap": false, | ||
"target": "es6", | ||
"strictNullChecks": true, | ||
"lib": [ | ||
"es5", | ||
"es2015", | ||
"es2016", | ||
"es2017", | ||
"dom" | ||
] | ||
} | ||
} | ||
"compilerOptions": { | ||
// | ||
"allowSyntheticDefaultImports": true, | ||
"experimentalDecorators": true, | ||
// | ||
"isolatedModules": false, | ||
"module": "commonjs", | ||
// | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"noUnusedLocals": false, // it is ok for the example | ||
"noUnusedParameters": false, | ||
"removeComments": true, | ||
"preserveConstEnums": true, | ||
// | ||
"moduleResolution": "node", | ||
"emitDecoratorMetadata": true, | ||
"esModuleInterop": true, // testing | ||
"sourceMap": false, | ||
"target": "es6", | ||
"strictNullChecks": true, | ||
"lib": ["es5", "es2015", "es2016", "es2017", "dom"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,42 @@ | ||
import { serial } from "node-web-serial-ponyfill"; | ||
import { ProgramIniConfig, V5SerialDevice, ZerobaseSlotNumber } from "../src"; | ||
import { | ||
ProgramIniConfig, | ||
V5SerialDevice, | ||
type ZerobaseSlotNumber, | ||
} from "../src"; | ||
|
||
import fs from 'fs'; | ||
import fs from "fs"; | ||
|
||
function toUint8(b: Buffer): Uint8Array { | ||
let ab = b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength); | ||
return new Uint8Array(ab); | ||
const ab = b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength); | ||
return new Uint8Array(ab); | ||
} | ||
|
||
(async function() { | ||
let device = new V5SerialDevice(serial); | ||
|
||
await device.connect(); | ||
|
||
let slot = 2; | ||
let bin = toUint8(fs.readFileSync("./examples/pros-demo-program/hot.package.bin")); | ||
let cold = toUint8(fs.readFileSync("./examples/pros-demo-program/cold.package.bin")); | ||
|
||
let ini = new ProgramIniConfig(); | ||
ini.autorun = true; | ||
ini.baseName = "slot_" + slot; | ||
ini.program.name = "PROS Demo"; | ||
ini.program.slot = (slot - 1) as ZerobaseSlotNumber; | ||
ini.program.icon = "USER902x.bmp"; | ||
ini.program.description = "Demo"; | ||
|
||
const onProgress = (state: string, current: number, total: number) => { | ||
console.log(state, current, total); | ||
}; | ||
|
||
let isDone = await device.brain.uploadProgram(ini, bin, cold, onProgress); | ||
console.log("done", isDone); | ||
})(); | ||
void (async function () { | ||
const device = new V5SerialDevice(serial); | ||
|
||
await device.connect(); | ||
|
||
const slot = 2; | ||
const bin = toUint8( | ||
fs.readFileSync("./examples/pros-demo-program/hot.package.bin"), | ||
); | ||
const cold = toUint8( | ||
fs.readFileSync("./examples/pros-demo-program/cold.package.bin"), | ||
); | ||
|
||
const ini = new ProgramIniConfig(); | ||
ini.autorun = true; | ||
ini.baseName = "slot_" + slot; | ||
ini.program.name = "PROS Demo"; | ||
ini.program.slot = (slot - 1) as ZerobaseSlotNumber; | ||
ini.program.icon = "USER902x.bmp"; | ||
ini.program.description = "Demo"; | ||
|
||
const onProgress = (state: string, current: number, total: number): void => { | ||
console.log(state, current, total); | ||
}; | ||
|
||
const isDone = await device.brain.uploadProgram(ini, bin, cold, onProgress); | ||
console.log("done", isDone); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.