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

Put actual package contents on npm #3

Merged
merged 24 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bea5ccc
ci: :technologist: add linter, formatter, pre-commit, ci, etc
meisZWFLZ Dec 4, 2023
358dc8d
style: :art: format code
meisZWFLZ Dec 4, 2023
b685627
ci: :bug: fix pre-commit hook
meisZWFLZ Dec 4, 2023
f7d5314
chore: :truck: scope package name to lemlib
meisZWFLZ Dec 4, 2023
e64cda1
ci: :hammer: fix lint script
meisZWFLZ Dec 4, 2023
c44e470
refactor: :rotating_light: fix some linter errors
meisZWFLZ Dec 4, 2023
21c4403
chore: :truck: add scope to package-lock.json
meisZWFLZ Dec 4, 2023
ee87c8a
fix: :bug: fix compile error
meisZWFLZ Dec 4, 2023
27de9d8
chore: :fire: .npmignore is not necessary
meisZWFLZ Dec 4, 2023
b35c815
ci: :hammer: add executable modifier for pre commit hooks
meisZWFLZ Dec 4, 2023
f728825
ci: :construction_worker: automate publishing
meisZWFLZ Dec 4, 2023
65f2827
refactor: :recycle: use map for listeners and fix linter errors
meisZWFLZ Dec 4, 2023
ef8df50
Merge branch 'main' of https://github.com/LemLib/v5-serial-protocol
meisZWFLZ Dec 4, 2023
48d61af
style: :rotating_light: fix linter errors
meisZWFLZ Dec 5, 2023
4d1a723
refactor: :recycle: implement IniBuilder
meisZWFLZ Dec 5, 2023
f502039
style: :rotating_light: fix linter warnings
meisZWFLZ Dec 5, 2023
da58c20
style: :rotating_light: fix linter warnings
meisZWFLZ Dec 6, 2023
3f8dfea
fix: :bug: add back "port_" prefix
meisZWFLZ Dec 7, 2023
e86e720
style: :rotating_light: fix linter warnings
meisZWFLZ Dec 15, 2023
2bbf9f6
style: :rotating_light: fix linter warnings
meisZWFLZ Dec 15, 2023
9322205
style: :rotating_light: fix linter warnings
meisZWFLZ Dec 17, 2023
bf56048
style: :rotating_light: fix linter warnings
meisZWFLZ Dec 17, 2023
149d258
style: :rotating_light: fix all the linter warnings!
meisZWFLZ Dec 18, 2023
440d11d
style: :art: fix format
meisZWFLZ Dec 18, 2023
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
3 changes: 3 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["@commitlint/config-conventional"]
}
10 changes: 10 additions & 0 deletions .eslintrc.json
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": {}
}
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.md
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 -->
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
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 -->
11 changes: 11 additions & 0 deletions .github/dependabot.yml
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"
69 changes: 69 additions & 0 deletions .github/workflows/ci.yml
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 }}
4 changes: 4 additions & 0 deletions .husky/commit-msg
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}
4 changes: 4 additions & 0 deletions .husky/pre-commit
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
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
out
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
20 changes: 10 additions & 10 deletions babel.config.js
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",
],
],
};
10 changes: 5 additions & 5 deletions examples/connect.ts
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);
})();
54 changes: 24 additions & 30 deletions examples/tsconfig.json
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"]
}
}
64 changes: 36 additions & 28 deletions examples/upload.ts
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);
})();
10 changes: 5 additions & 5 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
*/

export default {
preset: 'ts-jest',
preset: "ts-jest",

testEnvironment: 'node',
testEnvironment: "node",

transform: {
'^.+\\.jsx?$': 'babel-jest',
'^.+\\.ts?$': 'ts-jest',
"^.+\\.jsx?$": "babel-jest",
"^.+\\.ts?$": "ts-jest",
},

// Indicates whether the coverage information should be collected while executing the test
Expand All @@ -20,5 +20,5 @@ export default {
coverageDirectory: "coverage",

// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8"
coverageProvider: "v8",
};
Loading