爱意满满的作品展示区。
riceball

花了一天时间开发了 templify: 一键生成可重用模板项目,保留原结构,智能参数替换

  •  
  •   riceball · Mar 31, 2025 · 1859 views
    This topic created in 407 days ago, the information mentioned may be changed or developed.

    我需要将现有项目快速转为模板项目,以及将模板项目一键原地转为项目目录,cookiecutter 之类完全满足不了我的需求。

    于是周末开始搞,准确的说是三天,第一天是找资料,确定选型,第二天开发,第三天测试。

    项目 Github 地址: https://github.com/isdk/templify.js

    scan 命令

    使用该命令templify scan,可以快速将项目转为模板。

    第一步,先把项目里的相关文件参数化,如package.json:

    {
      "name": "{{name}}",
      "description": "{{description}}",
      "version": "{{version}}",
      "author": "{{author}}",
      "bugs": "{{githubUrl}}/issues",
      "homepage": "{{githubUrl}}",
      "keywords": {{keywords | tojson}},
      ...
    }
    

    完毕后,在项目根目录下执行templify scan, 创建默认的参数配置:

    templify scan
    found template file: package.json
    Scanned. found 1 template files
    Saved ./.templify.yaml
    

    打开创建好的参数配置文件,进行修改调整:

    asciicast

    apply 命令

    直接快速应用模板仓库为项目:

    asciicast

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5691 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 07:58 · PVG 15:58 · LAX 00:58 · JFK 03:58
    ♥ Do have faith in what you're doing.