From d81233d4700e6dffcec834c562f4d3ff842f9635 Mon Sep 17 00:00:00 2001 From: "Nut.andor" Date: Mon, 26 Aug 2024 23:20:18 +0200 Subject: [PATCH] createProject --- createProject.bat | 98 +++++++++++++++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 33 deletions(-) diff --git a/createProject.bat b/createProject.bat index eccdcf1..056eb42 100644 --- a/createProject.bat +++ b/createProject.bat @@ -27,51 +27,83 @@ if not exist %2 md %2 rem --- Create ATCS project (if not already done) :atcs -if exist %2\%1\created\drawable\char_hero.png goto :git -echo. -echo Do the following steps: -echo. -echo 1. Start ATCS -echo 2. Create your ATCS workspace in %2 -echo 3. Add the new project %1 -echo 4. Exit ATCS -echo. -pause -goto :atcs +if not exist %2\%1\created\drawable\char_hero.png ( + echo. + echo Do the following steps: + echo. + echo 1. Start ATCS + echo 2. Create your ATCS workspace in %2 + echo 3. Add the new project %1 + echo 4. Exit ATCS + echo. + pause + goto :atcs +) else ( + echo ATCS Project exists +) rem --- Create git repository rem This is the really important part :) -:git -if exist %2\%1\.gitignore goto :ok +rem -- go into project dir (even if we do not need to create the git repo) +echo cd %2\%1 cd %2\%1 -git init -b main -echo # %1 > readme.md -git add readme.md -rem git add LICENSE -echo .workspace > .gitignore -echo .project >> .gitignore -echo altered/drawable >> .gitignore -echo altered/drawable/* >> .gitignore -echo created/drawable >> .gitignore -echo created/drawable/* >> .gitignore -echo tmp/res/values/loadresources.xml >> .gitignore -git add .gitignore -git commit -m "Init project" -git remote add origin https://github.com/%3/%1.git +if not exist %2\%1\readme.md ( + echo creating readme + + echo # %1 > readme.md +) else ( + echo readme already exists +) + +if not exist %2\%1\.gitignore ( + echo creating gitignore + + echo .workspace > .gitignore + echo .project >> .gitignore + echo altered/drawable >> .gitignore + echo altered/drawable/* >> .gitignore + echo created/drawable >> .gitignore + echo created/drawable/* >> .gitignore + echo tmp/res/values/loadresources.xml >> .gitignore +) else ( + echo gitignore already existed +) + +:git +if not exist %2\%1\.git ( + echo Initializing git + git init -b main || ( + echo "failed to init git. Please make sure it is installed" + pause + goto :git + ) + :git_commit + git add readme.md + git add .gitignore + git commit -m "Init project" || ( + echo "failed to create the initial commit." + pause + goto :git_commit + ) + echo Done initializing git +) else ( + echo git was already initialized +) -:ok echo. echo Now create your repo %1 on https://github.com/%3 (if not already done) echo. pause +echo pushing to git repo https://github.com/%3/%1.git +git remote add origin https://github.com/%3/%1.git git push -u origin main echo. echo At last you have to find the repo in your git client: echo - In Smartgit: Menu option: Repository / Search for repository echo. -goto :ende +goto :end :noParamError echo. @@ -79,17 +111,17 @@ echo You have given no parameter. echo Maybe you have just double clicked it? That won't work. echo I have opened a CMD shell for you. Enter the command in that shell. start cmd +echo Please switch to the CMD shell :help echo. -echo Please switch to the CMD shell -echo and enter the command with 3 parameters: +echo Enter the command with 3 parameters: echo %0 project path git-user echo. -echo Example: %0 feygard_1 c:\AT\ATCS\feygard_1 NutAndor +echo Example: %0 feygard_1 c:\AT\ATCS NutAndor echo. -:ende +:end echo. echo *** End *** pause