|
1 |
| -# CLI |
| 1 | +# Command Line Tool |
2 | 2 |
|
3 |
| -`@module-federation/enhanced` and `@module-federation/modern-js` provides a lightweight CLI. |
| 3 | +<p> |
| 4 | +{props.name || 'Module Federation'} provides lightweight command-line tools: {(props.cmdTools || ['@module-federation/enhanced', '@module-federation/modern-js']).map((cmdTool,index,arr)=>(<><code>{cmdTool}</code>{index+1===arr.length ? '':' and '}</>))} . |
| 5 | +</p> |
4 | 6 |
|
5 |
| -## All commands |
| 7 | +## View All Commands |
6 | 8 |
|
7 |
| -To view all available CLI commands, run the following command in the project directory: |
| 9 | +import React from 'react'; |
| 10 | +import ViewAllCmdsMdx from '@components/common/cli/view-all-cmds'; |
8 | 11 |
|
9 |
| -```bash |
10 |
| -npx mf -h |
11 |
| -``` |
| 12 | +{/* rspress flattenMdxContent issue */} |
| 13 | +{props.show || React.createElement(ViewAllCmdsMdx)} |
12 | 14 |
|
13 |
| -The output is shown below: |
| 15 | +## Common Options |
14 | 16 |
|
15 |
| -```text |
16 |
| -Usage: mf <command> [options] |
| 17 | +{props.name || 'Module Federation'} CLI provides some common options that can be used for all commands: |
17 | 18 |
|
18 |
| -Options: |
19 |
| - -V, --version output the version number |
20 |
| - -h, --help display help for command |
| 19 | +| Option | Description | |
| 20 | +| -------------------------- | ----------------------------------------------------------------------------------------------------------------- | |
| 21 | +| `-c, --config <config>` | Specify the configuration file path, which can be a relative or absolute path. The default value is {props.configName ? props.configName : 'module-federation.config.ts' } | |
| 22 | +| `-m, --mode <mode>` | Specify the running environment, you can choose "dev" or "prod". The default value is "dev". After setting, "development" or "production" will be automatically injected into the `process.env.NODE_ENV` environment variable according to the value. | |
| 23 | +| `-h, --help` | Show command help | |
21 | 24 |
|
22 |
| -Commands: |
23 |
| - dts [options] generate or fetch the mf types |
24 |
| - help [command] display help for command |
25 |
| -``` |
| 25 | +## {props.cmd || 'mf'} dts |
26 | 26 |
|
27 |
| -## Common flags |
| 27 | +<p> |
| 28 | + The <code>{props.cmd || 'mf'} dts</code> command is used to pull or generate TypeScript type declaration files. |
| 29 | +</p> |
28 | 30 |
|
29 |
| -Module Federation CLI provides several common flags that can be used with all commands: |
| 31 | +import CommandInfo from '@components/common/cli/cmd-info'; |
30 | 32 |
|
31 |
| -| Flag | Description | |
32 |
| -| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | |
33 |
| -| `-c, --config <config>` | Specify the configuration file, can be a relative or absolute path, default value is `module-federation.ts` | |
34 |
| -| `-m, --mode <mode>` | Specify the runtime environment. You can choose "dev" or "prod". The default value is "dev". After setting, the `process.env.NODE_ENV` environment variable will be automatically injected with "development" or "production" according to the value. | |
35 |
| -| `-h, --help` | Display help for command | |
| 33 | +{props.commandInfo || <CommandInfo />} |
36 | 34 |
|
37 |
| -## mf dts |
| 35 | +:::info 注意 |
38 | 36 |
|
39 |
| -The `mf dts` command is used to generate or fetch remote types. |
| 37 | +<p>The <code>{props.cmd || 'mf'} dts</code> command will automatically generate or pull type declaration files based on the configuration in <code>{props.configName || 'module-federation.config.ts'}</code>. This means you must provide a valid configuration file, otherwise the command will not run correctly.</p> |
40 | 38 |
|
41 |
| -```bash |
42 |
| -Usage: mf dts [options] |
| 39 | +If you are only using the runtime API, you need to create a temporary <code>{props.configName || 'module-federation.config.ts'}</code> file, configure [dts.consumeTypes.remoteTypeUrls](../../configure/dts#remotetypeurls), and then run the `mf dts` command. |
43 | 40 |
|
44 |
| -generate or fetch the mf types |
45 |
| - |
46 |
| -Options: |
47 |
| - --root <root> specify the project root directory |
48 |
| - --output <output> specify the generated dts output directory |
49 |
| - --fetch <boolean> fetch types from remote, default is true (default: true) |
50 |
| - --generate <boolean> generate types, default is true (default: true) |
51 |
| - -c --config <config> specify the configuration file, can be a relative or absolute path |
52 |
| - -m --mode <mode> Specify the runtime environment. You can choose "dev" or "prod". The default value is "dev". After setting, the process.env.NODE_ENV environment variable will be |
53 |
| - automatically injected with "development" or "production" according to the value. (default: "dev") |
54 |
| - -h, --help display help for command |
55 |
| -``` |
56 |
| - |
57 |
| -:::info Note |
58 |
| - |
59 |
| -The `mf dts` command will automatically generate or pull type declaration files based on the configuration in `module-federation.config.ts`. This means you must provide a valid configuration file, otherwise the command will not work properly. |
60 |
| - |
61 |
| -If you only use the runtime API, you need to create a temporary `module-federation.config.ts` file, write the remote configuration you need to get the type, and then run the `mf dts` command. |
62 |
| -If you are only using the runtime API, you need to create a temporary `module-federation.config.ts` file, configure [dts.consumeTypes.remoteTypeUrls](../../configure/dts#remotetypeurls), and then run the `mf dts` command. |
63 |
| - |
64 |
| -::: |
| 41 | +::: |
0 commit comments