Comparing version 0.20.13 to 0.20.14
@@ -10,4 +10,2 @@ #!/usr/bin/env node | ||
const argv = require('getopts')(process.argv.slice(2)); | ||
const fs = require('fs'); | ||
const { promisify } = require('util'); | ||
const cliPkg = require('../package'); | ||
@@ -24,13 +22,12 @@ const { | ||
} = require('./utils/cli-config-utils'); | ||
const { readFile, writeFile } = require('./../lib/util/fs'); | ||
const { listMigrations } = require('./utils/migrationsLister'); | ||
const fsPromised = { | ||
readFile: promisify(fs.readFile), | ||
writeFile: promisify(fs.writeFile), | ||
}; | ||
async function openKnexfile(configPath) { | ||
let config = require(configPath); | ||
if (typeof config === 'function') { | ||
config = await config(); | ||
} | ||
function openKnexfile(configPath) { | ||
const config = require(configPath); | ||
// FYI: By default, the extension for the migration files is inferred | ||
@@ -44,3 +41,3 @@ // from the knexfile's extension. So, the following lines are in | ||
function initKnex(env, opts) { | ||
async function initKnex(env, opts) { | ||
checkLocalModule(env); | ||
@@ -61,3 +58,3 @@ if (process.cwd() !== env.cwd) { | ||
env.configuration = env.configPath | ||
? openKnexfile(env.configPath) | ||
? await openKnexfile(env.configPath) | ||
: mkConfigObj(opts); | ||
@@ -125,11 +122,10 @@ | ||
const stubPath = `./knexfile.${type}`; | ||
pending = fsPromised | ||
.readFile( | ||
path.dirname(env.modulePath) + | ||
'/lib/migrate/stub/knexfile-' + | ||
type + | ||
'.stub' | ||
) | ||
pending = readFile( | ||
path.dirname(env.modulePath) + | ||
'/lib/migrate/stub/knexfile-' + | ||
type + | ||
'.stub' | ||
) | ||
.then((code) => { | ||
return fsPromised.writeFile(stubPath, code); | ||
return writeFile(stubPath, code); | ||
}) | ||
@@ -153,6 +149,6 @@ .then(() => { | ||
) | ||
.action((name) => { | ||
.action(async (name) => { | ||
const opts = commander.opts(); | ||
opts.client = opts.client || 'sqlite3'; // We don't really care about client when creating migrations | ||
const instance = initKnex(env, opts); | ||
const instance = await initKnex(env, opts); | ||
const ext = getMigrationExtension(env, opts); | ||
@@ -180,3 +176,3 @@ const configOverrides = { extension: ext }; | ||
pending = initKnex(env, commander.opts()) | ||
.migrate.latest() | ||
.then((instance) => instance.migrate.latest()) | ||
.then(([batchNo, log]) => { | ||
@@ -201,3 +197,3 @@ if (log.length === 0) { | ||
pending = initKnex(env, commander.opts()) | ||
.migrate.up({ name }) | ||
.then((instance) => instance.migrate.up({ name })) | ||
.then(([batchNo, log]) => { | ||
@@ -228,3 +224,3 @@ if (log.length === 0) { | ||
pending = initKnex(env, commander.opts()) | ||
.migrate.rollback(null, all) | ||
.then((instance) => instance.migrate.rollback(null, all)) | ||
.then(([batchNo, log]) => { | ||
@@ -250,3 +246,3 @@ if (log.length === 0) { | ||
pending = initKnex(env, commander.opts()) | ||
.migrate.down({ name }) | ||
.then((instance) => instance.migrate.down({ name })) | ||
.then(([batchNo, log]) => { | ||
@@ -273,3 +269,3 @@ if (log.length === 0) { | ||
pending = initKnex(env, commander.opts()) | ||
.migrate.currentVersion() | ||
.then((instance) => instance.migrate.currentVersion()) | ||
.then((version) => { | ||
@@ -287,3 +283,5 @@ success(color.green('Current Version: ') + color.blue(version)); | ||
pending = initKnex(env, commander.opts()) | ||
.migrate.list() | ||
.then((instance) => { | ||
return instance.migrate.list(); | ||
}) | ||
.then(([completed, newMigrations]) => { | ||
@@ -306,6 +304,6 @@ listMigrations(completed, newMigrations); | ||
) | ||
.action((name) => { | ||
.action(async (name) => { | ||
const opts = commander.opts(); | ||
opts.client = opts.client || 'sqlite3'; // We don't really care about client when creating seeds | ||
const instance = initKnex(env, opts); | ||
const instance = await initKnex(env, opts); | ||
const ext = getSeedExtension(env, opts); | ||
@@ -333,3 +331,3 @@ const configOverrides = { extension: ext }; | ||
pending = initKnex(env, commander.opts()) | ||
.seed.run({ specific: argv.specific }) | ||
.then((instance) => instance.seed.run({ specific: argv.specific })) | ||
.then(([log]) => { | ||
@@ -336,0 +334,0 @@ if (log.length === 0) { |
# Master (Unreleased) | ||
# 0.20.14 - 13 April, 2020 | ||
### New features: | ||
- CLI: adds support for asynchronous knexfile loading #3748 | ||
- Add clearGroup method #3771 | ||
### Typings: | ||
- Support Raw types for insert, where, update #3730 | ||
- Add typings for MigrationSource #3756 | ||
- Update signature of orderBy to support QueryBuilder inside array #3757 | ||
- Add toSQL and toString to SchemaBuilder #3758 | ||
- `interface Knex` and `function Knex` should have the same types #3787 | ||
- Fix minor issues around typings #3765 | ||
### Test / internal changes: | ||
- Minor test internal enhancements #3747 | ||
- Minor improvements on the usage of fs utilities #3749 | ||
- Split tests in groups #3785 | ||
# 0.20.13 - 23 March, 2020 | ||
@@ -4,0 +26,0 @@ |
@@ -1,7 +0,5 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { promisify } = require('util'); | ||
const { sortBy, filter } = require('lodash'); | ||
const readDirAsync = promisify(fs.readdir); | ||
const { readdir } = require('../../util/fs'); | ||
@@ -38,3 +36,3 @@ const DEFAULT_LOAD_EXTENSIONS = Object.freeze([ | ||
const absoluteDir = path.resolve(process.cwd(), configDir); | ||
return readDirAsync(absoluteDir).then((files) => ({ | ||
return readdir(absoluteDir).then((files) => ({ | ||
files, | ||
@@ -41,0 +39,0 @@ configDir, |
@@ -1031,2 +1031,8 @@ // Builder | ||
// Remove everything from group clause | ||
clearGroup() { | ||
this._clearGrouping('group'); | ||
return this; | ||
}, | ||
// Remove everything from order clause | ||
@@ -1033,0 +1039,0 @@ clearOrder() { |
@@ -81,2 +81,3 @@ // All properties we can use to start a query chain | ||
'clearWhere', | ||
'clearGroup', | ||
'clearOrder', | ||
@@ -83,0 +84,0 @@ 'clearHaving', |
// Seeder | ||
// ------- | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { promisify } = require('util'); | ||
const mkdirp = require('mkdirp'); | ||
const { filter, includes, extend } = require('lodash'); | ||
const { readdir, ensureDirectoryExists } = require('../util/fs'); | ||
const { writeJsFileUsingTemplate } = require('../util/template'); | ||
@@ -45,3 +43,3 @@ | ||
const loadExtensions = this.config.loadExtensions; | ||
return promisify(fs.readdir)(this._absoluteConfigDir()).then((seeds) => | ||
return readdir(this._absoluteConfigDir()).then((seeds) => | ||
filter(seeds, (value) => { | ||
@@ -58,7 +56,4 @@ const extension = path.extname(value); | ||
const dir = this._absoluteConfigDir(); | ||
try { | ||
await promisify(fs.stat)(dir); | ||
} catch (e) { | ||
await promisify(mkdirp)(dir); | ||
} | ||
await ensureDirectoryExists(dir); | ||
} | ||
@@ -65,0 +60,0 @@ |
const { template } = require('lodash'); | ||
const { promisify } = require('util'); | ||
const fs = require('fs'); | ||
const { readFile, writeFile } = require('./fs'); | ||
/** | ||
@@ -19,5 +19,2 @@ * Light wrapper over lodash templates making it safer to be used with javascript source code. | ||
const readFile = promisify(fs.readFile, { context: fs }); | ||
const writeFile = promisify(fs.writeFile, { context: fs }); | ||
/** | ||
@@ -24,0 +21,0 @@ * Compile the contents of specified (javascript) file as a lodash template |
{ | ||
"name": "knex", | ||
"version": "0.20.13", | ||
"version": "0.20.14", | ||
"description": "A batteries-included SQL query & schema builder for Postgres, MySQL and SQLite3 and the Browser", | ||
@@ -12,3 +12,3 @@ "main": "knex.js", | ||
"format": "prettier --write \"{lib,bin,scripts,test}/**/*.js\"", | ||
"debug:test": "mocha --inspect-brk --exit -t 0 test/index.js", | ||
"debug:test": "mocha --inspect-brk --exit -t 0 test/all-tests-suite.js", | ||
"debug:tape": "node --inspect-brk test/tape/index.js", | ||
@@ -19,4 +19,6 @@ "coveralls": "nyc report --reporter=text-lcov | coveralls", | ||
"lint:everything": "npm run lint:types && npm run lint", | ||
"test": "mocha --exit -t 10000 test/index.js && npm run test:tape && npm run test:cli", | ||
"test:coverage": "nyc mocha --exit --check-leaks --globals __core-js_shared__ -t 10000 test/index.js && npm run test:tape && npm run test:cli", | ||
"test:unit": "mocha --exit -t 10000 test/db-less-test-suite.js && npm run test:tape && npm run test:cli", | ||
"test:db": "mocha --exit -t 10000 test/integration-test-suite.js", | ||
"test": "mocha --exit -t 10000 test/all-tests-suite.js && npm run test:tape && npm run test:cli", | ||
"test:coverage": "nyc mocha --exit --check-leaks --globals __core-js_shared__ -t 10000 test/all-tests-suite.js && npm run test:tape && npm run test:cli", | ||
"test:everything": "npm run lint:everything && npm run test:coverage", | ||
@@ -29,3 +31,3 @@ "test:sqlite": "cross-env DB=sqlite3 npm test", | ||
"stress:init": "docker-compose -f scripts/stress-test/docker-compose.yml up --no-start && docker-compose -f scripts/stress-test/docker-compose.yml start", | ||
"stress:test": "node scripts/stress-test/knex-stress-test.js | grep -A 5 -B 60 -- '- STATS '", | ||
"stress:test": "node scripts/stress-test/knex-stress-test.js | grep -A 5 -B 60 -- '- STATS '", | ||
"stress:destroy": "docker-compose -f scripts/stress-test/docker-compose.yml stop" | ||
@@ -32,0 +34,0 @@ }, |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
574346
133
15214
26