New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@vbilopav/pgmigrations

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vbilopav/pgmigrations - npm Package Compare versions

Comparing version 0.0.7 to 0.1.0

tests.js

4

config.js

@@ -45,2 +45,6 @@ const crypto = require('crypto');

versionSortFunction: (a, b) => a.localeCompare(b, "en", {numeric: true}),
testFunctionsSchemaContains: null,
testFunctionsNameContains: null,
testFunctionsCommentContains: "test",
}

@@ -46,3 +46,12 @@ const colors = {

}
},
passed: (msg) => {
process.stdout.write(colors.fg.green + "Passed: " + colors.reset + msg);
console.log(colors.reset);
},
failed: (msg) => {
process.stdout.write(colors.fg.red + "Failed: " + colors.reset + msg);
console.log(colors.reset);
}
};

9

package.json
{
"name": "@vbilopav/pgmigrations",
"version": "0.0.7",
"version": "0.1.0",
"description": "PostgreSQL Migration Tool for Node.js and NPM",

@@ -22,3 +22,8 @@ "author": "vb-consulting",

"schema",
"pg"
"pg",
"testing",
"tests",
"database",
"unit tests",
"database tests"
],

@@ -25,0 +30,0 @@ "bugs": {

@@ -9,2 +9,3 @@ #!/usr/bin/env node

const migrate = require("./migration.js");
const tests = require("./tests.js");

@@ -121,3 +122,3 @@ var defaultconfigFile = "./db.js";

console.log('Usage:');
info('db [command] [switches]');
info('pgmigrations [command] [switches]');
console.log('\nCommands:');

@@ -131,2 +132,3 @@

{key: "psql", value: "Run arbitrary psql command or open psql shell. Any additional arguments will be passed to a psql."},
{key: "test", value: "Run database tests."},
], 16);

@@ -138,3 +140,3 @@

{key: "-h, --help", value: "Show help"},
{key: "--list", value: "List available migrations in this direction (up or down)."},
{key: "--list", value: "List available migrations in this direction (up or down) or list available database tests."},
{key: "--dry", value: "Run in the migrations dry run mode on database in this direction (up or down). No changes will be made to the database (rollbacks changes)."},

@@ -309,2 +311,34 @@ {key: "--full", value: "Executes all migrations in this direction (up or down). Schema history will be ignored."},

} else if (cmd == "test") {
let list = false;
let userConfig;
for (let i = 0; i < options.length; i++) {
let opt = options[i];
if (opt.startsWith("-")) {
if (opt == "--list") {
list = true;
} else if (opt == "--verbose") {
verbose = true;
} else if (opt.startsWith("--config")) {
let parts = opt.split("=");
if (parts.length <= 1) {
error("Config file is required. Please provide a valid config file.");
return;
}
userConfig = parts[1];
} else {
error("Unknown option: " + opt + ". Please provide a valid option");
return;
}
}
}
const opt = {list, verbose};
const config = buildConfig(userConfig, opt);
opt.verbose = opt.verbose || config.verbose;
tests(opt, config);
} else {

@@ -311,0 +345,0 @@

@@ -23,6 +23,7 @@ # PgMigrations

psql Run arbitrary psql command or open psql shell. Any additional arguments will be passed to a psql.
test Run database tests.
Switches:
-h, --help Show help
--list List available migrations in this direction (up or down).
--list List available migrations in this direction (up or down) or list available database tests.
--dry Run in the migrations dry run mode on database in this direction (up or down). No changes will be made to the database (rollbacks changes).

@@ -337,2 +338,34 @@ --full Executes all migrations in this direction (up or down). Schema history will be ignored.

### Testing
Test command will run tests on PostgreSQL functions and procedures:
- Test functions and procedures are required to have no parameters.
- The test is considered passed if:
- Doesn't raise any exceptions.
- The function doesn't return either boolean False, or text `f`, or return text doesn't start with `not ok` (case insensitive).
To assert a failed test:
- Raise custom exception with a custom message: `raise exception 'failed message';`
- Return false: `return false;`
- Return text that starts with "not ok": `return 'not ok: failed message'`
#### testFunctionsSchemaContains
Default: `null`
Test function or procedure schema contains this text (case insensitive) or `null` for all non-system schemas.
#### testFunctionsNameContains
Default: `null`
Test function or procedure name contains this text (case insensitive) or `null` for all function or procedure names without parameters.
#### testFunctionsCommentContains
Default: `test`
Test function or procedure comment contains this text (case insensitive) or `null` for all function or procedure names without parameters.
## Contributing

@@ -339,0 +372,0 @@

@@ -5,11 +5,15 @@ const fs = require("fs");

const message = (msg) => {
const message = (msg, error) => {
msg.split("\n").forEach(line => {
var lower = line.toLowerCase();
if (lower.indexOf("error:") > -1 || lower.indexOf("fatal:") > -1 || lower.indexOf("panic:") > -1) {
if (error) {
error(line);
} else if (lower.indexOf("warning:") > -1) {
warning(line);
} else {
info(line);
var lower = line.toLowerCase();
if (lower.indexOf("error:") > -1 || lower.indexOf("fatal:") > -1 || lower.indexOf("panic:") > -1) {
error(line);
} else if (lower.indexOf("warning:") > -1) {
warning(line);
} else {
info(line);
}
}

@@ -108,3 +112,3 @@ });

const msg = stdoutBuffer.slice(0, index).trim();
if (msg) {
if (msg && !options.muted) {
message(msg);

@@ -124,4 +128,4 @@ }

const msg = stderrBuffer.slice(0, index).trim();
if (msg) {
message(msg);
if (msg && !options.muted) {
message(msg, true);
}

@@ -141,3 +145,3 @@ stderrBuffer = stderrBuffer.slice(index + prefix.length);

} else {
} else if (!options.muted) {
if (stdoutBuffer) {

@@ -152,6 +156,12 @@ const msg = stdoutBuffer.trim();

if (msg) {
message(msg);
message(msg, true);
}
}
resolve(code);
} else {
resolve({
stdout: stdoutBuffer.trim(),
stderr: stderrBuffer.trim(),
code
});
}

@@ -163,3 +173,3 @@ });

function command(command, opt, additionalArgs, config, isCommand = false) {
function command(command, opt, additionalArgs, config, isCommand = false, muted = false) {
var fileExists = false;

@@ -178,3 +188,4 @@ if (!isCommand) {

inherit: false,
returnBuffer: false
returnBuffer: false,
muted: muted
})

@@ -181,0 +192,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc