Skip to content

Commit

Permalink
docs: translate
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc committed Mar 17, 2024
1 parent 67cb297 commit abb7619
Show file tree
Hide file tree
Showing 45 changed files with 2,380 additions and 3,902 deletions.
283 changes: 96 additions & 187 deletions docs/docs/docs/api/api.en-US.md

Large diffs are not rendered by default.

90 changes: 45 additions & 45 deletions docs/docs/docs/api/commands.en-US.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
---
order: 4
toc: content
translated_at: '2024-03-17T10:43:51.227Z'
---
# 命令行

umi 提供了很多内置的命令行用于启动,构建项目,另外还有一些辅助开发的命令,如生成器等。
# Command Line

要获取可用的命令列表,你可以在项目目录中运行 help 命令:
umi offers many built-in command line interfaces to start and build projects, as well as some auxiliary development commands, such as generators.

To get a list of available commands, you can run the help command in the project directory:

```bash
umi help
```

你应该能看到类似如下的日志:
You should see logs similar to the following:

```bash
Usage: umi <command> [options]
Expand All @@ -39,21 +41,21 @@ Run `umi help <command>` for more information of specific commands.
Visit https://umijs.org/ to learn more about Umi.
```

> 为方便查找,以下命令通过字母排序。
> For ease of lookup, the commands below are sorted alphabetically.
## build

构建项目,适用于生产环境的部署。
Build the project for deployment in a production environment.

```bash
$ umi build
```

## config

通过命令行快速查看和修改配置。
Quickly view and modify configuration via the command line.

查看配置,可以用 `list` `get`
Viewing configuration, you can use `list` or `get`.

```bash
$ umi config list
Expand All @@ -64,7 +66,7 @@ $ umi config get mfsu
- [key: externals] { esbuild: true }
```
修改配置,可以用 `set` `remove`
Modifying configuration, you can use `set` or `remove`.
```bash
$ umi config set polyfill false
Expand All @@ -76,7 +78,7 @@ remove config:polyfill on /private/tmp/sorrycc-wsYpty/.umirc.ts
## dev
启动本地开发服务器,进行项目的开发与调试。
Start a local development server for project development and debugging.
```bash
$ umi dev
Expand All @@ -92,29 +94,29 @@ event - compiled successfully in 1051 ms (416 modules)
## generate
用于增量生成文件或启用功能,命令行别名是 `g`
Used for incrementally generating files or enabling features, the command line alias is `g`.
不加任何参数时会给交互式的生成器选择。
When used without any parameters, it will opt for an interactive generator selection.
```bash
$ umi g
#
# or
$ umi generate
? Pick generator type › - Use arrow-keys. Return to submit.
❯ Create Pages -- Create a umi page by page name
Enable Prettier -- Enable Prettier
```
也可以指定参数。
You can also specify parameters.
```bash
# 生成路由文件
# Generate route files
$ umi g page index --typescript --less
```
## help
查看帮助。
View help.
```bash
$ umi help
Expand All @@ -135,7 +137,7 @@ Run `umi help <command>` for more information of specific commands.
Visit https://umijs.org/ to learn more about Umi.
```
也可指定命令,查看特定命令的详细帮助。
You can also specify a command to see detailed help for that command.
```bash
$ umi help build
Expand All @@ -154,27 +156,27 @@ Details:
## lint
用于检查及修正代码是否符合规则。
Used to check and correct code to match rules.
```bash
$ umi lint
Usage: umi lint

支持只校验 js、ts、tsxjsx 类型文件: umi lint --eslint-only
Support for validation of js, ts, tsx, jsx type files only: umi lint --eslint-only

支持只校验 cssless 等样式文件: umi lint --stylelint-only
Support for validation of css, less and other style files only: umi lint --stylelint-only

支持校验 cssinjs 模式校验: umi lint --stylelint-only --cssinjs
Support for cssinjs mode validation: umi lint --stylelint-only --cssinjs

修正代码: --fix
Correct the code: --fix

```
## plugin
插件相关操作,目前只支持 `list` 子命令。
Plugin related operations, currently only supports the `list` subcommand.
列出所有插件。
List all plugins.
```bash
$ umi plugin list
Expand All @@ -193,37 +195,37 @@ $ umi plugin list
## preview
`umi preview` 命令会在本地启动一个静态 Web 服务器,将 dist 文件夹运行在 http://127.0.0.1:4172, 用于预览构建后产物, 支持 proxymock 等设置。
The `umi preview` command will launch a local static web server, running the dist folder at http://127.0.0.1:4172, for previewing the production build, supporting proxy, mock, etc. settings.
你可以通过 `--port` 参数来配置服务的运行端口。
You can use the `--port` parameter to configure the service's running port.
```bash
$ umi preview --port 9527
```
现在 `preview` 命令会将服务器运行在 http://127.0.0.1:9527.
Now the `preview` command will run the server at http://127.0.0.1:9527.
通过 `--host` 参数来指定 配置服务运行的 hostname
Use the `--host` parameter to specify the service's running hostname.
以下用户配置在 `preview` 时也会生效
The following user configurations will also take effect during `preview`
* [https](./config#https)
* [proxy](../guides/proxy)
* [mock](../guides/mock)
注意 `dist` 目录会随着配置 `outputPath` 的变更而变更。
Note that the `dist` directory will change with the configuration of `outputPath`.
## run
`umi run` 命令可以让你像 node 运行 js 一样来运行 TypeScript ESM 文件。你可以搭配 [zx](https://github.com/google/zx) 来更好的使用脚本命令。
The `umi run` command allows you to run TypeScript and ESM files like running js with node. You can pair it with [zx](https://github.com/google/zx) for better script command usability.
```bash
$ umi run ./script.ts
```
## setup
初始化项目,会做临时文件的生成等操作。通常在 package.json 的 `scripts.postinstall` 里设置。
Initialize the project, doing operations like generating temporary files. Usually set in `scripts.postinstall` in package.json.
```bash
{
Expand All @@ -233,7 +235,7 @@ $ umi run ./script.ts
## deadcode
用于查找 src 目录下未被引用的文件,并在根目录输出文件。
Used to find files in the src directory that are not referenced, and output to the root directory.
```bash
$ umi deadcode
Expand All @@ -245,14 +247,13 @@ $ umi deadcode
## mfsu
`umi mfsu` 命令可以查看 MFSU 依赖信息、重新构建 MFSU 依赖和清除 MFSU 依赖。
The `umi mfsu` command can be used to view MFSU dependency information, rebuild MFSU dependencies, and clear MFSU dependencies.
```bash title="获取 MFSU 命令帮忙"
```bash title="Get MFSU command help"
$ umi mfsu
```
```bash title="获取 MFSU 依赖列表"
```bash title="Get MFSU dependency list"
$ umi mfsu ls
warning@4.0.3
regenerator-runtime/runtime.js@0.13.11
Expand All @@ -267,7 +268,7 @@ lodash/concat@4.17.21
...
```
```bash title="重新构建 MFSU 依赖"
```bash title="Rebuild MFSU dependency"
$ umi mfsu build
info - Preparing...
info - MFSU eager strategy enabled
Expand All @@ -277,18 +278,18 @@ info - [MFSU] buildDeps since cacheDependency has changed
info - [plugin: @umijs/preset-umi/dist/commands/mfsu/mfsu] [MFSU][eager] build success
```
```bash title="清除 MFSU 依赖"
$ # 删除依赖信息列表
```bash title="Clear MFSU dependency"
$ # Delete dependency information list
$ umi mfsu remove
$ # 删除依赖信息列表和产物文件
$ # Delete dependency information list and product files
$ umi mfsu remove --all
```
## verifyCommit
验证 commit message 信息,通常和 [husky](https://github.com/typicode/husky) 搭配使用。
Verify commit message information, usually used in conjunction with [husky](https://github.com/typicode/husky).
比如在 `.husky/commit-msg` 做如下配置,
For example, configure the following in `.husky/commit-msg`,
```bash
#!/bin/sh
Expand All @@ -299,10 +300,9 @@ npx --no-install umi verify-commit $1
## version
查看 `umi` 版本,等同于 `umi -v`
View the `umi` version, equivalent to `umi -v`.
```bash
$ umi version
4.0.0
```
Loading

0 comments on commit abb7619

Please sign in to comment.