Skip to main content

命令

本页列出了Backstage CLI 提供的所有命令、它们的用途以及使用地点。

help

该命令显示每条命令的帮助摘要或详细帮助屏幕。 以下是经过清理的yarn backstage-cli --help:

new [options]                                  Open up an interactive guide to creating new things in
your app
test Run tests, forwarding args to Jest, defaulting to watch
mode [DEPRECATED]
config:docs [options] Browse the configuration reference documentation
config:print [options] Print the app configuration for the current package
config:check [options] Validate that the given configuration loads and matches
schema
config:schema [options] Print configuration schema
repo [command] Command that run across an entire Backstage project
package [command] Lifecycle scripts for individual packages
migrate [command] Migration utilities
versions:bump [options] Bump Backstage packages to the latest versions
versions:check [options] Check Backstage package versioning
clean Delete cache directories [DEPRECATED]
build-workspace <workspace-dir> [packages...] Builds a temporary dist workspace from the provided
packages
create-github-app <github-org> Create new GitHub App in your organization.
info Show helpful information for debugging and reporting bugs
help [command] display help for command

package命令类别、yarn backstage-cli package --help:

start [options]                  Start a package for local development
build [options] Build a package for production deployment or publishing
lint [options] [directories...] Lint a package
test Run tests, forwarding args to Jest, defaulting to watch mode
clean Delete cache directories
prepack Prepares a package for packaging before publishing
postpack Restores the changes made by the prepack command
help [command] display help for command

repo命令类别、yarn backstage-cli repo --help:

build [options]              Build packages in the project, excluding bundled app and backend packages.
lint [options] Lint all packages in the project
clean Delete cache and output directories
list-deprecations [options] List deprecations
test [options] Run tests, forwarding args to Jest, defaulting to watch mode
help [command] display help for command

migrate命令类别、yarn backstage-cli migrate --help:

package-roles Add package role field to packages that don't have it
package-scripts Set package scripts according to each package role
package-exports Synchronize package subpath export definitions
package-lint-configs Migrates all packages to use @backstage/cli/config/eslint-factory
react-router-deps Migrates the react-router dependencies for all packages to be peer dependencies
help [command] display help for command

repo build

编译项目中的所有软件包,默认情况下不包括捆绑软件包,即角色为'frontend''backend'.

Usage: backstage-cli repo build [options]

Build packages in the project, excluding bundled app and backend packages.

Options:
--all Build all packages, including bundled app and backend packages.
--since <ref> Only build packages and their dev dependents that changed since the specified ref

repo lint

检查项目中的所有软件包。

Usage: backstage-cli repo lint [options]

Lint all packages in the project

Options:
--format <format> Lint report output format (default: "eslint-formatter-friendly")
--since <ref> Only lint packages that changed since the specified ref
--fix Attempt to automatically fix violations

软件包启动

启动用于本地开发的软件包。 参见构建系统中的前端和后端开发部分捆绑部分了解更多详情。

Usage: backstage-cli package start [options]

Start a package for local development

Options:
--config <path> Config files to load instead of app-config.yaml (default: [])
--role <name> Run the command with an explicit package role
--check Enable type checking and linting if available
--inspect Enable debugger in Node.js environments
--inspect-brk Enable debugger in Node.js environments, breaking before code starts

软件包构建

根据软件包的作用构建单个软件包。 参见构建系统架构物捆绑章节了解更多详情。

Usage: backstage-cli package build [options]

Build a package for production deployment or publishing

Options:
--role <name> Run the command with an explicit package role
--minify Minify the generated code. Does not apply to app or backend packages.
--skip-build-dependencies Skip the automatic building of local dependencies. Applies to backend packages only.
--stats If bundle stats are available, write them to the output directory. Applies to app packages only.
--config <path> Config files to load instead of app-config.yaml. Applies to app packages only. (default: [])

软件包 lint

除了默认的eslint行为,该命令将包含 TypeScript 文件,将警告视为错误,如果没有列出特定文件,则默认对整个目录进行着色。 更多信息,请参阅构建系统皮棉节。

Usage: backstage-cli package lint [options]

Lint a package

Options:
--format <format> Lint report output format (default: "eslint-formatter-friendly")
--fix Attempt to automatically fix violations

软件包测试

运行测试时,将所有未知选项转发给 Jest,并默认为观察模式。 执行测试时、process.env.NODE_ENV将设置为"test".

该命令使用 CLI 中包含的默认 Jest 配置,其设置目标类似于速度、规模和在 monorepo 中工作。 该配置设置了src作为根目录,执行.test.后缀进行测试,并使用src/setupTests.ts作为测试设置位置。 附带的配置还支持在 yarn workspaces monorepo 根目录下执行测试,方法是自动创建一个分组配置,其中包括所有具有backstage-cli test在其包装中test剧本

有关配置重写和编辑器支持的更多信息,请参阅Jest 配置部分在构建系统文档中。

Usage: backstage-cli package test [options]

Run tests, forwarding args to Jest, defaulting to watch mode

Options:
--backstage-cli-help display help for command

package clean

删除缓存和输出目录

Usage: backstage-cli package clean [options]

Delete cache directories

package prepack

该命令应添加为scripts.prepack在所有软件包中,它可以在打包和发布时覆盖packages.json更多详情,请参阅构建系统出版节。

Usage: backstage-cli package prepack [options]

Prepares a package for packaging before publishing

package postpack

应添加为scripts.postpack在所有软件包中恢复package.json与调用prepack指挥。

Usage: backstage-cli package postpack [options]

Restores the changes made by the prepack command

new

new命令会打开一个交互式指南,供您在应用程序中创建新内容。 如果您不输入任何选项,它就是完全交互式的,但也可以使用--select标记,并使用--option例如

backstage-cli new --select plugin --option id=foo

该命令通常作为脚本添加到根目录的package.json执行yarn new例如,您可以这样设置:

{
"scripts": {
"new": "backstage-cli new --scope internal --no-private --npm-registry https://acme.org/npm"
}
}
Usage: backstage-cli create [options]

Options:
--select <name> Select the thing you want to be creating upfront
--option <name>=<value> Pre-fill options for the creation process (default: [])
--scope <scope> The scope to use for new packages
--npm-registry <URL> The package registry to use for new packages
--no-private Do not mark new packages as private
-h, --help display help for command

config

该命令将在浏览器中打开应用程序本地配置模式的参考文档,有助于全面了解哪些配置值可供使用、这些配置值的作用和格式说明,以及这些配置值的发送位置。

Usage: backstage-cli config:docs [options]

Browse the configuration reference documentation

Options:
--package <name> Only include the schema that applies to the given package
-h, --help display help for command

config

打印静态配置,默认为读取app-config.yaml在软件包根目录中使用从软件包中所有本地软件包收集的模式。

例如,要验证给定的配置值在构建my-app软件包,您可以使用

yarn backstage-cli config:print --frontend --package my-app
Usage: backstage-cli config:print [options]

Options:
--package <name> Only load config schema that applies to the given package
--lax Do not require environment variables to be set
--frontend Print only the frontend configuration
--with-secrets Include secrets in the printed configuration
--format <format> Format to print the configuration in, either json or yaml [yaml]
--config <path> Config files to load instead of app-config.yaml (default: [])
-h, --help display help for command

config

验证静态配置是否加载并与模式匹配,默认为读取app-config.yaml并使用从软件包根目录中所有本地软件包收集的模式。

Usage: backstage-cli config:check [options]

Options:
--package <name> Only load config schema that applies to the given package
--lax Do not require environment variables to be set
--frontend Only validate the frontend configuration
--deprecated Output deprecated configuration settings
--strict Ensure that the provided config(s) has no errors and does not contain keys not in the schema.
--config <path> Config files to load instead of app-config.yaml (default: [])
-h, --help display help for command

config

转储从软件包库中所有本地软件包收集的配置模式。

注:当由yarn提供纱线选项--silent如果在命令行管道中使用输出,以避免管道中出现非模式输出。

Usage: backstage-cli config:schema [options]

Print configuration schema

Options:
--package <name> Only output config schema that applies to the given package
--format <format> Format to print the schema in, either json or yaml [yaml]
-h, --help display help for command

版本:碰撞

全部@backstage这将检查软件包注册表中的更新,并更新软件包注册表中的yarn.lockpackage.json文件。

Usage: backstage-cli versions:bump [options]

Options:
-h, --help display help for command
--pattern <glob> Override glob for matching packages to upgrade
--release <version|next|main> Bump to a specific Backstage release line or version (default: "main")

版本:检查

验证@backstage的依赖关系,确保没有可能导致故障的重复软件包。

通过提供--fix标记,该命令将尝试修复任何可以通过编辑yarn.lock但不会尝试搜索远程更新或修改任何package.json文件

Usage: backstage-cli versions:check [options]

Options:
--fix Fix any auto-fixable versioning problems
-h, --help display help for command

构建工作空间

使用每个软件包的打包生产版本构建工作区镜像。 这主要调用yarn pack中的每个软件包,并将生成的压缩包解压到目标workspace-dir.

Usage: backstage-cli build-workspace [options] <workspace-dir>

create-github-app

在你的 GitHub 组织中创建一个 GitHub 应用程序。 这是基于令牌的GitHub 集成请看用于Backstage身份验证的 GitHub 应用程序.

启动浏览器通过 GitHub 创建应用程序,并将结果保存为可在 GitHub 集成配置中引用的 YAML 文件。

Usage: backstage-cli create-github-app <github-org>

信息

输出调试信息,这些信息在打开问题时非常有用。 输出系统信息、node.js 和 npm 版本、CLI 版本和类型(Backstage软件仓库或创建的应用程序内部),以及全部@backstage/*软件包依赖版本。

Usage: backstage-cli info