Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let files = buffer.map(file => _.merge(file, {
dependency_list: deptree.toList(dep_opts(file))
}));
// Parse the code
// @ts-ignore
import * as lockFileGen from "@yarnpkg/lockfile"
// @ts-ignore
import * as dependencyTree from "dependency-tree"
// @ts-ignore
import * as detective from "detective-typescript"
// @ts-ignore
import * as semverSort from "semver-sort"
import * as fs from "fs"
import * as path from "path"
// Starting at the runner, generate a list of all the
// files inside the Peril repo which are referenced by the runner
const tree = dependencyTree.toList({
filename: path.resolve(__dirname, "..", "runner", "run.ts"),
directory: path.resolve(__dirname, "..", ".."),
})
const filterDefTypes = (fpath: string) => !fpath.endsWith("d.ts")
const onlyModules = (fpath: string) => !fpath.startsWith(".")
// Filter that list down to just source-files
const perilModules = tree.filter(filterDefTypes)
// Now we pull out every node module reference in
// all of the in-app dependencies
let allDeps: string[] = []
// Hide some of the extra stuff
const builtIn = ["fs", "path", "util", "child_process", "http"]
function getDependencyListForComponent(name) {
const nodeModules = [];
const dependencies = dependencyTree.toList({
filename: join(srcPath, 'components', name, 'index.ts'),
directory: join(srcPath, 'components', name),
tsConfig: tsConfigPath,
filter(path) {
if (path.includes('node_modules')) {
nodeModules.push(extractPackageNameFromPath(path));
return false;
}
return true;
},
});
return {dependencies, nodeModules};
}
paths.forEach(function(module) {
let absPath = path.join(options.jsSource, module);
if (fs.existsSync(absPath)) {
depTree.toList({
filename: absPath,
root: options.jsSource,
config: './help/tasks/config/paths.json'
}).forEach(function(item) {
tree[item] = true;
});
log(module, 1);
}
});
paths.forEach(function(module) {
depTree.toList(path.join(options.js, module), options.js).forEach(function(item) {
tree[item] = true;
});
log(module, 1);
});
file =>
(tree[file] = dependencyTree.toList({
filename: resolve(`./pages/${file}`),
directory: '/'
}))
)
function analyzeDeps(component: string) {
const checkList = ['base'];
search(
dependencyTree({
directory: ES_DIR,
filename: join(ES_DIR, component, 'index.js'),
filter: path => !~path.indexOf('node_modules')
}),
component,
checkList
);
checkList.push(component);
return checkList.filter(checkStyleExists);
}