Skip to content

node-esm ​

接口 ​

BootstrapGitRunner ​

定义于: node-esm/scripts/relizy-runner/index.ts:34

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
deleteTag(tagName, env) => void只删除本地 tag,用于失败回滚;远端 tag 属于共享状态,不在这个接口里提供删除能力。node-esm/scripts/relizy-runner/index.ts:39
listTags(packageName, env) => string[]查询某个包已有的历史发版 tag;只要存在任意 name@* tag,就可作为 relizy 的 independent 基线。node-esm/scripts/relizy-runner/index.ts:42
pushTags(tagNames, env) => void推送本轮创建的 bootstrap tags;生产实现使用 atomic push,避免远端出现半成功 tag 集合。node-esm/scripts/relizy-runner/index.ts:45

BootstrapTagPreparationResult ​

定义于: node-esm/scripts/relizy-runner/index.ts:54

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

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

属性 ​

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

MoveVercelOutputToRootOptions ​

定义于: node-esm/scripts/move-vercel-output-to-root/index.ts:7

属性 ​

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

MoveVercelOutputToRootResult ​

定义于: node-esm/scripts/move-vercel-output-to-root/index.ts:68

继承 ​

属性 ​

属性类型继承自定义于
copiedboolean-node-esm/scripts/move-vercel-output-to-root/index.ts:69
cwdstringResolvedMoveVercelOutputToRootOptions.cwdnode-esm/scripts/move-vercel-output-to-root/index.ts:59
dereferencebooleanResolvedMoveVercelOutputToRootOptions.dereferencenode-esm/scripts/move-vercel-output-to-root/index.ts:64
dryRunbooleanResolvedMoveVercelOutputToRootOptions.dryRunnode-esm/scripts/move-vercel-output-to-root/index.ts:65
monorepoRootstringResolvedMoveVercelOutputToRootOptions.monorepoRootnode-esm/scripts/move-vercel-output-to-root/index.ts:60
skipCleanbooleanResolvedMoveVercelOutputToRootOptions.skipCleannode-esm/scripts/move-vercel-output-to-root/index.ts:63
sourceDirstringResolvedMoveVercelOutputToRootOptions.sourceDirnode-esm/scripts/move-vercel-output-to-root/index.ts:61
targetDirstringResolvedMoveVercelOutputToRootOptions.targetDirnode-esm/scripts/move-vercel-output-to-root/index.ts:62

PackageInfo ​

定义于: node-esm/ruan-cat-pkg-info.ts:4

包的信息

属性 ​

属性类型描述定义于
descriptionstring包的描述node-esm/ruan-cat-pkg-info.ts:8
namestring包名node-esm/ruan-cat-pkg-info.ts:6
url`https://npm.im/${string}`带有包名的官方镜像源地址node-esm/ruan-cat-pkg-info.ts:10

RelizyRunnerOptions ​

定义于: node-esm/scripts/relizy-runner/index.ts:80

runRelizyRunner 的测试接缝。

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

属性 ​

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

ResolvedMoveVercelOutputToRootOptions ​

定义于: node-esm/scripts/move-vercel-output-to-root/index.ts:58

继承于 ​

属性 ​

属性类型定义于
cwdstringnode-esm/scripts/move-vercel-output-to-root/index.ts:59
dereferencebooleannode-esm/scripts/move-vercel-output-to-root/index.ts:64
dryRunbooleannode-esm/scripts/move-vercel-output-to-root/index.ts:65
monorepoRootstringnode-esm/scripts/move-vercel-output-to-root/index.ts:60
skipCleanbooleannode-esm/scripts/move-vercel-output-to-root/index.ts:63
sourceDirstringnode-esm/scripts/move-vercel-output-to-root/index.ts:61
targetDirstringnode-esm/scripts/move-vercel-output-to-root/index.ts:62

WriteYaml2mdParams ​

定义于: node-esm/yaml-to-md.ts:7

类型参数 ​

类型参数默认类型
TRecord<string, any>

属性 ​

属性类型描述定义于
dataT被插入到md头部的数据node-esm/yaml-to-md.ts:12
mdPathstring目标md文件地址node-esm/yaml-to-md.ts:9

类型别名 ​

WorkspacePackageInfo ​

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

定义于: node-esm/scripts/relizy-runner/index.ts:25

发版基线 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

函数 ​

buildBootstrapInstructions() ​

ts
function buildBootstrapInstructions(missingPackages): string;

定义于: node-esm/scripts/relizy-runner/index.ts:450

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

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

参数 ​

参数类型
missingPackagesRequired<Pick<PackageJson, "name" | "version">>[]

返回 ​

string


clean() ​

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

定义于: node-esm/scripts/clean.ts:28

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

参数 ​

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

返回 ​

Promise<void>

Description ​


ensureRelizyShellEnv() ​

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

定义于: node-esm/scripts/relizy-runner/index.ts:210

确保 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

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

参数 ​

参数类型
pkgWorkspacePackageInfo

返回 ​

string


getBootstrapTagNames() ​

ts
function getBootstrapTagNames(packages): string[];

定义于: node-esm/scripts/relizy-runner/index.ts:341

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

参数 ​

参数类型
packagesRequired<Pick<PackageJson, "name" | "version">>[]

返回 ​

string[]


getMoveVercelOutputToRootHelpText() ​

ts
function getMoveVercelOutputToRootHelpText(): string;

定义于: node-esm/scripts/move-vercel-output-to-root/index.ts:254

CLI 帮助信息。

返回 ​

string


getPackagesMissingBootstrapTags() ​

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

定义于: node-esm/scripts/relizy-runner/index.ts:366

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

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

参数 ​

参数类型
envProcessEnv
options{ gitRunner?: Pick<BootstrapGitRunner, "listTags">; packages?: Required<Pick<PackageJson, "name" | "version">>[]; }
options.gitRunner?Pick<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

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

返回 ​

string


getRuanCatPkgInfo() ​

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

定义于: node-esm/ruan-cat-pkg-info.ts:23

获得阮喵喵全部的包信息

返回 ​

Promise<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

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

使用 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

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

参数 ​

参数类型
optionsMoveVercelOutputToRootOptions

返回 ​

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

解析命令行参数。

参数 ​

参数类型
argsstring[]

返回 ​

MoveVercelOutputToRootOptions & {
help?: boolean;
}


parseRelizyRunnerCliArgs() ​

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

定义于: node-esm/scripts/relizy-runner/index.ts:680

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

参数 ​

参数类型
argsstring[]

返回 ​

ts
{
  help: boolean;
  relizyArgs: string[];
}
名称类型定义于
helpbooleannode-esm/scripts/relizy-runner/index.ts:680
relizyArgsstring[]node-esm/scripts/relizy-runner/index.ts:680

prepareBootstrapTags() ​

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

定义于: node-esm/scripts/relizy-runner/index.ts:386

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

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

参数 ​

参数类型默认值
missingPackagesRequired<Pick<PackageJson, "name" | "version">>[]undefined
relizyArgsstring[]undefined
envProcessEnvprocess.env
gitRunnerBootstrapGitRunnerdefaultBootstrapGitRunner

返回 ​

BootstrapTagPreparationResult


prepareRelizySpawnArgs() ​

ts
function prepareRelizySpawnArgs(relizyArgs): string[];

定义于: node-esm/scripts/relizy-runner/index.ts:317

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

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

参数 ​

参数类型
relizyArgsstring[]

返回 ​

string[]


resolveMoveVercelOutputToRootOptions() ​

ts
function resolveMoveVercelOutputToRootOptions(options?): ResolvedMoveVercelOutputToRootOptions;

定义于: node-esm/scripts/move-vercel-output-to-root/index.ts:107

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

参数 ​

参数类型
optionsMoveVercelOutputToRootOptions

返回 ​

ResolvedMoveVercelOutputToRootOptions


runMoveVercelOutputToRootCli() ​

ts
function runMoveVercelOutputToRootCli(args?): void;

定义于: node-esm/scripts/move-vercel-output-to-root/index.ts:272

执行 CLI。

参数 ​

参数类型
argsstring[]

返回 ​

void


runRelizyRunner() ​

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

定义于: node-esm/scripts/relizy-runner/index.ts:585

执行 relizy-runner。

参数 ​

参数类型描述
relizyArgsstring[]透传给 relizy 的子命令与参数(会先经 prepareRelizySpawnArgs 规整)
optionsRelizyRunnerOptions测试接缝;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

执行 relizy-runner CLI。

参数 ​

参数类型
argsstring[]

返回 ​

void


shouldCheckIndependentBootstrap() ​

ts
function shouldCheckIndependentBootstrap(relizyArgs): boolean;

定义于: node-esm/scripts/relizy-runner/index.ts:301

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

参数 ​

参数类型
relizyArgsstring[]

返回 ​

boolean


shouldPushBootstrapTags() ​

ts
function shouldPushBootstrapTags(relizyArgs): boolean;

定义于: node-esm/scripts/relizy-runner/index.ts:346

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

参数 ​

参数类型
relizyArgsstring[]

返回 ​

boolean


shouldWriteBootstrapTags() ​

ts
function shouldWriteBootstrapTags(relizyArgs): boolean;

定义于: node-esm/scripts/relizy-runner/index.ts:351

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

参数 ​

参数类型
relizyArgsstring[]

返回 ​

boolean


writeYaml2md() ​

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

定义于: node-esm/yaml-to-md.ts:20

将YAML数据写入到MD文件内

类型参数 ​

类型参数
T

参数 ​

参数类型
paramsWriteYaml2mdParams<T>

返回 ​

void

已被弃用 ​

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

参考 ​

findMonorepoRoot ​

重新导出 findMonorepoRoot


isMonorepoProject ​

重新导出 isMonorepoProject

贡献者

暂无相关贡献者

页面历史

暂无最近变更历史
最近更新