api2cli-publish-to-github
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePublish to GitHub
发布到GitHub
Push an api2cli-generated CLI (from ) to a new GitHub repository.
~/.cli/<app>-cli/将api2cli生成的CLI(来自)推送到新的GitHub仓库。
~/.cli/<app>-cli/Phase 1: Pre-flight
阶段1:前置检查
Auth
鉴权
Run . If not logged in, tell the user to run first. Stop and wait.
gh auth statusgh auth loginNote the GitHub username from the output (e.g. ).
Logged in to github.com account <username>运行。如果未登录,告知用户需要先运行。停止操作并等待用户完成。
gh auth statusgh auth login从输出结果中记录GitHub用户名(例如)。
Logged in to github.com account <username>Resolve the CLI
确定CLI对象
If the user didn't specify which CLI, check and ask which one. Read to get the package name.
~/.cli/package.json如果用户没有指定要处理的CLI,检查目录并询问用户选择目标CLI。读取文件获取包名。
~/.cli/package.jsonPhase 2: Prepare the repo
阶段2:准备仓库
From the CLI directory ():
~/.cli/<app>-cli/-
Ensureexists with at least:
.gitignorenode_modules/ dist/ -
Init or check git:
- If no : run
.git/git init && git add -A && git commit -m "Initial commit: <app>-cli" - If already a git repo: stage and commit any uncommitted changes.
- If no
-
Never commitor
node_modules/. If already tracked,dist/them and rewrite history so secrets in dependencies don't trigger GitHub push protection.git rm -r --cached
在CLI目录()下执行以下操作:
~/.cli/<app>-cli/-
确保文件存在,至少包含以下内容:
.gitignorenode_modules/ dist/ -
初始化或检查git状态:
- 如果不存在目录:运行
.git/git init && git add -A && git commit -m "Initial commit: <app>-cli" - 如果已经是git仓库:暂存并提交所有未提交的变更。
- 如果不存在
-
绝对不要提交或
node_modules/目录。 如果它们已经被跟踪,执行dist/命令移除它们并重写提交历史,避免依赖中的敏感信息触发GitHub推送保护。git rm -r --cached
Phase 3: Create the repo and push
阶段3:创建仓库并推送
bash
gh repo create <app>-cli --public --source=. --push --description "<description from package.json>"- If succeeds but push fails (e.g. push protection), fix the issue per Phase 2 and run
gh repo create.git push -u origin <branch> --force - If says "unable to add remote" (remote already exists), just push:
gh repo create.git push -u origin <branch> - If the repo name is taken, ask the user for an alternative name.
bash
gh repo create <app>-cli --public --source=. --push --description "<description from package.json>"- 如果执行成功但推送失败(例如触发推送保护),按照阶段2的要求修复问题后运行
gh repo create。git push -u origin <branch> --force - 如果提示“无法添加远程仓库”(远程仓库已存在),直接执行推送命令即可:
gh repo create。git push -u origin <branch> - 如果仓库名已被占用,询问用户提供备选名称。
Phase 3.5: Update README
阶段3.5:更新README
After pushing, check if the README contains in the install commands. If so, replace with the actual GitHub username and commit + push the fix.
<user>/<user>推送完成后,检查README中的安装命令是否包含占位符。如果存在,将替换为实际的GitHub用户名,提交并推送该修改。
<user>/<user>Phase 4: Done
阶段4:完成
Report:
- Repo URL:
https://github.com/<username>/<app>-cli - What was pushed (file count, branch name)
向用户反馈以下信息:
- 仓库地址:
https://github.com/<username>/<app>-cli - 推送内容说明:文件数量、分支名称
Do NOT
禁止操作
- Do not commit ,
node_modules/,dist/, or token files..env - Do not force-push to an existing repo with other contributors without asking.
- Do not change the git user config.
- 不要提交、
node_modules/、dist/或令牌文件。.env - 不要在未征得用户同意的情况下,强制推送到有其他贡献者的已有仓库。
- 不要修改git用户配置。