Skip to content
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
19 changes: 12 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,25 @@ jobs:
name: push
runs-on: ubuntu-latest

permissions:
contents: read
# https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions
id-token: write

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v6
- run: corepack enable
- uses: actions/setup-node@v6
with:
node-version: 16.x
node-version: 22.x
registry-url: https://registry.npmjs.org
cache: yarn

- run: yarn install --frozen-lockfile
- run: yarn install --immutable
- run: yarn run build
- run: yarn run lint:ci
- run: yarn run test

- name: Publish to NPM
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: yarn publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
run: yarn npm publish --provenance --access public
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,13 @@ dist

# TernJS port file
.tern-port
.DS_Store

# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.pnp.*
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@foxglove/cdr",
"version": "3.5.0",
"packageManager": "[email protected]",
"description": "Common Data Representation serialization and deserialization library",
"license": "MIT",
"keywords": [
Expand Down Expand Up @@ -30,7 +31,7 @@
],
"scripts": {
"build": "yarn clean && tsc -b",
"clean": "rimraf dist *.tsbuildinfo",
"clean": "rimraf dist '*.tsbuildinfo'",
"lint:ci": "eslint --report-unused-disable-directives .",
"lint": "eslint --report-unused-disable-directives --fix .",
"prepack": "yarn build",
Expand All @@ -41,21 +42,21 @@
"node": ">= 14"
},
"devDependencies": {
"@foxglove/eslint-plugin": "0.17.0",
"@types/jest": "27.0.1",
"@typescript-eslint/eslint-plugin": "4.31.1",
"@typescript-eslint/parser": "4.31.1",
"eslint": "7.32.0",
"eslint-config-prettier": "8.3.0",
"@foxglove/eslint-plugin": "0.21.0",
"@types/jest": "29.5.14",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-es": "4.1.0",
"eslint-plugin-filenames": "1.3.2",
"eslint-plugin-import": "2.24.2",
"eslint-plugin-jest": "24.4.0",
"eslint-plugin-prettier": "4.0.0",
"jest": "27.2.0",
"prettier": "2.4.0",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-jest": "27.9.0",
"eslint-plugin-prettier": "5.2.1",
"jest": "29.7.0",
"prettier": "3.5.1",
"rimraf": "3.0.2",
"ts-jest": "27.0.5",
"typescript": "4.4.3"
"ts-jest": "29.2.5",
"typescript": "5.7.3"
}
}
16 changes: 8 additions & 8 deletions src/CdrReader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@
expect(Array.from(array.values())).toEqual(expected);
});

it.each([

Check warning on line 131 in src/CdrReader.test.ts

View workflow job for this annotation

GitHub Actions / push

Test has no assertions
["float32Array", "float32", [-3.835, 0, Math.PI], 6],
["float64Array", "float64", [-3.835, 0, Math.PI], 15],
["float64Array", "float64", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -0.123456789121212121212], 15],
["float64Array", "float64", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -0.12345678912121212], 15],
])("reads float %s", (getter: string, setter: string, expected: number[], numDigits: number) => {
const writer = new CdrWriter();
writeArray(writer, setter as Setter, expected);
Expand Down Expand Up @@ -231,12 +231,12 @@
const buffer = new Uint8Array(Buffer.from("00030000017f080064000000400000000", "hex"));
const reader = new CdrReader(buffer);
expect(reader.emHeader()).toMatchInlineSnapshot(`
Object {
"id": 100,
"mustUnderstand": true,
"objectSize": 64,
}
`);
{
"id": 100,
"mustUnderstand": true,
"objectSize": 64,
}
`);
});

it("takes a length when reading a string and doesn't read the sequence length again", () => {
Expand Down Expand Up @@ -403,7 +403,7 @@
const writer = new CdrWriter({ kind: EncapsulationKind.CDR_LE });
writer.uint8(1); // placeholder, won't be read
const reader = new CdrReader(writer.data);
expect(() => reader.isPresentFlag()).toThrowError(/only supported for CDR2/i);
expect(() => reader.isPresentFlag()).toThrow(/only supported for CDR2/i);
});
it("can seek to end of the buffer", () => {
const writer = new CdrWriter({ size: 8 });
Expand Down
4 changes: 2 additions & 2 deletions src/CdrWriter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe("CdrWriter", () => {
writer.uint32BE(0x12345678);
writer.uint64BE(0x123456789abcdef0n);
writer.float32(-9.14);
writer.float64(1.7976931348623158e100);
writer.float64(1.7976931348623e100);
writer.string("abc");
writer.sequenceLength(42);
const data = writer.data;
Expand All @@ -120,7 +120,7 @@ describe("CdrWriter", () => {
expect(reader.uint32BE()).toEqual(0x12345678);
expect(reader.uint64BE()).toEqual(0x123456789abcdef0n);
expect(reader.float32()).toBeCloseTo(-9.14);
expect(reader.float64()).toBeCloseTo(1.7976931348623158e100);
expect(reader.float64()).toBeCloseTo(1.7976931348623e100);
expect(reader.string()).toEqual("abc");
expect(reader.sequenceLength()).toEqual(42);
});
Expand Down
Loading