├── .my_commands.sh ├── README.md ├── create.py ├── remove.py ├── requirements.txt └── windows_OS ├── .gitignore ├── README.md ├── create.bat ├── local.py ├── remote.py └── requirements.txt /.my_commands.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function create() { 4 | 5 | source .env 6 | python create.py $1 7 | cd $FILEPATH$1 8 | git init 9 | git remote add origin git@github.com:$USERNAME/$1.git 10 | touch README.md 11 | git add . 12 | git commit -m "Initial commit" 13 | git push -u origin master 14 | code . 15 | } 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Install: 2 | ```bash 3 | git clone "https://github.com/KalleHallden/ProjectInitializationAutomation.git" 4 | cd ProjectInitializationAutomation 5 | pip install -r requirements.txt 6 | touch .env 7 | Then open the .env file and store your username, password, and desired file destination. Use the provided format at the bottom of this README. 8 | source ~/.my_commands.sh 9 | ``` 10 | 11 | ### Usage: 12 | ```bash 13 | To run the script type in 'create ' 14 | ``` 15 | 16 | ### Env File Format: 17 | ```bash 18 | USERNAME="Username123" 19 | PASSWORD="Password123" 20 | FILEPATH="/path/to/your/project/" 21 | ``` 22 | -------------------------------------------------------------------------------- /create.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | from github import Github 4 | from dotenv import load_dotenv 5 | 6 | load_dotenv() 7 | 8 | path = os.getenv("FILEPATH") 9 | username = os.getenv("USERNAME") 10 | password = os.getenv("PASSWORD") 11 | 12 | def create(): 13 | folderName = str(sys.argv[1]) 14 | os.makedirs(path + str(folderName)) 15 | user = Github(username, password).get_user() 16 | repo = user.create_repo(folderName) 17 | # f strings 18 | print(f"Succesfully created repository {folderName}") 19 | 20 | if __name__ == "__main__": 21 | create() 22 | -------------------------------------------------------------------------------- /remove.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from selenium import webdriver 3 | 4 | username = sys.argv[1] 5 | password = sys.argv[2] 6 | reponame = sys.argv[3] 7 | 8 | browser = webdriver.Chrome() 9 | browser.get('http://github.com/login') 10 | 11 | 12 | def remove(): 13 | browser.find_elements_by_xpath("//input[@name='login']")[0].send_keys(username) 14 | browser.find_elements_by_xpath("//input[@name='password']")[0].send_keys(password) 15 | browser.find_elements_by_xpath("//input[@name='commit']")[0].click() 16 | browser.get('https://github.com/' + username + '/' + reponame + '/settings') 17 | browser.find_elements_by_xpath('//*[@id="options_bucket"]/div[9]/ul/li[4]/details/summary')[0].click() 18 | browser.find_elements_by_xpath( 19 | '//*[@id="options_bucket"]/div[9]/ul/li[4]/details/details-dialog/div[3]/form/p/input')[0].send_keys(username + "/" + reponame) 20 | browser.find_elements_by_xpath( 21 | '//*[@id="options_bucket"]/div[9]/ul/li[4]/details/details-dialog/div[3]/form/button')[0].click() 22 | browser.get("https://github.com/" + username) 23 | 24 | 25 | if __name__ == "__main__": 26 | remove() 27 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | selenium 2 | PyGithub 3 | python-dotenv 4 | -------------------------------------------------------------------------------- /windows_OS/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | __pycache__ -------------------------------------------------------------------------------- /windows_OS/README.md: -------------------------------------------------------------------------------- 1 | ### pre-setup: 2 | ``` 3 | create env vars : 4 | > projects directory as - "mp" 5 | > Github token as - "gt" 6 | ``` 7 | 8 | ### setup: 9 | ```bash 10 | git clone "https://github.com/wikyprash/projectInitializerAutomation.git" 11 | cd projectInitializerAutomation 12 | pip install -r requirements.txt 13 | 14 | path: 15 | "projectInitializerAutomation" folder directory to path 16 | ``` 17 | 18 | ### Usage: 19 | ```bash 20 | Command to run the program type 21 | 22 | 'create ' 23 | 'create ' - for just locally 24 | ``` 25 | -------------------------------------------------------------------------------- /windows_OS/create.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set fn=%1 4 | set flag=%2 5 | cd /d %~dp0 6 | 7 | If "%1"=="" ( 8 | echo "error" 9 | ) else ( 10 | if "%2"=="" ( 11 | python remote.py %fn% %flag% 12 | ) else ( 13 | if "%2"=="l" ( 14 | python local.py %fn% 15 | ) 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /windows_OS/local.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | 4 | foldername = str(sys.argv[1]) 5 | path = os.environ.get('mp') 6 | _dir = path + '/' + foldername 7 | 8 | try: 9 | os.mkdir(_dir) 10 | os.chdir(_dir) 11 | os.system('git init') 12 | os.system(f'echo "# {foldername}" > README.md') 13 | os.system('git add README.md') 14 | os.system('git commit -m "first commit"') 15 | 16 | print(f'{foldername} created locally') 17 | os.system('code .') 18 | 19 | 20 | except: 21 | print("create l") 22 | -------------------------------------------------------------------------------- /windows_OS/remote.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | from github import Github 4 | 5 | foldername = str(sys.argv[1]) 6 | path = os.environ.get('mp') # add projects dirctory to the env vars 7 | token = os.environ.get('gt') # add github token to the env vars 8 | _dir = path + '/' + foldername 9 | 10 | g = Github(token) 11 | user = g.get_user() 12 | login = user.login 13 | repo = user.create_repo(foldername) 14 | 15 | commands = [f'echo "# {repo.name}" >> README.md', 16 | 'git init', 17 | f'git remote add origin https://github.com/{login}/{foldername}.git', 18 | 'git add .', 19 | 'git commit -m "Initial commit"', 20 | 'git push -u origin master'] 21 | 22 | if sys.argv[2] == "g": 23 | os.mkdir(_dir) 24 | os.chdir(_dir) 25 | 26 | for c in commands: 27 | os.system(c) 28 | 29 | print(f'{foldername} created locally') 30 | os.system('code .') # add github token to the env vars 31 | 32 | else: 33 | print("create ") 34 | -------------------------------------------------------------------------------- /windows_OS/requirements.txt: -------------------------------------------------------------------------------- 1 | PyGithub --------------------------------------------------------------------------------