Skip to main content

探索项目图

¥Explore the Project Graph

为了让 Lerna(和 Nx)快速、正确地运行任务,它会创建存储库中所有项目之间的依赖图。直观地探索该图有助于理解 Lerna 为何以某种方式运行,并获得代码架构的高级视图。

¥For Lerna (and Nx) to run tasks quickly and correctly, it creates a graph of the dependencies between all the projects in the repository. Exploring this graph visually can be useful to understand why Lerna is behaving in a certain way and to get a high level view of your code architecture.

要启动项目图形可视化,请运行:

¥To launch the project graph visualization run:

nx graph

这将打开一个浏览器窗口,其中包含当前代码库的项目图的交互式表示。即使对于较小的存储库,查看整个图表也可能难以管理,因此有多种方法可以将可视化的焦点缩小到当前图表中最有用的部分。

¥This will open a browser window with an interactive representation of the project graph of your current codebase. Viewing the entire graph can be unmanageable even for smaller repositories, so there are several ways to narrow the focus of the visualization down to the most useful part of the graph at the moment.

  1. 专注于特定项目,然后使用邻近度和按文件夹分组控件来修改该项目周围的图表。

    ¥Focus on a specific project and then use the proximity and group by folder controls to modify the graph around that project.

  2. 使用搜索栏查找名称中包含特定字符串的所有项目。

    ¥Use the search bar to find all projects with names that contain a certain string.

  3. 手动隐藏或显示侧边栏中的项目

    ¥Manually hide or show projects in the sidebar

显示图表后,你可以单击单个依赖链接来查找创建该依赖的特定文件。

¥Once the graph is displayed, you can click on an individual dependency link to find out what specific file(s) created that dependency.

JSON 项目图

¥JSON Project Graph

如果你喜欢使用脚本或其他工具分析项目图的基础数据,你可以运行:

¥If you prefer to analyze the underlying data of the project graph with a script or some other tool, you can run:

nx graph --file=output.json

这将为你提供用于创建项目图形可视化的所有信息。

¥This will give you all the information that is used to create the project graph visualization.