# @xstate/cli

@xstate/cli package (opens new window) 包含运行 typegen 的命令。目前它还很小,但我们计划添加许多很酷的功能。

¥The @xstate/cli package (opens new window) contains commands for running typegen. It's pretty small right now, but we're planning on adding many cool features.

# 安装

¥Installation

  • 运行 npm install @xstate/cli

    ¥Run npm install @xstate/cli

# 命令

¥Commands

# xstate typegen <files>

xstate typegen "src/**/*.ts?(x)"

针对 glob 运行 typegen。这将扫描每个目标文件,并生成一个随附的 typegen 文件。它还会将 typegen 导入到你的文件中,如 我们的 typegen 文档 (opens new window) 中所述。

¥Run the typegen against a glob. This will scan every file targeted, and generate a typegen file accompanying it. It will also import the typegen into your file, as described in our typegen documentation (opens new window).

确保将 glob 括在引号中,以便它正确执行。如果它没有用引号引起来,它将被解释为文件列表,而不是 glob。这会带来意想不到的结果。

¥Ensure you wrap your glob in quotes so that it executes correctly. If it isn't wrapped in quotes, it will be interpreted as a list of files, not a glob. This will give unexpected results.

# 选项

¥Options

xstate typegen "src/**/*.ts?(x)" --watch

在监视上运行任务,监视更改的文件并针对它们运行 typegen 脚本。

¥Runs the task on a watch, monitoring for changed files and running the typegen script against them.