├── .gitignore ├── EDITORS.md ├── LICENSE ├── README.md ├── assets └── html │ ├── index.html │ ├── scripts │ └── app.js │ └── styles │ └── style.css ├── automate_project.py ├── mac-linux └── new-project ├── project_types.py ├── script.config └── windows └── new-project.bat /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | .vscode -------------------------------------------------------------------------------- /EDITORS.md: -------------------------------------------------------------------------------- 1 | # Editor Help 2 | This is a list of editors and what string to use in `script.config` for them. 3 | #### NOTE: IF USING ATOM, GO INTO IT, SELECT "ATOM" AND SELECT "INSTALL SCRIPT COMMANDS" BEFORE RUNNING THE SCRIPT! 4 | Any editor, so long as it has a terminal command to open it, will work with this. If you don't want your new project to open in an editor, set the string to `"none"`. By default, it is set to open VSCode. 5 | ``` 6 | Visual Studio Code (aka VSCode): "code" (use "code-insiders" if you use VSCode Insiders) 7 | Visual Source Codium (aka VSCodium): "codium" 8 | Atom: "atom" (use "atom-beta"/"atom-nightly if you use Atom Beta/Nightly) 9 | Vim: "vim" 10 | Emacs: "emacs" 11 | ``` 12 | #### Special cases: 13 | Sublime Text (and any editor with no command to open it): 14 | 1. Find the path Sublime/the editor is in. 15 | 2. Copy it. 16 | 3. Go to the start menu (or Flie Explorer), right-click This PC and select Properties. 17 | 4. Go to Advanced - Eviroment Variables - New. 18 | 5. Set the name to " .", and the value to the path where subl.exe/whichever editor is kept. 19 | 6. Click OK, then **MAKE SURE to set the editor variable in script.config to the name of the variable (without the dot).** 20 | 7. Restart the command terminal and rerun the script. 21 | 22 | Please help by adding editors to this list! 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2019] [Jarod Burchill] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Project Automation 2 | 3 | Python script for creating new projects in the desired local directory, with a GitHub origin. 4 | 5 | Contact us [on Discord.](https://discord.gg/eqWstJu) 6 | 7 | ## Requirements: 8 | 9 | #### Universal 10 | 11 | - [Python 3.4+](https://www.python.org/downloads/) 12 | - [Git](https://git-scm.com/downloads) 13 | - A text editor i.e. [VS Code](https://code.visualstudio.com/), [Atom](https://atom.io/), etc. (Optional but recommended.) 14 | 15 | #### React/Node.js/Express.js 16 | 17 | - [npm](https://nodejs.org/) 18 | 19 | #### Vue 20 | 21 | - [Vue CLI](https://cli.vuejs.org/guide/installation.html) 22 | 23 | #### Laravel 24 | 25 | - [PHP](https://www.php.net/manual/en/install.php) 26 | - [Composer](https://getcomposer.org/) 27 | - [Laravel](https://laravel.com/docs/5.8/installation) 28 | 29 | ## Installation: 30 | 31 | ### Windows: 32 | 33 | Clone the repository: 34 | 35 | ``` 36 | cd C:\ 37 | git clone https://github.com/jarodburchill/project-automation 38 | ``` 39 | 40 | Set the environment variable: 41 | 42 | ``` 43 | setx path "%path%;C:\project-automation\windows" 44 | ``` 45 | 46 | ### Mac/Linux: 47 | 48 | Clone the repository: 49 | 50 | ``` 51 | cd ~ 52 | git clone https://github.com/jarodburchill/project-automation 53 | ``` 54 | 55 | Set the environment variable: 56 | 57 | ``` 58 | PATH=$PATH:~/project-automation/mac-linux 59 | ``` 60 | 61 | Make executable: 62 | 63 | ``` 64 | cd ~/project-automation/mac-linux 65 | chmod +x new-project 66 | ``` 67 | 68 | ## Configuration: 69 | 70 | All configuration options can be found in the `script.config` file. 71 | 72 | ### Options and Defaults: 73 | | Name | Description | Usage | Default | 74 | | ------------- | --------------------- | -------------------- | ----------------- | 75 | | `directory` | Takes a file path string to determine where new projects will be created. | `directory = ` | `C:/Projects`. If on Windows, change if you like. If on Mac, you must set it to `/Users//desired path`. If on Linux, you must set it to `/home//desired path`. | 76 | | `editor` | Takes a string to determine which editor new projects will be opened in after creation. | `editor = ` (see EDITORS.md) | `code` (opens VSCode) | 77 | | `username` | If a valid GitHub username is entered into this option, the script will not prompt for your usernane every run. | `username = ` | blank | 78 | | `password` | If the `username` option is set, the script will not prompt for your GitHub password every run. | `password = ` | blank | 79 | | `private` | Takes a string to determine if projects should have a private or public GitHub repo. | `private = ` | blank | 80 | 81 | ## Usage: 82 | 83 | ### Run in Terminal: 84 | 85 | ``` 86 | new-project 87 | ``` 88 | 89 | ### Project Types: 90 | 91 | | Type | Description | 92 | | ------------- | --------------------- | 93 | | `blank` | Blank repository with a README | 94 | | `html` | HTML boilerplate complete with CSS and JS | 95 | | `react` | Create-react-app | 96 | | `react-ts` | Create-react-app with TypeScript | 97 | | `node` | Node.js project | 98 | | `express` | Express.js project | 99 | | `laravel` | Laravel project | 100 | | `vue` | Vue project | 101 | | `python` | Pyscaffold project | 102 | 103 | #### For lots of python config options, [see the pyscaffold README.](https://github.com/pyscaffold/pyscaffold#configuration--packaging) 104 | 105 | ## Contributors: 106 | 107 | 108 | 109 | 110 | 111 | 112 | ## License: 113 | 114 | MIT © [Jarod Burchill](http://burchilldevelopment.com) 115 | -------------------------------------------------------------------------------- /assets/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Document 11 | 12 | 13 | 14 |

15 | Created using 16 | 17 | ProjectAutomation 18 | 19 |

20 | 21 | 22 | -------------------------------------------------------------------------------- /assets/html/scripts/app.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jarodburchill/project-automation/231eedbc321db12ab14520e00d901be6a9b04b60/assets/html/scripts/app.js -------------------------------------------------------------------------------- /assets/html/styles/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 9 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 10 | sans-serif; 11 | -webkit-font-smoothing: antialiased; 12 | -moz-osx-font-smoothing: grayscale; 13 | } 14 | 15 | #welcome { 16 | text-align: center; 17 | } -------------------------------------------------------------------------------- /automate_project.py: -------------------------------------------------------------------------------- 1 | import os 2 | import subprocess 3 | import getpass 4 | import configparser 5 | import webbrowser 6 | import project_types 7 | try: 8 | from github import Github 9 | except ImportError: 10 | subprocess.call("pip install PyGithub", shell=True) 11 | from github import Github 12 | try: 13 | from colorama import init, Fore 14 | except ImportError: 15 | subprocess.call("pip install colorama", shell=True) 16 | from colorama import init, Fore 17 | 18 | 19 | # makes colorama work on Windows 20 | init() 21 | print(Fore.WHITE) 22 | 23 | 24 | # config parser set up 25 | config = configparser.ConfigParser() 26 | config.read("script.config") 27 | 28 | 29 | # global project variables 30 | directory = config.get("DEFAULT", "directory") 31 | projectName = "" 32 | projectType = "" 33 | editor = config.get("DEFAULT", "editor") 34 | 35 | 36 | # global GitHub credentials 37 | repoName = "" 38 | username = config.get("DEFAULT", "username") 39 | password = config.get("DEFAULT", "password") 40 | private = config.get("DEFAULT", "private") 41 | 42 | 43 | # runs the proccess to run based on the type of project 44 | def RunProjectProcess(projectType): 45 | project_types.Init(projectName, repoName, directory) 46 | project_types.types[projectType]() 47 | 48 | 49 | # gets user input to update GitHub credentials 50 | def GetCredentials(): 51 | global repoName 52 | global private 53 | global username 54 | global password 55 | 56 | if repoName == "": 57 | repoName = input("Enter a name for the GitHub repository: ") 58 | if private == "": 59 | private = input("Private GitHub repository (y/n): ") 60 | while private != False and private != True: 61 | if private == "y": 62 | private = True 63 | elif private == "n": 64 | private = False 65 | else: 66 | print("{}Invalid value.{}".format(Fore.YELLOW, Fore.WHITE)) 67 | private = input("Private GitHub repository (y/n): ") 68 | if username == "": 69 | username = input("Enter your GitHub username: ") 70 | if username == "" or password == "": 71 | password = getpass.getpass("Enter your GitHub password: ") 72 | 73 | 74 | # creates GitHub repo if credentials are valid 75 | def CreateGitHubRepo(): 76 | global repoName 77 | global private 78 | global username 79 | global password 80 | GetCredentials() 81 | try: 82 | user = Github(username, password).get_user() 83 | user.create_repo(repoName, private=private) 84 | return True 85 | except Exception as e: 86 | repoName = "" 87 | username = "" 88 | password = "" 89 | private = "" 90 | print(Fore.RED + str(e) + Fore.WHITE) 91 | return False 92 | 93 | 94 | def DeleteGitHubRepo(): 95 | global repoName 96 | global username 97 | global password 98 | try: 99 | user = Github(username, password) 100 | repo = user.get_repo("{}/{}".format(username, repoName)) 101 | repo.delete() 102 | except Exception as e: 103 | print(str(e)) 104 | print("{}Could not delete new repository \'{}\'. Please delete it online.{}".format( 105 | Fore.RED, repoName, Fore.WHITE)) 106 | 107 | 108 | # loops until there is a valid file path 109 | if not os.path.isdir(directory): 110 | print("{}Invalid string for the directory option in script.config; please make sure the directory in script.config exists to stop seeing this message in the future.{}".format( 111 | Fore.RED, Fore.WHITE)) 112 | directory = input("Enter valid local path: ") 113 | while not os.path.isdir(directory): 114 | print("{}Invalid local path; please try again.{}".format( 115 | Fore.YELLOW, Fore.WHITE)) 116 | directory = input("Enter valid local path: ") 117 | 118 | 119 | # requests user for project name 120 | projectName = input("Project name: ") 121 | repoName = projectName 122 | 123 | 124 | # loops until there is a valid project name 125 | while os.path.isdir(directory + "\\" + projectName): 126 | print("{}Project name already exists; please try again.{}".format( 127 | Fore.YELLOW, Fore.WHITE)) 128 | projectName = input("Project name: ") 129 | 130 | 131 | # requests user for project type 132 | projectType = input("Project type: ") 133 | 134 | 135 | # loops until project type is valid 136 | while projectType not in project_types.types: 137 | print("{}Invalid project type; please try again.{}".format( 138 | Fore.YELLOW, Fore.WHITE)) 139 | print("Valid project types: ") 140 | for key, value in project_types.types.items(): 141 | print(Fore.BLUE + key + Fore.WHITE) 142 | projectType = input("Project type: ") 143 | 144 | 145 | # loops until GitHub repo has been created successfully 146 | while CreateGitHubRepo() == False: 147 | print("{}Something went wrong when creating the GitHub repo. See above for more details.{}".format( 148 | Fore.YELLOW, Fore.WHITE)) 149 | 150 | 151 | try: 152 | # changes into correct directory and runs the project proccess for the declared project type 153 | os.chdir(directory) 154 | RunProjectProcess(projectType) 155 | 156 | # git proccesses 157 | subprocess.call("git init", shell=True) 158 | subprocess.call("git add .", shell=True) 159 | subprocess.call("git commit -m \"initial commit\"", shell=True) 160 | subprocess.call("git remote add origin https://github.com/{}/{}".format(username, repoName), 161 | shell=True) 162 | subprocess.call("git push -u origin master", shell=True) 163 | 164 | # opens project in editor 165 | if editor is not "none": 166 | try: 167 | subprocess.call("{} .".format(editor), shell=True) 168 | except Exception as e: 169 | print("{}No editor found:{} {}".format( 170 | Fore.RED, Fore.WHITE, str(e))) 171 | else: 172 | print("{}No editor selected.{}".format(Fore.YELLOW, Fore.WHITE)) 173 | print("{}Project created succesfully!{}".format(Fore.GREEN, Fore.WHITE)) 174 | 175 | # starts a dev server for certain project types 176 | if projectType == "react" or projectType == "react-ts": 177 | subprocess.call("npm start", shell=True) 178 | elif projectType == "laravel": 179 | webbrowser.open("http://localhost:8000/") 180 | subprocess.call("php artisan serve", shell=True) 181 | elif projectType == "vue": 182 | webbrowser.open("http://localhost:8080/") 183 | subprocess.call("npm run serve", shell=True) 184 | elif projectType == "html": 185 | webbrowser.open("{}\\{}\\index.html".format(directory, projectName)) 186 | except Exception as e: 187 | print("{}There was an error when creating the project:{} {}".format( 188 | Fore.RED, Fore.WHITE, str(e))) 189 | DeleteGitHubRepo() 190 | -------------------------------------------------------------------------------- /mac-linux/new-project: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | python3 ~/ProjectAutomation/automate_project.py 3 | -------------------------------------------------------------------------------- /project_types.py: -------------------------------------------------------------------------------- 1 | import os 2 | import subprocess 3 | import shutil 4 | 5 | 6 | # global variables 7 | projectName = "" 8 | repoName = "" 9 | directory = "" 10 | 11 | 12 | # gets variables from main script 13 | def Init(project, repo, dirPath): 14 | global projectName 15 | global repoName 16 | global directory 17 | projectName = project 18 | repoName = repo 19 | directory = dirPath 20 | 21 | 22 | # proccess for blank projects 23 | def Blank(): 24 | os.mkdir(projectName) 25 | os.chdir(projectName) 26 | subprocess.check_call("echo {} >> README.md".format(repoName), shell=True) 27 | 28 | 29 | # process for html projects 30 | def Html(): 31 | scriptPath = os.path.dirname(os.path.realpath(__file__)) 32 | src = "{}\\assets\\html\\".format(scriptPath) 33 | dst = "{}\\{}\\".format(directory, projectName) 34 | shutil.copytree(src, dst) 35 | os.chdir(projectName) 36 | subprocess.check_call("echo {} >> README.md".format(repoName), shell=True) 37 | 38 | 39 | # process for react projects 40 | def React(): 41 | subprocess.check_call( 42 | "npx create-react-app {}".format(projectName), shell=True) 43 | os.chdir(projectName) 44 | 45 | 46 | # process for react typescript projects 47 | def ReactTS(): 48 | subprocess.check_call( 49 | "npx create-react-app {} --typescript".format(projectName), shell=True) 50 | os.chdir(projectName) 51 | 52 | 53 | # process for nodejs projects 54 | def Node(): 55 | Blank() 56 | subprocess.check_call("npm init", shell=True) 57 | 58 | 59 | # process for python projects 60 | def Python(): 61 | try: 62 | import pyscaffold 63 | except ImportError: 64 | subprocess.call("pip install pyscaffold", shell=True) 65 | 66 | subprocess.check_call("putup {}".format(projectName), shell=True) 67 | os.chdir(projectName) 68 | 69 | 70 | # process for expressjs projects 71 | def Express(): 72 | Node() 73 | subprocess.check_call("npm install express --save", shell=True) 74 | 75 | 76 | # process for laravel projects 77 | def Laravel(): 78 | subprocess.check_call("laravel new {}".format(projectName), shell=True) 79 | os.chdir(projectName) 80 | 81 | 82 | def Vue(): 83 | subprocess.check_call("vue create {}".format(projectName), shell=True) 84 | os.chdir(projectName) 85 | 86 | 87 | # project types dict with values for correct process function 88 | types = { 89 | 'blank': Blank, 90 | 'html': Html, 91 | 'react': React, 92 | 'react-ts': ReactTS, 93 | 'node': Node, 94 | 'python': Python, 95 | 'express': Express, 96 | 'laravel': Laravel, 97 | 'vue': Vue 98 | } 99 | -------------------------------------------------------------------------------- /script.config: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | directory = C:\Projects\ 3 | editor = code 4 | username = 5 | password = 6 | private = -------------------------------------------------------------------------------- /windows/new-project.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | cd /D %~dp0.. 3 | python automate_project.py --------------------------------------------------------------------------------