---
url: /typedoc-md/node-esm.md
---
# node-esm

## 接口

### BootstrapGitRunner

定义于: [node-esm/scripts/relizy-runner/index.ts:34](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L34)

relizy-runner 准备基线 tag 时依赖的最小 git 操作。

这里刻意只抽象出 tag 相关命令，避免测试直接 mock `child_process`：
生产环境使用本文件内的 defaultBootstrapGitRunner，单测可注入内存实现，
从而精确断言“创建、推送、回滚”的顺序和边界。

#### 属性

| 属性 | 类型 | 描述 | 定义于 |
| ------ | ------ | ------ | ------ |
|  `createAnnotatedTag` | (`tagName`, `message`, `env`) => `void` | 创建 annotated tag；不能改成 lightweight tag，否则 `git push --follow-tags` 不会自动携带。 | [node-esm/scripts/relizy-runner/index.ts:36](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L36) |
|  `deleteTag` | (`tagName`, `env`) => `void` | 只删除本地 tag，用于失败回滚；远端 tag 属于共享状态，不在这个接口里提供删除能力。 | [node-esm/scripts/relizy-runner/index.ts:39](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L39) |
|  `listTags` | (`packageName`, `env`) => `string`\[] | 查询某个包已有的历史发版 tag；只要存在任意 `name@*` tag，就可作为 relizy 的 independent 基线。 | [node-esm/scripts/relizy-runner/index.ts:42](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L42) |
|  `pushTags` | (`tagNames`, `env`) => `void` | 推送本轮创建的 bootstrap tags；生产实现使用 atomic push，避免远端出现半成功 tag 集合。 | [node-esm/scripts/relizy-runner/index.ts:45](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L45) |

***

### BootstrapTagPreparationResult

定义于: [node-esm/scripts/relizy-runner/index.ts:54](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L54)

independent 基线 tag 准备阶段的结构化结果。

`runRelizyRunner` 需要根据这些字段决定是否继续调用 relizy，以及 relizy 后续失败时
是否可以安全回滚本地 tag。

#### 属性

| 属性 | 类型 | 描述 | 定义于 |
| ------ | ------ | ------ | ------ |
|  `error?` | `unknown` | 原始异常对象，仅在 `ok: false` 时用于日志输出；不要在准备函数内提前吞掉错误语义。 | [node-esm/scripts/relizy-runner/index.ts:56](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L56) |
|  `instructions?` | `string` | 自动处理失败或禁写模式下给用户的手工兜底命令。 | [node-esm/scripts/relizy-runner/index.ts:59](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L59) |
|  `ok` | `boolean` | tag 准备阶段是否完成；为 false 时调用方必须停止后续 relizy 执行。 | [node-esm/scripts/relizy-runner/index.ts:62](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L62) |
|  `pushed` | `boolean` | 本轮创建的 tag 是否已经推送到远端；一旦为 true，失败回滚只能告警，不能自动删除。 | [node-esm/scripts/relizy-runner/index.ts:65](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L65) |
|  `tagNames` | `string`\[] | 本轮期望准备的 tag 名列表，按 workspace 包发现顺序保留。 | [node-esm/scripts/relizy-runner/index.ts:68](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L68) |
|  `wrote` | `boolean` | 是否已经产生本地 tag 副作用；用于区分“无缺失 tag”和“创建后 relizy 失败需回滚”。 | [node-esm/scripts/relizy-runner/index.ts:71](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L71) |

***

### MoveVercelOutputToRootOptions

定义于: [node-esm/scripts/move-vercel-output-to-root/index.ts:7](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L7)

#### 属性

| 属性 | 类型 | 描述 | 定义于 |
| ------ | ------ | ------ | ------ |
|  `cwd?` | `string` | 运行目录。 默认值为 `process.cwd()`。 | [node-esm/scripts/move-vercel-output-to-root/index.ts:12](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L12) |
|  `dereference?` | `boolean` | 是否解引用符号链接，将链接目标复制为实体文件或目录。 **默认值** `false` | [node-esm/scripts/move-vercel-output-to-root/index.ts:48](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L48) |
|  `dryRun?` | `boolean` | 仅打印解析结果，不实际复制文件。 **默认值** `false` | [node-esm/scripts/move-vercel-output-to-root/index.ts:55](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L55) |
|  `rootDir?` | `string` | monorepo 根目录。 不传时会从 `cwd` 开始，向上查找 `pnpm-workspace.yaml`。 | [node-esm/scripts/move-vercel-output-to-root/index.ts:18](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L18) |
|  `skipClean?` | `boolean` | 是否跳过目标目录清理。 **默认值** `false` | [node-esm/scripts/move-vercel-output-to-root/index.ts:41](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L41) |
|  `sourceDir?` | `string` | 子包内构建产物目录。 相对路径基于 `cwd` 解析。 **默认值** `".vercel/output"` | [node-esm/scripts/move-vercel-output-to-root/index.ts:26](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L26) |
|  `targetDir?` | `string` | monorepo 根目录内的目标输出目录。 相对路径基于 monorepo 根目录解析。 **默认值** `".vercel/output"` | [node-esm/scripts/move-vercel-output-to-root/index.ts:34](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L34) |

***

### MoveVercelOutputToRootResult

定义于: [node-esm/scripts/move-vercel-output-to-root/index.ts:68](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L68)

#### 继承

* [`ResolvedMoveVercelOutputToRootOptions`](#resolvedmoveverceloutputtorootoptions)

#### 属性

| 属性 | 类型 | 继承自 | 定义于 |
| ------ | ------ | ------ | ------ |
|  `copied` | `boolean` | - | [node-esm/scripts/move-vercel-output-to-root/index.ts:69](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L69) |
|  `cwd` | `string` | [`ResolvedMoveVercelOutputToRootOptions`](#resolvedmoveverceloutputtorootoptions).[`cwd`](#cwd-2) | [node-esm/scripts/move-vercel-output-to-root/index.ts:59](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L59) |
|  `dereference` | `boolean` | [`ResolvedMoveVercelOutputToRootOptions`](#resolvedmoveverceloutputtorootoptions).[`dereference`](#dereference-2) | [node-esm/scripts/move-vercel-output-to-root/index.ts:64](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L64) |
|  `dryRun` | `boolean` | [`ResolvedMoveVercelOutputToRootOptions`](#resolvedmoveverceloutputtorootoptions).[`dryRun`](#dryrun-2) | [node-esm/scripts/move-vercel-output-to-root/index.ts:65](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L65) |
|  `monorepoRoot` | `string` | [`ResolvedMoveVercelOutputToRootOptions`](#resolvedmoveverceloutputtorootoptions).[`monorepoRoot`](#monoreporoot-1) | [node-esm/scripts/move-vercel-output-to-root/index.ts:60](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L60) |
|  `skipClean` | `boolean` | [`ResolvedMoveVercelOutputToRootOptions`](#resolvedmoveverceloutputtorootoptions).[`skipClean`](#skipclean-2) | [node-esm/scripts/move-vercel-output-to-root/index.ts:63](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L63) |
|  `sourceDir` | `string` | [`ResolvedMoveVercelOutputToRootOptions`](#resolvedmoveverceloutputtorootoptions).[`sourceDir`](#sourcedir-2) | [node-esm/scripts/move-vercel-output-to-root/index.ts:61](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L61) |
|  `targetDir` | `string` | [`ResolvedMoveVercelOutputToRootOptions`](#resolvedmoveverceloutputtorootoptions).[`targetDir`](#targetdir-2) | [node-esm/scripts/move-vercel-output-to-root/index.ts:62](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L62) |

***

### PackageInfo

定义于: [node-esm/ruan-cat-pkg-info.ts:4](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/ruan-cat-pkg-info.ts#L4)

包的信息

#### 属性

| 属性 | 类型 | 描述 | 定义于 |
| ------ | ------ | ------ | ------ |
|  `description` | `string` | 包的描述 | [node-esm/ruan-cat-pkg-info.ts:8](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/ruan-cat-pkg-info.ts#L8) |
|  `name` | `string` | 包名 | [node-esm/ruan-cat-pkg-info.ts:6](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/ruan-cat-pkg-info.ts#L6) |
|  `url` | `` `https://npm.im/${string}` `` | 带有包名的官方镜像源地址 | [node-esm/ruan-cat-pkg-info.ts:10](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/ruan-cat-pkg-info.ts#L10) |

***

### RelizyRunnerOptions

定义于: [node-esm/scripts/relizy-runner/index.ts:80](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L80)

`runRelizyRunner` 的测试接缝。

CLI 正常运行时不需要传入这些选项；单测通过它们替换 git、包发现、relizy 入口与子进程执行，
以覆盖发版脚本中最危险的外部副作用，而不真的修改调用者仓库。

#### 属性

| 属性 | 类型 | 描述 | 定义于 |
| ------ | ------ | ------ | ------ |
|  `bootstrapGitRunner?` | [`BootstrapGitRunner`](#bootstrapgitrunner) | 替换真实 git 命令的执行器，通常只在单测中使用。 | [node-esm/scripts/relizy-runner/index.ts:82](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L82) |
|  `getMissingPackages?` | (`env`) => `Required`<`Pick`<`PackageJson`, `"name"` | `"version"`>>\[] | 替换 workspace 包扫描逻辑，用于构造缺失基线 tag 的测试场景。 | [node-esm/scripts/relizy-runner/index.ts:85](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L85) |
|  `relizyEntrypoint?` | `string` | 指定 relizy CLI 入口；默认解析当前工作目录下的本地依赖。 | [node-esm/scripts/relizy-runner/index.ts:88](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L88) |
|  `spawnRelizy?` | (`relizyEntrypoint`, `spawnArgs`, `env`) => `number` | `null` | 替换 relizy 子进程执行逻辑，返回值对齐 `spawnSync().status`。 | [node-esm/scripts/relizy-runner/index.ts:91](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L91) |

***

### ResolvedMoveVercelOutputToRootOptions

定义于: [node-esm/scripts/move-vercel-output-to-root/index.ts:58](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L58)

#### 继承于

* [`MoveVercelOutputToRootResult`](#moveverceloutputtorootresult)

#### 属性

| 属性 | 类型 | 定义于 |
| ------ | ------ | ------ |
|  `cwd` | `string` | [node-esm/scripts/move-vercel-output-to-root/index.ts:59](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L59) |
|  `dereference` | `boolean` | [node-esm/scripts/move-vercel-output-to-root/index.ts:64](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L64) |
|  `dryRun` | `boolean` | [node-esm/scripts/move-vercel-output-to-root/index.ts:65](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L65) |
|  `monorepoRoot` | `string` | [node-esm/scripts/move-vercel-output-to-root/index.ts:60](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L60) |
|  `skipClean` | `boolean` | [node-esm/scripts/move-vercel-output-to-root/index.ts:63](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L63) |
|  `sourceDir` | `string` | [node-esm/scripts/move-vercel-output-to-root/index.ts:61](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L61) |
|  `targetDir` | `string` | [node-esm/scripts/move-vercel-output-to-root/index.ts:62](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L62) |

***

### WriteYaml2mdParams

定义于: [node-esm/yaml-to-md.ts:7](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/yaml-to-md.ts#L7)

#### 类型参数

| 类型参数 | 默认类型 |
| ------ | ------ |
| `T` | `Record`<`string`, `any`> |

#### 属性

| 属性 | 类型 | 描述 | 定义于 |
| ------ | ------ | ------ | ------ |
|  `data` | `T` | 被插入到md头部的数据 | [node-esm/yaml-to-md.ts:12](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/yaml-to-md.ts#L12) |
|  `mdPath` | `string` | 目标md文件地址 | [node-esm/yaml-to-md.ts:9](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/yaml-to-md.ts#L9) |

## 类型别名

### WorkspacePackageInfo

```ts
type WorkspacePackageInfo = Required<Pick<PackageJson, "name" | "version">>;
```

定义于: [node-esm/scripts/relizy-runner/index.ts:25](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L25)

发版基线 tag 校验所需的最小字段，由 PackageJson 派生。

## 变量

### defaultCleanTargets

```ts
const defaultCleanTargets: readonly ["node_modules", "yarn.lock", "pnpm-lock.yaml", "package-lock.json", "dist", ".turbo", ".vercel", ".cache", ".temp"];
```

定义于: [node-esm/scripts/clean.ts:5](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/clean.ts#L5)

## 函数

### buildBootstrapInstructions()

```ts
function buildBootstrapInstructions(missingPackages): string;
```

定义于: [node-esm/scripts/relizy-runner/index.ts:450](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L450)

根据缺少基线 tag 的包列表，生成包含补打 tag 命令的提示文本。

这段文本用于两类路径：禁写模式下的主动失败提示，以及自动创建失败后的兜底说明。
命令刻意使用 annotated tag，和 runner 自动路径、`git push --follow-tags` 语义保持一致。

#### 参数

| 参数 | 类型 |
| ------ | ------ |
| `missingPackages` | `Required`<`Pick`<`PackageJson`, `"name"` | `"version"`>>\[] |

#### 返回

`string`

***

### clean()

```ts
function clean(targets?): Promise<void>;
```

定义于: [node-esm/scripts/clean.ts:28](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/clean.ts#L28)

删除node项目的依赖项便于重新安装依赖，也包括常见的各种垃圾文件。

#### 参数

| 参数 | 类型 | 描述 |
| ------ | ------ | ------ |
| `targets?` | `string`\[] | 被清除的目标文件夹 也包括文件 |

#### 返回

`Promise`<`void`>

#### Description

***

### ensureRelizyShellEnv()

```ts
function ensureRelizyShellEnv(): 
  | {
  PATH: string;
}
  | {
[key: string]: string | undefined;
};
```

定义于: [node-esm/scripts/relizy-runner/index.ts:210](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L210)

确保 relizy 所需的 GNU 工具（grep / head / sed）在 PATH 中可用。
Windows 下会自动补齐 Git for Windows 的 `usr\bin` 路径。

返回的是新的 env 对象，不直接修改 `process.env`。后续 git 与 relizy 子进程都使用同一个 env，
保证 baseline tag 检查和 relizy 真正执行时看到一致的 shell 工具环境。

#### 返回

| {
`PATH`: `string`;
}
| {
\[`key`: `string`]: `string` | `undefined`;
}

***

### getBootstrapTagName()

```ts
function getBootstrapTagName(pkg): string;
```

定义于: [node-esm/scripts/relizy-runner/index.ts:336](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L336)

生成 relizy 使用的包级发版 tag 名，例如 `@scope/pkg@1.0.0`。

#### 参数

| 参数 | 类型 |
| ------ | ------ |
| `pkg` | [`WorkspacePackageInfo`](#workspacepackageinfo) |

#### 返回

`string`

***

### getBootstrapTagNames()

```ts
function getBootstrapTagNames(packages): string[];
```

定义于: [node-esm/scripts/relizy-runner/index.ts:341](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L341)

按包发现顺序批量生成 bootstrap tag 名，便于日志、命令与测试断言保持稳定。

#### 参数

| 参数 | 类型 |
| ------ | ------ |
| `packages` | `Required`<`Pick`<`PackageJson`, `"name"` | `"version"`>>\[] |

#### 返回

`string`\[]

***

### getMoveVercelOutputToRootHelpText()

```ts
function getMoveVercelOutputToRootHelpText(): string;
```

定义于: [node-esm/scripts/move-vercel-output-to-root/index.ts:254](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L254)

CLI 帮助信息。

#### 返回

`string`

***

### getPackagesMissingBootstrapTags()

```ts
function getPackagesMissingBootstrapTags(env, options?): Required<Pick<PackageJson, "name" | "version">>[];
```

定义于: [node-esm/scripts/relizy-runner/index.ts:366](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L366)

找出仍缺少 independent 基线 tag 的 workspace 包。

判定标准是“该包是否已有任意 `name@*` tag”。已有 tag 说明 relizy 后续有历史版本可比较；
没有 tag 时，runner 会按当前 package.json 版本补一个 bootstrap baseline。

#### 参数

| 参数 | 类型 |
| ------ | ------ |
| `env` | `ProcessEnv` |
| `options` | { `gitRunner?`: `Pick`<[`BootstrapGitRunner`](#bootstrapgitrunner), `"listTags"`>; `packages?`: `Required`<`Pick`<`PackageJson`, `"name"` | `"version"`>>\[]; } |
| `options.gitRunner?` | `Pick`<[`BootstrapGitRunner`](#bootstrapgitrunner), `"listTags"`> |
| `options.packages?` | `Required`<`Pick`<`PackageJson`, `"name"` | `"version"`>>\[] |

#### 返回

`Required`<`Pick`<`PackageJson`, `"name"` | `"version"`>>\[]

***

### getRelizyRunnerHelpText()

```ts
function getRelizyRunnerHelpText(): string;
```

定义于: [node-esm/scripts/relizy-runner/index.ts:474](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L474)

获取 relizy-runner CLI 的帮助文本。

#### 返回

`string`

***

### getRuanCatPkgInfo()

```ts
function getRuanCatPkgInfo(): Promise<PackageInfo[]>;
```

定义于: [node-esm/ruan-cat-pkg-info.ts:23](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/ruan-cat-pkg-info.ts#L23)

获得阮喵喵全部的包信息

#### 返回

`Promise`<[`PackageInfo`](#packageinfo)\[]>

#### Description

这是一个node环境下的函数，用于获取阮喵喵的所有包的信息。

使用的是node的child\_process模块，调用pnpm命令获取包信息。

* 默认仅考虑pnpm包
* 在node环境下运行

***

### getWorkspacePackages()

```ts
function getWorkspacePackages(workspaceRoot?): Required<Pick<PackageJson, "name" | "version">>[];
```

定义于: [node-esm/scripts/relizy-runner/index.ts:105](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L105)

解析根目录 `pnpm-workspace.yaml` 并展开一层 `xxx/*` glob 模式，
收集所有含 `package.json` 的子包目录，返回其 name 与 version。

使用 [pnpm-workspace-yaml](https://github.com/antfu/pnpm-workspace-utils/tree/main/packages/pnpm-workspace-yaml)
解析工作区清单，再用 `pkg-types` 的 `PackageJson` 约束子包字段。
其他复杂 glob 会被跳过：本 runner 只需要覆盖仓库内常规 workspace 包，
不尝试复刻 pnpm 的完整 glob 语义，避免发版前置脚本承担过宽职责。

#### 参数

| 参数 | 类型 |
| ------ | ------ |
| `workspaceRoot?` | `string` |

#### 返回

`Required`<`Pick`<`PackageJson`, `"name"` | `"version"`>>\[]

***

### moveVercelOutputToRoot()

```ts
function moveVercelOutputToRoot(options?): MoveVercelOutputToRootResult;
```

定义于: [node-esm/scripts/move-vercel-output-to-root/index.ts:155](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L155)

将当前子包内的 `.vercel/output` 移动到 monorepo 根目录。

#### 参数

| 参数 | 类型 |
| ------ | ------ |
| `options` | [`MoveVercelOutputToRootOptions`](#moveverceloutputtorootoptions) |

#### 返回

[`MoveVercelOutputToRootResult`](#moveverceloutputtorootresult)

#### Description

该函数服务于 Vercel 在 monorepo 场景下的部署：

1. 构建仍在子包目录内执行
2. 产物默认出现在子包的 `.vercel/output`
3. Vercel 却要求在 monorepo 根目录下读取 `.vercel/output`

***

### parseMoveVercelOutputToRootCliArgs()

```ts
function parseMoveVercelOutputToRootCliArgs(args): MoveVercelOutputToRootOptions & {
  help?: boolean;
};
```

定义于: [node-esm/scripts/move-vercel-output-to-root/index.ts:203](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L203)

解析命令行参数。

#### 参数

| 参数 | 类型 |
| ------ | ------ |
| `args` | `string`\[] |

#### 返回

[`MoveVercelOutputToRootOptions`](#moveverceloutputtorootoptions) & {
`help?`: `boolean`;
}

***

### parseRelizyRunnerCliArgs()

```ts
function parseRelizyRunnerCliArgs(args): {
  help: boolean;
  relizyArgs: string[];
};
```

定义于: [node-esm/scripts/relizy-runner/index.ts:680](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L680)

解析 relizy-runner CLI 参数。
如果首个参数是 `--help` 或 `-h`，返回 `{ help: true }`。
否则将所有参数透传给 relizy。

#### 参数

| 参数 | 类型 |
| ------ | ------ |
| `args` | `string`\[] |

#### 返回

```ts
{
  help: boolean;
  relizyArgs: string[];
}
```

| 名称 | 类型 | 定义于 |
| ------ | ------ | ------ |
| `help` | `boolean` | [node-esm/scripts/relizy-runner/index.ts:680](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L680) |
| `relizyArgs` | `string`\[] | [node-esm/scripts/relizy-runner/index.ts:680](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L680) |

***

### prepareBootstrapTags()

```ts
function prepareBootstrapTags(
   missingPackages, 
   relizyArgs, 
   env?, 
   gitRunner?
): BootstrapTagPreparationResult;
```

定义于: [node-esm/scripts/relizy-runner/index.ts:386](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L386)

在调用 relizy 前准备 independent 模式所需的 baseline tags。

执行顺序必须保持：先创建所有本地 annotated tags，再按 `--no-push` 决定是否推送。
如果处于 `--dry-run` / `--no-commit` 禁写模式，本函数不会创建任何 tag，只返回手工兜底命令。
如果创建或推送失败，会尽量回滚本轮已经创建的本地 tag，并把原始错误交给调用方输出。

#### 参数

| 参数 | 类型 | 默认值 |
| ------ | ------ | ------ |
| `missingPackages` | `Required`<`Pick`<`PackageJson`, `"name"` | `"version"`>>\[] | `undefined` |
| `relizyArgs` | `string`\[] | `undefined` |
| `env` | `ProcessEnv` | `process.env` |
| `gitRunner` | [`BootstrapGitRunner`](#bootstrapgitrunner) | `defaultBootstrapGitRunner` |

#### 返回

[`BootstrapTagPreparationResult`](#bootstraptagpreparationresult)

***

### prepareRelizySpawnArgs()

```ts
function prepareRelizySpawnArgs(relizyArgs): string[];
```

定义于: [node-esm/scripts/relizy-runner/index.ts:317](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L317)

规整即将交给 relizy 的参数：移除 runner 专用选项，并在适当时追加 `--yes`。

* 对 `release` / `bump`：若未出现 `--yes` 且未要求 `--no-yes`，则在末尾追加 `--yes`。
* 对 `changelog`：显式传入的 `--yes` 会被 runner 兼容接受，但不会继续传给 relizy。
* `--no-yes` 仅由 relizy-runner 识别，不会传递给 relizy。

#### 参数

| 参数 | 类型 |
| ------ | ------ |
| `relizyArgs` | `string`\[] |

#### 返回

`string`\[]

***

### resolveMoveVercelOutputToRootOptions()

```ts
function resolveMoveVercelOutputToRootOptions(options?): ResolvedMoveVercelOutputToRootOptions;
```

定义于: [node-esm/scripts/move-vercel-output-to-root/index.ts:107](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L107)

解析脚本所需的全部路径。

#### 参数

| 参数 | 类型 |
| ------ | ------ |
| `options` | [`MoveVercelOutputToRootOptions`](#moveverceloutputtorootoptions) |

#### 返回

[`ResolvedMoveVercelOutputToRootOptions`](#resolvedmoveverceloutputtorootoptions)

***

### runMoveVercelOutputToRootCli()

```ts
function runMoveVercelOutputToRootCli(args?): void;
```

定义于: [node-esm/scripts/move-vercel-output-to-root/index.ts:272](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/move-vercel-output-to-root/index.ts#L272)

执行 CLI。

#### 参数

| 参数 | 类型 |
| ------ | ------ |
| `args` | `string`\[] |

#### 返回

`void`

***

### runRelizyRunner()

```ts
function runRelizyRunner(relizyArgs, options?): number;
```

定义于: [node-esm/scripts/relizy-runner/index.ts:585](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L585)

执行 relizy-runner。

#### 参数

| 参数 | 类型 | 描述 |
| ------ | ------ | ------ |
| `relizyArgs` | `string`\[] | 透传给 relizy 的子命令与参数（会先经 [prepareRelizySpawnArgs](#preparerelizyspawnargs) 规整） |
| `options` | [`RelizyRunnerOptions`](#relizyrunneroptions) | 测试接缝；CLI 正常运行时保持默认值即可 |

#### 返回

`number`

退出码

#### Description

围绕 relizy 执行做以下前后置处理：

1. Windows 下自动补齐 Git for Windows 的 `usr\bin` 路径，避免 relizy 内部调用 `grep`/`head`/`sed` 失败。
2. 在 `release`/`bump` 前校验 independent 基线 tag，缺失时自动创建 annotated baseline tags。
3. relizy 后续失败时，只回滚本轮未推送的本地 bootstrap tags，避免误删远端共享状态。

***

### runRelizyRunnerCli()

```ts
function runRelizyRunnerCli(args?): void;
```

定义于: [node-esm/scripts/relizy-runner/index.ts:691](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L691)

执行 relizy-runner CLI。

#### 参数

| 参数 | 类型 |
| ------ | ------ |
| `args` | `string`\[] |

#### 返回

`void`

***

### shouldCheckIndependentBootstrap()

```ts
function shouldCheckIndependentBootstrap(relizyArgs): boolean;
```

定义于: [node-esm/scripts/relizy-runner/index.ts:301](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L301)

判断当前 relizy 子命令是否需要检查 independent 基线 tag。
仅 `release` 与 `bump` 需要：它们会触发版本计算或写入，缺少基线 tag 时 relizy 会提前失败。

#### 参数

| 参数 | 类型 |
| ------ | ------ |
| `relizyArgs` | `string`\[] |

#### 返回

`boolean`

***

### shouldPushBootstrapTags()

```ts
function shouldPushBootstrapTags(relizyArgs): boolean;
```

定义于: [node-esm/scripts/relizy-runner/index.ts:346](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L346)

判断本轮 bootstrap tags 是否应推送到远端；语义跟随 relizy 的 `--no-push`。

#### 参数

| 参数 | 类型 |
| ------ | ------ |
| `relizyArgs` | `string`\[] |

#### 返回

`boolean`

***

### shouldWriteBootstrapTags()

```ts
function shouldWriteBootstrapTags(relizyArgs): boolean;
```

定义于: [node-esm/scripts/relizy-runner/index.ts:351](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/scripts/relizy-runner/index.ts#L351)

判断本轮是否允许产生 git tag 副作用；dry-run / no-commit 下必须保持完全禁写。

#### 参数

| 参数 | 类型 |
| ------ | ------ |
| `relizyArgs` | `string`\[] |

#### 返回

`boolean`

***

### ~~writeYaml2md()~~

```ts
function writeYaml2md<T>(params): void;
```

定义于: [node-esm/yaml-to-md.ts:20](https://github.com/ruan-cat/monorepo/blob/main/packages/utils/src/node-esm/yaml-to-md.ts#L20)

将YAML数据写入到MD文件内

#### 类型参数

| 类型参数 |
| ------ |
| `T` |

#### 参数

| 参数 | 类型 |
| ------ | ------ |
| `params` | [`WriteYaml2mdParams`](#writeyaml2mdparams)<`T`> |

#### 返回

`void`

#### 已被弃用

请使用 gray-matter 库来实现相关的更改，不使用 `writeYaml2md` 函数了。

## 参考

### findMonorepoRoot

重新导出 [findMonorepoRoot](node-cjs.md#findmonoreporoot)

***

### isMonorepoProject

重新导出 [isMonorepoProject](node-cjs.md#ismonorepoproject)
