Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const addDependency = dependency => {
if (!externals[dependency] && !excludes[dependency]) {
externals[dependency] = {
root: camelize(dependency, true),
amd: dependency,
commonjs: dependency,
commonjs2: dependency
}
try {
// Attempt loading the dependency's own dependencies and recursively
// mark these as externals as well:
const packageJson = require(`${dependency}/package.json`)
addDependencies(packageJson.dependencies)
addDependencies(packageJson.peerDependencies)
addDependencies(packageJson.devDependencies)
} catch (err) {
}
}
}
// Start with cwd to read from './package.json' and take it from there.
indices[name] = index
return indices
},
{}
)
// Collect all seed, and separate between seed functions and model see data:
for (const file of files) {
const { name, ext, base } = path.parse(file)
if (!name.startsWith('.') && ['.js', '.json'].includes(ext)) {
const object = await import(path.resolve(seedDir, file))
const seed = object.default || object
// Try to determine the related model from the seed name, and use it also
// to determine seed sequence based on its index in `app.models`.
const modelClass =
app.models[name] ||
app.models[camelize(pluralize.singular(name), true)]
const index = modelClass ? modelIndices[modelClass.name] : Infinity
seeds.push({
base,
seed,
modelClass,
index
})
}
}
// Now sort the seed model data according to `app.models` sorting,
// as determined by `Application.sortModels()`:
seeds.sort((entry1, entry2) => entry1.index - entry2.index)
for (const { base, seed, modelClass } of seeds) {
await handleSeed(app, base, seed, modelClass)
}
return true
setup() {
super.setup(true)
this.modelClass = this.modelClass ||
this.app.models[camelize(pluralize.singular(this.name), true)]
this.relations = this.setupRelations()
}
export function getRelationClass(relation) {
return isString(relation)
? relationLookup[camelize(relation)] || relationClasses[relation]
: Relation.isPrototypeOf(relation)
? relation
: null
}
? toObject(descriptions, value => (
isObject(value) ? value : {
name: camelize(value, false)
}
))
: isObject(descriptions)
function getCommand(commands, parts) {
const part = parts.shift()
return commands && part
? getCommand(commands[camelize(part)], parts)
: commands
}
? toObject(descriptions, value => (
isObject(value) ? value : {
name: camelize(value, false)
}
))
: isObject(descriptions) && Object.keys(descriptions).length
constructor(app, name) {
this.app = app
this.name = camelize(
(name || this.constructor.name).match(/^(.*?)(?:Service|)$/)[1]
)
this.config = null
}