Skip to content

feat(czdev): 新增 czdev new 从模板脚手架(不绑定 commit) - #17

Merged
eggfly merged 1 commit into
mainfrom
feat/czdev-new
Jul 29, 2026
Merged

feat(czdev): 新增 czdev new 从模板脚手架(不绑定 commit)#17
eggfly merged 1 commit into
mainfrom
feat/czdev-new

Conversation

@eggfly

@eggfly eggfly commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

背景

需求是「把 Template 作为 submodule 引入,但不绑定某次 commit」。这在 Git 里做不到:submodule 的本质就是父仓库 tree 里的一个 gitlink(40 位 commit SHA),没有「浮动」选项——否则 git clone --recursive 不知道该 checkout 什么。

真正想要的效果是「永远从最新模板起步」,所以走脚手架路线而不是 submodule:AppBuilder 不记录任何模板 commit。

改动

  • czdev new <name>:浅克隆 CardputerZero/Template 的默认分支 → 丢掉模板历史(脚手架而非 fork) → 替换占位符 → git init + 首次提交(提交信息里记下模板 commit 供追溯,仅信息性,不是 pin)。
    参数:--dir / --template / --ref / --display-name / --no-git
  • 顺手修了一个真实的坑:模板的图标装进共享目录 /usr/share/APPLaunch/share/images/,都叫 template*.png。两个基于模板的 app 装到同一台设备会 dpkg 文件冲突。czdev new 会把图标连同 cm0-package.cmake 的 install glob、app.desktop.inIcon= 一起改名。
  • 同时把上游 Template 标记为 GitHub template repository,gh repo create my-app --template CardputerZero/Template 现在也可用,两条路径都写进了 README 与三语 QUICKSTART。
  • 指向上游组织仓库而非个人 fork(Harrison-Xu/Template 是 fork,会漂移)。

验证

czdev new my-cool-app 实跑:6 个文件替换、3 个图标改名、占位符零残留、无 upstream remote、单条初始提交;project(my-cool-app ...)#define APP_NAME "my-cool-app"Icon=share/images/my-cool-app.pngPATTERN "my-cool-app*.png"APP_DISPLAY_NAME "My Cool App" 均正确。非法包名与非空目录都有拦截,--no-git--display-name 生效。

Made with Cursor

A git submodule cannot float: it stores a gitlink (an exact commit SHA) in
the parent tree, so vendoring CardputerZero/Template as a submodule would
freeze every developer on one template commit and require a commit here for
every template update. Copy the branch tip at scaffold time instead, so no
template commit is recorded anywhere.

`czdev new <name>` shallow-clones the template's default branch, drops its
history (scaffold, not fork) and renames the per-app placeholders: the CMake
project name, the compiled-in APP_NAME, the launcher display name and the
icon files. The icons matter beyond cosmetics — they install into the shared
/usr/share/APPLaunch/share/images/, so two packages both shipping
template.png conflict at dpkg level.

The upstream template is now also marked as a GitHub template repository,
so `gh repo create --template CardputerZero/Template` is an equivalent
route; both are documented in the README and all three quickstarts.

Co-authored-by: Cursor <cursoragent@cursor.com>
@eggfly
eggfly merged commit e0d6ab0 into main Jul 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant