跳转到主要内容

scaffer

项目描述

Scaffer

另一个脚手架工具。这是真正做你所想的事情的工具。如果你不是一个阅读型的人,在YouTube上查看演示

与许多其他脚手架工具(如cookiecutter,angular schematics等)不同,这个

  • 允许使用可工作/可编译的代码作为模板。也就是说,你只需要更改实时代码中的符号,它仍然可以编译和/或运行。这样可以在不重新制作模板以发布的情况下自然修改和测试模板。
  • 不需要为您的模板创建任何配置。只需将文件放在某个地方并使用即可。
  • 允许使用您自己的repo/source树中的模板。
  • 允许树包含您想要的任何数量的模板。例如,与cookiecutter一样,您在每个repo中只能有一个模板。
  • 是图灵完备的!您可以将scaffer_init.py添加到您的模板中,例如从外部系统读取值到模板变量(例如,调用git以获取用户名,检查目录名以获取项目名称...)
  • 不是在Node中实现的。

逻辑

如果您想在模板中拥有模板变量'myvar',请在这些模板中表示它

ScfMyvar,scf-myvar,scf.myvar,scf_myvar,或其大写等效形式。它应该至少在词边界出现一次以被发现。例如,fooscfoeoevaroeuoeuoeu将不会被发现或替换,以避免在可能包含"scf"字符的随机字符串中触发逻辑。

带有所有支持的模板的文件示例,针对变量"prj"和"bar"

ScfPrjHello vs ScfBarWorld in pascalcase.
Lower kebab scf-prj-hello scf-bar-world
Lower snake scf_prj_hello scf_bar_world
Lower dotted scf.prj.hello scf.bar.world
Lower flat scfprj scfbar
Upper dotted SCF.PRJ.HELLO SCF.BAR.world
Upper kebab SCF-PRJ-HELLO SCF-BAR-world
Upper snake SCF_PRJ_HELLO SCF_BAR_world
Upper flat SCFPRJ SCFBAR

请注意,"flat"变体(如scfprjSCFPRJ)不能包含后缀,这是显而易见的原因。

当scaffer在您的模板中看到这些标记时,它将询问这些并执行智能搜索和替换操作,根据您在模板中使用的符号进行PascalCasing,kebab-casing,dot.separation和snake_casing。

用户在被提示时总会提供一种kebab-case格式的变体。因此,如果用户想要输出MyClass,她只需在提示时输入my-class。Scaffer将在替换位置知道如何发出正确的复合词格式。

模板变量也可以在文件和目录名称中使用,并按您期望的方式表现。

有关示例模板,请参阅 https://github.com/vivainio/scaffer-templates

模板发现

  1. 将您的文件放在某个地方。
  2. 在项目根目录或任何父目录中,放置指向包含您的模板的目录的scaffer.json文件
{
    "scaffer": ["my/templates", "some/other/templates"]
}

您还可以添加scaffer_template_urls并配置通过HTTP下载的模板。在这种情况下,模板必须是zip文件,由Scaffer自动下载并提取。

{
    "scaffer": ["my/templates", "some/other/templates"],
    "scaffer_template_urls": {
        "template_1": "http://localhost/1.zip",
        "template_2": "http://localhost/2.zip"
    }
}

如果您不想用新文件污染您的树,还可以在package.json中将该“scaffer”键放入其中。

安装

pip install scaffer

用法

usage: scaffer [-h] {barrel,gitignore,setup,g,add} ...

positional arguments:
  {barrel,gitignore,setup,g,add}
    barrel              Create index.tx for current directory
    gitignore           Create .gitignore file
    g                   Generate code from named or downloaded template
    add                 Add current directory as template root in user global
                        scaffer.json

$ scaffer g -h
usage: scaffer g [-h] [-v variable=value [variable=value ...]] [-f] [--dry]
                 [template]

positional arguments:
  template              Template to generate or a URL to template zip package

optional arguments:
  -h, --help            show this help message and exit
  -v variable=value [variable=value ...]
                        Give value to variable
  -f                    Overwrite files if needed
  --dry                 Dry run, do not create files

许可协议

MIT。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分发

scaffer-3.0.tar.gz (7.9 kB 查看哈希值)

上传时间

构建分发

scaffer-3.0-py3-none-any.whl (8.2 kB 查看哈希值)

上传时间 Python 3

支持者:

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页