Socket
Socket
Sign inDemoInstall

@connectedcars/test

Package Overview
Dependencies
Maintainers
0
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@connectedcars/test - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

3

build/dist/bin/local-mysql.js

@@ -60,3 +60,4 @@ #!/usr/bin/env node

mysqlClient: mySqlClient,
migrationsPaths: [flags.migrationsDir]
migrationsPaths: [flags.migrationsDir],
skipAllChecks: true
});

@@ -63,0 +64,0 @@ console.log(`Running migrations`);

@@ -26,2 +26,3 @@ import { MySQLClient } from './mysql-client';

dryRun?: boolean;
skipAllChecks?: boolean;
skipCharacterSetCollationChecks?: string[];

@@ -44,2 +45,3 @@ skipTimestampChecks?: string[];

private dryRun;
private skipAllChecks;
private skipCharacterSetCollationChecks;

@@ -46,0 +48,0 @@ private skipTimestampChecks;

@@ -35,2 +35,3 @@ "use strict";

_defineProperty(this, "dryRun", void 0);
_defineProperty(this, "skipAllChecks", false);
_defineProperty(this, "skipCharacterSetCollationChecks", void 0);

@@ -51,2 +52,3 @@ _defineProperty(this, "skipTimestampChecks", void 0);

this.dryRun = (_options$dryRun = options.dryRun) !== null && _options$dryRun !== void 0 ? _options$dryRun : false;
this.skipAllChecks = options.skipAllChecks || false;
this.skipCharacterSetCollationChecks = new Set(options.skipCharacterSetCollationChecks || []);

@@ -265,24 +267,26 @@ this.skipTimestampChecks = new Set(options.skipTimestampChecks || []);

};
if (!this.skipCharacterSetCollationChecks.has(migration.path)) {
// Check create table statements that have missing character set or collation
const [createTableStatementCount, hasCharacterSetCount, hasCollationCount] = (0, _parse.parseCreateTableStatements)(migration.sql);
if (createTableStatementCount !== hasCharacterSetCount) {
throw new Error(`Found ${createTableStatementCount - hasCharacterSetCount} create table statement(s) with missing character sets (${migration.path})`);
if (!this.skipAllChecks) {
if (!this.skipCharacterSetCollationChecks.has(migration.path)) {
// Check create table statements that have missing character set or collation
const [createTableStatementCount, hasCharacterSetCount, hasCollationCount] = (0, _parse.parseCreateTableStatements)(migration.sql);
if (createTableStatementCount !== hasCharacterSetCount) {
throw new Error(`Found ${createTableStatementCount - hasCharacterSetCount} create table statement(s) with missing character sets (${migration.path})`);
}
if (createTableStatementCount !== hasCollationCount) {
throw new Error(`Found ${createTableStatementCount - hasCollationCount} create table statement(s) with missing collations (${migration.path})`);
}
// Check singular statements that set a disallowed character set or collation
this.checkMigrationCharacterSetsOrCollations(migration, 'character set', [/charset\s*=\s*(\w+)/gi, /charset\s+(\w+)/gi, /character\s+set\s+(\w+)/gi, /character\s+set\s*=\s*(\w+)/gi]);
this.checkMigrationCharacterSetsOrCollations(migration, 'collation', [/collate\s*=\s*(\w+)/gi, /collate\s+(\w+)/gi]);
}
if (createTableStatementCount !== hasCollationCount) {
throw new Error(`Found ${createTableStatementCount - hasCollationCount} create table statement(s) with missing collations (${migration.path})`);
if (!this.skipTimestampChecks.has(migration.path)) {
// Check singular statements that uses disallowed TIMESTAMP type
const cleanSql = migration.sql.replace(/\n/g, ' ').replace(/\scomment\s*=?\s*'.*?'\s*(?:;|after|\n|\)|,)/gim, ' ');
const match = cleanSql.match(/\s+timestamp(?:(?:\s+)|,|\n|\))/gi);
if (match) {
throw new Error(`Migration uses disallowed TIMESTAMP type, use DATETIME type instead (${migration.path})`);
}
}
// Check singular statements that set a disallowed character set or collation
this.checkMigrationCharacterSetsOrCollations(migration, 'character set', [/charset\s*=\s*(\w+)/gi, /charset\s+(\w+)/gi, /character\s+set\s+(\w+)/gi, /character\s+set\s*=\s*(\w+)/gi]);
this.checkMigrationCharacterSetsOrCollations(migration, 'collation', [/collate\s*=\s*(\w+)/gi, /collate\s+(\w+)/gi]);
}
if (!this.skipTimestampChecks.has(migration.path)) {
// Check singular statements that uses disallowed TIMESTAMP type
const cleanSql = migration.sql.replace(/\n/g, ' ').replace(/\scomment\s*=?\s*'.*?'\s*(?:;|after|\n|\)|,)/gim, ' ');
const match = cleanSql.match(/\s+timestamp(?:(?:\s+)|,|\n|\))/gi);
if (match) {
throw new Error(`Migration uses disallowed TIMESTAMP type, use DATETIME type instead (${migration.path})`);
}
}
return migration;

@@ -289,0 +293,0 @@ }

{
"name": "@connectedcars/test",
"version": "1.6.0",
"version": "1.7.0",
"description": "Test utilities for Node projects",

@@ -5,0 +5,0 @@ "main": "build/dist/src/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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