Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const dependencies = function(settings, moduleName, cb) {
var cruiseResult = depcruise.cruise(
[path.relative(path.resolve("./"), settings.computed.mainDirectory)],
{
validate: true,
ruleSet: {
forbidden: [{
name: 'no-circular',
comment: 'circular dependencies will make you dizzy',
severity: 'error',
from: {},
to: {
circular: true
}
}],
options: {
doNotFollow: "node_modules",
tsConfig: {
exports.dependencyTree = (entry) => {
if (!entry.length) {
return [];
}
const cruiseResult = dependency_cruiser_1.cruise(entry, {
outputType: 'json',
preserveSymlinks: true
});
const dependencies = JSON.parse(cruiseResult.modules).modules;
return dependencies.filter((dependency) => {
return dependency.coreModule !== true;
}).map((notCoreDependency) => {
let depPath = path_1.join(paths_1.default.appCwd, notCoreDependency.source);
return depPath = isDevStage ? depPath.replace('packages', 'node_modules') : depPath;
});
};
export const dependencyTree = (entry: string[]): string[] => {
if (!entry.length) { return []; }
const cruiseResult = cruise(
entry,
{
outputType: 'json',
preserveSymlinks: true
}
);
const dependencies = JSON.parse(cruiseResult.modules).modules;
return dependencies.filter((dependency) => {
return dependency.coreModule !== true;
}).map((notCoreDependency) => {
let depPath = join(paths.appCwd, notCoreDependency.source);
return depPath = isDevStage ? depPath.replace('packages', 'node_modules') : depPath;
});
};
function getDepcruise(params) {
if(!params){
throw new Error('params is required')
}
const { rootPath, aliasPath, excludePattern } = params
const exePath = process.cwd()
let absPath = path.resolve(exePath, rootPath)
const alias = aliasPath ? require(path.resolve(exePath, aliasPath)) : {}
const exts = defaultAllowExt.slice()
const exclude = defaultExcludePattern
.concat(excludePattern)
.map(v => `(${v})`)
.join('|')
const excludeReg = new RegExp(exclude)
const extReg = new RegExp(`\\.(${exts.join('|')})$`)
let dependencies = depcruise([absPath], {
exclude: excludeReg
})
let dirtrees = dirtree(absPath, {
extensions: extReg,
exclude: excludeReg
})
let fileList = getFileList(dirtrees)
let aliasModules = []
dependencies.modules = dependencies.modules.map(v => {
v.source = path.resolve(exePath, v.source)
v.dependencies = v.dependencies
.filter(dv => !dv.coreModule)
.map(dv => {
dv.resolved = path.resolve(exePath, dv.resolved)
if (dv.dependencyTypes && dv.dependencyTypes[0] === 'unknown') {