-
Notifications
You must be signed in to change notification settings - Fork 0
/
git_started_api.py
151 lines (121 loc) · 4.68 KB
/
git_started_api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import subprocess
import requests
import json
import typer
subprocess.run('clear')
app = typer.Typer()
def repo(name):
return name
def project(type_of):
return type_of
def create(repo, project_type):
new_directory = f'FILENAME/{repo}'
URL = f'https://api.github.com/user/repos'
TOKEN = '' # PERSONAL ACCESS TOKEN
AUTHENTICATION = f"token {TOKEN}"
jsonPayload = {"name": repo}
headers = {"Accept": "appliechoion/vnd.github.v3+json",
"Authorization": AUTHENTICATION
}
response = requests.post(URL, headers=headers, data=json.dumps(jsonPayload))
def project_creator(commands):
project_creator = [subprocess.run(command) for command in commands]
# Lists of commands that will create the individual project folder with the proper coding language and files needed.
# Python Project Folder
commands_py = [
['mkdir',f'{new_directory}'],
['mkdir',f'{new_directory}/tests'],
['touch',f'{new_directory}/{repo}.py'],
['python3', '-m', 'venv', f'{new_directory}/env'],
['git', 'init',f'{new_directory}'],
['code', f'{new_directory}/'],
# Test Folder
['mkdir',f'{new_directory}/tests'],
['touch',f'{new_directory}/tests/__init__.py'],
['touch',f'{new_directory}/tests/test_{repo}.py']
]
# ETL Project Folder
commands_etl = [
['mkdir',f'{new_directory}'],
# Script Folder
['mkdir',f'{new_directory}/scripts'],
['cp', 'prompts/etl.py', f'{new_directory}/scripts/execute.py'],
['touch',f'{new_directory}/scripts/__init__.py'],
['touch',f'{new_directory}/scripts/extract.py'],
['touch',f'{new_directory}/scripts/transform.py'],
['touch',f'{new_directory}/scripts/load.py'],
# Test Folder
['mkdir',f'{new_directory}/tests'],
['touch',f'{new_directory}/tests/__init__.py'],
['touch',f'{new_directory}/tests/test_execute.py'],
['touch',f'{new_directory}/tests/test_extract.py'],
['touch',f'{new_directory}/tests/test_transform.py'],
['touch',f'{new_directory}/tests/test_load.py'],
# Data Folder
['mkdir',f'{new_directory}/data'],
['python3', '-m', 'venv', f'{new_directory}/env'],
['git', 'init',f'{new_directory}'],
['code', f'{new_directory}/']
]
# Airflow Project Folder
commands_af = [
['mkdir',f'{new_directory}'],
# Script Folder
['mkdir',f'{new_directory}/scripts'],
['cp', 'prompts/etl.py', f'{new_directory}/scripts/execute.py'],
['touch',f'{new_directory}/scripts/extract.py'],
['touch',f'{new_directory}/scripts/transform.py'],
['touch',f'{new_directory}/scripts/load.py'],
# Test Folder
['mkdir',f'{new_directory}/tests'],
['touch',f'{new_directory}/tests/__init__.py'],
['touch',f'{new_directory}/tests/test_execute.py'],
['touch',f'{new_directory}/tests/test_extract.py'],
['touch',f'{new_directory}/tests/test_transform.py'],
['touch',f'{new_directory}/tests/test_load.py'],
# Airflow folder
['mkdir',f'{new_directory}/dags'],
['cp', 'prompts/dag.py', f'{new_directory}/dags/dag.py'],
['mkdir',f'{new_directory}/data'],
['python3', '-m', 'venv', f'{new_directory}/env'],
['git', 'init',f'{new_directory}'],
['code', f'{new_directory}/']
]
# Web Development Project Folder
commands_web_dev = [
['mkdir',f'{new_directory}'],
['mkdir',f'{new_directory}/tests'],
['touch',f'{new_directory}/{repo}.html'],
['touch',f'{new_directory}/index.js'],
['touch',f'{new_directory}/style.css'],
['git', 'init',f'{new_directory}'],
['code', f'{new_directory}/']
]
if project_type == 'py':
project_creator(commands_py)
elif project_type == 'etl':
project_creator(commands_etl)
elif project_type == 'af':
project_creator(commands_af)
elif project_type == 'wd':
project_creator(commands_web_dev)
# Confirms that the project template was created successfully.
if response.status_code == 201:
print(f"\n'{repo}' was successfully created!!!\n")
else:
print(f'\n{response.status_code}')
print(f'{response.content}\n')
@app.command()
def py(name: str):
create(repo(name), project('py'))
@app.command()
def etl(name: str):
create(repo(name), project('etl'))
@app.command()
def wd(name: str):
create(repo(name), project('wd'))
@app.command()
def af(name: str):
create(repo(name), project('af'))
if __name__ == "__main__":
app()