Skip to content

feat(cli): create develop, qa and main branches on project creation - #158

Open
fernandatoledo wants to merge 2 commits into
masterfrom
feat/cli-init-git-branches
Open

feat(cli): create develop, qa and main branches on project creation#158
fernandatoledo wants to merge 2 commits into
masterfrom
feat/cli-init-git-branches

Conversation

@fernandatoledo

Copy link
Copy Markdown
Collaborator

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 to develop, and qa and main are branched off it. The generated project ends with a clean working tree, three branches, and develop checked out.

The git init step also moved to the end of setupProject. It used to run before the CLI rewrote package.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.js and cli/utils.js — generator only, no app code.
  • execShellCommand now takes an optional options argument, forwarded to exec. Backwards compatible: every existing call site passes nothing. The new code uses { cwd: projectName } instead of cd ${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 master clone and inspected the result: three branches (develop, qa, main), HEAD on develop, exactly one commit, and a clean working tree. Confirmed the commit contains the CLI's own edits — package.json in the generated project reads name: gitapp, version: 0.0.1, rsMetadata.templateVersion: 1.9.0. pnpm lint and pnpm type-check pass.

  • Tested on iOS
  • Tested on Android
  • Tested on a small device
  • Tested on a real device
  • Tested all flows related with this PR changes
  • Tested accessibility
  • Added tests

Notes:

  • The ticket also asks to "make default". That cannot be done from the generator: the default branch is a property of the GitHub remote, which does not exist yet at that point. develop is left as the checked-out branch, so it becomes the default when the repo is first pushed. Setting it explicitly would need gh repo edit --default-branch develop after the remote exists — happy to add that as a documented follow-up step if wanted.
  • No --no-verify on the initial commit: at that point in the flow pnpm install has not run yet, so husky is not installed and no hooks fire.

Screenshots / Previews

Copilot AI lite review requested due to automatic review settings September 7, 2026 18:41
@fernandatoledo
fernandatoledo requested a review from a team as a code owner September 7, 2026 18:41
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

💯 Test Coverage

Lines Statements Branches Functions
Coverage: 56%
56.23% (347/617) 59.18% (174/294) 48.76% (118/242)

😎 Tests Results

Tests Skipped Failures Errors Time
139 0 💤 0 ❌ 0 🔥 35.548s ⏱️
👀 Tests Details • (56%)
File% Stmts% Branch% Funcs% LinesUncovered Line #s
All files56.2359.1848.7656.9 
report-only-changed-files is enabled. No files were changed in this commit :)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 execShellCommand to accept exec options and forward them to child_process.exec.
  • Move Git initialization to the end of setupProject, create the initial commit, rename the current branch to develop, and create qa/main branches.
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

  • execShellCommand calls reject(error) but then continues to call resolve(...) 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 an else).
    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 thread cli/setup-project.js
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 thread cli/setup-project.js
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
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.

2 participants