接口
使用 core 包可以脱离 cli 包使用 DepSpy 的核心功能.
- 引入
bash
pnpm add @dep-spy/corepnpm add @dep-spy/corejavascript
import { generateGraph } from "@dep-spy/core";import { generateGraph } from "@dep-spy/core";生成
Graph对象- 第一个参数是项目的名称
- 第二个参数是配置 (同默认配置)
javascript
const graph = generateGraph("", config);const graph = generateGraph("", config);- 调用
graph对象的方法进行交互
javascript
await graph.getGraph(); //获取树结构的json对象
await graph.getCodependency(); //获取所有相同依赖节点对象
await graph.getCircularDependency(); //获取所有循环节点数组
await graph.outputToFile(); //根据配置输出对应文件await graph.getGraph(); //获取树结构的json对象
await graph.getCodependency(); //获取所有相同依赖节点对象
await graph.getCircularDependency(); //获取所有循环节点数组
await graph.outputToFile(); //根据配置输出对应文件