-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create git commits and push to github by default
- Loading branch information
Showing
3 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,9 @@ def output_parent_directory | |
end | ||
|
||
def project_directory | ||
"#{output_parent_directory}/#{empty_typescript_react_project_config.project_dir}" | ||
path = "#{output_parent_directory}/#{empty_typescript_react_project_config.project_dir}" | ||
|
||
Pathname.new(path).realpath.to_s | ||
end | ||
|
||
def generate_file_contents | ||
|
@@ -50,6 +52,10 @@ def generate_file_contents | |
def run_pre_generation_tasks | ||
run_npx_create_react_app | ||
add_necessary_dev_dependencies_for_eslint | ||
eslint_fix | ||
git_init | ||
git_add_all | ||
git_commit_lint_fixes | ||
end | ||
|
||
def run_npx_create_react_app | ||
|
@@ -82,6 +88,12 @@ def add_necessary_dev_dependencies_for_eslint | |
|
||
def run_post_generation_tasks | ||
eslint_fix | ||
git_add_all | ||
git_commit_generated_files | ||
github_create_repo | ||
git_add_remote_origin | ||
git_branch_main | ||
push_to_github | ||
end | ||
|
||
def eslint_fix | ||
|
@@ -90,6 +102,76 @@ def eslint_fix | |
run_cmd_and_write_output(cmd) | ||
end | ||
end | ||
|
||
def git_init | ||
cmd = "git init" | ||
|
||
Dir.chdir project_directory do | ||
run_cmd_and_write_output(cmd) | ||
end | ||
end | ||
|
||
def git_add_all | ||
cmd = "git add ." | ||
|
||
Dir.chdir project_directory do | ||
run_cmd_and_write_output(cmd) | ||
end | ||
end | ||
|
||
def git_commit_lint_fixes | ||
cmd = "git commit -m 'Make project work with eslint and eslint --fix everything'" | ||
|
||
Dir.chdir project_directory do | ||
run_cmd_and_write_output(cmd) | ||
end | ||
end | ||
|
||
def git_commit_generated_files | ||
cmd = "git commit -m 'Generate additional files to make things work with Foobara'" | ||
|
||
Dir.chdir project_directory do | ||
run_cmd_and_write_output(cmd) | ||
end | ||
end | ||
|
||
def git_repo_path | ||
org = empty_typescript_react_project_config.github_organization || | ||
File.basename(File.dirname(project_directory.to_s)) | ||
"#{org}/#{empty_typescript_react_project_config.project_dir}" | ||
end | ||
|
||
def github_create_repo | ||
cmd = "gh repo create --public --push --source=. #{git_repo_path}" | ||
|
||
Dir.chdir project_directory do | ||
run_cmd_and_write_output(cmd, raise_if_fails: false) | ||
end | ||
end | ||
|
||
def git_add_remote_origin | ||
cmd = "git remote add origin [email protected]:#{git_repo_path}.git" | ||
|
||
Dir.chdir project_directory do | ||
run_cmd_and_write_output(cmd) | ||
end | ||
end | ||
|
||
def git_branch_main | ||
cmd = "git branch -M main" | ||
|
||
Dir.chdir project_directory do | ||
run_cmd_and_write_output(cmd) | ||
end | ||
end | ||
|
||
def push_to_github | ||
cmd = "git push -u origin main" | ||
|
||
Dir.chdir project_directory do | ||
run_cmd_and_write_output(cmd, raise_if_fails: false) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|