@cactuslab/update-template

中文文档
2.1.0发布于 2021/04/26MITTypeScriptCommonJS近 30 天下载 2184

Easily update repos created with GitHub or local templates

原始使用文档
文档目录5 节
  1. ⭐ Get started
  2. Using a template
  3. Creating a template
  4. 👩‍💻 Development
  5. 📄 License

📠 Update Template

If you've created a repository using a template (see Creating a repository from a template on GitHub), it can be hard to "update" the template when new features are added, since it's not a fork. This package fixes that.

⭐ Get started

Using a template

If your template is a git repostiroy, you can install or update it using the URL of the original template repo:

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

Or if your repo is based on a template in a local directory:

npx update-template ./templates/my-template

You can also specify multiple templates, and they will be applied sequentially.

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

A .update-template-changes.json file will be created to store the changes that have been made by the template(s), so that when you re-run update-template any files or dependencies etc added by the template, but that are no longer in the template, will be removed.

Creating a template

If you're building a template repository, add update-template as a dependency:

npm install @cactuslab/update-template

Then, create a .templaterc.json file with a list of files you'd like to overwrite:

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

Lastly, add an update script to your package.json with the URL of your repository:

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

When users want to update your template, they can run npm run update-template

If you want to sync your package.json (without changing keys like the package name), you can add any of the following keys to sync the corresponding parts of package.json:

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

👩‍💻 Development

Build TypeScript:

npm run build

📄 License

MIT © Koj

Koj

An open source project by Koj.
Furnish your home in style, for as low as CHF175/month →

版本与发布记录

@cactuslab/update-template 共发布 4 个版本,首次发布于 2021/03/22;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.1.0latest2021/04/265 年前
2.0.22021/03/225 年前
2.0.12021/03/225 年前
2.0.02021/03/225 年前

关于 @cactuslab/update-template 的常见问题

@cactuslab/update-template 是什么?

Easily update repos created with GitHub or local templates

如何安装 @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 和提交记录判断。