graph - 从 Bazel 依赖关系图中排除 @npm// 依赖关系(bazel 查询)
问题描述
我使用以下命令为我的 Bazel 项目生成图表。
bazel query 'deps(//services/gateway:lib)' --output graph --nohost_deps --noimplicit_deps > graph.in
dot -Tpng < graph.in > graph.png
生成以下图表:
digraph mygraph {
node [shape=box];
"//services/gateway:lib"
"//services/gateway:lib" -> "//services/gateway:controllers/auth.controller.ts\n//services/gateway:index.ts\n//services/gateway:controllers/index.controller.ts\n//:tsconfig.json\n//services/gateway:controllers/index.ts"
"//services/gateway:lib" -> "@npm//@types/node:node"
"//services/gateway:lib" -> "@npm//inversify-express-utils:inversify-express-utils"
"//services/gateway:lib" -> "@npm//helmet:helmet"
"//services/gateway:lib" -> "@npm//inversify:inversify"
"@npm//inversify:inversify"
"@npm//inversify:inversify" -> "@npm//inversify:inversify__contents"
"@npm//inversify:inversify" -> "@npm//inversify:inversify__files"
"@npm//inversify:inversify" -> "@bazel_tools//src/conditions:host_windows"
MANY MORE LINES
"@npm//:node_modules/bytes/index.js\n@npm//:node_modules/bytes/History.md\n@npm//:node_modules/bytes/Readme.md\n@npm//:node_modules/bytes/LICENSE\n@npm//:node_modules/bytes/package.json"
"@npm//methods:methods__nested_node_modules"
"@npm//array-flatten:array-flatten__files"
"@npm//array-flatten:array-flatten__files" -> "@npm//:node_modules/array-flatten/LICENSE\n@npm//:node_modules/array-flatten/array-flatten.js\n@npm//:node_modules/array-flatten/README.md\n@npm//:node_modules/array-flatten/package.json"
"@npm//:node_modules/array-flatten/LICENSE\n@npm//:node_modules/array-flatten/array-flatten.js\n@npm//:node_modules/array-flatten/README.md\n@npm//:node_modules/array-flatten/package.json"
}
正如你所看到的,这个图非常大,因为所有这些依赖于@npm//<something>
我真正想要的是这样的:
digraph mygraph {
node [shape=box];
"//services/gateway:lib"
"//services/gateway:lib" -> "//services/gateway:controllers/auth.controller.ts\n//services/gateway:index.ts\n//services/gateway:controllers/index.controller.ts\n//:tsconfig.json\n//services/gateway:controllers/index.ts"
"//services/gateway:lib" -> "@npm//@types/node:node"
"//services/gateway:lib" -> "@npm//inversify-express-utils:inversify-express-utils"
"//services/gateway:lib" -> "@npm//helmet:helmet"
"//services/gateway:lib" -> "@npm//inversify:inversify"
}
是否可以在不手动从 graph.in 文件中删除它们的情况下删除图中的所有这些 npm 依赖项?
解决方案
当您描述您感兴趣的目标时(例如用deps()
),您应该能够要求更多或(在这种情况下为更少):
deps(//services/gateway:lib) except @npm//...:*
或者:
deps(//services/gateway:lib) - @npm//...:*
推荐阅读
- postgresql - 如何通过 PostgreSQL 查询 odoo 14 从日期时间字段更新浮点字段中的时间
- java - Freemarker 以下已评估为 null 或缺失
- c# - 如何修复 Azure 管道错误 NETSDK1152?
- redis - 在 redis / sentinel 中设置身份验证密码,停机时间为零
- javascript - zustand:更改存储对象中的参数值
- java - 产品减去按钮在电子商务应用程序中无法正常工作
- java - 仅当文件已更改时如何在 Maven 中复制文件
- java - 如何在android中创建贝塞尔曲线底部导航栏
- regex - 使用星号将正则表达式变为粗体
- bash - pqsub 作业提交中用户定义的输出文件名