Итак, для проекта нам нужна следующая структура:
project-root/
│
├── frontend/
│ ├── public/
│ │ └── index.html
│ ├── src/
│ │ ├── assets/
│ │ ├── components/
│ │ │ └── PostList.vue
│ │ ├── views/
│ │ │ ├── HomeView.vue
│ │ │ └── PostDetailView.vue
│ │ ├── router/
│ │ │ └── index.js
│ │ ├── App.vue
│ │ └── main.js
│ ├── Dockerfile
│ ├── docker-compose.yml
│ ├── package.json
│ └── README.md
│
└── docker-compose.yml (глобальный)
Для ее реализации напишем скрипт на Python, который создаст нужные нам файлы:
import os
# Определяем структуру проекта
project_structure = {
"project-root": {
"frontend": {
"public": {
"index.html": ""
},
"src": {
"assets": {},
"components": {
"PostList.vue": ""
},
"views": {
"HomeView.vue": "",
"PostDetailView.vue": ""
},
"router": {
"index.js": ""
},
"App.vue": "",
"main.js": ""
},
"Dockerfile": "",
"docker-compose.yml": "",
"package.json": "",
"README.md": ""
},
"docker-compose.yml": ""
}
}
# Функция для создания структуры
def create_structure(base_path, structure):
for name, content in structure.items():
path = os.path.join(base_path, name)
if isinstance(content, dict):
os.makedirs(path, exist_ok=True)
create_structure(path, content)
else:
with open(path, 'w') as file:
file.write(content)
# Основная часть скрипта
if __name__ == "__main__":
base_path = "project-root"
create_structure(base_path, project_structure)
print(f"Структура проекта создана в папке '{base_path}'")
Для запуска скрипта из консоли выполняем команду:
python makeDefaultStructure.py
