kiro-cli 1.0.0__tar.gz → 1.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kiro_cli-1.0.2/PKG-INFO +166 -0
- kiro_cli-1.0.2/README.md +153 -0
- kiro_cli-1.0.2/kiro/cli.py +75 -0
- {kiro_cli-1.0.0 → kiro_cli-1.0.2}/kiro/database.py +7 -3
- kiro_cli-1.0.2/kiro/generators.py +100 -0
- kiro_cli-1.0.2/kiro/installers.py +98 -0
- kiro_cli-1.0.2/kiro/orm.py +275 -0
- kiro_cli-1.0.2/kiro/packages.py +97 -0
- {kiro_cli-1.0.0 → kiro_cli-1.0.2}/kiro/prompts.py +131 -121
- kiro_cli-1.0.2/kiro/templates/go/gin/README.md +11 -0
- kiro_cli-1.0.2/kiro/templates/go/gin/go.mod +3 -0
- kiro_cli-1.0.2/kiro/templates/go/gin/main.go +15 -0
- kiro_cli-1.0.2/kiro/templates/node/express/javascript/README.md +11 -0
- kiro_cli-1.0.2/kiro/templates/node/express/javascript/package.json +11 -0
- kiro_cli-1.0.2/kiro/templates/node/express/javascript/src/index.js +11 -0
- kiro_cli-1.0.2/kiro/templates/node/express/javascript/src/routes/index.js +9 -0
- kiro_cli-1.0.2/kiro/templates/node/express/typescript/package.json +18 -0
- kiro_cli-1.0.2/kiro/templates/node/express/typescript/src/index.ts +11 -0
- kiro_cli-1.0.2/kiro/templates/node/express/typescript/src/routes/index.ts +9 -0
- kiro_cli-1.0.2/kiro/templates/node/express/typescript/tsconfig.json +13 -0
- kiro_cli-1.0.2/kiro/templates/node/fastify/javascript/package.json +11 -0
- kiro_cli-1.0.2/kiro/templates/node/fastify/javascript/src/index.js +16 -0
- kiro_cli-1.0.2/kiro/templates/node/fastify/typescript/package.json +17 -0
- kiro_cli-1.0.2/kiro/templates/node/fastify/typescript/src/index.ts +18 -0
- kiro_cli-1.0.2/kiro/templates/node/fastify/typescript/tsconfig.json +13 -0
- kiro_cli-1.0.2/kiro/templates/python/fastapi/README.md +12 -0
- kiro_cli-1.0.2/kiro/templates/python/fastapi/requirements.txt +2 -0
- kiro_cli-1.0.2/kiro/templates/python/flask/README.md +12 -0
- kiro_cli-1.0.2/kiro/templates/python/flask/requirements.txt +1 -0
- kiro_cli-1.0.2/kiro_cli.egg-info/PKG-INFO +166 -0
- kiro_cli-1.0.2/kiro_cli.egg-info/SOURCES.txt +44 -0
- kiro_cli-1.0.2/kiro_cli.egg-info/entry_points.txt +2 -0
- {kiro_cli-1.0.0 → kiro_cli-1.0.2}/kiro_cli.egg-info/top_level.txt +1 -0
- {kiro_cli-1.0.0 → kiro_cli-1.0.2}/pyproject.toml +9 -2
- kiro_cli-1.0.0/PKG-INFO +0 -83
- kiro_cli-1.0.0/README.md +0 -70
- kiro_cli-1.0.0/kiro/cli.py +0 -62
- kiro_cli-1.0.0/kiro/generators.py +0 -48
- kiro_cli-1.0.0/kiro/installers.py +0 -79
- kiro_cli-1.0.0/kiro/orm.py +0 -99
- kiro_cli-1.0.0/kiro/packages.py +0 -155
- kiro_cli-1.0.0/kiro/utils/logger.py +0 -0
- kiro_cli-1.0.0/kiro/utils/shell.py +0 -0
- kiro_cli-1.0.0/kiro_cli.egg-info/PKG-INFO +0 -83
- kiro_cli-1.0.0/kiro_cli.egg-info/SOURCES.txt +0 -26
- kiro_cli-1.0.0/kiro_cli.egg-info/entry_points.txt +0 -2
- {kiro_cli-1.0.0 → kiro_cli-1.0.2}/LICENSE +0 -0
- {kiro_cli-1.0.0 → kiro_cli-1.0.2}/kiro/__init__.py +0 -0
- {kiro_cli-1.0.0 → kiro_cli-1.0.2}/kiro/main.py +0 -0
- {kiro_cli-1.0.0 → kiro_cli-1.0.2}/kiro/state.py +0 -0
- {kiro_cli-1.0.0 → kiro_cli-1.0.2}/kiro/templates/python/fastapi/app/main.py +0 -0
- {kiro_cli-1.0.0 → kiro_cli-1.0.2}/kiro/templates/python/flask/app.py +0 -0
- {kiro_cli-1.0.0 → kiro_cli-1.0.2}/kiro/ui.py +0 -0
- /kiro_cli-1.0.0/kiro/constants.py → /kiro_cli-1.0.2/kiro/utils/__init__.py +0 -0
- {kiro_cli-1.0.0 → kiro_cli-1.0.2}/kiro/utils/files.py +0 -0
- {kiro_cli-1.0.0 → kiro_cli-1.0.2}/kiro_cli.egg-info/dependency_links.txt +0 -0
- {kiro_cli-1.0.0 → kiro_cli-1.0.2}/kiro_cli.egg-info/requires.txt +0 -0
- {kiro_cli-1.0.0 → kiro_cli-1.0.2}/setup.cfg +0 -0
kiro_cli-1.0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kiro-cli
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: A CLI scaffolding tool for backend projects
|
|
5
|
+
License: MIT
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: typer
|
|
10
|
+
Requires-Dist: questionary
|
|
11
|
+
Requires-Dist: rich
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# ⚡ Kiro
|
|
15
|
+
|
|
16
|
+
> **Stop setting up. Start building.**
|
|
17
|
+
|
|
18
|
+
Kiro is an intelligent CLI scaffolding tool that helps developers bootstrap backend applications in seconds. Instead of repeatedly creating folders, installing dependencies, configuring environments, and writing boilerplate, Kiro generates a production-ready project structure tailored to your stack.
|
|
19
|
+
|
|
20
|
+
Whether you're starting a small API or the foundation of your next startup, Kiro removes the repetitive setup so you can focus on building features.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## ✨ Features
|
|
25
|
+
|
|
26
|
+
### 🚀 Project Generation
|
|
27
|
+
|
|
28
|
+
* Interactive CLI experience
|
|
29
|
+
* Multiple runtime support
|
|
30
|
+
|
|
31
|
+
* Node.js
|
|
32
|
+
* Python
|
|
33
|
+
* Go
|
|
34
|
+
* Automatic project structure generation
|
|
35
|
+
|
|
36
|
+
### ⚙️ Framework Support
|
|
37
|
+
|
|
38
|
+
#### Node.js
|
|
39
|
+
|
|
40
|
+
* Express
|
|
41
|
+
* Fastify
|
|
42
|
+
* NestJS *(coming soon)*
|
|
43
|
+
|
|
44
|
+
#### Python
|
|
45
|
+
|
|
46
|
+
* FastAPI
|
|
47
|
+
* Flask
|
|
48
|
+
|
|
49
|
+
#### Go
|
|
50
|
+
|
|
51
|
+
* Gin
|
|
52
|
+
|
|
53
|
+
### 💻 Language Support
|
|
54
|
+
|
|
55
|
+
* JavaScript
|
|
56
|
+
* TypeScript
|
|
57
|
+
|
|
58
|
+
### 🗄 Database Support
|
|
59
|
+
|
|
60
|
+
* PostgreSQL
|
|
61
|
+
* MySQL
|
|
62
|
+
* SQLite
|
|
63
|
+
* MongoDB
|
|
64
|
+
* No database
|
|
65
|
+
|
|
66
|
+
### 🧩 ORM Support
|
|
67
|
+
|
|
68
|
+
* Prisma
|
|
69
|
+
* Drizzle
|
|
70
|
+
* SQLAlchemy
|
|
71
|
+
* Peewee
|
|
72
|
+
* MongoEngine
|
|
73
|
+
* GORM
|
|
74
|
+
|
|
75
|
+
### 📦 Automatic Setup
|
|
76
|
+
|
|
77
|
+
Kiro automatically:
|
|
78
|
+
|
|
79
|
+
* Generates your project structure
|
|
80
|
+
* Creates configuration files
|
|
81
|
+
* Generates a `.env` file
|
|
82
|
+
* Installs project dependencies
|
|
83
|
+
* Creates framework starter files
|
|
84
|
+
* Generates a project README
|
|
85
|
+
* Adds a LICENSE file
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 📁 Example Project
|
|
90
|
+
|
|
91
|
+
Below is an example of a project generated with **Node.js + TypeScript + Express + PostgreSQL + Prisma**.
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
hotelms/
|
|
95
|
+
├── prisma/
|
|
96
|
+
│ └── schema.prisma
|
|
97
|
+
├── src/
|
|
98
|
+
│ ├── index.ts
|
|
99
|
+
│ └── routes/
|
|
100
|
+
│ └── index.ts
|
|
101
|
+
├── .env
|
|
102
|
+
├── .gitignore
|
|
103
|
+
├── package.json
|
|
104
|
+
├── tsconfig.json
|
|
105
|
+
├── README.md
|
|
106
|
+
├── LICENSE
|
|
107
|
+
└── node_modules/
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Kiro automatically configures the project based on your selections, including the appropriate runtime, language, framework, database, ORM, configuration files, and required dependencies.
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 🛣 Roadmap
|
|
116
|
+
|
|
117
|
+
### v1.x
|
|
118
|
+
|
|
119
|
+
* Better project templates
|
|
120
|
+
* Improved error handling
|
|
121
|
+
* Smarter dependency detection
|
|
122
|
+
* Template customization
|
|
123
|
+
|
|
124
|
+
### v2
|
|
125
|
+
|
|
126
|
+
* Git initialization
|
|
127
|
+
* Docker support
|
|
128
|
+
* Testing setup
|
|
129
|
+
* Linting & formatting
|
|
130
|
+
* Authentication templates
|
|
131
|
+
* Plugin system
|
|
132
|
+
* Redis support
|
|
133
|
+
* Background jobs
|
|
134
|
+
* CI/CD templates
|
|
135
|
+
|
|
136
|
+
### Future
|
|
137
|
+
|
|
138
|
+
* Global installation (`pipx`, `npm create`)
|
|
139
|
+
* Official documentation
|
|
140
|
+
* Web landing page
|
|
141
|
+
* Community template marketplace
|
|
142
|
+
* First-party plugins
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 🧠 Philosophy
|
|
147
|
+
|
|
148
|
+
Starting a new backend project shouldn't require copying an old repository, searching for setup commands, or recreating the same files over and over.
|
|
149
|
+
|
|
150
|
+
Kiro exists to eliminate that friction.
|
|
151
|
+
|
|
152
|
+
Generate your project. Install your dependencies. Start writing business logic.
|
|
153
|
+
|
|
154
|
+
**Stop setting up. Start building.**
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## 👨💻 Author
|
|
159
|
+
|
|
160
|
+
Built with ❤️ by **Jimoh Olamide Prince**
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## 📄 License
|
|
165
|
+
|
|
166
|
+
This project is licensed under the MIT License.
|
kiro_cli-1.0.2/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# ⚡ Kiro
|
|
2
|
+
|
|
3
|
+
> **Stop setting up. Start building.**
|
|
4
|
+
|
|
5
|
+
Kiro is an intelligent CLI scaffolding tool that helps developers bootstrap backend applications in seconds. Instead of repeatedly creating folders, installing dependencies, configuring environments, and writing boilerplate, Kiro generates a production-ready project structure tailored to your stack.
|
|
6
|
+
|
|
7
|
+
Whether you're starting a small API or the foundation of your next startup, Kiro removes the repetitive setup so you can focus on building features.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## ✨ Features
|
|
12
|
+
|
|
13
|
+
### 🚀 Project Generation
|
|
14
|
+
|
|
15
|
+
* Interactive CLI experience
|
|
16
|
+
* Multiple runtime support
|
|
17
|
+
|
|
18
|
+
* Node.js
|
|
19
|
+
* Python
|
|
20
|
+
* Go
|
|
21
|
+
* Automatic project structure generation
|
|
22
|
+
|
|
23
|
+
### ⚙️ Framework Support
|
|
24
|
+
|
|
25
|
+
#### Node.js
|
|
26
|
+
|
|
27
|
+
* Express
|
|
28
|
+
* Fastify
|
|
29
|
+
* NestJS *(coming soon)*
|
|
30
|
+
|
|
31
|
+
#### Python
|
|
32
|
+
|
|
33
|
+
* FastAPI
|
|
34
|
+
* Flask
|
|
35
|
+
|
|
36
|
+
#### Go
|
|
37
|
+
|
|
38
|
+
* Gin
|
|
39
|
+
|
|
40
|
+
### 💻 Language Support
|
|
41
|
+
|
|
42
|
+
* JavaScript
|
|
43
|
+
* TypeScript
|
|
44
|
+
|
|
45
|
+
### 🗄 Database Support
|
|
46
|
+
|
|
47
|
+
* PostgreSQL
|
|
48
|
+
* MySQL
|
|
49
|
+
* SQLite
|
|
50
|
+
* MongoDB
|
|
51
|
+
* No database
|
|
52
|
+
|
|
53
|
+
### 🧩 ORM Support
|
|
54
|
+
|
|
55
|
+
* Prisma
|
|
56
|
+
* Drizzle
|
|
57
|
+
* SQLAlchemy
|
|
58
|
+
* Peewee
|
|
59
|
+
* MongoEngine
|
|
60
|
+
* GORM
|
|
61
|
+
|
|
62
|
+
### 📦 Automatic Setup
|
|
63
|
+
|
|
64
|
+
Kiro automatically:
|
|
65
|
+
|
|
66
|
+
* Generates your project structure
|
|
67
|
+
* Creates configuration files
|
|
68
|
+
* Generates a `.env` file
|
|
69
|
+
* Installs project dependencies
|
|
70
|
+
* Creates framework starter files
|
|
71
|
+
* Generates a project README
|
|
72
|
+
* Adds a LICENSE file
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 📁 Example Project
|
|
77
|
+
|
|
78
|
+
Below is an example of a project generated with **Node.js + TypeScript + Express + PostgreSQL + Prisma**.
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
hotelms/
|
|
82
|
+
├── prisma/
|
|
83
|
+
│ └── schema.prisma
|
|
84
|
+
├── src/
|
|
85
|
+
│ ├── index.ts
|
|
86
|
+
│ └── routes/
|
|
87
|
+
│ └── index.ts
|
|
88
|
+
├── .env
|
|
89
|
+
├── .gitignore
|
|
90
|
+
├── package.json
|
|
91
|
+
├── tsconfig.json
|
|
92
|
+
├── README.md
|
|
93
|
+
├── LICENSE
|
|
94
|
+
└── node_modules/
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Kiro automatically configures the project based on your selections, including the appropriate runtime, language, framework, database, ORM, configuration files, and required dependencies.
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 🛣 Roadmap
|
|
103
|
+
|
|
104
|
+
### v1.x
|
|
105
|
+
|
|
106
|
+
* Better project templates
|
|
107
|
+
* Improved error handling
|
|
108
|
+
* Smarter dependency detection
|
|
109
|
+
* Template customization
|
|
110
|
+
|
|
111
|
+
### v2
|
|
112
|
+
|
|
113
|
+
* Git initialization
|
|
114
|
+
* Docker support
|
|
115
|
+
* Testing setup
|
|
116
|
+
* Linting & formatting
|
|
117
|
+
* Authentication templates
|
|
118
|
+
* Plugin system
|
|
119
|
+
* Redis support
|
|
120
|
+
* Background jobs
|
|
121
|
+
* CI/CD templates
|
|
122
|
+
|
|
123
|
+
### Future
|
|
124
|
+
|
|
125
|
+
* Global installation (`pipx`, `npm create`)
|
|
126
|
+
* Official documentation
|
|
127
|
+
* Web landing page
|
|
128
|
+
* Community template marketplace
|
|
129
|
+
* First-party plugins
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 🧠 Philosophy
|
|
134
|
+
|
|
135
|
+
Starting a new backend project shouldn't require copying an old repository, searching for setup commands, or recreating the same files over and over.
|
|
136
|
+
|
|
137
|
+
Kiro exists to eliminate that friction.
|
|
138
|
+
|
|
139
|
+
Generate your project. Install your dependencies. Start writing business logic.
|
|
140
|
+
|
|
141
|
+
**Stop setting up. Start building.**
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 👨💻 Author
|
|
146
|
+
|
|
147
|
+
Built with ❤️ by **Jimoh Olamide Prince**
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## 📄 License
|
|
152
|
+
|
|
153
|
+
This project is licensed under the MIT License.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import shutil
|
|
2
|
+
import sys
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from kiro.prompts import (
|
|
6
|
+
select_runtime,
|
|
7
|
+
select_framework,
|
|
8
|
+
ask_project_name,
|
|
9
|
+
ask_language,
|
|
10
|
+
select_database,
|
|
11
|
+
select_orm,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
from kiro.state import KiroState
|
|
15
|
+
from kiro.generators import create_project
|
|
16
|
+
from kiro.database import setup_database
|
|
17
|
+
from kiro.orm import setup_orm
|
|
18
|
+
from kiro.installers import InstallError, install_dependencies
|
|
19
|
+
from kiro.ui import show_success
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def run_cli():
|
|
23
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
24
|
+
sys.stdout.reconfigure(encoding="utf-8")
|
|
25
|
+
|
|
26
|
+
print("\n⚡ Welcome to Kiro\n")
|
|
27
|
+
|
|
28
|
+
state = KiroState()
|
|
29
|
+
|
|
30
|
+
state.runtime = select_runtime()
|
|
31
|
+
print(f"\n✔ Selected runtime: {state.runtime}")
|
|
32
|
+
|
|
33
|
+
if state.runtime == "Node.js":
|
|
34
|
+
state.language = ask_language()
|
|
35
|
+
print(f"\n✔ Language: {state.language}")
|
|
36
|
+
|
|
37
|
+
state.framework = select_framework(state.runtime)
|
|
38
|
+
print(f"\n✔ Selected framework: {state.framework}")
|
|
39
|
+
|
|
40
|
+
state.project_name = ask_project_name()
|
|
41
|
+
print(f"\n✔ Project name: {state.project_name}")
|
|
42
|
+
|
|
43
|
+
state.database = select_database()
|
|
44
|
+
print(f"\n✔ Database: {state.database}")
|
|
45
|
+
|
|
46
|
+
state.orm = select_orm(state.runtime, state.database)
|
|
47
|
+
|
|
48
|
+
if state.orm and state.orm != "None":
|
|
49
|
+
print(f"\n✔ ORM: {state.orm}")
|
|
50
|
+
|
|
51
|
+
project_path = Path(state.project_name)
|
|
52
|
+
already_existed = project_path.exists()
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
create_project(state)
|
|
56
|
+
setup_database(state)
|
|
57
|
+
setup_orm(state)
|
|
58
|
+
try:
|
|
59
|
+
install_dependencies(state)
|
|
60
|
+
except InstallError as exc:
|
|
61
|
+
print(f"\n⚠ Could not install dependencies: {exc}")
|
|
62
|
+
print(f"Project files were generated at ./{state.project_name}")
|
|
63
|
+
print("Install dependencies manually, then start building.\n")
|
|
64
|
+
show_success(state)
|
|
65
|
+
sys.exit(1)
|
|
66
|
+
|
|
67
|
+
show_success(state)
|
|
68
|
+
except KeyboardInterrupt:
|
|
69
|
+
print("\nCancelled.")
|
|
70
|
+
sys.exit(130)
|
|
71
|
+
except Exception as exc:
|
|
72
|
+
print(f"\n✖ Failed to create project: {exc}")
|
|
73
|
+
if not already_existed and project_path.exists():
|
|
74
|
+
shutil.rmtree(project_path, ignore_errors=True)
|
|
75
|
+
sys.exit(1)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
def setup_database(state):
|
|
4
5
|
if state.database == "None":
|
|
5
6
|
return
|
|
@@ -15,9 +16,12 @@ def setup_database(state):
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
database_url = database_urls.get(state.database)
|
|
19
|
+
project.mkdir(parents=True, exist_ok=True)
|
|
18
20
|
|
|
19
21
|
if database_url:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
existing = env.read_text(encoding="utf-8") if env.exists() else ""
|
|
23
|
+
if "DATABASE_URL=" not in existing:
|
|
24
|
+
with env.open("a", encoding="utf-8") as f:
|
|
25
|
+
f.write(f"DATABASE_URL={database_url}\n")
|
|
22
26
|
|
|
23
|
-
print(f"🗄 Setting up {state.database}...")
|
|
27
|
+
print(f"🗄 Setting up {state.database}...")
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import shutil
|
|
3
|
+
|
|
4
|
+
from kiro.utils.files import replace_placeholders
|
|
5
|
+
|
|
6
|
+
PACKAGE_DIR = Path(__file__).resolve().parent
|
|
7
|
+
|
|
8
|
+
LICENSE_TEXT = """MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2026
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def create_project(state):
|
|
33
|
+
base_path = Path(state.project_name)
|
|
34
|
+
base_path.mkdir(parents=True, exist_ok=True)
|
|
35
|
+
|
|
36
|
+
template_path = get_template_path(state)
|
|
37
|
+
|
|
38
|
+
if not template_path or not template_path.exists():
|
|
39
|
+
raise FileNotFoundError(
|
|
40
|
+
f"No template found for {state.runtime} / {state.framework}"
|
|
41
|
+
+ (f" / {state.language}" if state.language else "")
|
|
42
|
+
+ f" (looked in {template_path})"
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
shutil.copytree(
|
|
46
|
+
template_path,
|
|
47
|
+
base_path,
|
|
48
|
+
dirs_exist_ok=True,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
write_readme(base_path, state)
|
|
52
|
+
(base_path / "LICENSE").write_text(LICENSE_TEXT, encoding="utf-8")
|
|
53
|
+
replace_placeholders(base_path, state)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def write_readme(base_path: Path, state):
|
|
57
|
+
language = f" ({state.language})" if state.language else ""
|
|
58
|
+
orm = f"\n- ORM: {state.orm}" if state.orm and state.orm != "None" else ""
|
|
59
|
+
database = f"\n- Database: {state.database}" if state.database and state.database != "None" else ""
|
|
60
|
+
|
|
61
|
+
if state.runtime == "Node.js":
|
|
62
|
+
run_block = "```bash\nnpm run dev\n```"
|
|
63
|
+
elif state.runtime == "Python" and state.framework == "FastAPI":
|
|
64
|
+
run_block = "```bash\nuvicorn app.main:app --reload\n```"
|
|
65
|
+
elif state.runtime == "Python":
|
|
66
|
+
run_block = "```bash\npython app.py\n```"
|
|
67
|
+
else:
|
|
68
|
+
run_block = "```bash\ngo run .\n```"
|
|
69
|
+
|
|
70
|
+
content = f"""# {state.project_name}
|
|
71
|
+
|
|
72
|
+
Backend project generated by Kiro.
|
|
73
|
+
|
|
74
|
+
- Runtime: {state.runtime}{language}
|
|
75
|
+
- Framework: {state.framework}{database}{orm}
|
|
76
|
+
|
|
77
|
+
## Run
|
|
78
|
+
|
|
79
|
+
{run_block}
|
|
80
|
+
"""
|
|
81
|
+
(base_path / "README.md").write_text(content, encoding="utf-8")
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def get_template_path(state):
|
|
85
|
+
base = PACKAGE_DIR / "templates"
|
|
86
|
+
|
|
87
|
+
if state.runtime == "Node.js":
|
|
88
|
+
framework = state.framework.lower()
|
|
89
|
+
language = state.language.lower()
|
|
90
|
+
return base / "node" / framework / language
|
|
91
|
+
|
|
92
|
+
if state.runtime == "Python":
|
|
93
|
+
framework = state.framework.lower()
|
|
94
|
+
return base / "python" / framework
|
|
95
|
+
|
|
96
|
+
if state.runtime == "Go":
|
|
97
|
+
framework = state.framework.lower()
|
|
98
|
+
return base / "go" / framework
|
|
99
|
+
|
|
100
|
+
return None
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""Install dependencies for generated Kiro projects."""
|
|
2
|
+
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from kiro.packages import get_packages
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class InstallError(Exception):
|
|
12
|
+
"""Raised when a project dependency install step fails."""
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def install_dependencies(state):
|
|
16
|
+
"""Install the dependencies implied by the user's project selections."""
|
|
17
|
+
project = Path(state.project_name).resolve()
|
|
18
|
+
|
|
19
|
+
if not project.is_dir():
|
|
20
|
+
raise InstallError(f"Generated project directory was not found: {project}")
|
|
21
|
+
|
|
22
|
+
packages, dev_packages = get_packages(state)
|
|
23
|
+
|
|
24
|
+
try:
|
|
25
|
+
if state.runtime == "Node.js":
|
|
26
|
+
_install_node_dependencies(project, packages, dev_packages, state)
|
|
27
|
+
elif state.runtime == "Python":
|
|
28
|
+
_install_python_dependencies(project, packages)
|
|
29
|
+
elif state.runtime == "Go":
|
|
30
|
+
_install_go_dependencies(project, packages)
|
|
31
|
+
else:
|
|
32
|
+
raise InstallError(f"Unsupported runtime: {state.runtime}")
|
|
33
|
+
except FileNotFoundError as exc:
|
|
34
|
+
raise InstallError(str(exc)) from exc
|
|
35
|
+
except subprocess.CalledProcessError as exc:
|
|
36
|
+
command = " ".join(str(part) for part in exc.cmd) if exc.cmd else "install"
|
|
37
|
+
raise InstallError(
|
|
38
|
+
f"`{command}` failed with exit code {exc.returncode}."
|
|
39
|
+
) from exc
|
|
40
|
+
|
|
41
|
+
print("Dependencies installed successfully.")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _require_command(name: str) -> str:
|
|
45
|
+
command = shutil.which(name)
|
|
46
|
+
if not command:
|
|
47
|
+
raise InstallError(f"{name} was not found on PATH. Install it and try again.")
|
|
48
|
+
return command
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _run(command: list[str], cwd: Path):
|
|
52
|
+
subprocess.run(command, cwd=cwd, check=True)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _install_node_dependencies(project: Path, packages: list[str], dev_packages: list[str], state):
|
|
56
|
+
npm = _require_command("npm")
|
|
57
|
+
|
|
58
|
+
_run([npm, "install"], project)
|
|
59
|
+
|
|
60
|
+
if packages:
|
|
61
|
+
_run([npm, "install", *packages], project)
|
|
62
|
+
if dev_packages:
|
|
63
|
+
_run([npm, "install", "--save-dev", *dev_packages], project)
|
|
64
|
+
|
|
65
|
+
if getattr(state, "orm", None) == "Prisma":
|
|
66
|
+
npx = _require_command("npx")
|
|
67
|
+
_run([npx, "prisma", "generate"], project)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _install_python_dependencies(project: Path, packages: list[str]):
|
|
71
|
+
pip = _create_python_venv(project)
|
|
72
|
+
requirements = project / "requirements.txt"
|
|
73
|
+
|
|
74
|
+
if requirements.is_file() and requirements.stat().st_size > 0:
|
|
75
|
+
_run([str(pip), "install", "-r", str(requirements)], project)
|
|
76
|
+
if packages:
|
|
77
|
+
_run([str(pip), "install", *packages], project)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _create_python_venv(project: Path) -> Path:
|
|
81
|
+
if sys.platform == "win32":
|
|
82
|
+
pip = project / ".venv" / "Scripts" / "pip.exe"
|
|
83
|
+
else:
|
|
84
|
+
pip = project / ".venv" / "bin" / "pip"
|
|
85
|
+
|
|
86
|
+
if not pip.is_file():
|
|
87
|
+
print("Creating virtual environment...")
|
|
88
|
+
_run([sys.executable, "-m", "venv", ".venv"], project)
|
|
89
|
+
|
|
90
|
+
return pip
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _install_go_dependencies(project: Path, packages: list[str]):
|
|
94
|
+
go = _require_command("go")
|
|
95
|
+
|
|
96
|
+
for package in packages:
|
|
97
|
+
_run([go, "get", package], project)
|
|
98
|
+
_run([go, "mod", "tidy"], project)
|