Skip to content

Commit

Permalink
fix: update deps, add debug module
Browse files Browse the repository at this point in the history
  • Loading branch information
AVVS committed Apr 3, 2022
1 parent 8c315c1 commit f1d8325
Show file tree
Hide file tree
Showing 10 changed files with 2,592 additions and 1,414 deletions.
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

"`$(npm bin)/mdep bin 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 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint && yarn typecheck
8 changes: 8 additions & 0 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

case "$2,$3" in
merge,)
ex "+%s/Merge branch '\([^']\+\)'/chore(merge): \1/i" -scwq $1 ;;
*) ;;
esac
48 changes: 22 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "@microfleet/clickhouse-root",
"license": "MIT",
"private": true,
"version": "0.0.0",
"workspaces": [
"packages/**/*",
"test"
Expand All @@ -15,46 +17,40 @@
"format": "prettier \"**/*.ts\" --write && git status",
"test": "yarn compile && lerna run test --stream",
"prepublishOnly": "yarn compile",
"semantic-release": "semantic-release"
"semantic-release": "semantic-release",
"prepare": "mdep install"
},
"keywords": [
"clickhouse",
"adapter",
"client"
],
"devDependencies": {
"@makeomatic/deploy": "10.4.0",
"@makeomatic/deploy": "12.6.3",
"@types/bluebird": "3.5.36",
"@types/jest": "27.0.1",
"@types/lodash": "4.14.172",
"@types/node": "16.7.2",
"@typescript-eslint/eslint-plugin": "4.29.3",
"@typescript-eslint/parser": "4.29.3",
"@types/jest": "27.4.1",
"@types/lodash": "4.14.181",
"@types/node": "17.0.23",
"@typescript-eslint/eslint-plugin": "5.17.0",
"@typescript-eslint/parser": "5.17.0",
"commitizen": "4.2.4",
"cross-env": "7.0.3",
"cz-lerna-changelog": "2.0.3",
"eslint": "7.32.0",
"eslint-config-airbnb-typescript": "14.0.0",
"eslint-config-makeomatic": "^5.0.4",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-import": "2.24.2",
"eslint-plugin-prettier": "3.4.1",
"husky": "4.3.0",
"jest": "27.0.6",
"eslint": "8.12.0",
"eslint-config-airbnb-typescript": "16.2.0",
"eslint-config-makeomatic": "^5.1.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-prettier": "4.0.0",
"husky": "7.0.4",
"jest": "27.5.1",
"lerna": "4.0.0",
"prettier": "2.3.2",
"prettier": "2.6.2",
"prettier-eslint": "13.0.0",
"rimraf": "3.0.2",
"ts-jest": "27.0.5",
"ts-node": "10.2.1",
"typescript": "4.3.5"
},
"husky": {
"hooks": {
"pre-commit": "yarn lint && yarn typecheck",
"commit-msg": "commitlint -e $HUSKY_GIT_PARAMS",
"prepare-commit-msg": "./node_modules/@makeomatic/deploy/git-hooks/prepare-commit-msg $HUSKY_GIT_PARAMS"
}
"ts-jest": "27.1.4",
"ts-node": "10.7.0",
"typescript": "4.6.3"
},
"config": {
"commitizen": {
Expand Down
2 changes: 1 addition & 1 deletion packages/clickhouse-adapter/.mdeprc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"repo": "makeomatic/node",
"node": "14.17",
"node": "16",
"nycCoverage": false,
"coverage": false,
"test_framework": "jest --verbose -i -b -c ../../jest.config.js --coverageDirectory <coverageDirectory>",
Expand Down
10 changes: 6 additions & 4 deletions packages/clickhouse-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@makeomatic/clickhouse": "1.7.1",
"@makeomatic/clickhouse": "1.8.0",
"bluebird": "3.7.2",
"debug": "^4.3.4",
"lodash": "4.17.21",
"moment": "2.29.1",
"sqlstring": "2.3.2"
"moment": "2.29.2",
"sqlstring": "2.3.3"
},
"devDependencies": {
"@types/lodash": "4.14.172",
"@types/debug": "^4.1.7",
"@types/lodash": "4.14.181",
"@types/sqlstring": "2.3.0"
},
"publishConfig": {
Expand Down
8 changes: 8 additions & 0 deletions packages/clickhouse-adapter/src/migrators/migrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import SqlString from 'sqlstring'
import { Promise } from 'bluebird'
import { ClickhouseClient } from '../client'
import { Migration } from '../interfaces'
import _debug = require('debug')

const debug = _debug('microfleet:clickhouse:migrator')
export class Migrator {
private readonly ch: ClickhouseClient

Expand All @@ -23,8 +25,10 @@ export class Migrator {
public migrateAll(dbName: string) {
return (migrator: Migrator): Promise<Migration[]> => {
const migrations = migrator.migrationList()
debug('migration list', migrations)

return Promise.each(migrations, (migration: Migration) => {
debug('migrating', dbName, migration.name)
return migrator.migrate(dbName)(migration)
})
}
Expand All @@ -36,10 +40,14 @@ export class Migrator {

private migrate(dbName: string): (migration: Migration) => Promise<void> {
return async (migration: Migration) => {
debug('verifying existance', dbName, migration.name)
if (!(await this.isExistsMigration(dbName, migration.name))) {
debug('migration.up', dbName, migration.name)
await migration.up(this.ch, dbName)
debug('saveMigrationResult', dbName, migration.name)
await this.saveMigrationResult(dbName, migration.name)
}
debug('migration done', dbName, migration.name)
}
}

Expand Down
9 changes: 9 additions & 0 deletions packages/clickhouse-adapter/src/migrators/system.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { ClickhouseClient } from '../client'
import { TableMaker } from '../utils'
import _debug = require('debug')

const debug = _debug('microfleet:clickhouse:system')

const createDb = (dbName: string): string =>
`CREATE DATABASE IF NOT EXISTS ${dbName} ON CLUSTER '{cluster}'`
Expand All @@ -12,6 +15,8 @@ export class SystemMigrator {
}

public async up(dbName: string): Promise<void> {
debug('creating db')

await this.ch.queryAsync(createDb(dbName), {
format: 'TabSeparated',
})
Expand All @@ -28,9 +33,13 @@ export class SystemMigrator {
],
})

debug('creating migration table')

await this.ch.queryAsync(migrationTable.toSql(), {
queryOptions: { database: dbName },
format: 'TabSeparated',
})

debug('done')
}
}
2 changes: 1 addition & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"version": "0.2.0",
"private": true,
"dependencies": {
"moment": "2.29.1"
"moment": "2.29.2"
}
}
Loading

0 comments on commit f1d8325

Please sign in to comment.