Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions cli/setup-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,25 @@ const ProjectFilesManager = require('./project-files-manager.js');
*/
let projectFilesManager;

const DEFAULT_BRANCH = 'develop';
const ADDITIONAL_BRANCHES = ['qa', 'main'];

// Branches can only be created once a commit exists, so the initial commit
// happens before renaming the current branch and branching off it.
const initializeProjectRepository = async (projectName) => {
await execShellCommand(`cd ${projectName} && git init && cd ..`);
const options = { cwd: projectName };

await execShellCommand('git init', options);
await execShellCommand('git add -A', options);
await execShellCommand(
'git commit -m "chore: initial commit from Rootstrap React Native template"',
options,
);
Comment on lines +31 to +39
await execShellCommand(`git branch -M ${DEFAULT_BRANCH}`, options);

for (const branch of ADDITIONAL_BRANCHES) {
await execShellCommand(`git branch ${branch}`, options);
}
};

const installDependencies = async (projectName) => {
Expand Down Expand Up @@ -211,12 +228,13 @@ const setupProject = async (projectName) => {

try {
removeUnrelatedFiles();
await initializeProjectRepository(projectName);
updatePackageJson(projectName);
updateProjectConfig(projectName);
updateGitHubWorkflows(projectName);
Comment on lines 240 to 243
updateProjectReadme(projectName);
updateAgentDocs(projectName);
// Runs last so the initial commit contains the fully set up project
await initializeProjectRepository(projectName);
consola.success(`Clean up and setup your project 🧹`);
} catch (error) {
consola.error(`Failed to clean up project folder`, error);
Expand Down
4 changes: 2 additions & 2 deletions cli/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const { consola } = require('consola');
const UPSTREAM_REPOSITORY = "obytes/react-native-template-obytes";
const TEMPLATE_REPOSITORY = "rootstrap/react-native-template";

const execShellCommand = (cmd) => {
const execShellCommand = (cmd, options) => {
return new Promise((resolve, reject) => {
exec(cmd, (error, stdout, stderr) => {
exec(cmd, options, (error, stdout, stderr) => {
if (error) {
console.warn(error);
reject(error);
Expand Down
Loading