@vbilopav/pgmigrations
Advanced tools
Comparing version 0.28.0 to 0.29.0
@@ -158,3 +158,3 @@ const path = require("path"); | ||
if (opt.verbose) { | ||
console.log("Using migration directory: " + migrationDir); | ||
info("Using migration directory: " + migrationDir); | ||
} | ||
@@ -170,3 +170,3 @@ } | ||
if (opt.verbose) { | ||
console.log("Using migration directory: " + migrationDir); | ||
info("Using migration directory: " + migrationDir); | ||
} | ||
@@ -182,3 +182,3 @@ } | ||
if (opt.verbose) { | ||
console.log("Creating tmp directory: " + config.tmpDir); | ||
info("Creating tmp directory: " + config.tmpDir); | ||
} | ||
@@ -188,3 +188,3 @@ fs.mkdirSync(config.tmpDir); | ||
if (opt.verbose) { | ||
console.log("Clearing tmp directory: " + config.tmpDir); | ||
info("Clearing tmp directory: " + config.tmpDir); | ||
} | ||
@@ -204,3 +204,3 @@ fs.readdirSync(config.tmpDir).forEach(file => { | ||
if (opt.verbose) { | ||
console.log("Creating history table..."); | ||
info("Creating history table..."); | ||
} | ||
@@ -358,3 +358,3 @@ var result = await command(formatByName(createHistoryTableScript, { | ||
//const topDir = getDirectoryPath(script); | ||
//console.log(topDir); | ||
//info(topDir); | ||
@@ -367,3 +367,3 @@ if (prefix.startsWith(config.upPrefix) || prefix.startsWith(config.downPrefix)) { | ||
//const parts = topDir.split(config.appendTopDirToVersionSplitBy); | ||
//console.log(topDir); | ||
//info(topDir); | ||
if (topDir) { | ||
@@ -614,3 +614,3 @@ if (config.appendTopDirToVersionSplitBy) { | ||
finalUpList.forEach((m, index) => { | ||
console.log({ | ||
info({ | ||
rank: index+1, | ||
@@ -629,3 +629,3 @@ name: m.name, | ||
for (let item of finalizeList) { | ||
console.log(item); | ||
info(item); | ||
} | ||
@@ -637,3 +637,3 @@ } | ||
downList.forEach((m, index) => { | ||
console.log({ | ||
info({ | ||
rank: index+1, | ||
@@ -652,3 +652,3 @@ name: m.name, | ||
for (let item of finalizeList) { | ||
console.log(item); | ||
info(item); | ||
} | ||
@@ -677,3 +677,3 @@ } | ||
if (opt.verbose) { | ||
console.log("Creating migration file: " + tmpFile); | ||
info("Creating migration file: " + tmpFile); | ||
} | ||
@@ -795,3 +795,3 @@ if (fs.existsSync(tmpFile)) { | ||
} else { | ||
console.log("Running migration..."); | ||
info("Running migration..."); | ||
try { | ||
@@ -798,0 +798,0 @@ |
{ | ||
"name": "@vbilopav/pgmigrations", | ||
"version": "0.28.0", | ||
"version": "0.29.0", | ||
"description": "PostgreSQL Migration Tool for Node.js and NPM", | ||
@@ -5,0 +5,0 @@ "author": "vb-consulting", |
@@ -20,3 +20,3 @@ #!/usr/bin/env node | ||
warning(require("./package.json").version); | ||
info("v"+require("./package.json").version); | ||
@@ -28,3 +28,3 @@ function buildConfig(opt) { | ||
if (opt.verbose) { | ||
console.log("Using default config file: " + configFile); | ||
info("Using default config file: " + configFile); | ||
} | ||
@@ -48,4 +48,7 @@ var config = require(configFile); | ||
if (typeof mainConfig.env === "string") { | ||
if (!fs.existsSync(path.resolve(mainConfig.env))) { | ||
warning("Env file not found: " + mainConfig.env + ". Please provide a valid env file."); | ||
} | ||
require('dotenv').config({ | ||
path: path.resolve(__dirname, mainConfig.env) | ||
path: path.resolve(mainConfig.env) | ||
}); | ||
@@ -72,3 +75,3 @@ } else { | ||
error("Command is required. Please provide a valid command."); | ||
return; | ||
cmd = "help"; | ||
} | ||
@@ -80,5 +83,5 @@ | ||
console.log('Usage:'); | ||
info('Usage:'); | ||
info('pgmigrations [command] [switches]'); | ||
console.log('\nCommands:'); | ||
info('\nCommands:'); | ||
@@ -88,3 +91,3 @@ sections([ | ||
{key: "down", value: "Run only down migrations. Optional switches: --list, --dry, --full, --dump."}, | ||
{key: "history", value: "console.log the current migration schema history."}, | ||
{key: "history", value: "info the current migration schema history."}, | ||
{key: "run | exec", value: "Run a command or a script file or script directory with psql. Command text or a script file is required as the second argument. Any additional arguments will be passed to a psql command."}, | ||
@@ -94,6 +97,6 @@ {key: "dump | schema", value: "Run pg_dump command with --schema-only --encoding=UTF8 swtiches on (plus schemaDumpAdditionalArgs from the config). Any additional arguments will be passed to pg_dump command."}, | ||
{key: "test", value: "Run database tests."}, | ||
{key: "config", value: "console.log the current configuration."}, | ||
{key: "config", value: "info the current configuration."}, | ||
], 16); | ||
console.log('\nSwitches:'); | ||
info('\nSwitches:'); | ||
@@ -109,3 +112,3 @@ sections([ | ||
console.log('\nConfigurations files:'); | ||
info('\nConfigurations files:'); | ||
sections([ | ||
@@ -116,3 +119,3 @@ {key: '', value: './db.js or ./pgmigrations.js from the current dir is the default configuration file. It will be ignored if not found.'}, | ||
console.log(); | ||
info(""); | ||
return; | ||
@@ -325,3 +328,3 @@ } | ||
const config = buildConfig({verbose}); | ||
console.log(config); | ||
info(config); | ||
@@ -328,0 +331,0 @@ } else if (cmd == "history") { |
@@ -61,3 +61,3 @@ const { warning, info, error, passed, failed } = require("./log.js"); | ||
tests.forEach((test, index) => { | ||
console.log(`${++index}. ${test.schema == "public" ? "" : test.schema + "."}${test.name}${test.comment ? " (" + test.comment.replace(/[\r\n\t]/g, " ").trim() + ")" : ""}`) | ||
info(`${++index}. ${test.schema == "public" ? "" : test.schema + "."}${test.name}${test.comment ? " (" + test.comment.replace(/[\r\n\t]/g, " ").trim() + ")" : ""}`) | ||
}); | ||
@@ -104,3 +104,3 @@ return; | ||
console.log(); | ||
info(); | ||
passed(passedCount.toString()); | ||
@@ -107,0 +107,0 @@ if (failedCount > 0) { |
87304
1540