-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLaravel-installer.py
executable file
·66 lines (58 loc) · 1.76 KB
/
Laravel-installer.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
try:
import os
except ImportError:
print("In order for this script to work properly the 'os' module required")
raise SystemExit(1)
#var
clear_command="clear"
LaravelCrucialFiles=[
"composer.json",
"package.json",
"artisan",
]
commands=[
"composer install",
"npm install",
"cp ./.env.example ./.env",
"php artisan key:generate",
"php artisan migrate",
]
programsToCheck = set(element.split()[0] for element in commands)
artisan_serve="php artisan serve"
#end vars
#func
def program_installed(program_name):
no_output="> /dev/null"
command = f"which {program_name} {no_output}"
return os.system(command) == 0
for file in LaravelCrucialFiles:
#Check if files exist
if not (os.path.exists(file)):
print(f"In order for LARAVEL to work properly,the project folder needs to have several files, including the following: {file}")
exit(1)
for program in programsToCheck:
if not program_installed(program):
print(f"In order for LARAVEL to work properly, Some programs must be installed :")
print(f"{program} is not installed")
exist(1)
for command in commands:
#execute commands
return_value = os.system(command)
if return_value == 0:
continue
else:
print(f"{command} failed with return value:", return_value)
break
#Ask to start local development server
os.system(clear_command)
while True:
opt = input("Run the local development server (y/n): ")
opt=opt.lower()
if opt == "y":
os.system(artisan_serve)
break
elif opt == "n":
print("Bye ...")
exit(1)
else:
print(f"unknown command : {opt} ")