# @cactuslab/update-template 中文文档

规范地址：https://npmcn.com/package/%40cactuslab/update-template/

版本：2\.1\.0
npm 元数据更新时间：2022-04-04T21:28:42.263Z
中文译文更新时间：2026-11-08T23:25:30.122Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40cactuslab/update-template
原文对照：https://npmcn.com/package/%40cactuslab/update-template/?lang=original
项目主页：https://github.com/karlvr/update-template#readme
源码仓库：https://github.com/karlvr/update-template

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：29.5 kB，12 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：6 个
- 首次发布：2021-03-21T22:28:17.684Z
- 最新版本发布：2021-04-26T09:39:18.402Z
- 近 30 天下载量：2184（2026-10-09 至 2026-11-07，npm 官方下载统计）
- 已发布版本数：4（近 12 个月 0 个）

## 中文简介

用 GitHub 或本地模板创建的易更新重置程序

## 安装

```sh
npm install @cactuslab/update-template
```

也可以使用：`pnpm add @cactuslab/update-template`、`yarn add @cactuslab/update-template`、`bun add @cactuslab/update-template`

## README

# QQ 更新模板

如果您使用模板创建了寄存器( 见 [从模板创建寄存器](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template) 在"GitHub"上,在添加新功能时,可能很难"更新"模板,因为它不是一个分叉. 这个包可以修复它.

## 开始吧

### 使用模板

如果您的模板是 git repostiroy, 您可以使用原始模板 repo 的 URL 安装或更新 :

```bash
npx update-template https://github.com/user/repo
```

或者如果您的 repo 是基于本地目录中的模板:

```bash
npx update-template ./templates/my-template
```

您也可以指定多个模板,并将依次应用.

```bash
npx update-template ./templates/my-template1 ./templates/my-template2
```

A 类 `.update-template-changes.json` 将创建文件,以存储由“% 1” 作出的更改 模板,用于重运行时 `update-template` 模板添加的任何文件或依赖等, 但那些已经不在模板中,将被删除.

### 创建模板

如果你正在建立一个模板存储器,请添加 `update-template` 作为依附关系:

```bash
npm install @cactuslab/update-template
```

然后,创建一个 `.templaterc.json` 包含您想要覆盖的文件列表的文件 :

```json
{
  "files": ["src/**/*.js"]
}
```

最后,将更新的脚本添加到您的 `package.json` 使用您仓库的 URL :

```json
{
  "scripts": {
    "update-template": "update-template"
  }
}
```

当用户想要更新您的模板时, 可以运行 `npm run update-template`

如果你想同步您的 `package.json` (不更改类似软件包名称的密钥),您可以添加以下任何一项 要同步相应部分的密钥 `package.json`数字 :

```json
{
  "package": {
    "engines": true,
        "dependencies": true,
        "devDependencies": true,
        "optionalDependencies": true,
        "peerDependencies": true,
        "scripts": true
  }
}
```

## 发展

构建类型脚本 :

```bash
npm run build
```

## 许可证

[麻省理工学院](https://npmcn.com/package/%40cactuslab/update-template/LICENSE) © [科伊语Name](https://koj.co/)

[![Koj](https://kojcdn.com/v1598284251/website-v2/koj-github-footer_m089ze.svg)](https://koj.co/)

开源项目 [科伊语Name](https://koj.co/)。 。 。 .  
[用风格装修你的家,低至每月175瑞士法郎 –](https://koj.co/)

## 常见问题

### @cactuslab/update-template 是什么？

用 GitHub 或本地模板创建的易更新重置程序

### 如何安装 @cactuslab/update-template？

在项目目录运行 npm install @cactuslab/update-template，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 update-template，可以用 npx update-template 直接运行。

### @cactuslab/update-template 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @cactuslab/update-template 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @cactuslab/update-template 可以商用吗？

@cactuslab/update-template 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @cactuslab/update-template 的下载量有多少？

根据 npm 官方下载统计，@cactuslab/update-template 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,184 次，日均约 73 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @cactuslab/update-template 还在维护吗？

最新版本 2\.1\.0 发布于 2021/04/26（5 年前）；至今共发布 4 个版本，其中过去 12 个月发布了 0 个；首次发布于 2021/03/22。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

