Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
Dependency/repo updates (#13)
Browse files Browse the repository at this point in the history
### Changelog
None

### Docs

None

### Description

Based on foxglove/rosbag2#20

- Upgrade yarn to v4
- Upgrade ESLint to v9
- Upgrade other devDependencies (will update dependencies separately)
- Add provenance attestation for npm publish
- Add dependabot
  • Loading branch information
jtbandes authored Dec 4, 2024
1 parent dc2c3f1 commit 3fec088
Show file tree
Hide file tree
Showing 11 changed files with 6,250 additions and 4,521 deletions.
19 changes: 0 additions & 19 deletions .eslintrc.yaml

This file was deleted.

13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: monthly
labels: [] # Disable default labels

- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
labels: [] # Disable default labels
17 changes: 12 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,30 @@ jobs:
name: push
runs-on: ubuntu-latest

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

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4.2.2
with:
lfs: true
- uses: actions/setup-node@v3
- run: corepack enable
- uses: actions/[email protected]
with:
node-version: 16.x
node-version: 20.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

- run: yarn pack
- name: Publish to NPM
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: yarn publish --access public
# `yarn npm publish` does not currently support --provenance: https://github.com/yarnpkg/berry/issues/5430
run: npm publish package.tgz --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
112 changes: 11 additions & 101 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,106 +1,16 @@
.DS_Store

# Logs
logs
.npm
.pnp.*
.yarn-integrity
.yarn/*
*.lcov
*.log
*.tgz
*.tsbuildinfo
coverage
dist
node_modules/
npm-debug.log*
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
5 changes: 1 addition & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,5 @@
".yarn/**": true,
"yarn.lock": true
},
"typescript.tsdk": "node_modules/typescript/lib",
"eslint.options": {
"reportUnusedDisableDirectives": true
}
"typescript.tsdk": "node_modules/typescript/lib"
}
3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defaultSemverRangePrefix: ""

nodeLinker: node-modules
27 changes: 27 additions & 0 deletions eslint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// @ts-check

const foxglove = require("@foxglove/eslint-plugin");
const tseslint = require("typescript-eslint");

module.exports = tseslint.config(
{
ignores: ["**/dist"],
},
{
files: ["**/*.ts", "**/*.tsx"],
languageOptions: {
parserOptions: {
project: "./tsconfig.json",
},
},
rules: {
"@typescript-eslint/explicit-member-accessibility": "error",
},
},
...foxglove.configs.base,
...foxglove.configs.jest,
...foxglove.configs.typescript.map((config) => ({
files: ["**/*.ts", "**/*.tsx"],
...config,
})),
);
33 changes: 13 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
],
"scripts": {
"build": "tsc -b",
"lint:ci": "eslint --report-unused-disable-directives .",
"lint": "eslint --report-unused-disable-directives --fix .",
"lint:ci": "eslint .",
"lint": "eslint --fix .",
"prepack": "yarn build",
"prepublishOnly": "yarn lint:ci && yarn test",
"test": "jest"
Expand All @@ -44,26 +44,19 @@
"node": ">= 14"
},
"devDependencies": {
"@foxglove/eslint-plugin": "0.21.0",
"@types/better-sqlite3": "^7.6.3",
"@types/jest": "^29.4.0",
"@types/node": "^18.14.2",
"@typescript-eslint/eslint-plugin": "5.54.0",
"@typescript-eslint/parser": "5.54.0",
"eslint": "8.35.0",
"eslint-config-prettier": "8.6.0",
"eslint-plugin-es": "4.1.0",
"eslint-plugin-filenames": "1.3.2",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jest": "27.2.1",
"eslint-plugin-prettier": "4.2.1",
"jest": "29.4.3",
"prettier": "2.8.4",
"ts-jest": "29.0.5",
"typescript": "4.9.5"
"@foxglove/eslint-plugin": "2.0.0",
"@types/better-sqlite3": "^7.6.12",
"@types/jest": "^29.5.14",
"@types/node": "^22.10.1",
"eslint": "9.16.0",
"jest": "29.7.0",
"prettier": "3.4.2",
"ts-jest": "29.2.5",
"typescript": "5.7.2"
},
"dependencies": {
"@foxglove/rosbag2": "^5.0.0",
"better-sqlite3": "^8.1.0"
}
},
"packageManager": "[email protected]"
}
5 changes: 3 additions & 2 deletions src/Rosbag2.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable jest/no-conditional-expect */
import { Rosbag2 } from "@foxglove/rosbag2";
import { Time, isGreaterThan, isTimeInRangeInclusive } from "@foxglove/rostime";
import path from "path";
Expand Down Expand Up @@ -63,7 +64,7 @@ describe("SqliteNodejs single bag file handling", () => {
expect(topics[2]!.name).toEqual("/topic");
});

it("reads the topic list", async () => {
it("reads message counts", async () => {
const bagFilename = path.join(__dirname, "..", "tests", "bags", "talker", "talker.db3");
const bag = await openNodejsFile(bagFilename);

Expand Down Expand Up @@ -133,7 +134,7 @@ describe("SqliteNodejs single bag directory handling", () => {
expect(topics[2]!.name).toEqual("/topic");
});

it("reads the topic list", async () => {
it("reads message counts", async () => {
const bagPath = path.join(__dirname, "..", "tests", "bags", "talker");
const bag = await openNodejsDirectory(bagPath);

Expand Down
17 changes: 9 additions & 8 deletions src/SqliteNodejs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ type TopicRow = {
};

export class SqliteNodejs implements SqliteDb {
readonly filename: string;
public readonly filename: string;
// eslint-disable-next-line @foxglove/prefer-hash-private
private context?: DbContext;

constructor(filename: string) {
public constructor(filename: string) {
this.filename = filename;
}

async open(): Promise<void> {
public async open(): Promise<void> {
if (this.context != undefined) {
return;
}
Expand Down Expand Up @@ -71,21 +72,21 @@ export class SqliteNodejs implements SqliteDb {
};
}

async close(): Promise<void> {
public async close(): Promise<void> {
if (this.context != undefined) {
this.context.db.close();
this.context = undefined;
}
}

async readTopics(): Promise<TopicDefinition[]> {
public async readTopics(): Promise<TopicDefinition[]> {
if (this.context == undefined) {
throw new Error(`Call open() before reading topics`);
}
return Array.from(this.context.idToTopic.values());
}

readMessages(opts: MessageReadOptions = {}): AsyncIterableIterator<RawMessage> {
public readMessages(opts: MessageReadOptions = {}): AsyncIterableIterator<RawMessage> {
if (this.context == undefined) {
throw new Error(`Call open() before reading messages`);
}
Expand Down Expand Up @@ -146,7 +147,7 @@ export class SqliteNodejs implements SqliteDb {
return new RawMessageIterator(iterator, idToTopic);
}

async timeRange(): Promise<[min: Time, max: Time]> {
public async timeRange(): Promise<[min: Time, max: Time]> {
if (this.context == undefined) {
throw new Error(`Call open() before retrieving the time range`);
}
Expand All @@ -157,7 +158,7 @@ export class SqliteNodejs implements SqliteDb {
return [fromNanoSec(res.start ?? 0n), fromNanoSec(res.end ?? 0n)];
}

async messageCounts(): Promise<Map<string, number>> {
public async messageCounts(): Promise<Map<string, number>> {
if (this.context == undefined) {
throw new Error(`Call open() before retrieving message counts`);
}
Expand Down
Loading

0 comments on commit 3fec088

Please sign in to comment.