schemalint
Advanced tools
Comparing version 0.0.2 to 0.1.0
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ export function processDatabase({ connection, rules, schemas }: { |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ export namespace preferJsonbToJson { |
@@ -0,0 +0,0 @@ "use strict"; |
{ | ||
"name": "schemalint", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -28,2 +28,5 @@ # Schemalint | ||
}, | ||
plugins: ['./custom-rules'], | ||
rules: { | ||
@@ -30,0 +33,0 @@ 'table-name-casing': ['error', 'snake'], |
@@ -0,0 +0,0 @@ import path from 'path'; |
@@ -0,1 +1,2 @@ | ||
import path from 'path'; | ||
import { keys, indexBy, prop, values } from 'ramda'; | ||
@@ -8,4 +9,2 @@ import knex from 'knex'; | ||
const registeredRules = indexBy(prop('name'), values(builtinRules)); | ||
let anyIssues = false; | ||
@@ -15,3 +14,5 @@ const suggestedMigrations = []; | ||
function report({ rule, identifier, message, suggestedMigration = null }) { | ||
console.log(`${chalk.yellow(identifier)}: error ${chalk.red(rule)} : ${message}`); | ||
console.log( | ||
`${chalk.yellow(identifier)}: error ${chalk.red(rule)} : ${message}` | ||
); | ||
if (suggestedMigration) { | ||
@@ -23,4 +24,14 @@ suggestedMigrations.push(suggestedMigration); | ||
export async function processDatabase({ connection, rules, schemas }) { | ||
console.log(`Connecting to ${chalk.greenBright(connection.database)} on ${connection.host}`); | ||
export async function processDatabase({ connection, plugins, rules, schemas }) { | ||
const pluginRules = plugins.map(p => require(path.join(process.cwd(), p))); | ||
const allRules = [builtinRules, ...pluginRules].reduce((acc, elem) => { | ||
return { ...acc, ...elem }; | ||
}, {}); | ||
const registeredRules = indexBy(prop('name'), values(allRules)); | ||
console.log( | ||
`Connecting to ${chalk.greenBright(connection.database)} on ${ | ||
connection.host | ||
}` | ||
); | ||
const knexConfig = { | ||
@@ -50,3 +61,3 @@ client: 'pg', | ||
for (const ruleKey of keys(mergedRules)) { | ||
if (!ruleKey in registeredRules) { | ||
if (!(ruleKey in registeredRules)) { | ||
throw new Error(`Unknown rule: "${ruleKey}"`); | ||
@@ -53,0 +64,0 @@ } |
@@ -0,0 +0,0 @@ import { recase, detectCasing } from '@kristiandupont/recase'; |
@@ -0,0 +0,0 @@ { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
15
701
47
34082
4