first commit
This commit is contained in:
39
directory.py
Normal file
39
directory.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
目录管理模块
|
||||
"""
|
||||
|
||||
import sys
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from utils import get_script_dir
|
||||
|
||||
|
||||
def create_directory_structure(project_name):
|
||||
"""创建项目目录结构"""
|
||||
print(f"\n📁 创建项目目录: {project_name}")
|
||||
|
||||
# 获取脚本所在目录
|
||||
script_dir = get_script_dir()
|
||||
project_root = script_dir / project_name
|
||||
|
||||
if project_root.exists():
|
||||
overwrite = input(f"⚠️ 项目目录 {project_name} 已存在,是否覆盖? (y/n): ").strip().lower()
|
||||
if overwrite != 'y':
|
||||
print("❌ 操作已取消")
|
||||
sys.exit(0)
|
||||
shutil.rmtree(project_root)
|
||||
|
||||
# 创建主目录
|
||||
project_root.mkdir(exist_ok=True)
|
||||
|
||||
# 创建前后端目录
|
||||
frontend_dir = project_root / f"{project_name}-frontend"
|
||||
backend_dir = project_root / f"{project_name}-backend"
|
||||
|
||||
frontend_dir.mkdir(exist_ok=True)
|
||||
backend_dir.mkdir(exist_ok=True)
|
||||
|
||||
print(f"✅ 目录创建成功: {project_root}")
|
||||
|
||||
return project_root, frontend_dir, backend_dir
|
||||
Reference in New Issue
Block a user