loopback-component-model-extender
Advanced tools
Comparing version 0.1.4 to 0.1.5
29
index.js
@@ -0,8 +1,10 @@ | ||
/* eslint global-require: 0 */ | ||
'use strict' | ||
const kebabCase = require('lodash.kebabcase') | ||
const fs = require('fs') | ||
const path = require('path') | ||
const debug = require('debug')('loopback:component:model-extender') | ||
const appRoot = require('app-root-path') | ||
const requireAll = require('require-all') | ||
@@ -26,2 +28,3 @@ module.exports = (app, options) => { | ||
let log = options.log || console | ||
if (typeof log === 'string') { | ||
@@ -32,18 +35,14 @@ log = require(log) | ||
// Apply models customisations. | ||
function customizeModel(sourcePath) { | ||
fs.readdirSync(sourcePath).forEach(sourceFile => { | ||
const filePath = path.join(sourcePath, sourceFile) | ||
if (path.extname(sourceFile) === '.js') { | ||
debug('Loading customization script %s', filePath) | ||
const code = require(filePath) | ||
function customizeModel(dirname) { | ||
requireAll({ | ||
dirname, | ||
resolve: code => { | ||
debug('Loading customization script %s', code) | ||
if (typeof code === 'function') { | ||
debug('Customizing model %s', Model.modelName) | ||
code(Model) | ||
return code(Model) | ||
} | ||
else { | ||
debug('Skipping model file %s - `module.exports` is not a function', sourceFile) | ||
} | ||
} | ||
debug('Skipping model file %s - `module.exports` is not a function', code) | ||
return code | ||
}, | ||
}) | ||
@@ -65,3 +64,3 @@ } | ||
log.error(`Failure loading component path: ${requirePath}`, err.stack) | ||
process.exit(1) | ||
throw err | ||
} | ||
@@ -68,0 +67,0 @@ } |
{ | ||
"name": "loopback-component-model-extender", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Loopback Component Model Extender", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha test/**/*.test.js" | ||
"lint": "eslint .", | ||
"pretest": "npm run lint", | ||
"test": "nyc --reporter=lcov --reporter=text --reporter=text-summary mocha test/*test.js", | ||
"test:watch": "npm run test -- -w", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/fullcube/loopback-component-model.extender.git" | ||
"url": "https://github.com/fullcube/loopback-component-model-extender.git" | ||
}, | ||
@@ -19,5 +24,5 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/fullcube/loopback-component-model.extender/issues" | ||
"url": "https://github.com/fullcube/loopback-component-model-extender/issues" | ||
}, | ||
"homepage": "https://github.com/fullcube/loopback-component-model.extender#readme", | ||
"homepage": "https://github.com/fullcube/loopback-component-model-extender#readme", | ||
"dependencies": { | ||
@@ -29,5 +34,36 @@ "app-root-path": "2.0.1", | ||
"devDependencies": { | ||
"@bubltechnology/customizable-commit-analyzer": "1.0.2-0", | ||
"chai": "3.5.0", | ||
"mocha": "3.1.2" | ||
"condition-circle": "1.5.0", | ||
"cors": "2.8.3", | ||
"coveralls": "2.13.1", | ||
"eslint": "3.19.0", | ||
"eslint-config-fullcube": "2.0.35-latest-20170602-0428.0", | ||
"loopback": "3.8.0", | ||
"loopback-boot": "2.24.0", | ||
"mocha": "3.1.2", | ||
"nyc": "11.0.2", | ||
"require-all": "2.2.0", | ||
"semantic-release": "6.3.6", | ||
"strong-error-handler": "2.1.0" | ||
}, | ||
"config": { | ||
"commitTypeMap": { | ||
"feat": "minor", | ||
"fix": "patch", | ||
"docs": "patch", | ||
"style": "patch", | ||
"refactor": "patch", | ||
"perf": "patch", | ||
"test": "patch", | ||
"build": "patch", | ||
"ci": "patch", | ||
"chore": "patch", | ||
"revert": "patch" | ||
} | ||
}, | ||
"release": { | ||
"verifyConditions": "condition-circle", | ||
"analyzeCommits": "@bubltechnology/customizable-commit-analyzer" | ||
} | ||
} | ||
} |
# Loopback Component Model Extender | ||
[![CircleCI](https://circleci.com/gh/fullcube/loopback-component-model-extender.svg?style=svg)](https://circleci.com/gh/fullcube/loopback-component-model-extender) [![Dependencies](http://img.shields.io/david/fullcube/loopback-component-model-extender.svg?style=flat)](https://david-dm.org/fullcube/loopback-component-model-extender) [![Coverage Status](https://coveralls.io/repos/github/fullcube/loopback-component-model-extender/badge.svg?branch=master)](https://coveralls.io/github/fullcube/loopback-component-model-extender?branch=master) | ||
A loopback component that enables componentized model customisation. | ||
@@ -4,0 +6,0 @@ |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
9684
18
198
1
1
64
2
14
1