git-auto-pro 1.0.0__py3-none-any.whl

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.
@@ -0,0 +1,149 @@
1
+ """gitignore generator."""
2
+
3
+ from typing import Optional
4
+ from rich.console import Console
5
+ import questionary
6
+
7
+ console = Console()
8
+
9
+
10
+ GITIGNORE_TEMPLATES = {
11
+ "python": """# Python
12
+ __pycache__/
13
+ *.py[cod]
14
+ *$py.class
15
+ *.so
16
+ .Python
17
+ build/
18
+ develop-eggs/
19
+ dist/
20
+ downloads/
21
+ eggs/
22
+ .eggs/
23
+ lib/
24
+ lib64/
25
+ parts/
26
+ sdist/
27
+ var/
28
+ wheels/
29
+ *.egg-info/
30
+ .installed.cfg
31
+ *.egg
32
+ MANIFEST
33
+
34
+ # Virtual Environment
35
+ venv/
36
+ env/
37
+ ENV/
38
+ .venv
39
+
40
+ # IDEs
41
+ .vscode/
42
+ .idea/
43
+ *.swp
44
+ *.swo
45
+ *~
46
+
47
+ # OS
48
+ .DS_Store
49
+ Thumbs.db
50
+
51
+ # Testing
52
+ .pytest_cache/
53
+ .coverage
54
+ htmlcov/
55
+ .tox/
56
+
57
+ # Jupyter
58
+ .ipynb_checkpoints
59
+ """,
60
+
61
+ "node": """# Node
62
+ node_modules/
63
+ npm-debug.log*
64
+ yarn-debug.log*
65
+ yarn-error.log*
66
+ .npm
67
+ .yarn-integrity
68
+
69
+ # Build
70
+ dist/
71
+ build/
72
+ *.tsbuildinfo
73
+
74
+ # Environment
75
+ .env
76
+ .env.local
77
+ .env.development.local
78
+ .env.test.local
79
+ .env.production.local
80
+
81
+ # IDEs
82
+ .vscode/
83
+ .idea/
84
+
85
+ # OS
86
+ .DS_Store
87
+ Thumbs.db
88
+
89
+ # Testing
90
+ coverage/
91
+ .nyc_output
92
+
93
+ # Logs
94
+ logs
95
+ *.log
96
+ """,
97
+
98
+ "web": """# Dependencies
99
+ node_modules/
100
+
101
+ # Build
102
+ dist/
103
+ build/
104
+ *.map
105
+
106
+ # Environment
107
+ .env
108
+ .env.local
109
+
110
+ # IDEs
111
+ .vscode/
112
+ .idea/
113
+
114
+ # OS
115
+ .DS_Store
116
+ Thumbs.db
117
+
118
+ # Logs
119
+ *.log
120
+ """,
121
+ }
122
+
123
+
124
+ def generate_gitignore(template: Optional[str] = None) -> None:
125
+ """Generate .gitignore file."""
126
+ console.print("[bold cyan]🚫 Generating .gitignore[/bold cyan]\n")
127
+
128
+ if not template:
129
+ template = questionary.select(
130
+ "Select template:",
131
+ choices=list(GITIGNORE_TEMPLATES.keys()) + ["Custom"]
132
+ ).ask()
133
+
134
+ if template == "Custom":
135
+ patterns = questionary.text(
136
+ "Enter patterns (comma-separated):",
137
+ default="*.log, .env, node_modules/"
138
+ ).ask()
139
+ content = "\n".join(p.strip() for p in patterns.split(","))
140
+ else:
141
+ content = GITIGNORE_TEMPLATES.get(
142
+ template if template else "python",
143
+ ""
144
+ )
145
+
146
+ with open(".gitignore", "w") as f:
147
+ f.write(content)
148
+
149
+ console.print("[green]✓ .gitignore generated[/green]")
@@ -0,0 +1,331 @@
1
+ """Git hooks setup module."""
2
+
3
+ from pathlib import Path
4
+ from typing import Optional
5
+ from rich.console import Console
6
+ import stat
7
+
8
+ console = Console()
9
+
10
+
11
+ def setup_hook(type: str, script: Optional[str] = None) -> None:
12
+ """Setup Git hooks."""
13
+ console.print(f"[bold cyan]🪝 Setting up {type} hook[/bold cyan]\n")
14
+
15
+ hooks_dir = Path(".git/hooks")
16
+ if not hooks_dir.exists():
17
+ console.print("[red]✗ Not a git repository[/red]")
18
+ return
19
+
20
+ hook_scripts = {
21
+ "pre-commit": PRE_COMMIT_HOOK,
22
+ "pre-push": PRE_PUSH_HOOK,
23
+ "commit-msg": COMMIT_MSG_HOOK,
24
+ "post-commit": POST_COMMIT_HOOK,
25
+ }
26
+
27
+ if script:
28
+ # Use custom script
29
+ hook_file = hooks_dir / type
30
+ hook_file.write_text(Path(script).read_text())
31
+ else:
32
+ # Use default script
33
+ content = hook_scripts.get(type)
34
+ if content:
35
+ hook_file = hooks_dir / type
36
+ hook_file.write_text(content)
37
+ else:
38
+ console.print(f"[red]✗ Unknown hook type: {type}[/red]")
39
+ return
40
+
41
+ # Make executable
42
+ hook_file.chmod(hook_file.stat().st_mode | stat.S_IEXEC)
43
+ console.print(f"[green]✓ Hook installed: {type}[/green]")
44
+
45
+
46
+ PRE_COMMIT_HOOK = """#!/bin/sh
47
+ # Pre-commit hook
48
+
49
+ echo "Running pre-commit checks..."
50
+
51
+ # Run linting
52
+ if command -v ruff &> /dev/null; then
53
+ echo "Linting with ruff..."
54
+ ruff check .
55
+ if [ $? -ne 0 ]; then
56
+ echo "Linting failed. Please fix errors before committing."
57
+ exit 1
58
+ fi
59
+ fi
60
+
61
+ # Run formatting check
62
+ if command -v black &> /dev/null; then
63
+ echo "Checking formatting with black..."
64
+ black --check .
65
+ if [ $? -ne 0 ]; then
66
+ echo "Code not formatted. Run 'black .' to fix."
67
+ exit 1
68
+ fi
69
+ fi
70
+
71
+ # Run tests
72
+ if command -v pytest &> /dev/null; then
73
+ echo "Running tests..."
74
+ pytest
75
+ if [ $? -ne 0 ]; then
76
+ echo "Tests failed. Please fix before committing."
77
+ exit 1
78
+ fi
79
+ fi
80
+
81
+ echo "Pre-commit checks passed!"
82
+ exit 0
83
+ """
84
+
85
+ PRE_PUSH_HOOK = """#!/bin/sh
86
+ # Pre-push hook
87
+
88
+ echo "Running pre-push checks..."
89
+
90
+ # Run full test suite
91
+ if command -v pytest &> /dev/null; then
92
+ echo "Running full test suite..."
93
+ pytest -v
94
+ if [ $? -ne 0 ]; then
95
+ echo "Tests failed. Push aborted."
96
+ exit 1
97
+ fi
98
+ fi
99
+
100
+ # Run type checking
101
+ if command -v mypy &> /dev/null; then
102
+ echo "Type checking with mypy..."
103
+ mypy .
104
+ if [ $? -ne 0 ]; then
105
+ echo "Type checking failed. Push aborted."
106
+ exit 1
107
+ fi
108
+ fi
109
+
110
+ echo "Pre-push checks passed!"
111
+ exit 0
112
+ """
113
+
114
+ COMMIT_MSG_HOOK = """#!/bin/sh
115
+ # Commit message hook
116
+
117
+ commit_msg_file=$1
118
+ commit_msg=$(cat "$commit_msg_file")
119
+
120
+ # Check conventional commit format
121
+ if ! echo "$commit_msg" | grep -qE "^(feat|fix|docs|style|refactor|test|chore)(\\(.+\\))?: .+"; then
122
+ echo "Invalid commit message format."
123
+ echo "Use: <type>(<scope>): <message>"
124
+ echo "Types: feat, fix, docs, style, refactor, test, chore"
125
+ exit 1
126
+ fi
127
+
128
+ exit 0
129
+ """
130
+
131
+ POST_COMMIT_HOOK = """#!/bin/sh
132
+ # Post-commit hook
133
+
134
+ echo "Commit successful!"
135
+
136
+ # Optional: Update changelog, send notification, etc.
137
+ """
138
+
139
+
140
+ # ============================================================================
141
+ # FILE: git_auto_pro/scaffolding/github_templates.py
142
+ # ============================================================================
143
+ """GitHub issue and PR template generator."""
144
+
145
+ from pathlib import Path
146
+ from rich.console import Console
147
+
148
+ console = Console()
149
+
150
+
151
+ def generate_github_templates(type: str) -> None:
152
+ """Generate GitHub issue/PR templates."""
153
+ console.print(f"[bold cyan]📋 Generating GitHub {type} template[/bold cyan]\n")
154
+
155
+ if type == "issue":
156
+ generate_issue_templates()
157
+ elif type == "pr":
158
+ generate_pr_template()
159
+ elif type == "contributing":
160
+ generate_contributing()
161
+ else:
162
+ console.print(f"[red]✗ Unknown template type: {type}[/red]")
163
+
164
+
165
+ def generate_issue_templates() -> None:
166
+ """Generate issue templates."""
167
+ templates_dir = Path(".github/ISSUE_TEMPLATE")
168
+ templates_dir.mkdir(parents=True, exist_ok=True)
169
+
170
+ # Bug report
171
+ (templates_dir / "bug_report.md").write_text(BUG_REPORT_TEMPLATE)
172
+
173
+ # Feature request
174
+ (templates_dir / "feature_request.md").write_text(FEATURE_REQUEST_TEMPLATE)
175
+
176
+ console.print("[green]✓ Issue templates generated[/green]")
177
+
178
+
179
+ BUG_REPORT_TEMPLATE = """---
180
+ name: Bug Report
181
+ about: Create a report to help us improve
182
+ title: '[BUG] '
183
+ labels: bug
184
+ assignees: ''
185
+ ---
186
+
187
+ **Describe the bug**
188
+ A clear and concise description of what the bug is.
189
+
190
+ **To Reproduce**
191
+ Steps to reproduce the behavior:
192
+ 1. Go to '...'
193
+ 2. Click on '....'
194
+ 3. Scroll down to '....'
195
+ 4. See error
196
+
197
+ **Expected behavior**
198
+ A clear and concise description of what you expected to happen.
199
+
200
+ **Screenshots**
201
+ If applicable, add screenshots to help explain your problem.
202
+
203
+ **Environment:**
204
+ - OS: [e.g. Ubuntu 22.04]
205
+ - Python Version: [e.g. 3.10]
206
+ - Package Version: [e.g. 1.0.0]
207
+
208
+ **Additional context**
209
+ Add any other context about the problem here.
210
+ """
211
+
212
+ FEATURE_REQUEST_TEMPLATE = """---
213
+ name: Feature Request
214
+ about: Suggest an idea for this project
215
+ title: '[FEATURE] '
216
+ labels: enhancement
217
+ assignees: ''
218
+ ---
219
+
220
+ **Is your feature request related to a problem? Please describe.**
221
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
222
+
223
+ **Describe the solution you'd like**
224
+ A clear and concise description of what you want to happen.
225
+
226
+ **Describe alternatives you've considered**
227
+ A clear and concise description of any alternative solutions or features you've considered.
228
+
229
+ **Additional context**
230
+ Add any other context or screenshots about the feature request here.
231
+ """
232
+
233
+
234
+ def generate_pr_template() -> None:
235
+ """Generate pull request template."""
236
+ github_dir = Path(".github")
237
+ github_dir.mkdir(exist_ok=True)
238
+
239
+ (github_dir / "PULL_REQUEST_TEMPLATE.md").write_text(PR_TEMPLATE)
240
+ console.print("[green]✓ PR template generated[/green]")
241
+
242
+
243
+ PR_TEMPLATE = """## Description
244
+ Please include a summary of the changes and the related issue.
245
+
246
+ Fixes # (issue)
247
+
248
+ ## Type of change
249
+ - [ ] Bug fix (non-breaking change which fixes an issue)
250
+ - [ ] New feature (non-breaking change which adds functionality)
251
+ - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
252
+ - [ ] Documentation update
253
+
254
+ ## How Has This Been Tested?
255
+ Please describe the tests that you ran to verify your changes.
256
+
257
+ - [ ] Test A
258
+ - [ ] Test B
259
+
260
+ ## Checklist:
261
+ - [ ] My code follows the style guidelines of this project
262
+ - [ ] I have performed a self-review of my own code
263
+ - [ ] I have commented my code, particularly in hard-to-understand areas
264
+ - [ ] I have made corresponding changes to the documentation
265
+ - [ ] My changes generate no new warnings
266
+ - [ ] I have added tests that prove my fix is effective or that my feature works
267
+ - [ ] New and existing unit tests pass locally with my changes
268
+ """
269
+
270
+
271
+ def generate_contributing() -> None:
272
+ """Generate CONTRIBUTING.md."""
273
+ Path("CONTRIBUTING.md").write_text(CONTRIBUTING_TEMPLATE)
274
+ console.print("[green]✓ CONTRIBUTING.md generated[/green]")
275
+
276
+
277
+ CONTRIBUTING_TEMPLATE = """# Contributing Guide
278
+
279
+ Thank you for your interest in contributing!
280
+
281
+ ## Getting Started
282
+
283
+ 1. Fork the repository
284
+ 2. Clone your fork
285
+ 3. Create a new branch for your feature
286
+ 4. Make your changes
287
+ 5. Run tests
288
+ 6. Submit a pull request
289
+
290
+ ## Development Setup
291
+
292
+ ```bash
293
+ # Clone the repository
294
+ git clone https://github.com/username/project.git
295
+ cd project
296
+
297
+ # Install dependencies
298
+ pip install -r requirements-dev.txt
299
+
300
+ # Run tests
301
+ pytest
302
+ ```
303
+
304
+ ## Code Style
305
+
306
+ - Follow PEP 8
307
+ - Use type hints
308
+ - Write docstrings
309
+ - Run `black` for formatting
310
+ - Run `ruff` for linting
311
+
312
+ ## Testing
313
+
314
+ All new features should include tests:
315
+
316
+ ```bash
317
+ pytest tests/
318
+ ```
319
+
320
+ ## Pull Request Process
321
+
322
+ 1. Update documentation
323
+ 2. Add tests for new features
324
+ 3. Ensure all tests pass
325
+ 4. Update the CHANGELOG.md
326
+ 5. Request a review
327
+
328
+ ## Questions?
329
+
330
+ Feel free to open an issue for any questions!
331
+ """
@@ -0,0 +1,109 @@
1
+ """LICENSE generator."""
2
+
3
+ from datetime import datetime
4
+ from typing import Optional
5
+ from rich.console import Console
6
+ import questionary
7
+
8
+ console = Console()
9
+
10
+
11
+ LICENSE_TEMPLATES = {
12
+ "MIT": """MIT License
13
+
14
+ Copyright (c) {year} {author}
15
+
16
+ Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ of this software and associated documentation files (the "Software"), to deal
18
+ in the Software without restriction, including without limitation the rights
19
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ copies of the Software, and to permit persons to whom the Software is
21
+ furnished to do so, subject to the following conditions:
22
+
23
+ The above copyright notice and this permission notice shall be included in all
24
+ copies or substantial portions of the Software.
25
+
26
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
+ SOFTWARE.
33
+ """,
34
+
35
+ "Apache-2.0": """Apache License
36
+ Version 2.0, January 2004
37
+ http://www.apache.org/licenses/
38
+
39
+ Copyright {year} {author}
40
+
41
+ Licensed under the Apache License, Version 2.0 (the "License");
42
+ you may not use this file except in compliance with the License.
43
+ You may obtain a copy of the License at
44
+
45
+ http://www.apache.org/licenses/LICENSE-2.0
46
+
47
+ Unless required by applicable law or agreed to in writing, software
48
+ distributed under the License is distributed on an "AS IS" BASIS,
49
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
50
+ See the License for the specific language governing permissions and
51
+ limitations under the License.
52
+ """,
53
+
54
+ "GPL-3.0": """GNU GENERAL PUBLIC LICENSE
55
+ Version 3, 29 June 2007
56
+
57
+ Copyright (C) {year} {author}
58
+
59
+ This program is free software: you can redistribute it and/or modify
60
+ it under the terms of the GNU General Public License as published by
61
+ the Free Software Foundation, either version 3 of the License, or
62
+ (at your option) any later version.
63
+
64
+ This program is distributed in the hope that it will be useful,
65
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
66
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67
+ GNU General Public License for more details.
68
+
69
+ You should have received a copy of the GNU General Public License
70
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
71
+ """,
72
+ }
73
+
74
+
75
+ def generate_license(
76
+ type: Optional[str] = None,
77
+ author: Optional[str] = None,
78
+ year: Optional[int] = None,
79
+ ) -> None:
80
+ """Generate LICENSE file."""
81
+ console.print("[bold cyan]⚖️ Generating LICENSE[/bold cyan]\n")
82
+
83
+ if not type:
84
+ type = questionary.select(
85
+ "Select license type:",
86
+ choices=list(LICENSE_TEMPLATES.keys()) + ["Custom"]
87
+ ).ask()
88
+
89
+ if type == "Custom":
90
+ console.print("[yellow]Please create your custom LICENSE file manually[/yellow]")
91
+ return
92
+
93
+ if not author:
94
+ author = questionary.text("Author name:", default="Your Name").ask()
95
+
96
+ if not year:
97
+ year = datetime.now().year
98
+
99
+ license_template = LICENSE_TEMPLATES.get(
100
+ type if type else "MIT",
101
+ LICENSE_TEMPLATES["MIT"]
102
+ )
103
+ license_content = license_template.format(year=year, author=author)
104
+
105
+ with open("LICENSE", "w") as f:
106
+ f.write(license_content)
107
+
108
+ console.print(f"[green]✓ LICENSE generated: {type}[/green]")
109
+
@@ -0,0 +1,83 @@
1
+ """Complete project creation module."""
2
+
3
+ from pathlib import Path
4
+ from typing import Optional
5
+ from rich.console import Console
6
+ from rich.progress import Progress, SpinnerColumn, TextColumn
7
+ import questionary
8
+
9
+ console = Console()
10
+
11
+
12
+ def create_new_project(
13
+ project_name: str,
14
+ template: Optional[str] = None,
15
+ private: bool = False,
16
+ no_github: bool = False,
17
+ ) -> None:
18
+ """Create a complete new project."""
19
+ from ..git_commands import git_init, git_add, git_commit, git_push
20
+ from ..github import create_github_repo, get_current_user
21
+ from .readme import generate_readme
22
+ from .license import generate_license
23
+ from .gitignore import generate_gitignore
24
+ from .templates import generate_template
25
+
26
+ console.print(f"[bold cyan]✨ Creating project: {project_name}[/bold cyan]\n")
27
+
28
+ # Create project directory
29
+ project_path = Path(project_name)
30
+ if project_path.exists():
31
+ console.print(f"[red]✗ Directory '{project_name}' already exists[/red]")
32
+ return
33
+
34
+ project_path.mkdir()
35
+ import os
36
+ os.chdir(project_path)
37
+
38
+ with Progress(
39
+ SpinnerColumn(),
40
+ TextColumn("[progress.description]{task.description}"),
41
+ console=console,
42
+ ) as progress:
43
+ # Generate project structure
44
+ task = progress.add_task("Generating project files...", total=None)
45
+
46
+ if template:
47
+ generate_template(template, ".")
48
+
49
+ generate_gitignore(template)
50
+ generate_readme(interactive=False, output="README.md")
51
+ generate_license(type=None, author=None, year=None)
52
+
53
+ progress.update(task, description="Initializing Git repository...")
54
+ git_init()
55
+
56
+ progress.update(task, description="Creating initial commit...")
57
+ git_add(all=True)
58
+ git_commit("Initial commit")
59
+
60
+ if not no_github:
61
+ progress.update(task, description="Creating GitHub repository...")
62
+ try:
63
+ user = get_current_user()
64
+ repo_data = create_github_repo(
65
+ project_name,
66
+ private=private,
67
+ description=f"Project: {project_name}",
68
+ )
69
+
70
+ # Connect to remote
71
+ import git
72
+ repo = git.Repo(".")
73
+ repo.create_remote("origin", repo_data["clone_url"])
74
+
75
+ progress.update(task, description="Pushing to GitHub...")
76
+ git_push(branch="main")
77
+
78
+ except Exception as e:
79
+ console.print(f"[yellow]⚠ Could not create GitHub repo: {e}[/yellow]")
80
+
81
+ console.print(f"\n[bold green]✓ Project created successfully![/bold green]")
82
+ console.print(f"[cyan]Location:[/cyan] {project_path.absolute()}")
83
+