From e21e230f6ecda34248225de228134640933e4af9 Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 21 Jul 2026 21:25:59 +0800 Subject: [PATCH 1/3] docs: polish website documentation --- website/README.md | 13 ++++++----- website/docs/en/guide/api-reference.mdx | 14 ++++++------ website/docs/en/guide/cli/build.mdx | 4 ++-- website/docs/en/guide/cli/dev.mdx | 4 ++-- website/docs/en/guide/cli/doc.mdx | 8 +++---- website/docs/en/guide/cli/lib.mdx | 2 +- website/docs/en/guide/cli/lint.mdx | 4 ++-- website/docs/en/guide/cli/preview.mdx | 8 +++---- website/docs/en/guide/cli/staged.mdx | 10 ++++----- website/docs/en/guide/cli/test.mdx | 6 ++--- website/docs/en/guide/configuration.mdx | 30 ++++++++++++------------- website/docs/en/guide/quick-start.mdx | 16 ++++++------- website/docs/en/guide/testing.mdx | 28 +++++++++++------------ website/docs/zh/guide/api-reference.mdx | 14 ++++++------ website/docs/zh/guide/cli/build.mdx | 4 ++-- website/docs/zh/guide/cli/dev.mdx | 6 ++--- website/docs/zh/guide/cli/doc.mdx | 10 ++++----- website/docs/zh/guide/cli/lib.mdx | 4 ++-- website/docs/zh/guide/cli/lint.mdx | 4 ++-- website/docs/zh/guide/cli/preview.mdx | 8 +++---- website/docs/zh/guide/cli/staged.mdx | 10 ++++----- website/docs/zh/guide/cli/test.mdx | 8 +++---- website/docs/zh/guide/configuration.mdx | 26 ++++++++++----------- website/docs/zh/guide/quick-start.mdx | 14 ++++++------ website/docs/zh/guide/testing.mdx | 26 ++++++++++----------- 25 files changed, 141 insertions(+), 140 deletions(-) diff --git a/website/README.md b/website/README.md index f2e87ff..5421dca 100644 --- a/website/README.md +++ b/website/README.md @@ -2,25 +2,26 @@ This website is built with [Rspress](https://rspress.rs/) through Rstack CLI. -Documentation can be written with Markdown or MDX. +The documentation source lives in `docs` and is written in Markdown or MDX. ## Development -Run the development server from the repository root: +Start the development server from the repository root: ```bash pnpm doc ``` -Build or preview the website from this directory: +Alternatively, run the website scripts from this directory: ```bash +pnpm dev pnpm build pnpm preview ``` ## Contributing -The website provides English and Chinese documentation. Keep both versions in -sync when possible. Placeholder pages marked with `TODO` are ready for future -documentation. +Keep corresponding English and Chinese pages aligned in structure, meaning, +links, and examples. When a translated heading would generate a different +anchor, add an explicit anchor that matches the English heading. diff --git a/website/docs/en/guide/api-reference.mdx b/website/docs/en/guide/api-reference.mdx index a94dcbb..71d1bfd 100644 --- a/website/docs/en/guide/api-reference.mdx +++ b/website/docs/en/guide/api-reference.mdx @@ -1,6 +1,6 @@ # API reference -Rstack provides a unified configuration API and re-exports the public APIs of Rsbuild, Rslib, Rstest, and Rslint through dedicated subpaths. Prefer these subpaths to direct imports from each tool's core package so that dependency entry points and tool versions remain aligned with Rstack. +Rstack exposes a unified configuration API and dedicated entry points for the public APIs of Rsbuild, Rslib, Rstest, and Rslint. Prefer these entry points over direct imports from each tool's core package so that import paths and tool versions stay aligned with Rstack. ## Import paths @@ -19,11 +19,11 @@ Rstack provides a unified configuration API and re-exports the public APIs of Rs ### `define` -Import `define` from `rstack` to register tool configurations in `rstack.config.ts`; see [Configuration APIs](./configuration#configuration-apis) for details. +Import `define` from `rstack` to register tool configurations in `rstack.config.ts`. For details, see [Configuration APIs](./configuration#configuration-apis). ## Re-exports -The tool-specific subpaths below re-export the public APIs from their corresponding core packages. Using these Rstack entry points keeps dependency entry points and tool versions aligned with the toolchain integrated by Rstack. +Each tool-specific subpath re-exports the public APIs of its corresponding core package. ### `rstack/app` @@ -53,7 +53,7 @@ For details, see the [Rslib core APIs](https://rslib.rs/api/javascript-api/core) import { describe, expect, test } from 'rstack/test'; ``` -See the [Rstest runtime API](https://rstest.rs/api/runtime-api/) for test APIs and the [Rstest core APIs](https://rstest.rs/api/javascript-api/rstest-core) for configuration helpers. +For test APIs, see the [Rstest runtime API](https://rstest.rs/api/runtime-api/). For configuration helpers, see the [Rstest core APIs](https://rstest.rs/api/javascript-api/rstest-core). > For more guidance on testing, see [Testing](./testing). @@ -69,7 +69,7 @@ For details about the available presets and plugins, see [Rslint rules and prese ## TypeScript types -These type-only entry points add ambient declarations to a TypeScript project. Add only the entries your project needs to [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig/#types) in `tsconfig.json`. +The following type-only entry points add ambient declarations to a TypeScript project. Add only the entries your project needs to [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig/#types) in `tsconfig.json`. ### `rstack/types` @@ -85,7 +85,7 @@ These type-only entry points add ambient declarations to a TypeScript project. A ### `rstack/test/globals` -`rstack/test/globals` declares Rstest APIs such as `test`, `expect`, and lifecycle hooks as globals. Add it when tests use these APIs without explicit imports. +`rstack/test/globals` declares Rstest APIs such as `test`, `expect`, and lifecycle hooks as globals. Add it when Rstest's [`globals`](https://rstest.rs/config/test/globals) option is enabled and tests use these APIs without explicit imports. ```json title="tsconfig.json" { @@ -97,7 +97,7 @@ These type-only entry points add ambient declarations to a TypeScript project. A ### `rstack/test/importMeta` -`rstack/test/importMeta` augments `ImportMeta` with the optional `rstest` property, enabling `import.meta.rstest` in in-source tests. +`rstack/test/importMeta` augments `ImportMeta` with the optional `rstest` property, providing type support for `import.meta.rstest` in in-source tests. ```json title="tsconfig.json" { diff --git a/website/docs/en/guide/cli/build.mdx b/website/docs/en/guide/cli/build.mdx index 6f2e728..0997399 100644 --- a/website/docs/en/guide/cli/build.mdx +++ b/website/docs/en/guide/cli/build.mdx @@ -20,7 +20,7 @@ Examples: # Write output files to the output directory rs build --dist-path output -# Generate source maps for the output files +# Generate source maps for output files rs build --source-map # Rebuild when files change @@ -29,7 +29,7 @@ rs build --watch ## Configuration -Configure the production build through [`define.app()`](../configuration#define-app) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rsbuild configuration](https://rsbuild.rs/config/): +Configure production builds with [`define.app()`](../configuration#define-app) in `rstack.config.ts`. The API accepts the standard [Rsbuild configuration](https://rsbuild.rs/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/en/guide/cli/dev.mdx b/website/docs/en/guide/cli/dev.mdx index 1af5534..cf452a0 100644 --- a/website/docs/en/guide/cli/dev.mdx +++ b/website/docs/en/guide/cli/dev.mdx @@ -20,7 +20,7 @@ Examples: # Start the server and open the page in the browser rs dev --open -# Use port 8080 and fail if it is already in use +# Use port 8080 and exit if it is already in use rs dev --port 8080 --strict-port # Make the server available on the local network @@ -29,7 +29,7 @@ rs dev --host ## Configuration -Configure the development server through [`define.app()`](../configuration#define-app) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rsbuild configuration](https://rsbuild.rs/config/): +Configure the development server with [`define.app()`](../configuration#define-app) in `rstack.config.ts`. The API accepts the standard [Rsbuild configuration](https://rsbuild.rs/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/en/guide/cli/doc.mdx b/website/docs/en/guide/cli/doc.mdx index 08877b4..c5a64bd 100644 --- a/website/docs/en/guide/cli/doc.mdx +++ b/website/docs/en/guide/cli/doc.mdx @@ -2,9 +2,9 @@ import { PackageManagerTabs } from '@rspress/core/theme'; -The `rs doc` command uses [Rspress](https://rspress.rs/guide/start/introduction) to develop, build, and preview a documentation site. +The `rs doc` command uses [Rspress](https://rspress.rs/guide/start/introduction) to develop, build, and locally preview a documentation site. -Install [`@rspress/core`](https://www.npmjs.com/package/@rspress/core) before using the command: +[`@rspress/core`](https://www.npmjs.com/package/@rspress/core) is an optional dependency. Install it before using `rs doc`: @@ -54,7 +54,7 @@ rs doc preview ### eject -[`rs doc eject`](https://rspress.rs/api/commands#rspress-eject) copies a built-in Rspress theme component into the project for customization. Run it without a component name to list all ejectable components. +[`rs doc eject`](https://rspress.rs/api/commands#rspress-eject) copies a built-in Rspress theme component into the project for customization. Run it without a component name to list the available components. ```bash rs doc eject @@ -62,7 +62,7 @@ rs doc eject ## Configuration -Configure the documentation site through [`define.doc()`](../configuration#define-doc) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rspress configuration](https://rspress.rs/api/config/config-basic): +Configure the documentation site with [`define.doc()`](../configuration#define-doc) in `rstack.config.ts`. The API accepts the standard [Rspress configuration](https://rspress.rs/api/config/config-basic): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/en/guide/cli/lib.mdx b/website/docs/en/guide/cli/lib.mdx index 79b7319..e2086b5 100644 --- a/website/docs/en/guide/cli/lib.mdx +++ b/website/docs/en/guide/cli/lib.mdx @@ -44,7 +44,7 @@ rs lib mf-dev ## Configuration -Configure library builds through [`define.lib()`](../configuration#define-lib) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rslib configuration](https://rslib.rs/config/): +Configure library builds with [`define.lib()`](../configuration#define-lib) in `rstack.config.ts`. The API accepts the standard [Rslib configuration](https://rslib.rs/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/en/guide/cli/lint.mdx b/website/docs/en/guide/cli/lint.mdx index 07b1592..0e4787a 100644 --- a/website/docs/en/guide/cli/lint.mdx +++ b/website/docs/en/guide/cli/lint.mdx @@ -1,6 +1,6 @@ # lint -The `rs lint` command uses [Rslint](https://rslint.rs/guide/) to lint source code. +The `rs lint` command uses [Rslint](https://rslint.rs/guide/) to lint source files. ## Usage @@ -29,7 +29,7 @@ rs lint --type-check ## Configuration -Configure linting through [`define.lint()`](../configuration#define-lint) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rslint configuration](https://rslint.rs/config/). Presets and plugins can be imported from `rstack/lint` on demand: +Configure linting with [`define.lint()`](../configuration#define-lint) in `rstack.config.ts`. The API accepts the standard [Rslint configuration](https://rslint.rs/config/). Presets and plugins can be imported from `rstack/lint` on demand: ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/en/guide/cli/preview.mdx b/website/docs/en/guide/cli/preview.mdx index dec9821..029bd3b 100644 --- a/website/docs/en/guide/cli/preview.mdx +++ b/website/docs/en/guide/cli/preview.mdx @@ -1,6 +1,6 @@ # preview -The `rs preview` command uses [Rsbuild](https://rsbuild.rs/guide/basic/cli#rsbuild-preview) to preview an application's production build locally. +The `rs preview` command uses [Rsbuild](https://rsbuild.rs/guide/basic/cli#rsbuild-preview) to preview an application's production output locally. ## Usage @@ -8,7 +8,7 @@ The `rs preview` command uses [Rsbuild](https://rsbuild.rs/guide/basic/cli#rsbui rs preview [options] ``` -The command loads the application configuration registered with [`define.app()`](../configuration#define-app). Run [`rs build`](./build) before starting the preview server to generate the production output: +The command loads the application configuration registered with [`define.app()`](../configuration#define-app). Before starting the preview server, run [`rs build`](./build) to generate the production output: ```bash rs build @@ -27,7 +27,7 @@ Examples: # Start the preview server and open the page in the browser rs preview --open -# Use port 8080 and fail if it is already in use +# Use port 8080 and exit if it is already in use rs preview --port 8080 --strict-port # Make the preview server available on the local network @@ -36,7 +36,7 @@ rs preview --host ## Configuration -Configure the preview server through [`define.app()`](../configuration#define-app) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rsbuild configuration](https://rsbuild.rs/config/): +Configure the preview server with [`define.app()`](../configuration#define-app) in `rstack.config.ts`. The API accepts the standard [Rsbuild configuration](https://rsbuild.rs/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/en/guide/cli/staged.mdx b/website/docs/en/guide/cli/staged.mdx index ee377d1..3ee35d6 100644 --- a/website/docs/en/guide/cli/staged.mdx +++ b/website/docs/en/guide/cli/staged.mdx @@ -1,8 +1,8 @@ # staged -The `rs staged` command uses [lint-staged](https://github.com/lint-staged/lint-staged) to run tasks against files staged in Git. +The `rs staged` command uses [lint-staged](https://github.com/lint-staged/lint-staged) to run tasks against files staged for commit. -A common use case is to run linters, formatters, or other checks on staged files before committing code. +It is typically used in a Git hook to lint, format, or otherwise check files before a commit. ## Usage @@ -16,7 +16,7 @@ The command loads the staged-file tasks registered with [`define.staged()`](../c ### `--allow-empty` -`--allow-empty` allows an empty commit when tasks revert all staged changes. +`--allow-empty` allows the commit to proceed if tasks revert all staged changes. ```bash rs staged --allow-empty @@ -48,7 +48,7 @@ rs staged --debug ### `--no-stash` -`--no-stash` disables the backup stash and keeps changes made by tasks when an error occurs. +`--no-stash` disables the backup stash and automatic reversion when a task fails. ```bash rs staged --no-stash @@ -88,7 +88,7 @@ rs staged --help ## Configuration -Configure staged-file tasks through [`define.staged()`](../configuration#define-staged) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [lint-staged configuration](https://github.com/lint-staged/lint-staged#configuration): +Configure staged-file tasks with [`define.staged()`](../configuration#define-staged) in `rstack.config.ts`. The API accepts the standard [lint-staged configuration](https://github.com/lint-staged/lint-staged#configuration): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/en/guide/cli/test.mdx b/website/docs/en/guide/cli/test.mdx index c1e393f..8ed0372 100644 --- a/website/docs/en/guide/cli/test.mdx +++ b/website/docs/en/guide/cli/test.mdx @@ -2,7 +2,7 @@ The `rs test` command uses [Rstest](https://rstest.rs/guide/basic/cli) to run tests. -For more guidance on testing, see [Testing](../testing). +> For more guidance on testing, see [Testing](../testing). ## Usage @@ -65,7 +65,7 @@ rs test merge-reports ### init -[`rs test init`](https://rstest.rs/guide/basic/cli#rstest-init) creates starter files for a supported Rstest project type. +[`rs test init`](https://rstest.rs/guide/basic/cli#rstest-init) initializes an Rstest configuration for a supported project type. ```bash rs test init browser @@ -73,7 +73,7 @@ rs test init browser ## Configuration -Configure tests through [`define.test()`](../configuration#define-test) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rstest configuration](https://rstest.rs/config/): +Configure tests with [`define.test()`](../configuration#define-test) in `rstack.config.ts`. The API accepts the standard [Rstest configuration](https://rstest.rs/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/en/guide/configuration.mdx b/website/docs/en/guide/configuration.mdx index d94fac3..b19dc34 100644 --- a/website/docs/en/guide/configuration.mdx +++ b/website/docs/en/guide/configuration.mdx @@ -1,6 +1,6 @@ # Configuration -Rstack centralizes the configuration for your project's tools in a single file. Define only the configurations your project needs with the `define.*()` APIs. +Rstack centralizes your project's tool configurations in one file. Register only the configurations your project needs with the `define.*()` APIs. ## Configuration file @@ -24,7 +24,7 @@ define.lint({ The configuration file does not require a default export. Each `define.*()` API can be called at most once; defining the same configuration type more than once throws an error. -By default, Rstack looks for a file with one of the following names: +By default, Rstack looks for any of the following files in the project root: - `rstack.config.ts` - `rstack.config.js` @@ -39,9 +39,9 @@ rs build --config ./configs/rstack.config.ts ## Loading dependencies on demand -Every `rs` command loads and executes the Rstack configuration file, then resolves only the configuration functions needed by that command. +Before running a tool, Rstack loads and executes the configuration file. It then resolves only the configuration functions required by that command. -When a configuration needs to import plugins or other tool-specific dependencies, use an async configuration function and load those dependencies with dynamic `import()` inside it. This ensures that they are loaded only when the configuration is resolved. +When a configuration uses a tool-specific plugin or dependency, define it as an async function and load that dependency with dynamic `import()` inside the function. This defers loading until the configuration is needed. ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -57,7 +57,7 @@ define.app(async () => { ## Configuration APIs -Configuration options follow the formats of the underlying tools. When using APIs and helpers that Rstack re-exports, prefer the `rstack/app`, `rstack/lib`, `rstack/test`, and `rstack/lint` entry points. +Each API accepts the configuration format of its underlying tool. When using APIs and helpers re-exported by Rstack, import them from the `rstack/app`, `rstack/lib`, `rstack/test`, and `rstack/lint` entry points. | API | Tool | Commands | | ----------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------- | @@ -70,7 +70,7 @@ Configuration options follow the formats of the underlying tools. When using API ### `define.app()` \{#define-app} -Defines the [Rsbuild configuration](https://rsbuild.rs/config/) for an application. It accepts a configuration object or a configuration function. The function receives the standard Rsbuild configuration parameters. +Defines the [Rsbuild configuration](https://rsbuild.rs/config/) for an application. It accepts a configuration object or a configuration function. The function receives the same configuration parameters as Rsbuild. ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -89,7 +89,7 @@ define.app({ ### `define.lib()` \{#define-lib} -Defines the [Rslib configuration](https://rslib.rs/config/) for a library. It accepts a configuration object or a configuration function. The function receives the standard Rslib configuration parameters. +Defines the [Rslib configuration](https://rslib.rs/config/) for a library. It accepts a configuration object or a configuration function. The function receives the same configuration parameters as Rslib. ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -106,7 +106,7 @@ define.lib({ ### `define.doc()` \{#define-doc} -Defines the [Rspress configuration](https://rspress.rs/api/config/config-basic) for a documentation site. It accepts a configuration object or an async configuration function. +Defines the [Rspress configuration](https://rspress.rs/api/config/config-basic) for a documentation site. It accepts either a configuration object or an async configuration function. ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -117,7 +117,7 @@ define.doc({ }); ``` -`@rspress/core` is an optional dependency of Rstack. Install it in every project that uses the `rs doc` command: +`@rspress/core` is an optional peer dependency of Rstack. Install it in each project that runs `rs doc`: ```bash pnpm add -D @rspress/core @@ -125,7 +125,7 @@ pnpm add -D @rspress/core ### `define.test()` \{#define-test} -Defines the [Rstest configuration](https://rstest.rs/config/). It accepts a configuration object or a configuration function. +Defines the [Rstest configuration](https://rstest.rs/config/). It accepts either a configuration object or a configuration function. ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -140,15 +140,15 @@ define.test({ }); ``` -When `extends` is omitted, Rstack automatically connects the test configuration to `define.app()` through the Rsbuild adapter. If no application configuration is defined, it falls back to `define.lib()` through the Rslib adapter. The application configuration takes precedence when both are defined. Set `extends` explicitly to opt out of this automatic inheritance. +When `extends` is omitted, Rstack uses the Rsbuild adapter to inherit the configuration from `define.app()`. If no application configuration is registered, it uses the Rslib adapter to inherit `define.lib()` instead. `define.app()` takes precedence when both are registered. Set `extends` explicitly to opt out of automatic inheritance. -If the root test configuration does not define `extends` and contains `projects`, Rstack applies automatic inheritance to each inline project that omits its own `extends`. A function-based application or library configuration is resolved once and shared by those projects. String project entries are passed to Rstest unchanged; they load their external configurations independently and do not inherit the current application or library configuration. +If the root test configuration contains `projects` and does not define `extends`, each inline project without its own `extends` inherits the same application or library configuration. A function-based configuration is resolved once and shared by those projects. String entries are passed to Rstest unchanged, so their external configurations load independently and do not inherit the current application or library configuration. > For more guidance on testing, see [Testing](./testing). ### `define.lint()` \{#define-lint} -Defines the [Rslint configuration](https://rslint.rs/config/). Pass the configuration directly, or use an async function to load presets and plugins from `rstack/lint` on demand. +Defines the [Rslint configuration](https://rslint.rs/config/). Pass a configuration directly, or use an async function to load presets and plugins from `rstack/lint` on demand. ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -162,7 +162,7 @@ define.lint(async () => { ### `define.staged()` \{#define-staged} -Defines the [lint-staged configuration](https://github.com/lint-staged/lint-staged#configuration) used to run tasks on staged Git files. It accepts either an object that maps glob patterns to tasks or a task-generator function. Tasks can be commands, command arrays, or functions supported by lint-staged. +Defines the [lint-staged configuration](https://github.com/lint-staged/lint-staged#configuration) for files staged in Git. It accepts either an object that maps glob patterns to tasks or a task-generator function. Tasks can be commands, command arrays, or functions supported by lint-staged. ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -172,4 +172,4 @@ define.staged({ }); ``` -Unlike the other commands, `rs staged` requires a `define.staged()` configuration and reports an error when it is missing. +Unlike the other tool commands, `rs staged` requires a `define.staged()` configuration and exits with an error when it is missing. diff --git a/website/docs/en/guide/quick-start.mdx b/website/docs/en/guide/quick-start.mdx index cf608ba..3289ace 100644 --- a/website/docs/en/guide/quick-start.mdx +++ b/website/docs/en/guide/quick-start.mdx @@ -2,13 +2,13 @@ import { PackageManagerTabs } from '@rspress/core/theme'; -Rstack CLI brings the Rstack toolchain together with one CLI and one configuration file. This guide adds Rstack to an existing project and introduces the available workflows. +Rstack CLI brings the Rstack toolchain together with one CLI and one configuration file. This guide shows how to add Rstack to an existing project and use its core workflows. ## Environment preparation Rstack supports using [Node.js](https://nodejs.org/), [Deno](https://deno.com/), or [Bun](https://bun.sh/) as the JavaScript runtime. -Use one of the following installation guides to set up a runtime: +Install one of the supported runtimes by following its installation guide: - [Install Node.js](https://nodejs.org/en/download) - [Install Bun](https://bun.com/docs/installation) @@ -16,7 +16,7 @@ Use one of the following installation guides to set up a runtime: :::tip Version requirements -Rstack requires Node.js 22.12.0 or higher when using Node.js as the runtime. +When using Node.js, Rstack requires version 22.12.0 or later. ::: @@ -49,22 +49,22 @@ Add the commands your project needs to the `scripts` field in `package.json`. Fo } ``` -Package scripts use the project-local `rs` binary, so Rstack does not need to be installed globally. +When invoked from a package script, `rs` resolves to the project-local binary, so Rstack does not need to be installed globally. The following commands are available: - [`rs dev`](./cli/dev): Start the application development server. - [`rs build`](./cli/build): Build the application for production. -- [`rs preview`](./cli/preview): Preview the application's production build locally. +- [`rs preview`](./cli/preview): Preview the application's production output locally. - [`rs lib`](./cli/lib): Build a library with Rslib. - [`rs doc`](./cli/doc): Develop, build, or preview a documentation site with Rspress. - [`rs test`](./cli/test): Run tests with Rstest. - [`rs lint`](./cli/lint): Lint source code with Rslint. -- [`rs staged`](./cli/staged): Run tasks against files staged in Git with lint-staged. +- [`rs staged`](./cli/staged): Run lint-staged tasks on files staged for commit. ## Configure Rstack -Create `rstack.config.ts` in the project root and register the configurations your project needs. The following is a minimal example for an application with testing and linting: +Create `rstack.config.ts` in the project root and register the configurations your project needs. The following minimal example configures an application, testing, and linting: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -82,4 +82,4 @@ define.lint({ }); ``` -See [Configuration](./configuration) for all available configuration APIs. +For details about all available configuration APIs, see [Configuration](./configuration). diff --git a/website/docs/en/guide/testing.mdx b/website/docs/en/guide/testing.mdx index 39e494b..df19b23 100644 --- a/website/docs/en/guide/testing.mdx +++ b/website/docs/en/guide/testing.mdx @@ -1,6 +1,6 @@ # Testing -Rstack uses [Rstest](https://rstest.rs/) to run tests. +Rstack runs tests with [Rstest](https://rstest.rs/). ```bash rs test @@ -10,7 +10,7 @@ For command-line options and subcommands, see [`rs test`](./cli/test). ## Configure tests -Register an Rstest configuration with [`define.test()`](./configuration#define-test). It accepts the same configuration as Rstest's `defineConfig()`: +Register an Rstest configuration with [`define.test()`](./configuration#define-test). It accepts the same options as Rstest's `defineConfig()`: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -22,7 +22,7 @@ define.test({ ## Test APIs -Import test APIs and configuration helpers from [`rstack/test`](./api-reference#rstacktest): +Import Rstest APIs and configuration helpers from [`rstack/test`](./api-reference#rstacktest): ```ts import { defineInlineProject, expect, test } from 'rstack/test'; @@ -30,7 +30,7 @@ import { defineInlineProject, expect, test } from 'rstack/test'; ## Single project -For a single test project, pass the Rstest options directly to `define.test()`: +When one test project is sufficient, pass the Rstest options directly to `define.test()`: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -44,15 +44,15 @@ define.test({ }); ``` -When `extends` is omitted, Rstack uses the Rsbuild adapter to extend the test configuration from `define.app()`. If no application configuration is defined, it uses the Rslib adapter with `define.lib()` instead. `define.app()` takes precedence when both are defined. +When `extends` is omitted, Rstack uses the Rsbuild adapter to inherit the configuration from `define.app()`. If no application configuration is registered, it uses the Rslib adapter to inherit `define.lib()` instead. `define.app()` takes precedence when both are registered. ## Multiple projects -Set Rstest's [`projects`](https://rstest.rs/config/test/projects) option to run multiple test configurations together. Entries can be inline projects or strings that Rstest resolves as external projects. +Set Rstest's [`projects`](https://rstest.rs/config/test/projects) option to run multiple test configurations together. Each entry can be an inline project or a string that points to an external project configuration. ### Inline projects -Use inline projects when different test environments should share the current application or library configuration: +Use inline projects when tests need different environments but should share the current application or library configuration: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -78,19 +78,19 @@ define.test({ }); ``` -Rstack applies the corresponding adapter to each inline project that omits `extends`. A function-based `define.app()` or `define.lib()` configuration is resolved once, then shared by those inline projects. +Rstack applies the corresponding adapter to every inline project that omits `extends`. A function-based `define.app()` or `define.lib()` configuration is resolved once and then shared by those projects. -Run one project by name: +To run one project by name, use `--project`: ```bash rs test --project dom ``` -See [`examples/rstest-inline-projects`](https://github.com/rstackjs/rstack-cli/tree/main/examples/rstest-inline-projects) for a complete React SSR example using Node.js and happy-dom. +For a complete React SSR example using the Node.js and happy-dom test environments, see [`examples/rstest-inline-projects`](https://github.com/rstackjs/rstack-cli/tree/main/examples/rstest-inline-projects). ### External projects -Use a string entry for an externally configured project: +Use a string entry to load an external project configuration: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -100,11 +100,11 @@ define.test({ }); ``` -Rstack passes string entries to Rstest unchanged. External projects load their own configuration and do not inherit the current `define.app()` or `define.lib()` configuration. Use external projects when each project manages its configuration independently. +Rstack passes string entries to Rstest unchanged. External projects load their own configuration and do not inherit the current `define.app()` or `define.lib()` configuration. Use them when each project should manage its configuration independently. ## Customize inheritance -Set Rstest's [`extends`](https://rstest.rs/config/test/extends) option explicitly when a project should not inherit the current application or library configuration: +To opt out of automatic inheritance, set Rstest's [`extends`](https://rstest.rs/config/test/extends) option explicitly: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -122,4 +122,4 @@ define.test({ }); ``` -Setting `extends` on an inline project disables automatic inheritance only for that project. Setting it on the root `define.test()` configuration disables automatic inheritance for the entire test configuration. +Setting `extends` on an inline project disables automatic inheritance only for that project. Setting it on the root `define.test()` configuration disables automatic inheritance for the entire configuration. diff --git a/website/docs/zh/guide/api-reference.mdx b/website/docs/zh/guide/api-reference.mdx index af26fea..6e0d62c 100644 --- a/website/docs/zh/guide/api-reference.mdx +++ b/website/docs/zh/guide/api-reference.mdx @@ -1,6 +1,6 @@ # API 参考 \{#api-reference} -Rstack 提供统一的配置 API,并通过专用子路径重导出 Rsbuild、Rslib、Rstest 和 Rslint 的公开 API。建议优先从这些子路径导入,以统一依赖入口,并确保 API 与 Rstack 集成的工具版本保持一致。 +Rstack 提供统一的配置 API,以及用于访问 Rsbuild、Rslib、Rstest 和 Rslint 公开 API 的专用入口。请优先使用这些入口,而不是直接从各工具的 core 包导入,以确保导入路径和工具版本与 Rstack 保持一致。 ## 导入路径 \{#import-paths} @@ -19,11 +19,11 @@ Rstack 提供统一的配置 API,并通过专用子路径重导出 Rsbuild、R ### `define` -从 `rstack` 导入 `define`,用于在 `rstack.config.ts` 中注册各项工具配置;详细用法请参阅[配置 API](./configuration#configuration-apis)。 +从 `rstack` 导入 `define`,用于在 `rstack.config.ts` 中注册各项工具配置。详细用法请参阅[配置 API](./configuration#configuration-apis)。 ## 重导出 \{#re-exports} -以下工具子路径均会重导出对应 core 包的公开 API。通过这些 Rstack 入口导入,可以让依赖入口和工具版本与 Rstack 集成的工具链保持一致。 +以下每个工具子路径都会重导出对应 core 包的公开 API。 ### `rstack/app` @@ -53,7 +53,7 @@ import { createRslib, mergeRslibConfig } from 'rstack/lib'; import { describe, expect, test } from 'rstack/test'; ``` -测试 API 请参阅 [Rstest 运行时 API](https://rstest.rs/zh/api/runtime-api/),配置辅助 API 请参阅 [Rstest 核心 API](https://rstest.rs/zh/api/javascript-api/rstest-core)。 +测试 API 请参阅 [Rstest 运行时 API](https://rstest.rs/zh/api/runtime-api/)。配置辅助函数请参阅 [Rstest 核心 API](https://rstest.rs/zh/api/javascript-api/rstest-core)。 > 如需了解更多测试相关用法,请参阅[测试](./testing)。 @@ -69,7 +69,7 @@ import { js, reactPlugin, ts } from 'rstack/lint'; ## TypeScript 类型 \{#typescript-types} -以下纯类型入口用于为 TypeScript 项目补充环境类型声明。请仅将项目需要的入口添加到 `tsconfig.json` 的 [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig/#types) 中。 +以下纯类型入口用于为 TypeScript 项目补充环境类型声明。请仅将项目所需的入口添加到 `tsconfig.json` 的 [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig/#types) 中。 ### `rstack/types` @@ -85,7 +85,7 @@ import { js, reactPlugin, ts } from 'rstack/lint'; ### `rstack/test/globals` -`rstack/test/globals` 提供 `test`、`expect` 和生命周期钩子等 Rstest API 的全局声明。测试代码无需显式导入这些 API 时,请添加该入口。 +`rstack/test/globals` 提供 `test`、`expect` 和生命周期钩子等 Rstest API 的全局声明。启用 Rstest 的 [`globals`](https://rstest.rs/zh/config/test/globals) 选项且测试代码不显式导入这些 API 时,请添加该入口。 ```json title="tsconfig.json" { @@ -97,7 +97,7 @@ import { js, reactPlugin, ts } from 'rstack/lint'; ### `rstack/test/importMeta` -`rstack/test/importMeta` 为 `ImportMeta` 增加可选的 `rstest` 属性,使源码内测试可以使用 `import.meta.rstest`。 +`rstack/test/importMeta` 为 `ImportMeta` 增加可选的 `rstest` 属性,为源码内测试中的 `import.meta.rstest` 提供类型支持。 ```json title="tsconfig.json" { diff --git a/website/docs/zh/guide/cli/build.mdx b/website/docs/zh/guide/cli/build.mdx index 62a7288..02533b5 100644 --- a/website/docs/zh/guide/cli/build.mdx +++ b/website/docs/zh/guide/cli/build.mdx @@ -12,7 +12,7 @@ rs build [options] ## 选项 \{#options} -`rs build` 支持与 Rsbuild 相同的构建选项,具体说明请参见 [Rsbuild CLI 文档](https://rsbuild.rs/zh/guide/basic/cli#rsbuild-build)。 +`rs build` 支持与 Rsbuild 相同的构建选项,详情请参阅 [Rsbuild CLI 文档](https://rsbuild.rs/zh/guide/basic/cli#rsbuild-build)。 示例: @@ -29,7 +29,7 @@ rs build --watch ## 配置 \{#configuration} -在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.app()`](../configuration#define-app) 配置生产构建。该 API 支持标准的 [Rsbuild 配置](https://rsbuild.rs/zh/config/): +在 `rstack.config.ts` 中通过 [`define.app()`](../configuration#define-app) 配置生产构建。该 API 接受标准的 [Rsbuild 配置](https://rsbuild.rs/zh/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/zh/guide/cli/dev.mdx b/website/docs/zh/guide/cli/dev.mdx index 0f67e73..2fecec4 100644 --- a/website/docs/zh/guide/cli/dev.mdx +++ b/website/docs/zh/guide/cli/dev.mdx @@ -1,6 +1,6 @@ # dev -`rs dev` 命令用于启动应用的 [Rsbuild 开发服务器](https://rsbuild.rs/guide/basic/server)。它会以开发模式编译源码、监听文件变化,并按需进行模块热更新(HMR)或刷新页面。 +`rs dev` 命令用于启动应用的 [Rsbuild 开发服务器](https://rsbuild.rs/zh/guide/basic/server)。它会以开发模式编译源码、监听文件变化,并按需进行模块热更新(HMR)或刷新页面。 ## 用法 \{#usage} @@ -12,7 +12,7 @@ rs dev [options] ## 选项 \{#options} -`rs dev` 支持与 Rsbuild 相同的开发服务器选项,具体说明请参见 [Rsbuild CLI 文档](https://rsbuild.rs/zh/guide/basic/cli#rsbuild)。 +`rs dev` 支持与 Rsbuild 相同的开发服务器选项,详情请参阅 [Rsbuild CLI 文档](https://rsbuild.rs/zh/guide/basic/cli#rsbuild)。 示例: @@ -29,7 +29,7 @@ rs dev --host ## 配置 \{#configuration} -在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.app()`](../configuration#define-app) 配置开发服务器。该 API 支持标准的 [Rsbuild 配置](https://rsbuild.rs/zh/config/): +在 `rstack.config.ts` 中通过 [`define.app()`](../configuration#define-app) 配置开发服务器。该 API 接受标准的 [Rsbuild 配置](https://rsbuild.rs/zh/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/zh/guide/cli/doc.mdx b/website/docs/zh/guide/cli/doc.mdx index 647184d..b7cc4fd 100644 --- a/website/docs/zh/guide/cli/doc.mdx +++ b/website/docs/zh/guide/cli/doc.mdx @@ -2,9 +2,9 @@ import { PackageManagerTabs } from '@rspress/core/theme'; -`rs doc` 命令使用 [Rspress](https://rspress.rs/zh/guide/start/introduction) 开发、构建和预览文档站点。 +`rs doc` 命令使用 [Rspress](https://rspress.rs/zh/guide/start/introduction) 开发、构建和本地预览文档站点。 -使用该命令前,请安装 [`@rspress/core`](https://www.npmjs.com/package/@rspress/core): +[`@rspress/core`](https://www.npmjs.com/package/@rspress/core) 是可选依赖。使用 `rs doc` 前,请先安装该依赖: @@ -18,7 +18,7 @@ rs doc [command] [root] [options] ## 选项 \{#options} -`rs doc` 支持与对应 Rspress 命令相同的选项,具体说明请参见 [Rspress CLI 文档](https://rspress.rs/zh/api/commands)。 +`rs doc` 支持与对应 Rspress 命令相同的选项,详情请参阅 [Rspress CLI 文档](https://rspress.rs/zh/api/commands)。 示例: @@ -54,7 +54,7 @@ rs doc preview ### eject -[`rs doc eject`](https://rspress.rs/zh/api/commands#rspress-eject) 用于将 Rspress 内置主题组件复制到项目中进行自定义。不指定组件名称时,会列出所有可导出的组件。 +[`rs doc eject`](https://rspress.rs/zh/api/commands#rspress-eject) 会将 Rspress 内置主题组件复制到项目中,以便自定义。不指定组件名称时,会列出所有可用组件。 ```bash rs doc eject @@ -62,7 +62,7 @@ rs doc eject ## 配置 \{#configuration} -在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.doc()`](../configuration#define-doc) 配置文档站点。该 API 支持标准的 [Rspress 配置](https://rspress.rs/zh/api/config/config-basic): +在 `rstack.config.ts` 中通过 [`define.doc()`](../configuration#define-doc) 配置文档站点。该 API 接受标准的 [Rspress 配置](https://rspress.rs/zh/api/config/config-basic): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/zh/guide/cli/lib.mdx b/website/docs/zh/guide/cli/lib.mdx index 63c5a90..0d986c3 100644 --- a/website/docs/zh/guide/cli/lib.mdx +++ b/website/docs/zh/guide/cli/lib.mdx @@ -12,7 +12,7 @@ rs lib [command] [options] ## 选项 \{#options} -`rs lib` 支持与 Rslib 相同的库构建选项,具体说明请参见 [Rslib CLI 文档](https://rslib.rs/zh/guide/basic/cli#rslib)。 +`rs lib` 支持与 Rslib 相同的库构建选项,详情请参阅 [Rslib CLI 文档](https://rslib.rs/zh/guide/basic/cli#rslib)。 示例: @@ -44,7 +44,7 @@ rs lib mf-dev ## 配置 \{#configuration} -在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.lib()`](../configuration#define-lib) 配置库构建。该 API 支持标准的 [Rslib 配置](https://rslib.rs/zh/config/): +在 `rstack.config.ts` 中通过 [`define.lib()`](../configuration#define-lib) 配置库构建。该 API 接受标准的 [Rslib 配置](https://rslib.rs/zh/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/zh/guide/cli/lint.mdx b/website/docs/zh/guide/cli/lint.mdx index 658ddb8..e424bde 100644 --- a/website/docs/zh/guide/cli/lint.mdx +++ b/website/docs/zh/guide/cli/lint.mdx @@ -12,7 +12,7 @@ rs lint [options] [files...] ## 选项 \{#options} -`rs lint` 支持与 Rslint 相同的命令行选项,具体说明请参见 [Rslint CLI 文档](https://rslint.rs/guide/cli)。 +`rs lint` 支持与 Rslint 相同的命令行选项,详情请参阅 [Rslint CLI 文档](https://rslint.rs/guide/cli)。 示例: @@ -29,7 +29,7 @@ rs lint --type-check ## 配置 \{#configuration} -在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.lint()`](../configuration#define-lint) 配置代码检查。该 API 支持标准的 [Rslint 配置](https://rslint.rs/config/)。预设和插件可以从 `rstack/lint` 按需导入: +在 `rstack.config.ts` 中通过 [`define.lint()`](../configuration#define-lint) 配置代码检查。该 API 接受标准的 [Rslint 配置](https://rslint.rs/config/)。预设和插件可以从 `rstack/lint` 按需导入: ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/zh/guide/cli/preview.mdx b/website/docs/zh/guide/cli/preview.mdx index 104472f..70d607b 100644 --- a/website/docs/zh/guide/cli/preview.mdx +++ b/website/docs/zh/guide/cli/preview.mdx @@ -1,6 +1,6 @@ # preview -`rs preview` 命令使用 [Rsbuild](https://rsbuild.rs/zh/guide/basic/cli#rsbuild-preview) 在本地预览应用的生产构建。 +`rs preview` 命令使用 [Rsbuild](https://rsbuild.rs/zh/guide/basic/cli#rsbuild-preview) 在本地预览应用的生产构建产物。 ## 用法 \{#usage} @@ -8,7 +8,7 @@ rs preview [options] ``` -该命令会加载通过 [`define.app()`](../configuration#define-app) 注册的应用配置。启动预览服务器前,请先运行 [`rs build`](./build) 生成生产构建: +该命令会加载通过 [`define.app()`](../configuration#define-app) 注册的应用配置。启动预览服务器前,请先运行 [`rs build`](./build) 生成生产构建产物: ```bash rs build @@ -19,7 +19,7 @@ rs preview ## 选项 \{#options} -`rs preview` 支持与 Rsbuild 相同的预览服务器选项,具体说明请参见 [Rsbuild CLI 文档](https://rsbuild.rs/zh/guide/basic/cli#rsbuild-preview)。 +`rs preview` 支持与 Rsbuild 相同的预览服务器选项,详情请参阅 [Rsbuild CLI 文档](https://rsbuild.rs/zh/guide/basic/cli#rsbuild-preview)。 示例: @@ -36,7 +36,7 @@ rs preview --host ## 配置 \{#configuration} -在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.app()`](../configuration#define-app) 配置预览服务器。该 API 支持标准的 [Rsbuild 配置](https://rsbuild.rs/zh/config/): +在 `rstack.config.ts` 中通过 [`define.app()`](../configuration#define-app) 配置预览服务器。该 API 接受标准的 [Rsbuild 配置](https://rsbuild.rs/zh/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/zh/guide/cli/staged.mdx b/website/docs/zh/guide/cli/staged.mdx index b9d2c76..e7ee966 100644 --- a/website/docs/zh/guide/cli/staged.mdx +++ b/website/docs/zh/guide/cli/staged.mdx @@ -1,8 +1,8 @@ # staged -`rs staged` 命令使用 [lint-staged](https://github.com/lint-staged/lint-staged) 对 Git 暂存文件运行任务。 +`rs staged` 命令使用 [lint-staged](https://github.com/lint-staged/lint-staged) 对 Git 暂存区中待提交的文件运行任务。 -常见的使用场景是在提交代码前,对暂存文件运行 linter、格式化工具或其他检查。 +通常会在 Git hook 中使用该命令,以便在提交前检查或格式化文件。 ## 用法 \{#usage} @@ -16,7 +16,7 @@ rs staged [options] ### `--allow-empty` -`--allow-empty` 允许在任务撤销全部暂存变更时创建空提交。 +`--allow-empty` 允许在任务撤销全部暂存变更后继续提交。 ```bash rs staged --allow-empty @@ -48,7 +48,7 @@ rs staged --debug ### `--no-stash` -`--no-stash` 会禁用备份 stash,并在出错时保留任务产生的变更。 +`--no-stash` 会禁用备份 stash,并在任务失败时跳过自动还原。 ```bash rs staged --no-stash @@ -88,7 +88,7 @@ rs staged --help ## 配置 \{#configuration} -在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.staged()`](../configuration#define-staged) 配置暂存文件任务。该 API 支持标准的 [lint-staged 配置](https://github.com/lint-staged/lint-staged#configuration): +在 `rstack.config.ts` 中通过 [`define.staged()`](../configuration#define-staged) 配置暂存文件任务。该 API 接受标准的 [lint-staged 配置](https://github.com/lint-staged/lint-staged#configuration): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/zh/guide/cli/test.mdx b/website/docs/zh/guide/cli/test.mdx index 469eae7..c50cbaa 100644 --- a/website/docs/zh/guide/cli/test.mdx +++ b/website/docs/zh/guide/cli/test.mdx @@ -2,7 +2,7 @@ `rs test` 命令使用 [Rstest](https://rstest.rs/zh/guide/basic/cli) 运行测试。 -如需了解更多测试相关用法,请参阅[测试](../testing)。 +> 如需了解更多测试相关用法,请参阅[测试](../testing)。 ## 用法 \{#usage} @@ -14,7 +14,7 @@ rs test [command] [...filters] [options] ## 选项 \{#options} -`rs test` 支持与 Rstest 相同的测试运行选项和过滤方式,具体说明请参见 [Rstest CLI 文档](https://rstest.rs/zh/guide/basic/cli#cli-选项)和[过滤测试](https://rstest.rs/zh/guide/basic/test-filter)。 +`rs test` 支持与 Rstest 相同的测试运行选项和过滤方式,详情请参阅 [Rstest CLI 文档](https://rstest.rs/zh/guide/basic/cli#cli-选项)和[筛选测试](https://rstest.rs/zh/guide/basic/test-filter)。 示例: @@ -65,7 +65,7 @@ rs test merge-reports ### init -[`rs test init`](https://rstest.rs/zh/guide/basic/cli#rstest-init) 用于为 Rstest 支持的项目类型创建初始文件。 +[`rs test init`](https://rstest.rs/zh/guide/basic/cli#rstest-init) 用于为支持的项目类型初始化 Rstest 配置。 ```bash rs test init browser @@ -73,7 +73,7 @@ rs test init browser ## 配置 \{#configuration} -在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.test()`](../configuration#define-test) 配置测试。该 API 支持标准的 [Rstest 配置](https://rstest.rs/zh/config/): +在 `rstack.config.ts` 中通过 [`define.test()`](../configuration#define-test) 配置测试。该 API 接受标准的 [Rstest 配置](https://rstest.rs/zh/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/zh/guide/configuration.mdx b/website/docs/zh/guide/configuration.mdx index c77694e..1e6ad86 100644 --- a/website/docs/zh/guide/configuration.mdx +++ b/website/docs/zh/guide/configuration.mdx @@ -1,6 +1,6 @@ # 配置 \{#configuration} -Rstack 将项目所用工具的配置集中到一份文件中。通过 `define.*()` API 定义项目实际需要的配置即可。 +Rstack 将项目所用工具的配置集中到一份文件中。只需通过 `define.*()` API 注册项目实际需要的配置。 ## 配置文件 \{#configuration-file} @@ -24,7 +24,7 @@ define.lint({ 配置文件无需默认导出。每个 `define.*()` API 最多调用一次;重复定义同一类型的配置会抛出错误。 -Rstack 默认会查找使用以下任一文件名的配置文件: +Rstack 默认会在项目根目录中查找以下任一配置文件: - `rstack.config.ts` - `rstack.config.js` @@ -39,9 +39,9 @@ rs build --config ./configs/rstack.config.ts ## 按需加载依赖 \{#loading-dependencies-on-demand} -每次执行 `rs` 命令时,Rstack 都会加载并执行配置文件,然后只解析当前命令需要的配置函数。 +`rs` 运行具体工具前,会先加载并执行配置文件,然后只解析当前命令所需的配置函数。 -如果配置需要导入插件或其他工具专属依赖,请使用异步配置函数,并在函数内通过动态 `import()` 加载这些依赖。这样只有解析该配置时才会加载相关依赖。 +如果配置使用了特定工具的插件或依赖,请将其定义为异步函数,并在函数内通过动态 `import()` 加载相关依赖。这样可以将加载时机推迟到该配置实际被使用时。 ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -57,7 +57,7 @@ define.app(async () => { ## 配置 API \{#configuration-apis} -各 API 沿用底层工具的配置格式。使用 Rstack 已重导出的 API 和辅助函数时,推荐从 `rstack/app`、`rstack/lib`、`rstack/test` 和 `rstack/lint` 入口导入。 +各 API 接受与底层工具相同的配置格式。使用 Rstack 重导出的 API 和辅助函数时,请从 `rstack/app`、`rstack/lib`、`rstack/test` 和 `rstack/lint` 入口导入。 | API | 底层工具 | 对应命令 | | ----------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------- | @@ -70,7 +70,7 @@ define.app(async () => { ### `define.app()` \{#define-app} -定义应用的 [Rsbuild 配置](https://rsbuild.rs/zh/config/),支持传入配置对象或配置函数。配置函数接收 Rsbuild 的标准配置参数。 +定义应用的 [Rsbuild 配置](https://rsbuild.rs/zh/config/),支持传入配置对象或配置函数。配置函数接收与 Rsbuild 相同的配置参数。 ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -89,7 +89,7 @@ define.app({ ### `define.lib()` \{#define-lib} -定义库的 [Rslib 配置](https://rslib.rs/zh/config/),支持传入配置对象或配置函数。配置函数接收 Rslib 的标准配置参数。 +定义库的 [Rslib 配置](https://rslib.rs/zh/config/),支持传入配置对象或配置函数。配置函数接收与 Rslib 相同的配置参数。 ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -117,7 +117,7 @@ define.doc({ }); ``` -`@rspress/core` 是 Rstack 的可选依赖。每个使用 `rs doc` 命令的项目都需要安装该依赖: +`@rspress/core` 是 Rstack 的可选依赖。每个运行 `rs doc` 的项目都需要安装该依赖: ```bash pnpm add -D @rspress/core @@ -140,15 +140,15 @@ define.test({ }); ``` -未设置 `extends` 时,Rstack 会通过 Rsbuild 适配器让测试配置自动继承 `define.app()`;如果未定义应用配置,则通过 Rslib 适配器回退到 `define.lib()`。二者同时存在时,应用配置的优先级更高。显式设置 `extends` 可关闭自动继承。 +未设置 `extends` 时,Rstack 会通过 Rsbuild 适配器继承 `define.app()` 的配置。如果未注册应用配置,则改用 Rslib 适配器继承 `define.lib()`。同时注册两者时,`define.app()` 的优先级更高。显式设置 `extends` 可关闭自动继承。 -如果测试根配置未定义 `extends` 且包含 `projects`,Rstack 会为每个未自行设置 `extends` 的内联项目应用自动继承。函数形式的应用或库配置只会解析一次,并由这些项目共享。字符串形式的项目会原样传给 Rstest;它们会独立加载外部配置,不继承当前应用或库的配置。 +如果测试根配置包含 `projects` 且未定义 `extends`,每个未自行设置 `extends` 的内联项目都会继承同一份应用或库配置。函数形式的配置只会解析一次,并由这些项目共享。字符串形式的项目会原样传给 Rstest,因此会独立加载外部配置,不继承当前应用或库的配置。 > 如需了解更多测试相关用法,请参阅[测试](./testing)。 ### `define.lint()` \{#define-lint} -定义 [Rslint 配置](https://rslint.rs/config/)。可以直接传入配置,也可以使用异步函数,按需从 `rstack/lint` 加载预设和插件。 +定义 [Rslint 配置](https://rslint.rs/config/)。可以直接传入配置,也可以使用异步函数按需从 `rstack/lint` 加载预设和插件。 ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -162,7 +162,7 @@ define.lint(async () => { ### `define.staged()` \{#define-staged} -定义用于处理 Git 暂存文件的 [lint-staged 配置](https://github.com/lint-staged/lint-staged#configuration)。支持传入从 glob 匹配模式映射到任务的配置对象,也支持传入任务生成函数。任务可以是 lint-staged 支持的命令、命令数组或函数。 +定义用于处理 Git 暂存文件的 [lint-staged 配置](https://github.com/lint-staged/lint-staged#configuration)。可以传入将 glob 匹配模式映射到任务的对象,也可以传入任务生成函数。任务可以是 lint-staged 支持的命令、命令数组或函数。 ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -172,4 +172,4 @@ define.staged({ }); ``` -与其他命令不同,`rs staged` 必须配置 `define.staged()`;缺少配置时会报错。 +与其他工具命令不同,`rs staged` 必须配置 `define.staged()`;缺少配置时会报错并退出。 diff --git a/website/docs/zh/guide/quick-start.mdx b/website/docs/zh/guide/quick-start.mdx index ca70558..b3d2efb 100644 --- a/website/docs/zh/guide/quick-start.mdx +++ b/website/docs/zh/guide/quick-start.mdx @@ -2,13 +2,13 @@ import { PackageManagerTabs } from '@rspress/core/theme'; -Rstack CLI 通过统一的命令行和配置文件整合 Rstack 工具链。本指南将介绍如何在现有项目中添加 Rstack,以及可以使用的工作流。 +Rstack CLI 通过统一的命令行和配置文件整合 Rstack 工具链。本指南介绍如何将 Rstack 添加到现有项目,并使用其核心工作流。 ## 环境准备 \{#environment-preparation} Rstack 支持使用 [Node.js](https://nodejs.org/)、[Deno](https://deno.com/) 或 [Bun](https://bun.sh/) 作为 JavaScript 运行时。 -参考以下安装指南,选择一种运行时: +请根据以下安装指南安装任一支持的运行时: - [安装 Node.js](https://nodejs.org/zh-cn/download) - [安装 Bun](https://bun.com/docs/installation) @@ -16,7 +16,7 @@ Rstack 支持使用 [Node.js](https://nodejs.org/)、[Deno](https://deno.com/) :::tip 版本要求 -使用 Node.js 作为运行时时,Rstack 要求 Node.js 版本为 22.12.0 或更高版本。 +使用 Node.js 时,版本须为 22.12.0 或更高版本。 ::: @@ -49,7 +49,7 @@ Rstack 支持使用 [Node.js](https://nodejs.org/)、[Deno](https://deno.com/) } ``` -package scripts 会使用项目本地安装的 `rs` 命令,因此无需全局安装 Rstack。 +通过 `package.json` 中的脚本运行时,`rs` 会解析为项目本地安装的命令,因此无需全局安装 Rstack。 Rstack 提供以下命令: @@ -60,11 +60,11 @@ Rstack 提供以下命令: - [`rs doc`](./cli/doc):使用 Rspress 开发、构建或预览文档站点。 - [`rs test`](./cli/test):使用 Rstest 运行测试。 - [`rs lint`](./cli/lint):使用 Rslint 检查源代码。 -- [`rs staged`](./cli/staged):使用 lint-staged 对 Git 暂存区中的文件运行任务。 +- [`rs staged`](./cli/staged):使用 lint-staged 对 Git 暂存区中待提交的文件运行任务。 ## 配置 Rstack \{#configure-rstack} -在项目根目录创建 `rstack.config.ts`,并注册项目所需的配置。以下是一个包含应用、测试和代码检查的最小示例: +在项目根目录创建 `rstack.config.ts`,并注册项目所需的配置。以下最小示例同时配置了应用构建、测试和代码检查: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -82,4 +82,4 @@ define.lint({ }); ``` -所有可用的配置 API 请参见[配置](./configuration)。 +所有配置 API 的详细说明请参阅[配置](./configuration)。 diff --git a/website/docs/zh/guide/testing.mdx b/website/docs/zh/guide/testing.mdx index ed89dc7..342a33b 100644 --- a/website/docs/zh/guide/testing.mdx +++ b/website/docs/zh/guide/testing.mdx @@ -1,6 +1,6 @@ # 测试 \{#testing} -Rstack 使用 [Rstest](https://rstest.rs/zh/) 运行测试。 +Rstack 通过 [Rstest](https://rstest.rs/zh/) 运行测试。 ```bash rs test @@ -10,7 +10,7 @@ rs test ## 配置测试 \{#configure-tests} -通过 [`define.test()`](./configuration#define-test) 注册 Rstest 配置,其用法与将配置传给 Rstest 的 `defineConfig()` 一致: +通过 [`define.test()`](./configuration#define-test) 注册 Rstest 配置。该 API 接受与 Rstest `defineConfig()` 相同的配置选项: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -22,7 +22,7 @@ define.test({ ## 测试 API \{#test-apis} -测试 API 和配置辅助函数可从 [`rstack/test`](./api-reference#rstacktest) 导入: +请从 [`rstack/test`](./api-reference#rstacktest) 导入 Rstest API 和配置辅助函数: ```ts import { defineInlineProject, expect, test } from 'rstack/test'; @@ -30,7 +30,7 @@ import { defineInlineProject, expect, test } from 'rstack/test'; ## 单项目 \{#single-project} -对于单个测试项目,直接将 Rstest 选项传给 `define.test()`: +只需一个测试项目时,直接将 Rstest 选项传给 `define.test()`: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -44,15 +44,15 @@ define.test({ }); ``` -未设置 `extends` 时,Rstack 会通过 Rsbuild 适配器让测试配置继承 `define.app()`。如果没有应用配置,则通过 Rslib 适配器回退到 `define.lib()`。同时定义两者时,`define.app()` 的优先级更高。 +未设置 `extends` 时,Rstack 会通过 Rsbuild 适配器继承 `define.app()` 的配置。如果未注册应用配置,则改用 Rslib 适配器继承 `define.lib()`。同时注册两者时,`define.app()` 的优先级更高。 ## 多项目 \{#multiple-projects} -通过 Rstest 的 [`projects`](https://rstest.rs/zh/config/test/projects) 选项可以同时运行多套测试配置。每一项既可以是内联项目,也可以是由 Rstest 解析为外部项目的字符串。 +通过 Rstest 的 [`projects`](https://rstest.rs/zh/config/test/projects) 选项可以同时运行多套测试配置。每一项既可以是内联项目,也可以是指向外部项目配置的字符串。 ### 内联项目 \{#inline-projects} -不同测试环境需要共享当前应用或库配置时,请使用内联项目: +测试需要使用不同环境但共享当前应用或库配置时,请使用内联项目: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -78,9 +78,9 @@ define.test({ }); ``` -Rstack 会将对应的适配器应用到每个未设置 `extends` 的内联项目。函数形式的 `define.app()` 或 `define.lib()` 配置只会解析一次,再由这些内联项目共享。 +Rstack 会将对应的适配器应用到每个未设置 `extends` 的内联项目。函数形式的 `define.app()` 或 `define.lib()` 配置只会解析一次,再由这些项目共享。 -按项目名称运行单个项目: +使用 `--project` 按名称运行单个项目: ```bash rs test --project dom @@ -90,7 +90,7 @@ rs test --project dom ### 外部项目 \{#external-projects} -使用字符串形式的配置项加载外部项目: +使用字符串配置项加载外部项目配置: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -100,11 +100,11 @@ define.test({ }); ``` -Rstack 会将字符串形式的项目原样传给 Rstest。外部项目会加载自己的配置,不会继承当前的 `define.app()` 或 `define.lib()` 配置。每个项目需要独立管理配置时,请使用外部项目。 +Rstack 会将字符串配置项原样传给 Rstest。外部项目会加载自己的配置,不会继承当前的 `define.app()` 或 `define.lib()` 配置。每个项目需要独立管理配置时,请使用这种方式。 ## 自定义继承 \{#customize-inheritance} -项目不应继承当前应用或库配置时,请显式设置 Rstest 的 [`extends`](https://rstest.rs/zh/config/test/extends) 选项: +如需关闭自动继承,请显式设置 Rstest 的 [`extends`](https://rstest.rs/zh/config/test/extends) 选项: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -122,4 +122,4 @@ define.test({ }); ``` -在内联项目中设置 `extends`,只会关闭当前项目的自动继承。在 `define.test()` 的根配置中设置该选项,则会关闭整个测试配置的自动继承。 +在内联项目中设置 `extends`,只会关闭该项目的自动继承。在 `define.test()` 的根配置中设置该选项,则会关闭整个测试配置的自动继承。 From dab0a3c5194a3d70259c9dd61823c9b8e2688f31 Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 21 Jul 2026 21:42:16 +0800 Subject: [PATCH 2/3] docs: restore CLI wording and links --- website/docs/en/guide/cli/build.mdx | 2 +- website/docs/en/guide/cli/dev.mdx | 2 +- website/docs/en/guide/cli/doc.mdx | 4 ++-- website/docs/en/guide/cli/lib.mdx | 2 +- website/docs/en/guide/cli/lint.mdx | 2 +- website/docs/en/guide/cli/preview.mdx | 2 +- website/docs/en/guide/cli/staged.mdx | 2 +- website/docs/en/guide/cli/test.mdx | 2 +- website/docs/zh/guide/cli/build.mdx | 2 +- website/docs/zh/guide/cli/dev.mdx | 2 +- website/docs/zh/guide/cli/doc.mdx | 4 ++-- website/docs/zh/guide/cli/lib.mdx | 2 +- website/docs/zh/guide/cli/lint.mdx | 2 +- website/docs/zh/guide/cli/preview.mdx | 2 +- website/docs/zh/guide/cli/staged.mdx | 2 +- website/docs/zh/guide/cli/test.mdx | 2 +- 16 files changed, 18 insertions(+), 18 deletions(-) diff --git a/website/docs/en/guide/cli/build.mdx b/website/docs/en/guide/cli/build.mdx index 0997399..6d009f1 100644 --- a/website/docs/en/guide/cli/build.mdx +++ b/website/docs/en/guide/cli/build.mdx @@ -29,7 +29,7 @@ rs build --watch ## Configuration -Configure production builds with [`define.app()`](../configuration#define-app) in `rstack.config.ts`. The API accepts the standard [Rsbuild configuration](https://rsbuild.rs/config/): +Configure the production build through [`define.app()`](../configuration#define-app) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rsbuild configuration](https://rsbuild.rs/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/en/guide/cli/dev.mdx b/website/docs/en/guide/cli/dev.mdx index cf452a0..bc6af48 100644 --- a/website/docs/en/guide/cli/dev.mdx +++ b/website/docs/en/guide/cli/dev.mdx @@ -29,7 +29,7 @@ rs dev --host ## Configuration -Configure the development server with [`define.app()`](../configuration#define-app) in `rstack.config.ts`. The API accepts the standard [Rsbuild configuration](https://rsbuild.rs/config/): +Configure the development server through [`define.app()`](../configuration#define-app) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rsbuild configuration](https://rsbuild.rs/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/en/guide/cli/doc.mdx b/website/docs/en/guide/cli/doc.mdx index c5a64bd..b53c682 100644 --- a/website/docs/en/guide/cli/doc.mdx +++ b/website/docs/en/guide/cli/doc.mdx @@ -54,7 +54,7 @@ rs doc preview ### eject -[`rs doc eject`](https://rspress.rs/api/commands#rspress-eject) copies a built-in Rspress theme component into the project for customization. Run it without a component name to list the available components. +[`rs doc eject`](https://rspress.rs/api/commands#rspress-eject) copies a built-in Rspress theme component into the project for customization. Run it without a component name to list all ejectable components. ```bash rs doc eject @@ -62,7 +62,7 @@ rs doc eject ## Configuration -Configure the documentation site with [`define.doc()`](../configuration#define-doc) in `rstack.config.ts`. The API accepts the standard [Rspress configuration](https://rspress.rs/api/config/config-basic): +Configure the documentation site through [`define.doc()`](../configuration#define-doc) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rspress configuration](https://rspress.rs/api/config/config-basic): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/en/guide/cli/lib.mdx b/website/docs/en/guide/cli/lib.mdx index e2086b5..79b7319 100644 --- a/website/docs/en/guide/cli/lib.mdx +++ b/website/docs/en/guide/cli/lib.mdx @@ -44,7 +44,7 @@ rs lib mf-dev ## Configuration -Configure library builds with [`define.lib()`](../configuration#define-lib) in `rstack.config.ts`. The API accepts the standard [Rslib configuration](https://rslib.rs/config/): +Configure library builds through [`define.lib()`](../configuration#define-lib) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rslib configuration](https://rslib.rs/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/en/guide/cli/lint.mdx b/website/docs/en/guide/cli/lint.mdx index 0e4787a..d93310e 100644 --- a/website/docs/en/guide/cli/lint.mdx +++ b/website/docs/en/guide/cli/lint.mdx @@ -29,7 +29,7 @@ rs lint --type-check ## Configuration -Configure linting with [`define.lint()`](../configuration#define-lint) in `rstack.config.ts`. The API accepts the standard [Rslint configuration](https://rslint.rs/config/). Presets and plugins can be imported from `rstack/lint` on demand: +Configure linting through [`define.lint()`](../configuration#define-lint) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rslint configuration](https://rslint.rs/config/). Presets and plugins can be imported from `rstack/lint` on demand: ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/en/guide/cli/preview.mdx b/website/docs/en/guide/cli/preview.mdx index 029bd3b..9d36469 100644 --- a/website/docs/en/guide/cli/preview.mdx +++ b/website/docs/en/guide/cli/preview.mdx @@ -36,7 +36,7 @@ rs preview --host ## Configuration -Configure the preview server with [`define.app()`](../configuration#define-app) in `rstack.config.ts`. The API accepts the standard [Rsbuild configuration](https://rsbuild.rs/config/): +Configure the preview server through [`define.app()`](../configuration#define-app) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rsbuild configuration](https://rsbuild.rs/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/en/guide/cli/staged.mdx b/website/docs/en/guide/cli/staged.mdx index 3ee35d6..93781f5 100644 --- a/website/docs/en/guide/cli/staged.mdx +++ b/website/docs/en/guide/cli/staged.mdx @@ -88,7 +88,7 @@ rs staged --help ## Configuration -Configure staged-file tasks with [`define.staged()`](../configuration#define-staged) in `rstack.config.ts`. The API accepts the standard [lint-staged configuration](https://github.com/lint-staged/lint-staged#configuration): +Configure staged-file tasks through [`define.staged()`](../configuration#define-staged) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [lint-staged configuration](https://github.com/lint-staged/lint-staged#configuration): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/en/guide/cli/test.mdx b/website/docs/en/guide/cli/test.mdx index 8ed0372..9d3f3a4 100644 --- a/website/docs/en/guide/cli/test.mdx +++ b/website/docs/en/guide/cli/test.mdx @@ -73,7 +73,7 @@ rs test init browser ## Configuration -Configure tests with [`define.test()`](../configuration#define-test) in `rstack.config.ts`. The API accepts the standard [Rstest configuration](https://rstest.rs/config/): +Configure tests through [`define.test()`](../configuration#define-test) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rstest configuration](https://rstest.rs/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/zh/guide/cli/build.mdx b/website/docs/zh/guide/cli/build.mdx index 02533b5..26c5c96 100644 --- a/website/docs/zh/guide/cli/build.mdx +++ b/website/docs/zh/guide/cli/build.mdx @@ -29,7 +29,7 @@ rs build --watch ## 配置 \{#configuration} -在 `rstack.config.ts` 中通过 [`define.app()`](../configuration#define-app) 配置生产构建。该 API 接受标准的 [Rsbuild 配置](https://rsbuild.rs/zh/config/): +在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.app()`](../configuration#define-app) 配置生产构建。该 API 支持标准的 [Rsbuild 配置](https://rsbuild.rs/zh/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/zh/guide/cli/dev.mdx b/website/docs/zh/guide/cli/dev.mdx index 2fecec4..46164f6 100644 --- a/website/docs/zh/guide/cli/dev.mdx +++ b/website/docs/zh/guide/cli/dev.mdx @@ -29,7 +29,7 @@ rs dev --host ## 配置 \{#configuration} -在 `rstack.config.ts` 中通过 [`define.app()`](../configuration#define-app) 配置开发服务器。该 API 接受标准的 [Rsbuild 配置](https://rsbuild.rs/zh/config/): +在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.app()`](../configuration#define-app) 配置开发服务器。该 API 支持标准的 [Rsbuild 配置](https://rsbuild.rs/zh/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/zh/guide/cli/doc.mdx b/website/docs/zh/guide/cli/doc.mdx index b7cc4fd..4f4633b 100644 --- a/website/docs/zh/guide/cli/doc.mdx +++ b/website/docs/zh/guide/cli/doc.mdx @@ -54,7 +54,7 @@ rs doc preview ### eject -[`rs doc eject`](https://rspress.rs/zh/api/commands#rspress-eject) 会将 Rspress 内置主题组件复制到项目中,以便自定义。不指定组件名称时,会列出所有可用组件。 +[`rs doc eject`](https://rspress.rs/zh/api/commands#rspress-eject) 会将 Rspress 内置主题组件复制到项目中,以便自定义。不指定组件名称时,会列出所有可导出的组件。 ```bash rs doc eject @@ -62,7 +62,7 @@ rs doc eject ## 配置 \{#configuration} -在 `rstack.config.ts` 中通过 [`define.doc()`](../configuration#define-doc) 配置文档站点。该 API 接受标准的 [Rspress 配置](https://rspress.rs/zh/api/config/config-basic): +在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.doc()`](../configuration#define-doc) 配置文档站点。该 API 支持标准的 [Rspress 配置](https://rspress.rs/zh/api/config/config-basic): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/zh/guide/cli/lib.mdx b/website/docs/zh/guide/cli/lib.mdx index 0d986c3..b7fee12 100644 --- a/website/docs/zh/guide/cli/lib.mdx +++ b/website/docs/zh/guide/cli/lib.mdx @@ -44,7 +44,7 @@ rs lib mf-dev ## 配置 \{#configuration} -在 `rstack.config.ts` 中通过 [`define.lib()`](../configuration#define-lib) 配置库构建。该 API 接受标准的 [Rslib 配置](https://rslib.rs/zh/config/): +在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.lib()`](../configuration#define-lib) 配置库构建。该 API 支持标准的 [Rslib 配置](https://rslib.rs/zh/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/zh/guide/cli/lint.mdx b/website/docs/zh/guide/cli/lint.mdx index e424bde..6bd40c4 100644 --- a/website/docs/zh/guide/cli/lint.mdx +++ b/website/docs/zh/guide/cli/lint.mdx @@ -29,7 +29,7 @@ rs lint --type-check ## 配置 \{#configuration} -在 `rstack.config.ts` 中通过 [`define.lint()`](../configuration#define-lint) 配置代码检查。该 API 接受标准的 [Rslint 配置](https://rslint.rs/config/)。预设和插件可以从 `rstack/lint` 按需导入: +在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.lint()`](../configuration#define-lint) 配置代码检查。该 API 支持标准的 [Rslint 配置](https://rslint.rs/config/)。预设和插件可以从 `rstack/lint` 按需导入: ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/zh/guide/cli/preview.mdx b/website/docs/zh/guide/cli/preview.mdx index 70d607b..543c638 100644 --- a/website/docs/zh/guide/cli/preview.mdx +++ b/website/docs/zh/guide/cli/preview.mdx @@ -36,7 +36,7 @@ rs preview --host ## 配置 \{#configuration} -在 `rstack.config.ts` 中通过 [`define.app()`](../configuration#define-app) 配置预览服务器。该 API 接受标准的 [Rsbuild 配置](https://rsbuild.rs/zh/config/): +在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.app()`](../configuration#define-app) 配置预览服务器。该 API 支持标准的 [Rsbuild 配置](https://rsbuild.rs/zh/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/zh/guide/cli/staged.mdx b/website/docs/zh/guide/cli/staged.mdx index e7ee966..720621a 100644 --- a/website/docs/zh/guide/cli/staged.mdx +++ b/website/docs/zh/guide/cli/staged.mdx @@ -88,7 +88,7 @@ rs staged --help ## 配置 \{#configuration} -在 `rstack.config.ts` 中通过 [`define.staged()`](../configuration#define-staged) 配置暂存文件任务。该 API 接受标准的 [lint-staged 配置](https://github.com/lint-staged/lint-staged#configuration): +在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.staged()`](../configuration#define-staged) 配置暂存文件任务。该 API 支持标准的 [lint-staged 配置](https://github.com/lint-staged/lint-staged#configuration): ```ts title="rstack.config.ts" import { define } from 'rstack'; diff --git a/website/docs/zh/guide/cli/test.mdx b/website/docs/zh/guide/cli/test.mdx index c50cbaa..fb3da7d 100644 --- a/website/docs/zh/guide/cli/test.mdx +++ b/website/docs/zh/guide/cli/test.mdx @@ -73,7 +73,7 @@ rs test init browser ## 配置 \{#configuration} -在 `rstack.config.ts` 中通过 [`define.test()`](../configuration#define-test) 配置测试。该 API 接受标准的 [Rstest 配置](https://rstest.rs/zh/config/): +在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.test()`](../configuration#define-test) 配置测试。该 API 支持标准的 [Rstest 配置](https://rstest.rs/zh/config/): ```ts title="rstack.config.ts" import { define } from 'rstack'; From a7ac36db3b8727dc40cc6aec96e9542045edf8d1 Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 21 Jul 2026 21:53:19 +0800 Subject: [PATCH 3/3] docs: revert unnecessary wording changes --- website/README.md | 12 +++++----- website/docs/en/guide/api-reference.mdx | 10 ++++----- website/docs/en/guide/cli/build.mdx | 2 +- website/docs/en/guide/cli/dev.mdx | 2 +- website/docs/en/guide/cli/doc.mdx | 4 ++-- website/docs/en/guide/cli/lint.mdx | 2 +- website/docs/en/guide/cli/preview.mdx | 6 ++--- website/docs/en/guide/cli/staged.mdx | 6 ++--- website/docs/en/guide/cli/test.mdx | 2 +- website/docs/en/guide/configuration.mdx | 30 ++++++++++++------------- website/docs/en/guide/quick-start.mdx | 16 ++++++------- website/docs/en/guide/testing.mdx | 28 +++++++++++------------ website/docs/zh/guide/api-reference.mdx | 10 ++++----- website/docs/zh/guide/cli/build.mdx | 2 +- website/docs/zh/guide/cli/dev.mdx | 2 +- website/docs/zh/guide/cli/doc.mdx | 8 +++---- website/docs/zh/guide/cli/lib.mdx | 2 +- website/docs/zh/guide/cli/lint.mdx | 2 +- website/docs/zh/guide/cli/preview.mdx | 6 ++--- website/docs/zh/guide/cli/staged.mdx | 6 ++--- website/docs/zh/guide/cli/test.mdx | 4 ++-- website/docs/zh/guide/configuration.mdx | 26 ++++++++++----------- website/docs/zh/guide/quick-start.mdx | 14 ++++++------ website/docs/zh/guide/testing.mdx | 26 ++++++++++----------- 24 files changed, 113 insertions(+), 115 deletions(-) diff --git a/website/README.md b/website/README.md index 5421dca..634b63b 100644 --- a/website/README.md +++ b/website/README.md @@ -2,26 +2,24 @@ This website is built with [Rspress](https://rspress.rs/) through Rstack CLI. -The documentation source lives in `docs` and is written in Markdown or MDX. +Documentation can be written with Markdown or MDX. ## Development -Start the development server from the repository root: +Run the development server from the repository root: ```bash pnpm doc ``` -Alternatively, run the website scripts from this directory: +Build or preview the website from this directory: ```bash -pnpm dev pnpm build pnpm preview ``` ## Contributing -Keep corresponding English and Chinese pages aligned in structure, meaning, -links, and examples. When a translated heading would generate a different -anchor, add an explicit anchor that matches the English heading. +The website provides English and Chinese documentation. Keep both versions in +sync when possible. diff --git a/website/docs/en/guide/api-reference.mdx b/website/docs/en/guide/api-reference.mdx index 71d1bfd..8c61e7f 100644 --- a/website/docs/en/guide/api-reference.mdx +++ b/website/docs/en/guide/api-reference.mdx @@ -1,6 +1,6 @@ # API reference -Rstack exposes a unified configuration API and dedicated entry points for the public APIs of Rsbuild, Rslib, Rstest, and Rslint. Prefer these entry points over direct imports from each tool's core package so that import paths and tool versions stay aligned with Rstack. +Rstack provides a unified configuration API and re-exports the public APIs of Rsbuild, Rslib, Rstest, and Rslint through dedicated subpaths. Prefer these subpaths to direct imports from each tool's core package so that dependency entry points and tool versions remain aligned with Rstack. ## Import paths @@ -19,11 +19,11 @@ Rstack exposes a unified configuration API and dedicated entry points for the pu ### `define` -Import `define` from `rstack` to register tool configurations in `rstack.config.ts`. For details, see [Configuration APIs](./configuration#configuration-apis). +Import `define` from `rstack` to register tool configurations in `rstack.config.ts`; see [Configuration APIs](./configuration#configuration-apis) for details. ## Re-exports -Each tool-specific subpath re-exports the public APIs of its corresponding core package. +The tool-specific subpaths below re-export the public APIs from their corresponding core packages. Using these Rstack entry points keeps dependency entry points and tool versions aligned with the toolchain integrated by Rstack. ### `rstack/app` @@ -53,7 +53,7 @@ For details, see the [Rslib core APIs](https://rslib.rs/api/javascript-api/core) import { describe, expect, test } from 'rstack/test'; ``` -For test APIs, see the [Rstest runtime API](https://rstest.rs/api/runtime-api/). For configuration helpers, see the [Rstest core APIs](https://rstest.rs/api/javascript-api/rstest-core). +See the [Rstest runtime API](https://rstest.rs/api/runtime-api/) for test APIs and the [Rstest core APIs](https://rstest.rs/api/javascript-api/rstest-core) for configuration helpers. > For more guidance on testing, see [Testing](./testing). @@ -69,7 +69,7 @@ For details about the available presets and plugins, see [Rslint rules and prese ## TypeScript types -The following type-only entry points add ambient declarations to a TypeScript project. Add only the entries your project needs to [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig/#types) in `tsconfig.json`. +These type-only entry points add ambient declarations to a TypeScript project. Add only the entries your project needs to [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig/#types) in `tsconfig.json`. ### `rstack/types` diff --git a/website/docs/en/guide/cli/build.mdx b/website/docs/en/guide/cli/build.mdx index 6d009f1..6f2e728 100644 --- a/website/docs/en/guide/cli/build.mdx +++ b/website/docs/en/guide/cli/build.mdx @@ -20,7 +20,7 @@ Examples: # Write output files to the output directory rs build --dist-path output -# Generate source maps for output files +# Generate source maps for the output files rs build --source-map # Rebuild when files change diff --git a/website/docs/en/guide/cli/dev.mdx b/website/docs/en/guide/cli/dev.mdx index bc6af48..1af5534 100644 --- a/website/docs/en/guide/cli/dev.mdx +++ b/website/docs/en/guide/cli/dev.mdx @@ -20,7 +20,7 @@ Examples: # Start the server and open the page in the browser rs dev --open -# Use port 8080 and exit if it is already in use +# Use port 8080 and fail if it is already in use rs dev --port 8080 --strict-port # Make the server available on the local network diff --git a/website/docs/en/guide/cli/doc.mdx b/website/docs/en/guide/cli/doc.mdx index b53c682..08877b4 100644 --- a/website/docs/en/guide/cli/doc.mdx +++ b/website/docs/en/guide/cli/doc.mdx @@ -2,9 +2,9 @@ import { PackageManagerTabs } from '@rspress/core/theme'; -The `rs doc` command uses [Rspress](https://rspress.rs/guide/start/introduction) to develop, build, and locally preview a documentation site. +The `rs doc` command uses [Rspress](https://rspress.rs/guide/start/introduction) to develop, build, and preview a documentation site. -[`@rspress/core`](https://www.npmjs.com/package/@rspress/core) is an optional dependency. Install it before using `rs doc`: +Install [`@rspress/core`](https://www.npmjs.com/package/@rspress/core) before using the command: diff --git a/website/docs/en/guide/cli/lint.mdx b/website/docs/en/guide/cli/lint.mdx index d93310e..07b1592 100644 --- a/website/docs/en/guide/cli/lint.mdx +++ b/website/docs/en/guide/cli/lint.mdx @@ -1,6 +1,6 @@ # lint -The `rs lint` command uses [Rslint](https://rslint.rs/guide/) to lint source files. +The `rs lint` command uses [Rslint](https://rslint.rs/guide/) to lint source code. ## Usage diff --git a/website/docs/en/guide/cli/preview.mdx b/website/docs/en/guide/cli/preview.mdx index 9d36469..dec9821 100644 --- a/website/docs/en/guide/cli/preview.mdx +++ b/website/docs/en/guide/cli/preview.mdx @@ -1,6 +1,6 @@ # preview -The `rs preview` command uses [Rsbuild](https://rsbuild.rs/guide/basic/cli#rsbuild-preview) to preview an application's production output locally. +The `rs preview` command uses [Rsbuild](https://rsbuild.rs/guide/basic/cli#rsbuild-preview) to preview an application's production build locally. ## Usage @@ -8,7 +8,7 @@ The `rs preview` command uses [Rsbuild](https://rsbuild.rs/guide/basic/cli#rsbui rs preview [options] ``` -The command loads the application configuration registered with [`define.app()`](../configuration#define-app). Before starting the preview server, run [`rs build`](./build) to generate the production output: +The command loads the application configuration registered with [`define.app()`](../configuration#define-app). Run [`rs build`](./build) before starting the preview server to generate the production output: ```bash rs build @@ -27,7 +27,7 @@ Examples: # Start the preview server and open the page in the browser rs preview --open -# Use port 8080 and exit if it is already in use +# Use port 8080 and fail if it is already in use rs preview --port 8080 --strict-port # Make the preview server available on the local network diff --git a/website/docs/en/guide/cli/staged.mdx b/website/docs/en/guide/cli/staged.mdx index 93781f5..e0e2c29 100644 --- a/website/docs/en/guide/cli/staged.mdx +++ b/website/docs/en/guide/cli/staged.mdx @@ -1,8 +1,8 @@ # staged -The `rs staged` command uses [lint-staged](https://github.com/lint-staged/lint-staged) to run tasks against files staged for commit. +The `rs staged` command uses [lint-staged](https://github.com/lint-staged/lint-staged) to run tasks against files staged in Git. -It is typically used in a Git hook to lint, format, or otherwise check files before a commit. +A common use case is to run linters, formatters, or other checks on staged files before committing code. ## Usage @@ -16,7 +16,7 @@ The command loads the staged-file tasks registered with [`define.staged()`](../c ### `--allow-empty` -`--allow-empty` allows the commit to proceed if tasks revert all staged changes. +`--allow-empty` allows an empty commit when tasks revert all staged changes. ```bash rs staged --allow-empty diff --git a/website/docs/en/guide/cli/test.mdx b/website/docs/en/guide/cli/test.mdx index 9d3f3a4..08f23e2 100644 --- a/website/docs/en/guide/cli/test.mdx +++ b/website/docs/en/guide/cli/test.mdx @@ -2,7 +2,7 @@ The `rs test` command uses [Rstest](https://rstest.rs/guide/basic/cli) to run tests. -> For more guidance on testing, see [Testing](../testing). +For more guidance on testing, see [Testing](../testing). ## Usage diff --git a/website/docs/en/guide/configuration.mdx b/website/docs/en/guide/configuration.mdx index b19dc34..d94fac3 100644 --- a/website/docs/en/guide/configuration.mdx +++ b/website/docs/en/guide/configuration.mdx @@ -1,6 +1,6 @@ # Configuration -Rstack centralizes your project's tool configurations in one file. Register only the configurations your project needs with the `define.*()` APIs. +Rstack centralizes the configuration for your project's tools in a single file. Define only the configurations your project needs with the `define.*()` APIs. ## Configuration file @@ -24,7 +24,7 @@ define.lint({ The configuration file does not require a default export. Each `define.*()` API can be called at most once; defining the same configuration type more than once throws an error. -By default, Rstack looks for any of the following files in the project root: +By default, Rstack looks for a file with one of the following names: - `rstack.config.ts` - `rstack.config.js` @@ -39,9 +39,9 @@ rs build --config ./configs/rstack.config.ts ## Loading dependencies on demand -Before running a tool, Rstack loads and executes the configuration file. It then resolves only the configuration functions required by that command. +Every `rs` command loads and executes the Rstack configuration file, then resolves only the configuration functions needed by that command. -When a configuration uses a tool-specific plugin or dependency, define it as an async function and load that dependency with dynamic `import()` inside the function. This defers loading until the configuration is needed. +When a configuration needs to import plugins or other tool-specific dependencies, use an async configuration function and load those dependencies with dynamic `import()` inside it. This ensures that they are loaded only when the configuration is resolved. ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -57,7 +57,7 @@ define.app(async () => { ## Configuration APIs -Each API accepts the configuration format of its underlying tool. When using APIs and helpers re-exported by Rstack, import them from the `rstack/app`, `rstack/lib`, `rstack/test`, and `rstack/lint` entry points. +Configuration options follow the formats of the underlying tools. When using APIs and helpers that Rstack re-exports, prefer the `rstack/app`, `rstack/lib`, `rstack/test`, and `rstack/lint` entry points. | API | Tool | Commands | | ----------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------- | @@ -70,7 +70,7 @@ Each API accepts the configuration format of its underlying tool. When using API ### `define.app()` \{#define-app} -Defines the [Rsbuild configuration](https://rsbuild.rs/config/) for an application. It accepts a configuration object or a configuration function. The function receives the same configuration parameters as Rsbuild. +Defines the [Rsbuild configuration](https://rsbuild.rs/config/) for an application. It accepts a configuration object or a configuration function. The function receives the standard Rsbuild configuration parameters. ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -89,7 +89,7 @@ define.app({ ### `define.lib()` \{#define-lib} -Defines the [Rslib configuration](https://rslib.rs/config/) for a library. It accepts a configuration object or a configuration function. The function receives the same configuration parameters as Rslib. +Defines the [Rslib configuration](https://rslib.rs/config/) for a library. It accepts a configuration object or a configuration function. The function receives the standard Rslib configuration parameters. ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -106,7 +106,7 @@ define.lib({ ### `define.doc()` \{#define-doc} -Defines the [Rspress configuration](https://rspress.rs/api/config/config-basic) for a documentation site. It accepts either a configuration object or an async configuration function. +Defines the [Rspress configuration](https://rspress.rs/api/config/config-basic) for a documentation site. It accepts a configuration object or an async configuration function. ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -117,7 +117,7 @@ define.doc({ }); ``` -`@rspress/core` is an optional peer dependency of Rstack. Install it in each project that runs `rs doc`: +`@rspress/core` is an optional dependency of Rstack. Install it in every project that uses the `rs doc` command: ```bash pnpm add -D @rspress/core @@ -125,7 +125,7 @@ pnpm add -D @rspress/core ### `define.test()` \{#define-test} -Defines the [Rstest configuration](https://rstest.rs/config/). It accepts either a configuration object or a configuration function. +Defines the [Rstest configuration](https://rstest.rs/config/). It accepts a configuration object or a configuration function. ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -140,15 +140,15 @@ define.test({ }); ``` -When `extends` is omitted, Rstack uses the Rsbuild adapter to inherit the configuration from `define.app()`. If no application configuration is registered, it uses the Rslib adapter to inherit `define.lib()` instead. `define.app()` takes precedence when both are registered. Set `extends` explicitly to opt out of automatic inheritance. +When `extends` is omitted, Rstack automatically connects the test configuration to `define.app()` through the Rsbuild adapter. If no application configuration is defined, it falls back to `define.lib()` through the Rslib adapter. The application configuration takes precedence when both are defined. Set `extends` explicitly to opt out of this automatic inheritance. -If the root test configuration contains `projects` and does not define `extends`, each inline project without its own `extends` inherits the same application or library configuration. A function-based configuration is resolved once and shared by those projects. String entries are passed to Rstest unchanged, so their external configurations load independently and do not inherit the current application or library configuration. +If the root test configuration does not define `extends` and contains `projects`, Rstack applies automatic inheritance to each inline project that omits its own `extends`. A function-based application or library configuration is resolved once and shared by those projects. String project entries are passed to Rstest unchanged; they load their external configurations independently and do not inherit the current application or library configuration. > For more guidance on testing, see [Testing](./testing). ### `define.lint()` \{#define-lint} -Defines the [Rslint configuration](https://rslint.rs/config/). Pass a configuration directly, or use an async function to load presets and plugins from `rstack/lint` on demand. +Defines the [Rslint configuration](https://rslint.rs/config/). Pass the configuration directly, or use an async function to load presets and plugins from `rstack/lint` on demand. ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -162,7 +162,7 @@ define.lint(async () => { ### `define.staged()` \{#define-staged} -Defines the [lint-staged configuration](https://github.com/lint-staged/lint-staged#configuration) for files staged in Git. It accepts either an object that maps glob patterns to tasks or a task-generator function. Tasks can be commands, command arrays, or functions supported by lint-staged. +Defines the [lint-staged configuration](https://github.com/lint-staged/lint-staged#configuration) used to run tasks on staged Git files. It accepts either an object that maps glob patterns to tasks or a task-generator function. Tasks can be commands, command arrays, or functions supported by lint-staged. ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -172,4 +172,4 @@ define.staged({ }); ``` -Unlike the other tool commands, `rs staged` requires a `define.staged()` configuration and exits with an error when it is missing. +Unlike the other commands, `rs staged` requires a `define.staged()` configuration and reports an error when it is missing. diff --git a/website/docs/en/guide/quick-start.mdx b/website/docs/en/guide/quick-start.mdx index 3289ace..cf608ba 100644 --- a/website/docs/en/guide/quick-start.mdx +++ b/website/docs/en/guide/quick-start.mdx @@ -2,13 +2,13 @@ import { PackageManagerTabs } from '@rspress/core/theme'; -Rstack CLI brings the Rstack toolchain together with one CLI and one configuration file. This guide shows how to add Rstack to an existing project and use its core workflows. +Rstack CLI brings the Rstack toolchain together with one CLI and one configuration file. This guide adds Rstack to an existing project and introduces the available workflows. ## Environment preparation Rstack supports using [Node.js](https://nodejs.org/), [Deno](https://deno.com/), or [Bun](https://bun.sh/) as the JavaScript runtime. -Install one of the supported runtimes by following its installation guide: +Use one of the following installation guides to set up a runtime: - [Install Node.js](https://nodejs.org/en/download) - [Install Bun](https://bun.com/docs/installation) @@ -16,7 +16,7 @@ Install one of the supported runtimes by following its installation guide: :::tip Version requirements -When using Node.js, Rstack requires version 22.12.0 or later. +Rstack requires Node.js 22.12.0 or higher when using Node.js as the runtime. ::: @@ -49,22 +49,22 @@ Add the commands your project needs to the `scripts` field in `package.json`. Fo } ``` -When invoked from a package script, `rs` resolves to the project-local binary, so Rstack does not need to be installed globally. +Package scripts use the project-local `rs` binary, so Rstack does not need to be installed globally. The following commands are available: - [`rs dev`](./cli/dev): Start the application development server. - [`rs build`](./cli/build): Build the application for production. -- [`rs preview`](./cli/preview): Preview the application's production output locally. +- [`rs preview`](./cli/preview): Preview the application's production build locally. - [`rs lib`](./cli/lib): Build a library with Rslib. - [`rs doc`](./cli/doc): Develop, build, or preview a documentation site with Rspress. - [`rs test`](./cli/test): Run tests with Rstest. - [`rs lint`](./cli/lint): Lint source code with Rslint. -- [`rs staged`](./cli/staged): Run lint-staged tasks on files staged for commit. +- [`rs staged`](./cli/staged): Run tasks against files staged in Git with lint-staged. ## Configure Rstack -Create `rstack.config.ts` in the project root and register the configurations your project needs. The following minimal example configures an application, testing, and linting: +Create `rstack.config.ts` in the project root and register the configurations your project needs. The following is a minimal example for an application with testing and linting: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -82,4 +82,4 @@ define.lint({ }); ``` -For details about all available configuration APIs, see [Configuration](./configuration). +See [Configuration](./configuration) for all available configuration APIs. diff --git a/website/docs/en/guide/testing.mdx b/website/docs/en/guide/testing.mdx index df19b23..39e494b 100644 --- a/website/docs/en/guide/testing.mdx +++ b/website/docs/en/guide/testing.mdx @@ -1,6 +1,6 @@ # Testing -Rstack runs tests with [Rstest](https://rstest.rs/). +Rstack uses [Rstest](https://rstest.rs/) to run tests. ```bash rs test @@ -10,7 +10,7 @@ For command-line options and subcommands, see [`rs test`](./cli/test). ## Configure tests -Register an Rstest configuration with [`define.test()`](./configuration#define-test). It accepts the same options as Rstest's `defineConfig()`: +Register an Rstest configuration with [`define.test()`](./configuration#define-test). It accepts the same configuration as Rstest's `defineConfig()`: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -22,7 +22,7 @@ define.test({ ## Test APIs -Import Rstest APIs and configuration helpers from [`rstack/test`](./api-reference#rstacktest): +Import test APIs and configuration helpers from [`rstack/test`](./api-reference#rstacktest): ```ts import { defineInlineProject, expect, test } from 'rstack/test'; @@ -30,7 +30,7 @@ import { defineInlineProject, expect, test } from 'rstack/test'; ## Single project -When one test project is sufficient, pass the Rstest options directly to `define.test()`: +For a single test project, pass the Rstest options directly to `define.test()`: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -44,15 +44,15 @@ define.test({ }); ``` -When `extends` is omitted, Rstack uses the Rsbuild adapter to inherit the configuration from `define.app()`. If no application configuration is registered, it uses the Rslib adapter to inherit `define.lib()` instead. `define.app()` takes precedence when both are registered. +When `extends` is omitted, Rstack uses the Rsbuild adapter to extend the test configuration from `define.app()`. If no application configuration is defined, it uses the Rslib adapter with `define.lib()` instead. `define.app()` takes precedence when both are defined. ## Multiple projects -Set Rstest's [`projects`](https://rstest.rs/config/test/projects) option to run multiple test configurations together. Each entry can be an inline project or a string that points to an external project configuration. +Set Rstest's [`projects`](https://rstest.rs/config/test/projects) option to run multiple test configurations together. Entries can be inline projects or strings that Rstest resolves as external projects. ### Inline projects -Use inline projects when tests need different environments but should share the current application or library configuration: +Use inline projects when different test environments should share the current application or library configuration: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -78,19 +78,19 @@ define.test({ }); ``` -Rstack applies the corresponding adapter to every inline project that omits `extends`. A function-based `define.app()` or `define.lib()` configuration is resolved once and then shared by those projects. +Rstack applies the corresponding adapter to each inline project that omits `extends`. A function-based `define.app()` or `define.lib()` configuration is resolved once, then shared by those inline projects. -To run one project by name, use `--project`: +Run one project by name: ```bash rs test --project dom ``` -For a complete React SSR example using the Node.js and happy-dom test environments, see [`examples/rstest-inline-projects`](https://github.com/rstackjs/rstack-cli/tree/main/examples/rstest-inline-projects). +See [`examples/rstest-inline-projects`](https://github.com/rstackjs/rstack-cli/tree/main/examples/rstest-inline-projects) for a complete React SSR example using Node.js and happy-dom. ### External projects -Use a string entry to load an external project configuration: +Use a string entry for an externally configured project: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -100,11 +100,11 @@ define.test({ }); ``` -Rstack passes string entries to Rstest unchanged. External projects load their own configuration and do not inherit the current `define.app()` or `define.lib()` configuration. Use them when each project should manage its configuration independently. +Rstack passes string entries to Rstest unchanged. External projects load their own configuration and do not inherit the current `define.app()` or `define.lib()` configuration. Use external projects when each project manages its configuration independently. ## Customize inheritance -To opt out of automatic inheritance, set Rstest's [`extends`](https://rstest.rs/config/test/extends) option explicitly: +Set Rstest's [`extends`](https://rstest.rs/config/test/extends) option explicitly when a project should not inherit the current application or library configuration: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -122,4 +122,4 @@ define.test({ }); ``` -Setting `extends` on an inline project disables automatic inheritance only for that project. Setting it on the root `define.test()` configuration disables automatic inheritance for the entire configuration. +Setting `extends` on an inline project disables automatic inheritance only for that project. Setting it on the root `define.test()` configuration disables automatic inheritance for the entire test configuration. diff --git a/website/docs/zh/guide/api-reference.mdx b/website/docs/zh/guide/api-reference.mdx index 6e0d62c..0f7a2dc 100644 --- a/website/docs/zh/guide/api-reference.mdx +++ b/website/docs/zh/guide/api-reference.mdx @@ -1,6 +1,6 @@ # API 参考 \{#api-reference} -Rstack 提供统一的配置 API,以及用于访问 Rsbuild、Rslib、Rstest 和 Rslint 公开 API 的专用入口。请优先使用这些入口,而不是直接从各工具的 core 包导入,以确保导入路径和工具版本与 Rstack 保持一致。 +Rstack 提供统一的配置 API,并通过专用子路径重导出 Rsbuild、Rslib、Rstest 和 Rslint 的公开 API。建议优先从这些子路径导入,以统一依赖入口,并确保 API 与 Rstack 集成的工具版本保持一致。 ## 导入路径 \{#import-paths} @@ -19,11 +19,11 @@ Rstack 提供统一的配置 API,以及用于访问 Rsbuild、Rslib、Rstest ### `define` -从 `rstack` 导入 `define`,用于在 `rstack.config.ts` 中注册各项工具配置。详细用法请参阅[配置 API](./configuration#configuration-apis)。 +从 `rstack` 导入 `define`,用于在 `rstack.config.ts` 中注册各项工具配置;详细用法请参阅[配置 API](./configuration#configuration-apis)。 ## 重导出 \{#re-exports} -以下每个工具子路径都会重导出对应 core 包的公开 API。 +以下工具子路径均会重导出对应 core 包的公开 API。通过这些 Rstack 入口导入,可以让依赖入口和工具版本与 Rstack 集成的工具链保持一致。 ### `rstack/app` @@ -53,7 +53,7 @@ import { createRslib, mergeRslibConfig } from 'rstack/lib'; import { describe, expect, test } from 'rstack/test'; ``` -测试 API 请参阅 [Rstest 运行时 API](https://rstest.rs/zh/api/runtime-api/)。配置辅助函数请参阅 [Rstest 核心 API](https://rstest.rs/zh/api/javascript-api/rstest-core)。 +测试 API 请参阅 [Rstest 运行时 API](https://rstest.rs/zh/api/runtime-api/),配置辅助 API 请参阅 [Rstest 核心 API](https://rstest.rs/zh/api/javascript-api/rstest-core)。 > 如需了解更多测试相关用法,请参阅[测试](./testing)。 @@ -69,7 +69,7 @@ import { js, reactPlugin, ts } from 'rstack/lint'; ## TypeScript 类型 \{#typescript-types} -以下纯类型入口用于为 TypeScript 项目补充环境类型声明。请仅将项目所需的入口添加到 `tsconfig.json` 的 [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig/#types) 中。 +以下纯类型入口用于为 TypeScript 项目补充环境类型声明。请仅将项目需要的入口添加到 `tsconfig.json` 的 [`compilerOptions.types`](https://www.typescriptlang.org/tsconfig/#types) 中。 ### `rstack/types` diff --git a/website/docs/zh/guide/cli/build.mdx b/website/docs/zh/guide/cli/build.mdx index 26c5c96..62a7288 100644 --- a/website/docs/zh/guide/cli/build.mdx +++ b/website/docs/zh/guide/cli/build.mdx @@ -12,7 +12,7 @@ rs build [options] ## 选项 \{#options} -`rs build` 支持与 Rsbuild 相同的构建选项,详情请参阅 [Rsbuild CLI 文档](https://rsbuild.rs/zh/guide/basic/cli#rsbuild-build)。 +`rs build` 支持与 Rsbuild 相同的构建选项,具体说明请参见 [Rsbuild CLI 文档](https://rsbuild.rs/zh/guide/basic/cli#rsbuild-build)。 示例: diff --git a/website/docs/zh/guide/cli/dev.mdx b/website/docs/zh/guide/cli/dev.mdx index 46164f6..331ffab 100644 --- a/website/docs/zh/guide/cli/dev.mdx +++ b/website/docs/zh/guide/cli/dev.mdx @@ -12,7 +12,7 @@ rs dev [options] ## 选项 \{#options} -`rs dev` 支持与 Rsbuild 相同的开发服务器选项,详情请参阅 [Rsbuild CLI 文档](https://rsbuild.rs/zh/guide/basic/cli#rsbuild)。 +`rs dev` 支持与 Rsbuild 相同的开发服务器选项,具体说明请参见 [Rsbuild CLI 文档](https://rsbuild.rs/zh/guide/basic/cli#rsbuild)。 示例: diff --git a/website/docs/zh/guide/cli/doc.mdx b/website/docs/zh/guide/cli/doc.mdx index 4f4633b..647184d 100644 --- a/website/docs/zh/guide/cli/doc.mdx +++ b/website/docs/zh/guide/cli/doc.mdx @@ -2,9 +2,9 @@ import { PackageManagerTabs } from '@rspress/core/theme'; -`rs doc` 命令使用 [Rspress](https://rspress.rs/zh/guide/start/introduction) 开发、构建和本地预览文档站点。 +`rs doc` 命令使用 [Rspress](https://rspress.rs/zh/guide/start/introduction) 开发、构建和预览文档站点。 -[`@rspress/core`](https://www.npmjs.com/package/@rspress/core) 是可选依赖。使用 `rs doc` 前,请先安装该依赖: +使用该命令前,请安装 [`@rspress/core`](https://www.npmjs.com/package/@rspress/core): @@ -18,7 +18,7 @@ rs doc [command] [root] [options] ## 选项 \{#options} -`rs doc` 支持与对应 Rspress 命令相同的选项,详情请参阅 [Rspress CLI 文档](https://rspress.rs/zh/api/commands)。 +`rs doc` 支持与对应 Rspress 命令相同的选项,具体说明请参见 [Rspress CLI 文档](https://rspress.rs/zh/api/commands)。 示例: @@ -54,7 +54,7 @@ rs doc preview ### eject -[`rs doc eject`](https://rspress.rs/zh/api/commands#rspress-eject) 会将 Rspress 内置主题组件复制到项目中,以便自定义。不指定组件名称时,会列出所有可导出的组件。 +[`rs doc eject`](https://rspress.rs/zh/api/commands#rspress-eject) 用于将 Rspress 内置主题组件复制到项目中进行自定义。不指定组件名称时,会列出所有可导出的组件。 ```bash rs doc eject diff --git a/website/docs/zh/guide/cli/lib.mdx b/website/docs/zh/guide/cli/lib.mdx index b7fee12..63c5a90 100644 --- a/website/docs/zh/guide/cli/lib.mdx +++ b/website/docs/zh/guide/cli/lib.mdx @@ -12,7 +12,7 @@ rs lib [command] [options] ## 选项 \{#options} -`rs lib` 支持与 Rslib 相同的库构建选项,详情请参阅 [Rslib CLI 文档](https://rslib.rs/zh/guide/basic/cli#rslib)。 +`rs lib` 支持与 Rslib 相同的库构建选项,具体说明请参见 [Rslib CLI 文档](https://rslib.rs/zh/guide/basic/cli#rslib)。 示例: diff --git a/website/docs/zh/guide/cli/lint.mdx b/website/docs/zh/guide/cli/lint.mdx index 6bd40c4..658ddb8 100644 --- a/website/docs/zh/guide/cli/lint.mdx +++ b/website/docs/zh/guide/cli/lint.mdx @@ -12,7 +12,7 @@ rs lint [options] [files...] ## 选项 \{#options} -`rs lint` 支持与 Rslint 相同的命令行选项,详情请参阅 [Rslint CLI 文档](https://rslint.rs/guide/cli)。 +`rs lint` 支持与 Rslint 相同的命令行选项,具体说明请参见 [Rslint CLI 文档](https://rslint.rs/guide/cli)。 示例: diff --git a/website/docs/zh/guide/cli/preview.mdx b/website/docs/zh/guide/cli/preview.mdx index 543c638..104472f 100644 --- a/website/docs/zh/guide/cli/preview.mdx +++ b/website/docs/zh/guide/cli/preview.mdx @@ -1,6 +1,6 @@ # preview -`rs preview` 命令使用 [Rsbuild](https://rsbuild.rs/zh/guide/basic/cli#rsbuild-preview) 在本地预览应用的生产构建产物。 +`rs preview` 命令使用 [Rsbuild](https://rsbuild.rs/zh/guide/basic/cli#rsbuild-preview) 在本地预览应用的生产构建。 ## 用法 \{#usage} @@ -8,7 +8,7 @@ rs preview [options] ``` -该命令会加载通过 [`define.app()`](../configuration#define-app) 注册的应用配置。启动预览服务器前,请先运行 [`rs build`](./build) 生成生产构建产物: +该命令会加载通过 [`define.app()`](../configuration#define-app) 注册的应用配置。启动预览服务器前,请先运行 [`rs build`](./build) 生成生产构建: ```bash rs build @@ -19,7 +19,7 @@ rs preview ## 选项 \{#options} -`rs preview` 支持与 Rsbuild 相同的预览服务器选项,详情请参阅 [Rsbuild CLI 文档](https://rsbuild.rs/zh/guide/basic/cli#rsbuild-preview)。 +`rs preview` 支持与 Rsbuild 相同的预览服务器选项,具体说明请参见 [Rsbuild CLI 文档](https://rsbuild.rs/zh/guide/basic/cli#rsbuild-preview)。 示例: diff --git a/website/docs/zh/guide/cli/staged.mdx b/website/docs/zh/guide/cli/staged.mdx index 720621a..af25e6d 100644 --- a/website/docs/zh/guide/cli/staged.mdx +++ b/website/docs/zh/guide/cli/staged.mdx @@ -1,8 +1,8 @@ # staged -`rs staged` 命令使用 [lint-staged](https://github.com/lint-staged/lint-staged) 对 Git 暂存区中待提交的文件运行任务。 +`rs staged` 命令使用 [lint-staged](https://github.com/lint-staged/lint-staged) 对 Git 暂存文件运行任务。 -通常会在 Git hook 中使用该命令,以便在提交前检查或格式化文件。 +常见的使用场景是在提交代码前,对暂存文件运行 linter、格式化工具或其他检查。 ## 用法 \{#usage} @@ -16,7 +16,7 @@ rs staged [options] ### `--allow-empty` -`--allow-empty` 允许在任务撤销全部暂存变更后继续提交。 +`--allow-empty` 允许在任务撤销全部暂存变更时创建空提交。 ```bash rs staged --allow-empty diff --git a/website/docs/zh/guide/cli/test.mdx b/website/docs/zh/guide/cli/test.mdx index fb3da7d..d4ce4ac 100644 --- a/website/docs/zh/guide/cli/test.mdx +++ b/website/docs/zh/guide/cli/test.mdx @@ -2,7 +2,7 @@ `rs test` 命令使用 [Rstest](https://rstest.rs/zh/guide/basic/cli) 运行测试。 -> 如需了解更多测试相关用法,请参阅[测试](../testing)。 +如需了解更多测试相关用法,请参阅[测试](../testing)。 ## 用法 \{#usage} @@ -14,7 +14,7 @@ rs test [command] [...filters] [options] ## 选项 \{#options} -`rs test` 支持与 Rstest 相同的测试运行选项和过滤方式,详情请参阅 [Rstest CLI 文档](https://rstest.rs/zh/guide/basic/cli#cli-选项)和[筛选测试](https://rstest.rs/zh/guide/basic/test-filter)。 +`rs test` 支持与 Rstest 相同的测试运行选项和过滤方式,具体说明请参见 [Rstest CLI 文档](https://rstest.rs/zh/guide/basic/cli#cli-选项)和[过滤测试](https://rstest.rs/zh/guide/basic/test-filter)。 示例: diff --git a/website/docs/zh/guide/configuration.mdx b/website/docs/zh/guide/configuration.mdx index 1e6ad86..c77694e 100644 --- a/website/docs/zh/guide/configuration.mdx +++ b/website/docs/zh/guide/configuration.mdx @@ -1,6 +1,6 @@ # 配置 \{#configuration} -Rstack 将项目所用工具的配置集中到一份文件中。只需通过 `define.*()` API 注册项目实际需要的配置。 +Rstack 将项目所用工具的配置集中到一份文件中。通过 `define.*()` API 定义项目实际需要的配置即可。 ## 配置文件 \{#configuration-file} @@ -24,7 +24,7 @@ define.lint({ 配置文件无需默认导出。每个 `define.*()` API 最多调用一次;重复定义同一类型的配置会抛出错误。 -Rstack 默认会在项目根目录中查找以下任一配置文件: +Rstack 默认会查找使用以下任一文件名的配置文件: - `rstack.config.ts` - `rstack.config.js` @@ -39,9 +39,9 @@ rs build --config ./configs/rstack.config.ts ## 按需加载依赖 \{#loading-dependencies-on-demand} -`rs` 运行具体工具前,会先加载并执行配置文件,然后只解析当前命令所需的配置函数。 +每次执行 `rs` 命令时,Rstack 都会加载并执行配置文件,然后只解析当前命令需要的配置函数。 -如果配置使用了特定工具的插件或依赖,请将其定义为异步函数,并在函数内通过动态 `import()` 加载相关依赖。这样可以将加载时机推迟到该配置实际被使用时。 +如果配置需要导入插件或其他工具专属依赖,请使用异步配置函数,并在函数内通过动态 `import()` 加载这些依赖。这样只有解析该配置时才会加载相关依赖。 ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -57,7 +57,7 @@ define.app(async () => { ## 配置 API \{#configuration-apis} -各 API 接受与底层工具相同的配置格式。使用 Rstack 重导出的 API 和辅助函数时,请从 `rstack/app`、`rstack/lib`、`rstack/test` 和 `rstack/lint` 入口导入。 +各 API 沿用底层工具的配置格式。使用 Rstack 已重导出的 API 和辅助函数时,推荐从 `rstack/app`、`rstack/lib`、`rstack/test` 和 `rstack/lint` 入口导入。 | API | 底层工具 | 对应命令 | | ----------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------- | @@ -70,7 +70,7 @@ define.app(async () => { ### `define.app()` \{#define-app} -定义应用的 [Rsbuild 配置](https://rsbuild.rs/zh/config/),支持传入配置对象或配置函数。配置函数接收与 Rsbuild 相同的配置参数。 +定义应用的 [Rsbuild 配置](https://rsbuild.rs/zh/config/),支持传入配置对象或配置函数。配置函数接收 Rsbuild 的标准配置参数。 ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -89,7 +89,7 @@ define.app({ ### `define.lib()` \{#define-lib} -定义库的 [Rslib 配置](https://rslib.rs/zh/config/),支持传入配置对象或配置函数。配置函数接收与 Rslib 相同的配置参数。 +定义库的 [Rslib 配置](https://rslib.rs/zh/config/),支持传入配置对象或配置函数。配置函数接收 Rslib 的标准配置参数。 ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -117,7 +117,7 @@ define.doc({ }); ``` -`@rspress/core` 是 Rstack 的可选依赖。每个运行 `rs doc` 的项目都需要安装该依赖: +`@rspress/core` 是 Rstack 的可选依赖。每个使用 `rs doc` 命令的项目都需要安装该依赖: ```bash pnpm add -D @rspress/core @@ -140,15 +140,15 @@ define.test({ }); ``` -未设置 `extends` 时,Rstack 会通过 Rsbuild 适配器继承 `define.app()` 的配置。如果未注册应用配置,则改用 Rslib 适配器继承 `define.lib()`。同时注册两者时,`define.app()` 的优先级更高。显式设置 `extends` 可关闭自动继承。 +未设置 `extends` 时,Rstack 会通过 Rsbuild 适配器让测试配置自动继承 `define.app()`;如果未定义应用配置,则通过 Rslib 适配器回退到 `define.lib()`。二者同时存在时,应用配置的优先级更高。显式设置 `extends` 可关闭自动继承。 -如果测试根配置包含 `projects` 且未定义 `extends`,每个未自行设置 `extends` 的内联项目都会继承同一份应用或库配置。函数形式的配置只会解析一次,并由这些项目共享。字符串形式的项目会原样传给 Rstest,因此会独立加载外部配置,不继承当前应用或库的配置。 +如果测试根配置未定义 `extends` 且包含 `projects`,Rstack 会为每个未自行设置 `extends` 的内联项目应用自动继承。函数形式的应用或库配置只会解析一次,并由这些项目共享。字符串形式的项目会原样传给 Rstest;它们会独立加载外部配置,不继承当前应用或库的配置。 > 如需了解更多测试相关用法,请参阅[测试](./testing)。 ### `define.lint()` \{#define-lint} -定义 [Rslint 配置](https://rslint.rs/config/)。可以直接传入配置,也可以使用异步函数按需从 `rstack/lint` 加载预设和插件。 +定义 [Rslint 配置](https://rslint.rs/config/)。可以直接传入配置,也可以使用异步函数,按需从 `rstack/lint` 加载预设和插件。 ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -162,7 +162,7 @@ define.lint(async () => { ### `define.staged()` \{#define-staged} -定义用于处理 Git 暂存文件的 [lint-staged 配置](https://github.com/lint-staged/lint-staged#configuration)。可以传入将 glob 匹配模式映射到任务的对象,也可以传入任务生成函数。任务可以是 lint-staged 支持的命令、命令数组或函数。 +定义用于处理 Git 暂存文件的 [lint-staged 配置](https://github.com/lint-staged/lint-staged#configuration)。支持传入从 glob 匹配模式映射到任务的配置对象,也支持传入任务生成函数。任务可以是 lint-staged 支持的命令、命令数组或函数。 ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -172,4 +172,4 @@ define.staged({ }); ``` -与其他工具命令不同,`rs staged` 必须配置 `define.staged()`;缺少配置时会报错并退出。 +与其他命令不同,`rs staged` 必须配置 `define.staged()`;缺少配置时会报错。 diff --git a/website/docs/zh/guide/quick-start.mdx b/website/docs/zh/guide/quick-start.mdx index b3d2efb..ca70558 100644 --- a/website/docs/zh/guide/quick-start.mdx +++ b/website/docs/zh/guide/quick-start.mdx @@ -2,13 +2,13 @@ import { PackageManagerTabs } from '@rspress/core/theme'; -Rstack CLI 通过统一的命令行和配置文件整合 Rstack 工具链。本指南介绍如何将 Rstack 添加到现有项目,并使用其核心工作流。 +Rstack CLI 通过统一的命令行和配置文件整合 Rstack 工具链。本指南将介绍如何在现有项目中添加 Rstack,以及可以使用的工作流。 ## 环境准备 \{#environment-preparation} Rstack 支持使用 [Node.js](https://nodejs.org/)、[Deno](https://deno.com/) 或 [Bun](https://bun.sh/) 作为 JavaScript 运行时。 -请根据以下安装指南安装任一支持的运行时: +参考以下安装指南,选择一种运行时: - [安装 Node.js](https://nodejs.org/zh-cn/download) - [安装 Bun](https://bun.com/docs/installation) @@ -16,7 +16,7 @@ Rstack 支持使用 [Node.js](https://nodejs.org/)、[Deno](https://deno.com/) :::tip 版本要求 -使用 Node.js 时,版本须为 22.12.0 或更高版本。 +使用 Node.js 作为运行时时,Rstack 要求 Node.js 版本为 22.12.0 或更高版本。 ::: @@ -49,7 +49,7 @@ Rstack 支持使用 [Node.js](https://nodejs.org/)、[Deno](https://deno.com/) } ``` -通过 `package.json` 中的脚本运行时,`rs` 会解析为项目本地安装的命令,因此无需全局安装 Rstack。 +package scripts 会使用项目本地安装的 `rs` 命令,因此无需全局安装 Rstack。 Rstack 提供以下命令: @@ -60,11 +60,11 @@ Rstack 提供以下命令: - [`rs doc`](./cli/doc):使用 Rspress 开发、构建或预览文档站点。 - [`rs test`](./cli/test):使用 Rstest 运行测试。 - [`rs lint`](./cli/lint):使用 Rslint 检查源代码。 -- [`rs staged`](./cli/staged):使用 lint-staged 对 Git 暂存区中待提交的文件运行任务。 +- [`rs staged`](./cli/staged):使用 lint-staged 对 Git 暂存区中的文件运行任务。 ## 配置 Rstack \{#configure-rstack} -在项目根目录创建 `rstack.config.ts`,并注册项目所需的配置。以下最小示例同时配置了应用构建、测试和代码检查: +在项目根目录创建 `rstack.config.ts`,并注册项目所需的配置。以下是一个包含应用、测试和代码检查的最小示例: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -82,4 +82,4 @@ define.lint({ }); ``` -所有配置 API 的详细说明请参阅[配置](./configuration)。 +所有可用的配置 API 请参见[配置](./configuration)。 diff --git a/website/docs/zh/guide/testing.mdx b/website/docs/zh/guide/testing.mdx index 342a33b..ed89dc7 100644 --- a/website/docs/zh/guide/testing.mdx +++ b/website/docs/zh/guide/testing.mdx @@ -1,6 +1,6 @@ # 测试 \{#testing} -Rstack 通过 [Rstest](https://rstest.rs/zh/) 运行测试。 +Rstack 使用 [Rstest](https://rstest.rs/zh/) 运行测试。 ```bash rs test @@ -10,7 +10,7 @@ rs test ## 配置测试 \{#configure-tests} -通过 [`define.test()`](./configuration#define-test) 注册 Rstest 配置。该 API 接受与 Rstest `defineConfig()` 相同的配置选项: +通过 [`define.test()`](./configuration#define-test) 注册 Rstest 配置,其用法与将配置传给 Rstest 的 `defineConfig()` 一致: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -22,7 +22,7 @@ define.test({ ## 测试 API \{#test-apis} -请从 [`rstack/test`](./api-reference#rstacktest) 导入 Rstest API 和配置辅助函数: +测试 API 和配置辅助函数可从 [`rstack/test`](./api-reference#rstacktest) 导入: ```ts import { defineInlineProject, expect, test } from 'rstack/test'; @@ -30,7 +30,7 @@ import { defineInlineProject, expect, test } from 'rstack/test'; ## 单项目 \{#single-project} -只需一个测试项目时,直接将 Rstest 选项传给 `define.test()`: +对于单个测试项目,直接将 Rstest 选项传给 `define.test()`: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -44,15 +44,15 @@ define.test({ }); ``` -未设置 `extends` 时,Rstack 会通过 Rsbuild 适配器继承 `define.app()` 的配置。如果未注册应用配置,则改用 Rslib 适配器继承 `define.lib()`。同时注册两者时,`define.app()` 的优先级更高。 +未设置 `extends` 时,Rstack 会通过 Rsbuild 适配器让测试配置继承 `define.app()`。如果没有应用配置,则通过 Rslib 适配器回退到 `define.lib()`。同时定义两者时,`define.app()` 的优先级更高。 ## 多项目 \{#multiple-projects} -通过 Rstest 的 [`projects`](https://rstest.rs/zh/config/test/projects) 选项可以同时运行多套测试配置。每一项既可以是内联项目,也可以是指向外部项目配置的字符串。 +通过 Rstest 的 [`projects`](https://rstest.rs/zh/config/test/projects) 选项可以同时运行多套测试配置。每一项既可以是内联项目,也可以是由 Rstest 解析为外部项目的字符串。 ### 内联项目 \{#inline-projects} -测试需要使用不同环境但共享当前应用或库配置时,请使用内联项目: +不同测试环境需要共享当前应用或库配置时,请使用内联项目: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -78,9 +78,9 @@ define.test({ }); ``` -Rstack 会将对应的适配器应用到每个未设置 `extends` 的内联项目。函数形式的 `define.app()` 或 `define.lib()` 配置只会解析一次,再由这些项目共享。 +Rstack 会将对应的适配器应用到每个未设置 `extends` 的内联项目。函数形式的 `define.app()` 或 `define.lib()` 配置只会解析一次,再由这些内联项目共享。 -使用 `--project` 按名称运行单个项目: +按项目名称运行单个项目: ```bash rs test --project dom @@ -90,7 +90,7 @@ rs test --project dom ### 外部项目 \{#external-projects} -使用字符串配置项加载外部项目配置: +使用字符串形式的配置项加载外部项目: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -100,11 +100,11 @@ define.test({ }); ``` -Rstack 会将字符串配置项原样传给 Rstest。外部项目会加载自己的配置,不会继承当前的 `define.app()` 或 `define.lib()` 配置。每个项目需要独立管理配置时,请使用这种方式。 +Rstack 会将字符串形式的项目原样传给 Rstest。外部项目会加载自己的配置,不会继承当前的 `define.app()` 或 `define.lib()` 配置。每个项目需要独立管理配置时,请使用外部项目。 ## 自定义继承 \{#customize-inheritance} -如需关闭自动继承,请显式设置 Rstest 的 [`extends`](https://rstest.rs/zh/config/test/extends) 选项: +项目不应继承当前应用或库配置时,请显式设置 Rstest 的 [`extends`](https://rstest.rs/zh/config/test/extends) 选项: ```ts title="rstack.config.ts" import { define } from 'rstack'; @@ -122,4 +122,4 @@ define.test({ }); ``` -在内联项目中设置 `extends`,只会关闭该项目的自动继承。在 `define.test()` 的根配置中设置该选项,则会关闭整个测试配置的自动继承。 +在内联项目中设置 `extends`,只会关闭当前项目的自动继承。在 `define.test()` 的根配置中设置该选项,则会关闭整个测试配置的自动继承。