首页 > 解决方案 > 在 Arkit 中配置 JSON 以可视化 Package.json 中的 NPM 模块

问题描述

我正在使用以下名为arkit的 npm 包来创建 node.js 项目的架构图,但是我无法在我的 node.js 应用程序架构中可视化 npm 包(依赖项文件夹),如 Arkit 和 Vue/ 示例中所述Nuxt TodoMVC,我尝试遵循它们各自 arkits 的 json 配置,但它们要么像 Vue 中那样不存在,要么像 Arkit 本身那样模糊。我使用了 arkit 配置示例中给出的配置,但我最终得到了像这样的主要依赖项的所有依赖项。我尝试了以下配置

{ "$schema": "https://arkit.pro/schema.json", 
"excludePatterns": ["test/**", "tests/**", "**/*.test.*", "**/*.spec.*"], 
"components": [ 
{ "type": "Dependency", 
"patterns": ["node_modules/**/*.js"] }, 
{ "type": "Component", 
"patterns": ["**/*.js", "**/*.jsx"] 
} 
], 
"output": [ 
{ "path": "arkit.svg", 
"groups": [ { "first": true, "components": ["Component"] },
 { 
"type": "Dependencies", 
"components": ["Dependency"] 
} 
] 
} 
] 
}

但它在架构生成过程中崩溃了,我还通过电子邮件发送了这个 npm 包的所有者和另一个成功设法这样做的人,但他们正忙着指导我配置 arkit 的 JSON。我可以在 JSON 配置文件中使用 for-of 循​​环,以便仅获取 package.json 中包含的那些 node_modules,因为我不想在架构表示中获取主要 npm 包的其他子依赖项,如图所示在上面分享的链接中!

TL;DR 我想要具有此类依赖关系的图表,但我 尝试过,在命令行“npx arkit --config test.json --depth=0”中添加 --depth=0 但没有运气

标签: node.jsjsonnpmarchitecture

解决方案


我认为 arkit 期望 output.path 是一个数组 - 但你传递给它一个字符串。尝试使用修改后的配置:

{
    "$schema": "https://arkit.pro/schema.json",
    "excludePatterns": ["test/**", "tests/**", "**/*.test.*", "**/*.spec.*"],
    "components": [{
            "type": "Dependency",
            "patterns": ["node_modules/*"]
        },
        {
            "type": "Component",
            "patterns": ["**/*.js", "**/*.jsx"]
        }
    ],
    "output": [{
        "path": ["arkit.svg"],
        "groups": [{
                "first": true,
                "components": ["Component"]
            },
            {
                "type": "Dependencies",
                "components": ["Dependency"]
            }
        ]
    }]
}

推荐阅读