Skip to content

Commit

Permalink
chore: modernize
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Oct 3, 2024
1 parent 43c4ce6 commit ab094e9
Show file tree
Hide file tree
Showing 10 changed files with 542 additions and 561 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: yarn --frozen-lockfile

- name: build
run: yarn dev-lib build
run: yarn build

- name: release
env:
Expand Down
5 changes: 1 addition & 4 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/bin/sh
[ -n "$CI" ] && exit 0
. "$(dirname "$0")/_/husky.sh"

node_modules/.bin/commitlint-def $1
# exit 1 # uncomment to debug
dev-lib commitlint $1
4 changes: 1 addition & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/sh
[ -n "$CI" ] && exit 0
. "$(dirname "$0")/_/husky.sh"

node_modules/.bin/lint-staged-def
dev-lib lint-staged
4 changes: 4 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
"extends": ["node_modules/@naturalcycles/dev-lib/cfg/biome.jsonc"]
}
4 changes: 4 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// prettier-ignore
module.exports = [
...require('@naturalcycles/dev-lib/cfg/eslint.config'),
]
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"name": "@naturalcycles/mysql-lib",
"scripts": {
"prepare": "husky"
"prepare": "husky",
"build": "dev-lib build",
"test": "dev-lib test",
"lint": "dev-lib lint",
"bt": "dev-lib bt",
"lbt": "dev-lib lbt"
},
"dependencies": {
"@naturalcycles/db-lib": "^9.1.0",
Expand All @@ -12,7 +17,7 @@
},
"devDependencies": {
"@naturalcycles/dev-lib": "^15.18.0",
"@types/node": "^20.2.3",
"@types/node": "^22.7.4",
"dotenv": "^16.0.0",
"jest": "^29.0.0"
},
Expand All @@ -34,7 +39,7 @@
"url": "https://github.com/NaturalCycles/mysql-lib"
},
"engines": {
"node": ">=18.12.0"
"node": ">=20.13.0"
},
"version": "3.8.1",
"description": "MySQL client implementing CommonDB interface",
Expand Down
1 change: 1 addition & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@naturalcycles/dev-lib/cfg/prettier.config')
16 changes: 8 additions & 8 deletions src/mysql.db.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { Readable } from 'node:stream'
import { promisify } from 'node:util'
import {
DBPatch,
BaseCommonDB,
CommonDB,
CommonDBCreateOptions,
commonDBFullSupport,
CommonDBOptions,
CommonDBSaveOptions,
DBQuery,
RunQueryResult,
CommonDBSupport,
commonDBFullSupport,
CommonDBType,
DBPatch,
DBQuery,
RunQueryResult,
} from '@naturalcycles/db-lib'
import {
_assert,
Expand Down Expand Up @@ -253,7 +253,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB {
.map(s => s.trim())
.filter(Boolean)

for await (const sql of queries) {
for (const sql of queries) {
await this.runSQL({ sql })
}
}
Expand Down Expand Up @@ -310,7 +310,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB {
// Insert rows one-by-one, to get their auto-generated id

let i = -1
for await (const row of rows) {
for (const row of rows) {
i++
if (row.id) {
// Update already existing
Expand All @@ -331,7 +331,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB {

if (opt.saveMethod === 'update') {
// TODO: This fails if a combination of entities with id and without id are parsed
for await (const row of rows) {
for (const row of rows) {
// Update already existing
_assert(row.id, 'id is required for updating')
const query = new DBQuery(table).filterEq('id', row.id)
Expand All @@ -344,7 +344,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB {
// inserts are split into multiple sentenses to respect the max_packet_size (1Mb usually)
const sqls = insertSQL(table, rows, verb, this.cfg.logger)

for await (const sql of sqls) {
for (const sql of sqls) {
await this.runSQL({ sql })
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/schema/mysql.schema.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function jsonSchemaToMySQLDDL(
return `id VARCHAR(255) NOT NULL`
}

let type
let type: string

if (s.type === 'string') {
// can specify isoDate later
Expand Down
Loading

0 comments on commit ab094e9

Please sign in to comment.