feat(cli): create develop, qa and main branches on project creation - #158
Open
fernandatoledo wants to merge 2 commits into
Open
feat(cli): create develop, qa and main branches on project creation#158fernandatoledo wants to merge 2 commits into
fernandatoledo wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
There is at least one correctness/robustness issue in the updated flow (un-awaited async calls and a new git-commit step that can fail on fresh Git setups) that can break project generation.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the project generator CLI to leave newly generated projects with an initialized Git repository, an initial commit, and a standardized branch layout (develop, qa, main) that matches the expected workflow/deploy setup.
Changes:
- Extend
execShellCommandto acceptexecoptions and forward them tochild_process.exec. - Move Git initialization to the end of
setupProject, create the initial commit, rename the current branch todevelop, and createqa/mainbranches.
File summaries
| File | Description |
|---|---|
cli/utils.js |
Adds support for passing exec options into execShellCommand. |
cli/setup-project.js |
Initializes Git at the end of setup, creates initial commit, and sets up develop/qa/main branches. |
Review details
Suppressed comments (1)
cli/utils.js:14
execShellCommandcallsreject(error)but then continues to callresolve(...)unconditionally. While the Promise will typically settle on the first call, this control flow is confusing and can mask errors; it should return immediately after rejecting (or use anelse).
exec(cmd, options, (error, stdout, stderr) => {
if (error) {
console.warn(error);
reject(error);
}
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+25
to
+29
| await execShellCommand('git add -A', options); | ||
| await execShellCommand( | ||
| 'git commit -m "chore: initial commit from Rootstrap React Native template"', | ||
| options, | ||
| ); |
Comment on lines
230
to
233
| removeUnrelatedFiles(); | ||
| await initializeProjectRepository(projectName); | ||
| updatePackageJson(projectName); | ||
| updateProjectConfig(projectName); | ||
| updateGitHubWorkflows(projectName); |
- fall back to a template git identity when user.name/user.email are not configured - drop async from synchronous setup helpers so errors reach the try/catch - return after reject in execShellCommand
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.
Jira board reference:
What does this do?
The generator already ran
git init, but left the repository with no commit and a single default branch. It now creates the initial commit and sets up the branch layout the ticket asks for: the current branch is renamed todevelop, andqaandmainare branched off it. The generated project ends with a clean working tree, three branches, anddevelopchecked out.The
git initstep also moved to the end ofsetupProject. It used to run before the CLI rewrotepackage.json,env.js, the README, the workflows and the agent docs, so an initial commit made there would have excluded every one of those changes.Why did you do this?
New projects started life with no commit at all, so the first thing every developer had to do was stage a few hundred files by hand and invent a branch structure. Doing it in the generator makes that consistent across projects and matches the branches the deploy workflows already expect.
Who/what does this impact?
cli/setup-project.jsandcli/utils.js— generator only, no app code.execShellCommandnow takes an optionaloptionsargument, forwarded toexec. Backwards compatible: every existing call site passes nothing. The new code uses{ cwd: projectName }instead ofcd ${projectName} && …, which avoids the interpolation issue flagged by Copilot in chore(cli): install rn-toolkit plugin on project creation #156.How did you test this?
Ran the generator against a fresh
masterclone and inspected the result: three branches (develop,qa,main),HEADondevelop, exactly one commit, and a clean working tree. Confirmed the commit contains the CLI's own edits —package.jsonin the generated project readsname: gitapp,version: 0.0.1,rsMetadata.templateVersion: 1.9.0.pnpm lintandpnpm type-checkpass.Notes:
developis left as the checked-out branch, so it becomes the default when the repo is first pushed. Setting it explicitly would needgh repo edit --default-branch developafter the remote exists — happy to add that as a documented follow-up step if wanted.--no-verifyon the initial commit: at that point in the flowpnpm installhas not run yet, so husky is not installed and no hooks fire.Screenshots / Previews