import { ExecOptions, ExecSyncOptions, SpawnOptions, SpawnSyncOptions } from "node:child_process"; //#region src/enums.d.ts declare enum PkgManager { NPM = "npm", YARN = "yarn", PNPM = "pnpm" } /** * @deprecated Use `ConfirmResult` instead. */ declare enum YesOrNo { Yes = "yes", No = "no", Ignore = "ignore" } declare enum ConfirmResult { YES = "yes", NO = "no", IGNORE = "ignore" } declare enum HttpLibrary { EXPRESS = "express", FASTIFY = "fastify", KOA = "koa", HONO = "hono" } //#endregion //#region src/types.d.ts interface CopyOptions { rename?: Record; /** @deprecated use `ignore` */ skips?: ((name: string, isDir: boolean) => boolean)[]; ignore?: ((name: string, isDir: boolean) => boolean)[]; } type CliOptions = Record; interface PkgInfo { name: string; version: string; } //#endregion //#region src/utils.d.ts /** 判断测试文件(夹) */ declare const isTestFile: (name: string) => boolean; /** 基于 EOL 的可多换行函数 */ declare const eol: (n?: number) => string; /** 将字符串以空格分割为数组 */ declare const parseArgs: (args: string) => string[]; /** 将数组以空格拼接为字符串 */ declare const stringifyArgs: (args: string[]) => string; /** 去掉模板字符串首尾换行 */ declare const trimTemplate: (str: string) => string; /** 字符串按换行符分割并过滤 */ declare const splitLines: (text: string) => string[]; //#endregion //#region src/shell/types.d.ts interface BaseOptions { cwd?: string; env?: NodeJS.ProcessEnv; } interface ExtraOptions { /** 去掉结果的末尾空格 */ trimEnd?: boolean; /** 仅打印命令,不实际执行命令 */ dryRun?: boolean; /** log: 打印错误信息,返回 undefined; throw: 抛出错误; 未定义: 返回 undefined */ error?: "log" | "throw"; } type ShellResult = [T] extends [never] ? string | undefined : string | T; type ShellOpts = Omit & ExtraOptions & ({ fallback: TFallback; } | { fallback?: never; }); type SpawnAsyncOpts = ShellOpts; type SpawnSyncOpts = ShellOpts; type ExecAsyncOpts = ShellOpts; type ExecSyncOpts = ShellOpts; type ExecAsync = { (cmd: string, options?: ExecAsyncOpts): Promise>; (cmd: string, args: string[], options?: ExecAsyncOpts): Promise>; }; type ExecSync = { (cmd: string, options?: ExecSyncOpts): ShellResult; (cmd: string, args: string[], options?: ExecAsyncOpts): ShellResult; }; //#endregion //#region src/shell/spawn.d.ts /** 异步执行 `spawn` 获取字符串类型的结果 */ declare const spawnAsync: (cmd: string, args: string[], options?: SpawnAsyncOpts) => Promise>; /** 执行 `spawnSync` 获取字符串类型的结果 */ declare const spawnSyncRe: (cmd: string, args: string[], options?: SpawnSyncOpts) => ShellResult; //#endregion //#region src/shell/exec.d.ts /** 异步执行 `exec` 获取字符串类型的结果 */ declare const execAsync: ExecAsync; /** 执行 `execSync` 获取字符串类型的结果 */ declare const execSyncRe: ExecSync; //#endregion //#region src/shell/options.d.ts declare class Options { private global; private storage; private get stored(); configure(opts: Partial): void; resolve(opts?: Partial): Partial & T; run(opts: Partial, fn: () => R): R; } declare const shell: Options; //#endregion //#region src/shell.d.ts /** 基于 {@link spawnAsync} 实现 */ declare const runGit: (args: string[], options?: SpawnAsyncOpts) => Promise; /** 基于 {@link spawnSyncRe} 实现 */ declare const runGitSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** 基于 {@link execAsync} 实现 */ declare const runNpm: (args: string[], options?: ExecAsyncOpts) => Promise; /** 基于 {@link execSyncRe} 实现 */ declare const runNpmSync: (args: string[], options?: ExecSyncOpts) => string | undefined; /** 基于 {@link spawnAsync} 实现 */ declare const runNode: (args: string[], options?: SpawnAsyncOpts) => Promise; /** 基于 {@link spawnSyncRe} 实现 */ declare const runNodeSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** 支持所有支持 `--version` 命令的脚本查看版本 */ declare const checkVersion: (cmd: string) => Promise; /** {@link checkVersion} 的同步版本 */ declare const checkVersionSync: (cmd: string) => string | undefined; //#endregion //#region src/join-url.d.ts declare function joinUrl(...args: string[]): string; declare function joinUrl(input: readonly string[]): string; //#endregion //#region src/git/add.d.ts /** * 暂存所有文件 * @defaults `git add --all` */ declare const gitAddAll: (args?: string[]) => Promise; /** * 暂存已追踪文件 * @defaults `git add --update` */ declare const gitAddTracked: (args?: string[]) => Promise; //#endregion //#region src/git/branch.d.ts /** * 获取当前分支 * @defaults `git branch --show-current` * */ declare const gitBranchCurrent: () => Promise; /** * 重命名本地分支 * @defaults `git branch -m ` */ declare const gitBranchMove: (oldName: string, newName: string) => Promise; /** * 重命名本地分支(强制) * @defaults `git branch -M ` */ declare const gitBranchMoveForce: (oldName: string, newName: string) => Promise; /** * 删除本地分支 * @defaults `git branch -d ` */ declare const gitBranchDelete: (branch: string) => Promise; /** * 删除本地分支(强制) * @defaults `git branch -D ` */ declare const gitBranchDeleteForce: (branch: string) => Promise; /** 获取所有分支 */ declare const getLocalBranches: () => Promise; declare const getRemoteBranches: () => Promise; //#endregion //#region src/git/checkout.d.ts /** * 创建并签出 * @defaults `git checkout -b ` * @fallback `git checkout ` * @see * ``` * git branch * git checkout * ``` */ declare const gitCheckoutBranch: (branch: string, startpoint?: string) => Promise; /** * 强制创建/重置并签出 * @defaults `git checkout -B ` * @see * ``` * git checkout * git branch -f HEAD * git checkout * ``` */ declare const gitCheckoutBranchForce: (branch: string, startpoint?: string) => Promise; /** * 创建孤儿分支 * @defaults `git checkout --orphan ` */ declare const gitCheckoutBranchOrphan: (branch: string, startpoint?: string) => Promise; //#endregion //#region src/git/commit.d.ts /** * 提交 * @defaults `git commit --message message ` */ declare const gitCommitMessage: (message: string, args?: string[]) => Promise; /** * 空内容提交 * @defaults `git commit --message message --allow-empty ` */ declare const gitCommitAllowEmpty: (message: string, args?: string[]) => Promise; /** * 修正提交 * @defaults `git commit --message message --amend ` */ declare const gitCommitAmend: (message: string, args?: string[]) => Promise; /** * 修正提交 保留信息 * @defaults `git commit --amend --no-edit ` */ declare const gitCommitAmendNoEdit: (args?: string[]) => Promise; //#endregion //#region src/git/config.d.ts /** * 获取指定的 git 配置 * @defaults `git config [--global] --get ` */ declare const gitConfigGet: (key: string, global?: boolean) => Promise; /** * 指定的 git 配置 * @defaults `git config [--global] ` */ declare const gitConfigSet: (key: string, value: string, global?: boolean) => Promise; /** * 移除指定配置 * @defaults `git config [--global] --unset ` */ declare const gitConfigUnset: (key: string, global?: boolean) => Promise; /** * 配置列表 * @defaults `git config [--global] --list` */ declare const gitConfigList: (global?: boolean) => Promise; //#endregion //#region src/git/push.d.ts /** * 推送 tag 到远程 * @defaults `git push refs/tags/ ` */ declare const gitPushTag: (remote: string, tag: string, args?: string[]) => Promise; /** * 推送分支到远程 * 自动处理 upstream * @defaults `git push [--set-upstream] ` */ declare const gitPushBranch: (remote: string, branch: string, args?: string[]) => Promise; /** * 删除远程引用(分支、tag) * @defaults `git push --delete ` */ declare const gitPushDeleteRef: (remote: string, ref: string, args?: string[]) => Promise; //#endregion //#region src/git/remote.d.ts /** * 获取 url * @defaults `git remote get-url ` */ declare const gitRemoteGetUrl: (args: string[]) => Promise; /** * 设置 url * @defaults `git remote set-url ` */ declare const gitRemoteSetUrl: (args: string[]) => Promise; /** * 添加远程 * @defaults `git remote add ` */ declare const gitRemoteAdd: (name: string, url: string) => Promise; /** * 重命名远程 * @defaults `git remote rename ` */ declare const gitRemoteRename: (oldName: string, newName: string) => Promise; /** * 移除远程 * @defaults `git remote remove ` */ declare const gitRemoteRemove: (name: string) => Promise; /** 获取关联的所有远程 */ declare const getRemoteNames: () => Promise; /** 获取远程地址 */ declare const getRemoteUrl: (remote: string) => Promise; /** 获取所有远程 */ declare const getRemoteList: () => Promise<{ name: string; url?: string; }[]>; //#endregion //#region src/git/tag.d.ts /** * 创建 lightweight tag * @defaults `git tag ` */ declare const gitTagLightweight: (tag: string, args?: string[]) => Promise; /** * 创建 annotated * @defaults `git tag -annotate -message ` */ declare const gitTagAnnotated: (tag: string, message?: string, args?: string[]) => Promise; /** * 删除本地 tag * @defaults `git tag --delete ` */ declare const gitTagDelete: (tag: string, args?: string[]) => Promise; /** {@link gitTagDelete} 的同步版本 */ declare const gitTagDeleteSync: (tag: string, args?: string[]) => void; type SortKey = "v:refname" | "creatordate"; type GitSort = SortKey | `-${SortKey}`; declare enum GitSorter { NAME_ASC = "v:refname", NAME_DESC = "-v:refname", DATE_ASC = "creatordate", DATE_DESC = "-creatordate" } /** * 获取本地所有 tag * @defaults `git for-each-ref refs/tags/ --format "%(refname:short)" --sort * --exclude refs/tags/ --count ` */ declare const getLocalTags: (match?: string, exclude?: string | string[], sort?: GitSort, count?: number) => Promise; /** * 获取远程所有 tag * @defaults `git ls-remote --tags --refs --sort ` */ declare const getRemoteTags: (remote?: string, sort?: GitSort) => Promise; /** 获取最新 tag */ declare const getLatestTag: (match?: string, exclude?: string | string[]) => Promise; /** 获取上一个 tag */ declare const getPreviousTag: (tag: string, match?: string, exclude?: string | string[]) => Promise; //#endregion //#region src/git/undo.revert.d.ts /** * 安全撤销一个已提交(并可能已 push)的 commit * @defaults `git revert ` */ declare const gitRevertCommit: (hash: string) => Promise; //#endregion //#region src/git/misc.d.ts /** 初始化裸仓库,模拟远程仓库 */ declare const initBareRepo: (dir: string) => Promise; /** 初始化仓库 */ declare const initRepo: (branch?: string) => Promise; /** 判断指定目录是否是 git 仓库 */ declare const isGitRepo: (dir?: string) => Promise; /** 判断指定目录是否是 git 裸仓库 */ declare const isGitBareRepo: (dir?: string) => Promise; /** 判断工作区是否干净 */ declare const isWorkingTreeClean: () => Promise; /** * 判断当前分支是否已设置 upstream * @defaults `git rev-parse --abbrev-ref --symbolic-full-name "@{u}"` */ declare const hasUpstream: (branch?: string) => Promise; /** * 获取完整 hash * @defaults `git rev-parse ` */ declare const getFullHash: (rev: string) => Promise; /** * 获取短 hash * @defaults `git rev-parse --short ` */ declare const getShortHash: (rev: string) => Promise; /** * 提取所有分支 * @defaults `git fetch --all --prune` */ declare const fetchAllPrune: () => Promise; /** * 获取当前工作区状态 * @defaults `git status --short --untracked-files=no` */ declare const getShortStatus: () => Promise; /** * 为 git status / changeset 输出添加颜色 * * M -> 黄色(修改) * A -> 绿色(新增) * D -> 红色(删除) * @param {string} log `git status --short` 输出 * @returns {string} */ declare const coloredStatus: (log: string) => string; /** * 计算 changelog 的 commit 范围 * @param {boolean} isIncrement 是否为版本递增发布 * @param {string} match tag match * @param {string} exclude tag exclude * @returns {Promise<{from: string, to: string}>} */ declare const resolveChangelogRange: (isIncrement?: boolean, match?: string, exclude?: string | string[]) => Promise<{ from: string; to: string; }>; /** * 获取指定范围内的 commit 日志 * @defaults `git log --pretty=format:"* %s (%h)" ... -- ` */ declare const getLogSince: (from?: string, to?: string, scope?: string) => Promise; /** 判断字符串是否为合法 remote 名称 */ declare const isRemoteName: (remote: string) => Promise; /** 统计自 tag 以来的提交数量 */ declare const countCommitsSince: (tag?: string) => Promise; /** * 将 HEAD 指向指定分支(不会切换工作区) */ declare const gitSetHeadBranch: (branch: string) => Promise; /** 删除当前分支引用 */ declare const gitDeleteHeadRef: () => Promise; /** * 创建一个没有任何提交的分支状态。 */ declare const createUnbornBranch: (branch: string) => Promise; //#endregion //#region src/git/undo.reset.d.ts declare const headArg: (count?: number) => string; /** * 撤销最近的 commit(移动 HEAD + 取消暂存) * - 暂存区被重置到目标 commit * - 未提交修改保持不变 * @defaults `git reset --mixed HEAD~` */ declare const gitResetMixed: (count?: number) => Promise; /** * 撤销最近的 commit(完全重置) * - 暂存区 + 工作区都会被重置到目标 commit * - 未提交修改会丢失 * @defaults `git reset --hard HEAD~` */ declare const gitResetHard: (count?: number) => Promise; /** * 撤销最近的 commit(仅移动 HEAD) * - 暂存区保持不变 * - 未提交修改保持不变 * @defaults `git reset --soft HEAD~` */ declare const gitResetSoft: (count?: number) => Promise; /** * 撤销最近的 commit(安全重置) * - 行为类似 --hard * - 若会覆盖工作区未提交修改则直接失败 * @defaults `git reset --keep HEAD~` */ declare const gitResetKeep: (count?: number) => Promise; /** {@link gitResetMixed} 的同步版本 */ declare const gitResetMixedSync: (count?: number) => void; /** {@link gitResetHard} 的同步版本 */ declare const gitResetHardSync: (count?: number) => void; /** {@link gitResetSoft} 的同步版本 */ declare const gitResetSoftSync: (count?: number) => void; /** {@link gitResetKeep} 的同步版本 */ declare const gitResetKeepSync: (count?: number) => void; //#endregion //#region src/git/undo.restore.d.ts /** * 用【暂存区】覆盖【工作区】单个文件 * - 用 Index 覆盖 Working Tree * - 不影响暂存区(Index) * @defaults `git restore --worktree ` */ declare const gitRestoreFile: (file: string) => Promise; /** * 用【暂存区】覆盖【工作区】所有文件 * - 用 Index 覆盖 Working Tree * - 不影响暂存区(Index) * @defaults `git --worktree restore .` */ declare const gitRestoreAll: () => Promise; /** * 用 指定 source 中的文件内容覆盖【工作区】文件 * - 仅修改 Working Tree * - 不影响暂存区(Index) * - 不会改变提交历史(HEAD) * @defaults `git restore --worktree --source ` * @see source = `git rev-parse ` */ declare const gitRestoreWorktreeFileFrom: (source: string, file: string) => Promise; /** * 用指定 source 中的文件内容覆盖【工作区】所有文件 * - 仅修改 Working Tree * - 不影响暂存区(Index) * - 不会改变提交历史(HEAD) * @defaults `git restore --worktree --source .` * @see source = `git rev-parse ` */ declare const gitRestoreWorktreeAllFrom: (source: string) => Promise; /** * 用指定 source 覆盖【暂存区】中的文件 * - 用 source 覆盖 Index * - 不影响工作区(Working Tree) * - 不会改变提交历史(HEAD) * @defaults `git restore --staged --source ` * @see source = `git rev-parse ` */ declare const gitRestoreIndexFileFrom: (source: string, file: string) => Promise; /** * 用指定 source 覆盖整个【暂存区】 * - 用 source 覆盖 Index * - 不影响工作区(Working Tree) * - 不会改变提交历史(HEAD) * @defaults `git restore --staged --source .` * @see source = `git rev-parse ` */ declare const gitRestoreIndexAllFrom: (source: string) => Promise; /** * 用指定 source 覆盖指定文件(暂存区 + 工作区) * - 将 Index 和 Working Tree 恢复到 source 状态 * - 不会移动 HEAD * - 不会改变提交历史 * @defaults `git restore --staged --worktree --source ` * @see source = `git rev-parse ` */ declare const gitRestoreFileFrom: (source: string, file: string) => Promise; /** * 用指定 source 覆盖所有文件(暂存区 + 工作区) * - 将 Index 和 Working Tree 恢复到 source 状态 * - 不会移动 HEAD * - 不会改变提交历史 * @defaults `git restore --staged --worktree --source .` * @see source = `git rev-parse ` */ declare const gitRestoreAllFrom: (source: string) => Promise; //#endregion //#region src/git/undo.unstaged.d.ts /** * 取消单个文件的暂存状态 * - 用 HEAD 覆盖暂存区(Index) * - 不影响工作区(Working Tree) * - 等价于撤销 git add * @defaults `git restore --staged ` */ declare const gitUnstageFile: (file: string) => Promise; /** * 取消所有文件的暂存状态 * - 用 HEAD 覆盖暂存区(Index) * - 不影响工作区(Working Tree) * - 等价于撤销所有 git add * @defaults `git restore --staged .` */ declare const gitUnstageAll: () => Promise; //#endregion //#region src/git/undo.discard.d.ts /** * 丢弃指定文件的所有修改(暂存区 + 工作区) * - 强制将文件恢复到 HEAD 状态 * - 同时重置 Index 和 Working Tree * - 不会改变提交历史(HEAD) * @defaults `git restore --source=HEAD --staged --worktree ` */ declare const gitDiscardFile: (file: string) => Promise; /** * 丢弃所有文件的所有修改(暂存区 + 工作区) * - 强制将整个工作区恢复到 HEAD 状态 * - 行为等价于 git reset --hard HEAD(按文件粒度) * - 不会删除未跟踪文件(untracked files) * @defaults `git restore --source=HEAD --staged --worktree .` */ declare const gitDiscardAll: () => Promise; //#endregion //#region src/git/raw.d.ts /** * 引用解析操作 * @defaults `git rev-parse ` */ declare const gitRevParse: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitRevParse} 的同步版本 */ declare const gitRevParseSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 提交遍历操作 * @defaults `git rev-list ` */ declare const gitRevList: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitRevList} 的同步版本 */ declare const gitRevListSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 引用遍历操作 * @defaults `git for-each-ref ` */ declare const gitForEachRef: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitForEachRef} 的同步版本 */ declare const gitForEachRefSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 暂存操作 * @defaults `git add ` */ declare const gitAdd: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitAdd} 的同步版本 */ declare const gitAddSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 分支操作 * @defaults `git branch ` */ declare const gitBranch: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitBranch} 的同步版本 */ declare const gitBranchSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 迁出操作 * @defaults `git checkout ` */ declare const gitCheckout: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitCheckout} 的同步版本 */ declare const gitCheckoutSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 提交操作 * @defaults `git commit ` */ declare const gitCommit: (args?: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitCommit} 的同步版本 */ declare const gitCommitSync: (args?: string[], options?: SpawnSyncOpts) => string | undefined; /** * 配置操作 * @defaults `git config ` */ declare const gitConfig: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitConfig} 的同步版本 */ declare const gitConfigSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 符号引用操作 * @defaults `git symbolic-ref ` */ declare const gitSymbolicRef: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitSymbolicRef} 的同步版本 */ declare const gitSymbolicRefSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 引用更新操作 * @defaults `git update-ref ` */ declare const gitUpdateRef: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitUpdateRef} 的同步版本 */ declare const gitUpdateRefSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 推送操作 * @defaults `git push ` */ declare const gitPush: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitPush} 的同步版本 */ declare const gitPushSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 远程操作 * @defaults `git remote ` */ declare const gitRemote: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitRemote} 的同步版本 */ declare const gitRemoteSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * tag 操作 * @defaults `git tag ` */ declare const gitTag: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitTag} 的同步版本 */ declare const gitTagSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 重置操作 * @defaults `git reset ` */ declare const gitReset: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitReset} 的同步版本 */ declare const gitResetSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 恢复操作 * @defaults `git restore ` */ declare const gitRestore: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitRestore} 的同步版本 */ declare const gitRestoreSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 回退操作 * @defaults `git revert ` */ declare const gitRevert: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitRevert} 的同步版本 */ declare const gitRevertSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 远程引用查询操作 * @defaults `git ls-remote ` */ declare const gitLsRemote: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitLsRemote} 的同步版本 */ declare const gitLsRemoteSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 状态查询操作 * @defaults `git status ` */ declare const gitStatus: (args?: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitStatus} 的同步版本 */ declare const gitStatusSync: (args?: string[], options?: SpawnSyncOpts) => string | undefined; /** * 对象查看操作 * @defaults `git show ` */ declare const gitShow: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitShow} 的同步版本 */ declare const gitShowSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 差异比较操作 * @defaults `git diff ` */ declare const gitDiff: (args?: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitDiff} 的同步版本 */ declare const gitDiffSync: (args?: string[], options?: SpawnSyncOpts) => string | undefined; /** * 暂存区保存操作 * @defaults `git stash ` */ declare const gitStash: (args?: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitStash} 的同步版本 */ declare const gitStashSync: (args?: string[], options?: SpawnSyncOpts) => string | undefined; /** * 删除文件操作 * @defaults `git rm ` */ declare const gitRm: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitRm} 的同步版本 */ declare const gitRmSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 移动文件操作 * @defaults `git mv ` */ declare const gitMv: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitMv} 的同步版本 */ declare const gitMvSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 对象内容操作 * @defaults `git cat-file ` */ declare const gitCatFile: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitCatFile} 的同步版本 */ declare const gitCatFileSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 日志查询操作 * @defaults `git log ` */ declare const gitLog: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitLog} 的同步版本 */ declare const gitLogSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 仓库初始化操作 * @defaults `git init ` */ declare const gitInit: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitInit} 的同步版本 */ declare const gitInitSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; /** * 获取远程更新操作 * @defaults `git fetch ` */ declare const gitFetch: (args: string[], options?: SpawnAsyncOpts) => Promise; /** {@link gitFetch} 的同步版本 */ declare const gitFetchSync: (args: string[], options?: SpawnSyncOpts) => string | undefined; //#endregion //#region src/npm.d.ts declare const DEFAULT_TAG: string; declare const DEFAULT_ACCESS: string; declare const DEFAULT_REGISTRY: string; declare const accessArg: (access?: string) => string[]; declare const registryArg: (registry?: string) => string[]; declare const tagArg: (tag?: string) => string[]; /** * 获取 npm registry * @param {string} pkgDir * @returns {Promise} * @defaults https://registry.npmjs.org/ */ declare const getRegistry: (pkgDir: string) => Promise; /** * 获取 publish access * @param {string} pkgDir * @returns {Promise} * @defaults scoped: restricted; unscoped: public */ declare const getAccess: (pkgDir: string) => Promise<"restricted" | "public">; /** * 检查与仓库的连接 * @param {string} registry * @returns {Promise} * @defaults npm ping --registry https://registry.npmjs.org/ */ declare const pingRegistry: (registry?: string) => Promise; /** * 获取已登录用户 * @param {string} registry * @returns {Promise} * @defaults npm whoami --registry https://registry.npmjs.org/ */ declare const getAuthenticatedUser: (registry?: string) => Promise; /** * 用户是否拥有写入权限 * @param {string} pkg * @param {string} user * @param {string} registry * @returns {Promise} * @defaults npm access list collaborators --json * npm access ls-collaborators --json */ declare const hasWriteAccess: (pkg: string, user: string, registry?: string) => Promise; /** * 获取指定包的版本 * @param {string} pkg pkgName pkgName@tag * @param {string} registry * @returns {Promise} * @defaults npm view version */ declare const getPublishedVersion: (pkg: string, registry?: string) => Promise; /** * 获取所有已发布的 dist-tags * @param {string} pkg * @param {string} registry * @returns {Promise} * @defaults npm view dist-tags --json */ declare const getDistTags: (pkg: string, registry?: string) => Promise; /** * 更新包版本号 * @param {string} version * @param {string[]} args * @param {string} cwd * @returns {Promise} * @defaults npm version --workspaces=false --no-git-tag-version --allow-same-version */ declare const bumpPackageVersion: (version: string, args?: string[], cwd?: string) => Promise; /** * 发布 * @param {{access?: string, registry?: string, tag?: string, args?: string[], cwd?: string}} options * @returns {Promise} * @defaults npm publish --tag latest --access public --registry https://registry.npmjs.org/ --workspaces=false */ declare const publishPackage: (options?: { access?: string; registry?: string; tag?: string; args?: string[]; cwd?: string; }) => Promise; /** 解析发布的 dist-tag */ declare const resolvePublishTag: (pkgName: string, version: string) => Promise; /** OTP 错误 */ declare const isOtpError: (err: unknown) => boolean; /** 发布是否可以成功 */ declare const canPublish: (registry?: string) => Promise; /** 生成 npm 包指定版本的详情页地址 */ declare const getPackageUrl: (pkg: string, version: string) => string; //#endregion //#region src/version.d.ts interface ParsedVersion { version?: string; isPrerelease?: boolean; preId?: string; preBase?: string; } /** 是否是预发行版本 */ declare const isPrerelease: (version: string) => boolean; /** 是否是合法版本号 */ declare const isValidVersion: (version: string) => boolean; /** 清理版本号 */ declare const cleanVersion: (version: string) => string; /** 解析版本号 */ declare const parseVersion: (raw: string) => ParsedVersion; //#endregion //#region src/package.d.ts interface PackageJson { name: string; version: string; private?: boolean; publishConfig?: { access?: string; registry?: string; [key: string]: any; }; [key: string]: any; } interface PackageContext { pkg: PackageJson; pkgDir: string; pkgPath: string; } declare const isScopedPackageName: (name: string) => boolean; declare const isValidPackageName: (name: string) => boolean; declare const toValidPackageName: (name: string) => string; declare const toValidProjectName: (name: string) => string; declare const getPackageInfo: (pkgName: string, getPkgDir: (pkg: string) => string) => PackageContext; /** * 通过包管理器执行脚本时生效 * @defaults UserAgent: `process.env.npm_config_user_agent` */ declare const pkgFromUserAgent: (userAgent?: string) => { name: string; version: string; } | undefined; //#endregion //#region src/file-dir.d.ts declare const emptyDir: (dir: string, ignore?: string[]) => Promise; declare const isEmpty: (path: string, ignore?: string[]) => Promise; declare const readSubDirs: (source: string, ignore?: string[]) => Promise; declare const copyDirAsync: (src: string, dest: string, options?: { rename?: Record; /** @deprecated use `ignore` */ skips?: ((name: string, isDir: boolean) => boolean)[]; ignore?: ((name: string, isDir: boolean) => boolean)[]; }) => Promise; declare const editFile: (file: string, callback: (content: string) => Promise | string) => Promise; declare const editJsonFile: >(file: string, callback: (json: T) => Promise | void) => Promise; declare const readJsonFile: >(file: string) => T; //#endregion //#region src/github.d.ts /** 解析 Github 链接获取 owner 和 repo */ declare const parseGitHubRepo: (url: string) => string[]; /** 生成 GitHub 仓库主页地址 */ declare const getGithubUrl: (owner: string, repo: string) => string; /** 生成 GitHub Release 页面地址 */ declare const getGithubReleaseUrl: (owner: string, repo: string, tag: string) => string; //#endregion export { BaseOptions, CliOptions, ConfirmResult, CopyOptions, DEFAULT_ACCESS, DEFAULT_REGISTRY, DEFAULT_TAG, ExecAsync, ExecAsyncOpts, ExecSync, ExecSyncOpts, ExtraOptions, GitSort, GitSorter, HttpLibrary, PackageContext, PackageJson, ParsedVersion, PkgInfo, PkgManager, ShellOpts, ShellResult, SortKey, SpawnAsyncOpts, SpawnSyncOpts, YesOrNo, accessArg, bumpPackageVersion, canPublish, checkVersion, checkVersionSync, cleanVersion, coloredStatus, copyDirAsync, countCommitsSince, createUnbornBranch, editFile, editJsonFile, emptyDir, eol, execAsync, execSyncRe, execSyncRe as execSyncWithString, fetchAllPrune, getAccess, getAuthenticatedUser, getDistTags, getFullHash, getGithubReleaseUrl, getGithubUrl, getLatestTag, getLocalBranches, getLocalTags, getLogSince, getPackageInfo, getPackageUrl, getPreviousTag, getPublishedVersion, getRegistry, getRemoteBranches, getRemoteList, getRemoteNames, getRemoteTags, getRemoteUrl, getShortHash, getShortStatus, gitAdd, gitAddAll, gitAddSync, gitAddTracked, gitBranch, gitBranchCurrent, gitBranchDelete, gitBranchDeleteForce, gitBranchMove, gitBranchMoveForce, gitBranchSync, gitCatFile, gitCatFileSync, gitCheckout, gitCheckoutBranch, gitCheckoutBranchForce, gitCheckoutBranchOrphan, gitCheckoutSync, gitCommit, gitCommitAllowEmpty, gitCommitAmend, gitCommitAmendNoEdit, gitCommitMessage, gitCommitSync, gitConfig, gitConfigGet, gitConfigList, gitConfigSet, gitConfigSync, gitConfigUnset, gitDeleteHeadRef, gitDiff, gitDiffSync, gitDiscardAll, gitDiscardFile, gitFetch, gitFetchSync, gitForEachRef, gitForEachRefSync, gitInit, gitInitSync, gitLog, gitLogSync, gitLsRemote, gitLsRemoteSync, gitMv, gitMvSync, gitPush, gitPushBranch, gitPushDeleteRef, gitPushSync, gitPushTag, gitRemote, gitRemoteAdd, gitRemoteGetUrl, gitRemoteRemove, gitRemoteRename, gitRemoteSetUrl, gitRemoteSync, gitReset, gitResetHard, gitResetHardSync, gitResetKeep, gitResetKeepSync, gitResetMixed, gitResetMixedSync, gitResetSoft, gitResetSoftSync, gitResetSync, gitRestore, gitRestoreAll, gitRestoreAllFrom, gitRestoreFile, gitRestoreFileFrom, gitRestoreIndexAllFrom, gitRestoreIndexFileFrom, gitRestoreSync, gitRestoreWorktreeAllFrom, gitRestoreWorktreeFileFrom, gitRevList, gitRevListSync, gitRevParse, gitRevParseSync, gitRevert, gitRevertCommit, gitRevertSync, gitRm, gitRmSync, gitSetHeadBranch, gitShow, gitShowSync, gitStash, gitStashSync, gitStatus, gitStatusSync, gitSymbolicRef, gitSymbolicRefSync, gitTag, gitTagAnnotated, gitTagDelete, gitTagDeleteSync, gitTagLightweight, gitTagSync, gitUnstageAll, gitUnstageFile, gitUpdateRef, gitUpdateRefSync, hasUpstream, hasWriteAccess, headArg, initBareRepo, initRepo, isEmpty, isGitBareRepo, isGitRepo, isOtpError, isPrerelease, isRemoteName, isScopedPackageName, isTestFile, isValidPackageName, isValidVersion, isWorkingTreeClean, joinUrl, parseArgs, parseGitHubRepo, parseVersion, pingRegistry, pkgFromUserAgent, publishPackage, readJsonFile, readSubDirs, registryArg, resolveChangelogRange, resolvePublishTag, runGit, runGitSync, runNode, runNodeSync, runNpm, runNpmSync, shell, spawnAsync, spawnSyncRe, spawnSyncRe as spawnSyncWithString, splitLines, stringifyArgs, tagArg, toValidPackageName, toValidProjectName, trimTemplate };