Skip to content

Commit 31d783e

Browse files
authored
Merge pull request #198 from kshitish182/master
Upgrade `knex(v2.4.2)` and `typescript(v5.0.4)` to latest version
2 parents 3b93c8d + 2a5a29e commit 31d783e

27 files changed

Lines changed: 158 additions & 914 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
/tmp
88
node_modules
99
/coverage
10+
11+
# IDE settings
12+
.vscode

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,12 @@ import { synchronize, loadConfig, resolveConnections } from '@leapfrogtechnology
240240
You can also pass your own database connection (eg: Knex connection) instead of resolving `connections.sync-db.json` file.
241241

242242
```ts
243-
import * as Knex from 'knex';
243+
import { knex } from 'knex';
244244
import { synchronize, loadConfig } from '@leapfrogtechnology/sync-db';
245245

246246
(async () => {
247247
const config = await loadConfig(); // Load sync-db.yml
248-
const connection = Knex({
248+
const connection = knex({
249249
// Your Knex connection instance.
250250
client: 'mssql',
251251
connection: {

assets/templates/migration/create_ts.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as Knex from 'knex';
1+
import { Knex } from 'knex';
22

33
/**
44
* Create {{table}} table.

assets/templates/migration/update_ts.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as Knex from 'knex';
1+
import { Knex } from 'knex';
22

33
/**
44
* Alter {{table}} table.

examples/node-app-mssql-ts/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const { connections } = require('../connections.sync-db.json');
99
// Getting knex instance of mssql database with id db1.
1010
const db = knex({
1111
client: 'mssql',
12-
connection: connections.find(({ id }) => id === 'testdb1').connection
12+
connection: connections.find(({ id }) => id === 'db1').connection
1313
});
1414

1515
const tasks = await db.raw('SELECT * FROM utils.vw_tasks');

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@leapfrogtechnology/sync-db",
33
"description": "Command line utility to synchronize and version control relational database objects across databases",
4-
"version": "1.2.1",
4+
"version": "2.0.0",
55
"license": "MIT",
66
"main": "lib/index.js",
77
"types": "lib/index.d.ts",
@@ -62,8 +62,8 @@
6262
"debug": "^4.1.1",
6363
"esm": "^3.2.25",
6464
"globby": "^10.0.2",
65-
"knex": "^0.20.11",
66-
"ramda": "^0.26.1",
65+
"knex": "^2.4.2",
66+
"ramda": "^0.29.0",
6767
"ts-node": "^8",
6868
"tslib": "^1",
6969
"yamljs": "^0.3.0"
@@ -78,7 +78,7 @@
7878
"@types/debug": "^4.1.4",
7979
"@types/mocha": "^5",
8080
"@types/node": "^10",
81-
"@types/ramda": "^0.26.12",
81+
"@types/ramda": "^0.29.0",
8282
"@types/yamljs": "^0.2.30",
8383
"chai": "^4.2.0",
8484
"chai-as-promised": "^7.1.1",
@@ -90,7 +90,7 @@
9090
"prettier": "2.0.2",
9191
"tslint": "^6.1.3",
9292
"tslint-config-leapfrog": "^1.0.3",
93-
"typescript": "^3.8.2"
93+
"typescript": "^5.0.2"
9494
},
9595
"engines": {
9696
"node": ">= 14.15.0"

src/config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Knex } from 'knex';
12
import * as path from 'path';
23
import * as yaml from 'yamljs';
34
import { mergeDeepRight } from 'ramda';
@@ -58,7 +59,7 @@ export async function loadConfig(configFilename: string = CONFIG_FILENAME): Prom
5859

5960
log('Resolved config file.');
6061

61-
const loaded = mergeDeepRight(DEFAULT_CONFIG, loadedConfig) as Configuration;
62+
const loaded = mergeDeepRight<Configuration, Configuration>(DEFAULT_CONFIG, loadedConfig);
6263

6364
validate(loaded);
6465

@@ -130,8 +131,8 @@ export async function resolveConnections(config: Configuration, resolver?: strin
130131
id,
131132
client,
132133
connection: {
133-
host: (connection as any).host,
134-
database: (connection as any).database
134+
host: (connection as Knex.ConnectionConfig).host,
135+
database: (connection as Knex.ConnectionConfig).database
135136
}
136137
}))
137138
);

src/domain/ConnectionConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as Knex from 'knex';
1+
import { Knex } from 'knex';
22

33
/**
44
* Database connection configuration.

src/domain/ConnectionReference.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as Knex from 'knex';
1+
import { Knex } from 'knex';
22

33
/**
44
* Connection reference.

src/domain/MigrationContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as Knex from 'knex';
1+
import { Knex } from 'knex';
22

33
import OperationParams from './operation/OperationParams';
44
import OperationContext from './operation/OperationContext';

0 commit comments

Comments
 (0)