Skip to content
This repository was archived by the owner on May 25, 2025. It is now read-only.

Commit 846f39f

Browse files
feat: modernize
1 parent 0f191ee commit 846f39f

13 files changed

+1158
-1465
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
run: yarn --frozen-lockfile
2424

2525
- name: build
26-
run: yarn build-prod
26+
run: yarn build
2727

2828
- name: release
2929
env:

.husky/commit-msg

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#!/bin/sh
21
[ -n "$CI" ] && exit 0
3-
. "$(dirname "$0")/_/husky.sh"
42

5-
./node_modules/.bin/commitlint-def $1
6-
# exit 1 # uncomment to debug
3+
dev-lib commitlint $1

.husky/pre-commit

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/bin/sh
21
[ -n "$CI" ] && exit 0
3-
. "$(dirname "$0")/_/husky.sh"
42

5-
./node_modules/.bin/lint-staged-def
3+
dev-lib lint-staged

biome.jsonc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
3+
"extends": ["node_modules/@naturalcycles/dev-lib/cfg/biome.jsonc"]
4+
}

eslint.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// prettier-ignore
2+
module.exports = [
3+
...require('@naturalcycles/dev-lib/cfg/eslint.config'),
4+
]

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
22
"name": "@naturalcycles/sqlite-lib",
33
"scripts": {
4-
"prepare": "husky"
4+
"prepare": "husky",
5+
"build": "dev-lib build",
6+
"test": "dev-lib test",
7+
"lint": "dev-lib lint",
8+
"bt": "dev-lib bt",
9+
"lbt": "dev-lib lbt"
510
},
611
"dependencies": {
712
"@naturalcycles/db-lib": "^9.1.0",
@@ -14,8 +19,8 @@
1419
"sqlite3": "^5.1.1"
1520
},
1621
"devDependencies": {
17-
"@naturalcycles/dev-lib": "^13.0.1",
18-
"@types/node": "^20.5.9",
22+
"@naturalcycles/dev-lib": "^15.21.0",
23+
"@types/node": "^22.7.5",
1924
"jest": "^29.0.3"
2025
},
2126
"files": [

prettier.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@naturalcycles/dev-lib/cfg/prettier.config')

scripts/generateTestTable.script.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import { Readable } from 'node:stream'
1212
import { TEST_TABLE } from '@naturalcycles/db-lib/dist/testing'
1313
import { _range } from '@naturalcycles/js-lib'
1414
import {
15-
transformLogProgress,
16-
writableForEach,
1715
_pipeline,
1816
runScript,
17+
transformLogProgress,
18+
writableForEach,
1919
} from '@naturalcycles/nodejs-lib'
2020
import { SqliteKeyValueDB } from '../src'
2121
import { tmpDir } from '../src/test/paths.cnst'

scripts/streamingTest.script.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ DEBUG=nc* yarn tsn streamingTest
66

77
import { TEST_TABLE } from '@naturalcycles/db-lib/dist/testing'
88
import {
9-
transformLogProgress,
10-
writableForEach,
119
_pipeline,
1210
runScript,
11+
transformLogProgress,
12+
writableForEach,
1313
} from '@naturalcycles/nodejs-lib'
1414
import { SqliteKeyValueDB } from '../src'
1515
import { tmpDir } from '../src/test/paths.cnst'

src/betterSqliteKeyValueDB.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CommonDBCreateOptions, CommonKeyValueDB, KeyValueDBTuple } from '@naturalcycles/db-lib'
2-
import { CommonLogger } from '@naturalcycles/js-lib'
3-
import { readableCreate, ReadableTyped, boldWhite } from '@naturalcycles/nodejs-lib'
4-
import type { Options, Database } from 'better-sqlite3'
2+
import { AppError, CommonLogger } from '@naturalcycles/js-lib'
3+
import { boldWhite, readableCreate, ReadableTyped } from '@naturalcycles/nodejs-lib'
4+
import type { Database, Options } from 'better-sqlite3'
55
import BetterSqlite3 from 'better-sqlite3'
66

77
export interface BetterSQLiteKeyValueDBCfg extends Options {
@@ -192,4 +192,8 @@ export class BetterSqliteKeyValueDB implements CommonKeyValueDB {
192192
const { cnt } = this.db.prepare(sql).get() as { cnt: number }
193193
return cnt
194194
}
195+
196+
async increment(_table: string, _id: string, _by?: number): Promise<number> {
197+
throw new AppError('Not implemented')
198+
}
195199
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1+
export * from './betterSqliteKeyValueDB'
12
export * from './sqlite.db'
23
export * from './sqliteKeyValueDB'
3-
export * from './betterSqliteKeyValueDB'

src/sqliteKeyValueDB.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { CommonDBCreateOptions, CommonKeyValueDB, KeyValueDBTuple } from '@naturalcycles/db-lib'
2-
import { CommonLogger, pMap } from '@naturalcycles/js-lib'
3-
import { readableCreate, ReadableTyped, boldWhite } from '@naturalcycles/nodejs-lib'
2+
import { AppError, CommonLogger, pMap } from '@naturalcycles/js-lib'
3+
import { boldWhite, readableCreate, ReadableTyped } from '@naturalcycles/nodejs-lib'
44
import { Database, open } from 'sqlite'
55
import * as sqlite3 from 'sqlite3'
66
import { OPEN_CREATE, OPEN_READWRITE } from 'sqlite3'
@@ -51,8 +51,9 @@ export class SqliteKeyValueDB implements CommonKeyValueDB {
5151
_db?: Database
5252

5353
get db(): Database {
54-
if (!this._db)
54+
if (!this._db) {
5555
throw new Error('await SqliteKeyValueDB.open() should be called before using the DB')
56+
}
5657
return this._db
5758
}
5859

@@ -214,4 +215,8 @@ export class SqliteKeyValueDB implements CommonKeyValueDB {
214215
const { cnt } = (await this.db.get<{ cnt: number }>(sql))!
215216
return cnt
216217
}
218+
219+
async increment(_table: string, _id: string, _by?: number): Promise<number> {
220+
throw new AppError('Not implemented')
221+
}
217222
}

0 commit comments

Comments
 (0)