Comparing version 0.1.2 to 0.1.3
{ | ||
"name": "lazysql", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": | ||
@@ -5,0 +5,0 @@ "An unopinionated Sequelize boilerplate builder, with models and associations.", |
@@ -20,11 +20,10 @@ class Index { | ||
addAssociations (associations) { | ||
Object.keys(associations).forEach(key => { | ||
const type = Object.keys(associations[key])[0] | ||
const targetObj = associations[key][type] | ||
const target = Object.keys(targetObj)[0] | ||
const options = targetObj[target] | ||
? ', ' + JSON.stringify(targetObj[target]) | ||
: '' | ||
associations.forEach(association => { | ||
const source = Object.keys(association)[0] | ||
const type = Object.keys(association[source])[0] | ||
const target = Object.keys(association[source][type])[0] | ||
const option = association[source][type][target] | ||
const line = `${key}.${type}(${target}${options})\n` | ||
const options = option ? ', ' + JSON.stringify(option) : '' | ||
const line = `${source}.${type}(${target}${options})\n` | ||
@@ -31,0 +30,0 @@ this.output += line |
@@ -16,7 +16,2 @@ const fs = require('fs') | ||
const operator = (buildPath, data) => { | ||
// Create /destination directory | ||
// if (!fs.existsSync(buildPath)) { | ||
// fs.mkdirSync(buildPath) | ||
// } | ||
// Create root index file | ||
@@ -41,2 +36,3 @@ const index = new Index() | ||
// Create /models/index.js file | ||
// handles model associations | ||
const modelIndex = new ModelIndex(models, data.associations) | ||
@@ -65,9 +61,6 @@ createFile(buildPath + '/models', 'index.js', modelIndex.output) | ||
const prettierFixForJSON = content => { | ||
console.log('---- creating configuration file') | ||
console.log('obj', content) | ||
const fPrettier = 'const file = ' | ||
content = fPrettier + JSON.stringify(content, null, '\t') | ||
console.log('stringified -->', content) | ||
content = prettier.format(content, PRETTIER_SETTINGS) | ||
content = content.slice(fPrettier.length) | ||
console.log('final -->', content) | ||
return content | ||
@@ -78,3 +71,4 @@ } | ||
checkPath(buildPath) | ||
const formattedObject = prettierFixForJSON(jsObj) | ||
// const formattedObject = prettierFixForJSON(jsObj) | ||
const formattedObject = JSON.stringify(jsObj) | ||
writeFile(buildPath, fileName, formattedObject) | ||
@@ -81,0 +75,0 @@ console.log(`created configuration file: ${fileName} in ${buildPath}`) |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
44602
220