@ commercialtools- frontend/ create- mc- app
看看这个 文档 更多信息.
地方发展
此指南用于 内部开发者 想要在本地修改启动模板并测试更改而无需发布新版本.
如何运作
GitHub 寄存器中的 CLI 克隆模板( 不是您的本地文件系统) 。 这意味着您必须在本地测试前将模板更改推向 git 分支 .
先决条件
- 本地克隆仓库
pnpm已安装- Git 推动访问仓库
工作流程
1. 修改模板
编辑模板目录中的文件 :
# For custom applications
application-templates/starter/
application-templates/starter-typescript/
# For custom views
custom-views-templates/starter/
custom-views-templates/starter-typescript/
2. 向一个处提交和推动
git checkout -b my-template-changes # create a new branch
git add application-templates/starter/ # do this after you make changes
git commit -m "chore(templates): add welcome header to starter template"
git push origin my-template-changes # push the changes to the new branch
3. 与你的分行一起运行本地CLI
从寄存器根 :
NODE_ENV=test node packages/create-mc-app/bin/cli.js my-test-app \
--template starter \
--template-version my-template-changes # important: use the branch name you created
重要内容: 使用相对路径( 例如 ), my-test-app非绝对路径(例如, /Users/name/my-test-app) (中文(简体) ).
4. 校验您的更改
cd my-test-app # navigate to the new app
yarn start # verify your template changes are present
快速引用
# Complete workflow
git checkout -b template-updates # create a new branch
# ... make changes to application-templates/starter/ (e.g., add a welcome message) ...
git add application-templates/starter/ # do this after you make changes
git commit -m "chore(templates): update landing page styles"
git push origin template-updates # push the changes to the new branch
cd packages/create-mc-app
pnpm build
cd ../..
NODE_ENV=test node packages/create-mc-app/bin/cli.js test-project \
--template starter \
--template-version template-updates
cd test-project # navigate to the new app
yarn start # verify your template changes are present
关键点
- ✅ 必须推动更改到 git - 模板从 GitHub 复制,而不是从本地文件系统复制
- ✅ 使用相对路径 - 避免从绝对路径开始
/ - ✅ 使用
--template-version- 指定您的分支名称以测试更改 - ✅ 不需要 npm 发布 - 直接用树枝进行试验
- ✅ 合并前的测试 - 在合并到
main
解决问题
错误: “ 名称包含非法字符 ”
- 你在用一条绝对的道路 取而代之的是使用相对路径(例如,
my-app改为/Users/name/my-app(中文(简体) )
不反映变化的模板
- 确保您已经将您的更改推向了 Git 分支
- 校验
--template-version旗帜匹配您的分支名称