-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathavin_build_tools.py
71 lines (60 loc) · 3.08 KB
/
avin_build_tools.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
import subprocess
import tkinter as tk
from tkinter import filedialog, messagebox
# Function to run commands and create projects
def run_command(command, directory, log_widget):
try:
process = subprocess.Popen(command, shell=True, cwd=directory, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while True:
output = process.stdout.readline()
if output == b'' and process.poll() is not None:
break
if output:
log_widget.insert(tk.END, output.strip().decode() + '\n')
log_widget.see(tk.END)
# messagebox.showinfo("Success", f"{' '.join(command)} completed successfully!")
log_widget.insert(tk.END, "Project setup has been successful !!")
answer = messagebox.askquestion("Suggestion","Do you want to open with vs code??")
print(answer)
if answer == 'yes':
subprocess.Popen(['code', directory], shell=True) # Use Popen to launch VS Code
else:
log_widget.insert(tk.END, "\nSo, you chose not to open with VS code.")
except subprocess.CalledProcessError as e:
messagebox.showerror("Error", f"Sorry, I Failed to create the project: {e}")
def check_system(package, log_widget) -> bool:
result = subprocess.run([package, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode == 0:
version = result.stdout.decode().strip() # Get the output and decode it
log_widget.insert(tk.END, f"npm is installed. Version: {version}")
return True
else:
return False
# Function to initialize React project
def create_react_app(log_widget):
directory = filedialog.askdirectory(title="Select Directory")
if directory:
log_widget.insert(tk.END, "Initializing React project...\n")
run_command(["npx", "create-react-app", "my-react-app"], directory, log_widget)
# Function to initialize Django project
def create_django_app(log_widget):
directory = filedialog.askdirectory(title="Select Directory")
if directory:
log_widget.insert(tk.END, "Initializing Django project...\n")
run_command(["django-admin", "startproject", "my_django_project"], directory, log_widget)
# Function to initialize Next.js project
def create_next_app(log_widget):
directory = filedialog.askdirectory(title="Select Directory")
if directory:
log_widget.insert(tk.END, "Initializing Next.js project...\n")
run_command(["npx", "create-next-app", "my-next-app"], directory, log_widget)
def create_vue_app(log_widget):
directory = filedialog.askdirectory(title="Select Directory")
if directory:
log_widget.insert(tk.END, "Initializing Vue project...\n")
run_command(["npm", "install", "-g", "@vue/cli"], directory, log_widget)
run_command(["vue", "create", "my-vue-app"], directory, log_widget)
# Function to add new project setups (can be extended)
def add_new_setup():
# Simple form to add new framework (just as an idea placeholder)
tk.messagebox.showinfo("Feature Coming Soon", "My creator Avin will be adding setup features!")