feat(czdev): 新增 czdev new 从模板脚手架(不绑定 commit) - #17
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
需求是「把 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.in的Icon=一起改名。gh repo create my-app --template CardputerZero/Template现在也可用,两条路径都写进了 README 与三语 QUICKSTART。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.png、PATTERN "my-cool-app*.png"、APP_DISPLAY_NAME "My Cool App"均正确。非法包名与非空目录都有拦截,--no-git、--display-name生效。Made with Cursor