postgrator
Advanced tools
Comparing version 3.2.0 to 3.3.0
# CHANGELOG | ||
## 3.2.0 | ||
### Jan 15 2018 | ||
* Add support for pg@6 | ||
## 3.1.0 | ||
@@ -4,0 +10,0 @@ |
@@ -0,1 +1,3 @@ | ||
const utils = require('./utils') | ||
const DRIVERS = ['pg', 'mysql', 'mssql'] | ||
@@ -145,2 +147,3 @@ | ||
} | ||
utils.supportWarning('mysql', 2, 2) | ||
@@ -198,2 +201,4 @@ commonClient._createConnection = () => { | ||
} | ||
utils.supportWarning('pg', 6, 7) | ||
if (config.ssl) { | ||
@@ -241,2 +246,3 @@ commonClient.dbDriver.defaults.ssl = true | ||
} | ||
utils.supportWarning('mssql', 4, 4) | ||
@@ -243,0 +249,0 @@ const oneHour = 1000 * 60 * 60 |
@@ -50,7 +50,64 @@ const fs = require('fs') | ||
/** | ||
* Returns major version of installed package relative to this project | ||
* @param {string} packageName | ||
*/ | ||
function getMajorVersion(packageName) { | ||
let majorVersion, path | ||
// If module is not installed this throws error | ||
try { | ||
path = require.resolve(packageName) | ||
} catch (error) { | ||
return null | ||
} | ||
const parts = path.split('/') | ||
while (parts.length && !majorVersion) { | ||
parts.pop() | ||
const checkPath = parts.join('/') + '/package.json' | ||
if (fs.existsSync(checkPath)) { | ||
const pkg = require(checkPath) | ||
if (pkg.name === packageName) { | ||
majorVersion = require(checkPath).version.split('.')[0] | ||
} | ||
} | ||
} | ||
return parseInt(majorVersion) | ||
} | ||
/** | ||
* Checks installed version of driver and prints warning depending on outcome | ||
* @param {string} driver | ||
* @param {number} minMajor | ||
* @param {number} maxMajor | ||
*/ | ||
function supportWarning(driver, minMajor, maxMajor) { | ||
const installedMajor = getMajorVersion(driver) | ||
if (installedMajor < minMajor) { | ||
console.error( | ||
`Package ${driver} version ${installedMajor}.x.x not supported` | ||
) | ||
if (maxMajor && maxMajor !== minMajor) { | ||
console.error( | ||
`Install ${driver} version ${minMajor}.x.x - ${maxMajor}.x.x` | ||
) | ||
} else { | ||
console.error(`Install ${driver} version ${minMajor}.x.x`) | ||
} | ||
} else if (installedMajor > maxMajor) { | ||
console.warn(`Package ${driver} version ${installedMajor}.x.x not tested`) | ||
console.warn(`Please raise issue to support ${driver} > ${maxMajor}.x.x`) | ||
} | ||
} | ||
module.exports = { | ||
checksum, | ||
fileChecksum, | ||
getMajorVersion, | ||
sortMigrationsAsc, | ||
sortMigrationsDesc | ||
sortMigrationsDesc, | ||
supportWarning | ||
} |
{ | ||
"name": "postgrator", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"author": "Rick Bergfalk <rick.bergfalk@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "A SQL migration tool for SQL people", |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
39870
646
6