@contrast/cli
Contrast Node.js代理的指令线公用事业. @contrast/agent 取决于此软件包,所以在安装代理设备的任何地方,命令都可以使用.
运行
软件包有多个命令,所以以 npx -p 页:1 npx @contrast/cli 没用的:
npx -p @contrast/cli <command> [options]
从应用程序的目录中运行命令,与应用程序使用的环境变量相同. 他们发现的配置与代理完全一样(contrast_security.yaml 财务报告和审定财务报表 CONTRAST__* 变量),所以不同的工作目录或环境会给出不同的结果. 他们需要一个代理支持的Node.js版本.
图标
配置诊断
Usage: npx -p @contrast/cli config-diagnostics [options] <entrypoint>
Arguments:
entrypoint The entrypoint JavaScript or ESM file for the application
Options:
-q, --quiet suppress logging to stdout
-o, --output <string> output file for the generated JSON
(default: ./contrast_effective_config.json)
-V, --version output the version number
-h, --help display help for command
打印代理机的有效配置为 JSON, 显示每个选项的值及其来源( 环境变量、 配置文件、 对比 UI 或默认) 。 全权证书经过编辑.
除非我们.. api.enable 实值 false,它连接到 Contist (TeamServer) ,就像代理在启动时所做的那样,因此输出包含来自 Contist UI 的远程设置. 这个 Status 字段表示该连接是否成功,如果没有成功,则说明原因.
JSON去Stdout和输出文件. --quiet 只能压制 Stdout. 该文件仍被写入.
系统诊断
Usage: npx -p @contrast/cli system-diagnostics [options]
Options:
-q, --quiet suppress logging to stdout
-o, --output <string> output file for the generated JSON
(default: ./contrast_system_info.json)
-V, --version output the version number
-h, --help display help for command
作为JSON,打印代理机运行的宿主或容器的信息. 这和特工收集的系统信息一样 它不会联系到Conters.
JSON去Stdout和输出文件. --quiet 只能压制 stdout.
重写
Usage: npx -p @contrast/cli rewrite [options] <entrypoint>
Arguments:
entrypoint The entrypoint for the application
Options:
-a, --assess rewrite in assess mode
-p, --protect rewrite in protect mode
-V, --version output the version number
-h, --help display help for command
提前重写应用程序的源文件并缓存结果,因此代理机在应用程序启动时不需要重写. 从入口开始,它跟随每一个静态 import, (中文(简体) ), require(),以及 import() 带有字符串参数,并重写每个文件.
模式必须匹配应用程序将如何运行 :
--protect重写保护.--assess重写评估 。 当assess.enable实值true在配置中.- 既未启用旗帜又未启用评估, 它会重写保护 .
结果被缓存于 <agent.node.rewrite.cache.path>/<application name>/<agent version>/<mode>/。缓存路径默认为 .contrast/ 在工作目录中。 代理仅在应用程序名称、代理版本和模式全部匹配时使用缓存, 所以重运行 rewrite 升级代理后.
命令失败 Rewriting disabled. 若为 agent.node.rewrite.enable 或者说 agent.node.rewrite.cache.enable 实值 false。 。 。 .