forgepy-cli 1.0.0__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.
Files changed (80) hide show
  1. forgepy_cli-1.0.0/CHANGELOG.md +53 -0
  2. forgepy_cli-1.0.0/LICENSE +21 -0
  3. forgepy_cli-1.0.0/MANIFEST.in +3 -0
  4. forgepy_cli-1.0.0/PKG-INFO +176 -0
  5. forgepy_cli-1.0.0/README.md +153 -0
  6. forgepy_cli-1.0.0/builders/__init__.py +0 -0
  7. forgepy_cli-1.0.0/builders/base_builder.py +17 -0
  8. forgepy_cli-1.0.0/builders/file_builder.py +31 -0
  9. forgepy_cli-1.0.0/builders/folder_builder.py +30 -0
  10. forgepy_cli-1.0.0/builders/python_tools_builder.py +64 -0
  11. forgepy_cli-1.0.0/cli/__init__.py +3 -0
  12. forgepy_cli-1.0.0/cli/command.py +52 -0
  13. forgepy_cli-1.0.0/cli/commands/__init__.py +32 -0
  14. forgepy_cli-1.0.0/cli/commands/component_command.py +177 -0
  15. forgepy_cli-1.0.0/cli/commands/config_command.py +174 -0
  16. forgepy_cli-1.0.0/cli/commands/create_command.py +161 -0
  17. forgepy_cli-1.0.0/cli/commands/list_command.py +40 -0
  18. forgepy_cli-1.0.0/cli/commands/version_command.py +29 -0
  19. forgepy_cli-1.0.0/cli/dispatcher.py +61 -0
  20. forgepy_cli-1.0.0/cli/parser.py +84 -0
  21. forgepy_cli-1.0.0/components/__init__.py +1 -0
  22. forgepy_cli-1.0.0/components/base_component.py +30 -0
  23. forgepy_cli-1.0.0/components/component_context.py +21 -0
  24. forgepy_cli-1.0.0/components/component_installer.py +44 -0
  25. forgepy_cli-1.0.0/components/component_manifest.py +102 -0
  26. forgepy_cli-1.0.0/components/component_metadata.py +50 -0
  27. forgepy_cli-1.0.0/components/component_registry.py +74 -0
  28. forgepy_cli-1.0.0/components/component_state.py +243 -0
  29. forgepy_cli-1.0.0/components/component_validation.py +88 -0
  30. forgepy_cli-1.0.0/components/github_actions_component.py +75 -0
  31. forgepy_cli-1.0.0/components/pytest_component.py +40 -0
  32. forgepy_cli-1.0.0/components/ruff_component.py +40 -0
  33. forgepy_cli-1.0.0/config/__init__.py +0 -0
  34. forgepy_cli-1.0.0/config/default_structure.py +18 -0
  35. forgepy_cli-1.0.0/config/user_config.py +238 -0
  36. forgepy_cli-1.0.0/config/version.py +16 -0
  37. forgepy_cli-1.0.0/core/__init__.py +0 -0
  38. forgepy_cli-1.0.0/core/environment_builder.py +33 -0
  39. forgepy_cli-1.0.0/core/git_builder.py +90 -0
  40. forgepy_cli-1.0.0/core/project_generator.py +125 -0
  41. forgepy_cli-1.0.0/core/requirements_installer.py +50 -0
  42. forgepy_cli-1.0.0/core/vscode_builder.py +103 -0
  43. forgepy_cli-1.0.0/forgepy_cli.egg-info/PKG-INFO +176 -0
  44. forgepy_cli-1.0.0/forgepy_cli.egg-info/SOURCES.txt +78 -0
  45. forgepy_cli-1.0.0/forgepy_cli.egg-info/dependency_links.txt +1 -0
  46. forgepy_cli-1.0.0/forgepy_cli.egg-info/entry_points.txt +2 -0
  47. forgepy_cli-1.0.0/forgepy_cli.egg-info/top_level.txt +8 -0
  48. forgepy_cli-1.0.0/main.py +20 -0
  49. forgepy_cli-1.0.0/models/__init__.py +1 -0
  50. forgepy_cli-1.0.0/models/project_config.py +87 -0
  51. forgepy_cli-1.0.0/pyproject.toml +54 -0
  52. forgepy_cli-1.0.0/setup.cfg +4 -0
  53. forgepy_cli-1.0.0/templates/__init__.py +0 -0
  54. forgepy_cli-1.0.0/templates/app_template.py +20 -0
  55. forgepy_cli-1.0.0/templates/basic/basic_files.py +23 -0
  56. forgepy_cli-1.0.0/templates/basic/basic_template.py +32 -0
  57. forgepy_cli-1.0.0/templates/changelog_template.py +15 -0
  58. forgepy_cli-1.0.0/templates/cli/cli_files.py +70 -0
  59. forgepy_cli-1.0.0/templates/cli/cli_template.py +55 -0
  60. forgepy_cli-1.0.0/templates/env_template.py +20 -0
  61. forgepy_cli-1.0.0/templates/gitignore_template.py +27 -0
  62. forgepy_cli-1.0.0/templates/library/library_files.py +28 -0
  63. forgepy_cli-1.0.0/templates/library/library_template.py +56 -0
  64. forgepy_cli-1.0.0/templates/license_template.py +21 -0
  65. forgepy_cli-1.0.0/templates/pyproject_template.py +15 -0
  66. forgepy_cli-1.0.0/templates/readme_template.py +15 -0
  67. forgepy_cli-1.0.0/templates/requirements_template.py +13 -0
  68. forgepy_cli-1.0.0/templates/template_engine/base_template.py +58 -0
  69. forgepy_cli-1.0.0/templates/template_engine/file_template.py +76 -0
  70. forgepy_cli-1.0.0/templates/template_engine/package_name.py +30 -0
  71. forgepy_cli-1.0.0/templates/template_engine/template_context.py +24 -0
  72. forgepy_cli-1.0.0/templates/template_engine/template_files.py +10 -0
  73. forgepy_cli-1.0.0/templates/template_engine/template_metadata.py +59 -0
  74. forgepy_cli-1.0.0/templates/template_engine/template_registry.py +107 -0
  75. forgepy_cli-1.0.0/templates/template_manager.py +58 -0
  76. forgepy_cli-1.0.0/templates/vscode/__init__.py +0 -0
  77. forgepy_cli-1.0.0/templates/vscode/extensions_template.py +32 -0
  78. forgepy_cli-1.0.0/templates/vscode/launch_template.py +41 -0
  79. forgepy_cli-1.0.0/templates/vscode/settings_template.py +37 -0
  80. forgepy_cli-1.0.0/templates/vscode/tasks_template.py +66 -0
@@ -0,0 +1,53 @@
1
+ # Changelog
2
+
3
+ This changelog records release-facing changes without assigning versions or dates that do not exist in repository history.
4
+
5
+ ## Unreleased
6
+
7
+ ### Changed
8
+
9
+ - Prepared the first PyPI publication under the `forgepy-cli` distribution
10
+ name while preserving the ForgePy application name, `forgepy` command, and
11
+ canonical version `1.0.0`.
12
+ - Updated current project URLs for `rzou89/ForgePy` and added a GitHub OIDC
13
+ Trusted Publishing workflow. No PyPI publication has occurred.
14
+
15
+ ## 1.0.0
16
+
17
+ ForgePy 1.0.0 promotes the validated `1.0.0rc1` contents as the stable release
18
+ without additional product changes. The `v1.0.0` tag and GitHub Release exist;
19
+ no PyPI publication is claimed.
20
+
21
+ ## 1.0.0rc1
22
+
23
+ This is the first ForgePy v1.0 release candidate, not the final v1.0.0
24
+ release. It has not been published to PyPI.
25
+
26
+ ### Added
27
+
28
+ - Added the `library` and `cli` templates alongside the existing `basic` starter.
29
+ - Added project-local components for pytest, Ruff, and GitHub Actions, with explicit listing, installation, and installed-state commands.
30
+ - Added persistent user configuration for default template and location selection.
31
+ - Added standards-based setuptools packaging and the installed `forgepy` console command.
32
+ - Added a public getting-started README and repository CI for CPython 3.12, 3.13, and 3.14 on GitHub-hosted Windows runners.
33
+ - Added the maintainer-selected MIT License and corresponding package metadata.
34
+
35
+ ### Changed
36
+
37
+ - Defined Windows 10 and Windows 11 on CPython 3.12+ as the intended v1.0 support contract.
38
+ - Made Git initialization, staging, and the initial commit required for full project-creation success.
39
+ - Ordered VS Code generation before Git so editor configuration is included in the initial commit.
40
+ - Added finite timeouts and consistent operational failure reporting for external lifecycle commands.
41
+
42
+ ### Fixed
43
+
44
+ - Hardened project-name, destination, symlink, junction, and component-state confinement checks.
45
+ - Added package-name preflight so unusable library and CLI package identifiers fail before destination creation.
46
+ - Stabilized CLI exit codes and handled-error output while preserving unexpected programming failures.
47
+ - Made Windows tests compare equivalent resolved paths without weakening destination or state-safety assertions.
48
+
49
+ ## 0.6.0
50
+
51
+ The repository tag `v0.6.0` marks this Sprint 6 baseline. Its tagged `config/version.py` still reported `0.4.0`, which is a historical metadata mismatch.
52
+
53
+ - Established the tagged Sprint 6 baseline with the modular project generator, `basic` template, virtual-environment and requirements setup, VS Code configuration, and Git repository setup.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rendy Zou
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ include CHANGELOG.md
2
+ prune tests
3
+ prune utils
@@ -0,0 +1,176 @@
1
+ Metadata-Version: 2.4
2
+ Name: forgepy-cli
3
+ Version: 1.0.0
4
+ Summary: Create structured Python projects and prepare their development tooling.
5
+ Author: Rendy Zou
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/rzou89/ForgePy
8
+ Project-URL: Repository, https://github.com/rzou89/ForgePy
9
+ Project-URL: Issues, https://github.com/rzou89/ForgePy/issues
10
+ Keywords: python,project-generator,cli,windows
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Programming Language :: Python :: Implementation :: CPython
18
+ Classifier: Operating System :: Microsoft :: Windows
19
+ Requires-Python: >=3.12
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Dynamic: license-file
23
+
24
+ # ForgePy
25
+
26
+ ForgePy is a Windows-focused command-line tool that creates structured Python projects and prepares their development tooling.
27
+
28
+ ## What ForgePy Does
29
+
30
+ ForgePy generates a project from one of its built-in templates, creates a virtual environment, installs the generated requirements, writes VS Code configuration, and initializes the project as a Git repository with an initial commit. It also provides optional components that can add focused configuration files to an existing project.
31
+
32
+ ## Requirements
33
+
34
+ - Windows 10 or Windows 11
35
+ - CPython 3.12 or newer
36
+ - Git, required for project creation and configured with the user name and email needed to create a commit
37
+
38
+ Other operating systems and alternative Python implementations are not officially supported for ForgePy v1.0.
39
+
40
+ Repository CI tests ForgePy on GitHub-hosted `windows-latest` runners using CPython 3.12, 3.13, and 3.14. This verifies compatibility with the hosted Windows environment; it does not literally test native Windows 10 and Windows 11 client installations.
41
+
42
+ ## Installation
43
+
44
+ ForgePy is prepared for PyPI publication under the distribution name
45
+ `forgepy-cli`. After that first publication, install it with:
46
+
47
+ ```powershell
48
+ python -m pip install forgepy-cli
49
+ ```
50
+
51
+ The PyPI upload is still pending. Until it is completed, install from source as
52
+ described below or use the existing GitHub v1.0.0 release artifacts.
53
+
54
+ From a ForgePy source checkout, install the command with:
55
+
56
+ ```powershell
57
+ python -m pip install .
58
+ ```
59
+
60
+ For editable development work, use:
61
+
62
+ ```powershell
63
+ python -m pip install -e .
64
+ ```
65
+
66
+ ## Quick Start
67
+
68
+ Check the installed versions and available templates:
69
+
70
+ ```powershell
71
+ forgepy version
72
+ forgepy list
73
+ ```
74
+
75
+ Create a basic project below an existing parent directory:
76
+
77
+ ```powershell
78
+ forgepy create MyProject --location C:\Projects --template basic
79
+ cd C:\Projects\MyProject
80
+ ```
81
+
82
+ The destination must not already exist. Omitting the project name or location starts the corresponding prompt; an omitted template uses the configured default and then falls back to `basic`.
83
+
84
+ ## Available Templates
85
+
86
+ - `basic` - a basic application starter with a structured directory layout, `app.py`, project metadata, environment files, and generated requirements.
87
+ - `library` - a minimal reusable Python package with a normalized import-package directory and a `tests` package.
88
+ - `cli` - a minimal command-line package with `__main__.py`, an argparse interface, help and version behavior, and a `tests` package.
89
+
90
+ List the registered templates at any time with `forgepy list`.
91
+
92
+ ## Components
93
+
94
+ Components add one focused configuration file to an explicitly supplied existing project directory. ForgePy records successful component installations in project-local state.
95
+
96
+ Available components are:
97
+
98
+ - `pytest` - adds `pytest.ini`.
99
+ - `ruff` - adds `ruff.toml`.
100
+ - `github-actions` - adds a minimal `.github/workflows/ci.yml` for the generated project.
101
+
102
+ Use the verified component commands:
103
+
104
+ ```powershell
105
+ forgepy component list
106
+ forgepy component add pytest --project C:\Projects\MyProject
107
+ forgepy component installed --project C:\Projects\MyProject
108
+ ```
109
+
110
+ Component installation refuses an owned target that already exists. The generated-project `github-actions` component is separate from ForgePy's own repository CI workflow.
111
+
112
+ ## Configuration
113
+
114
+ ForgePy stores user configuration under `~/.forgepy/config.json`. Supported settings are `default_template`, `default_location`, `author`, and `license`.
115
+
116
+ ```powershell
117
+ forgepy config show
118
+ forgepy config set default_template library
119
+ forgepy config set default_location C:\Projects
120
+ forgepy config reset
121
+ ```
122
+
123
+ Only `default_template` and `default_location` currently affect project creation. `author` and `license` are persisted but are not applied to generated files.
124
+
125
+ Explicit `create` options take priority over configuration. See all supported syntax with:
126
+
127
+ ```powershell
128
+ forgepy create --help
129
+ forgepy config --help
130
+ ```
131
+
132
+ ## Project Creation Lifecycle
133
+
134
+ A successful `forgepy create` runs these stages in order:
135
+
136
+ 1. Generate the selected template.
137
+ 2. Create `.venv`.
138
+ 3. Update `pip`, `setuptools`, and `wheel` in that environment.
139
+ 4. Install the generated `requirements.txt`.
140
+ 5. Write VS Code configuration.
141
+ 6. Run `git init`.
142
+ 7. Run `git add .`.
143
+ 8. Create the initial Git commit.
144
+ 9. Report full success.
145
+
146
+ Git is a required part of successful project creation. Packaging-tool updates and dependency installation may require network access.
147
+
148
+ ## Failure and Partial Projects
149
+
150
+ If creation fails after ForgePy creates the destination, later stages stop and full success is not reported. Files generated by earlier stages may remain in the destination because ForgePy does not automatically roll back or clean up a partial project.
151
+
152
+ Inspect the destination and remove it when appropriate before retrying. ForgePy project creation is not transactional or atomic.
153
+
154
+ ## Development
155
+
156
+ Run the standard local validation from the repository root:
157
+
158
+ ```powershell
159
+ python -m unittest discover -s tests -v
160
+ python -m compileall -q components cli templates core config builders models tests
161
+ ```
162
+
163
+ Repository CI runs the test suite, compilation check, and packaging/support tests on `windows-latest` with CPython 3.12, 3.13, and 3.14. Its Python 3.12 job also builds and inspects the wheel and sdist, installs the wheel in isolation, and exercises the installed CLI.
164
+
165
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for repository workflow and review expectations.
166
+
167
+ ## Current Status
168
+
169
+ ForgePy v1.0.0 is the current stable Git tag and GitHub Release. The application
170
+ and command remain named ForgePy and `forgepy`; only the prepared PyPI
171
+ distribution name is `forgepy-cli`. Trusted Publishing is configured in the
172
+ repository, but the first PyPI upload has not occurred.
173
+
174
+ ## License
175
+
176
+ ForgePy is licensed under the [MIT License](LICENSE).
@@ -0,0 +1,153 @@
1
+ # ForgePy
2
+
3
+ ForgePy is a Windows-focused command-line tool that creates structured Python projects and prepares their development tooling.
4
+
5
+ ## What ForgePy Does
6
+
7
+ ForgePy generates a project from one of its built-in templates, creates a virtual environment, installs the generated requirements, writes VS Code configuration, and initializes the project as a Git repository with an initial commit. It also provides optional components that can add focused configuration files to an existing project.
8
+
9
+ ## Requirements
10
+
11
+ - Windows 10 or Windows 11
12
+ - CPython 3.12 or newer
13
+ - Git, required for project creation and configured with the user name and email needed to create a commit
14
+
15
+ Other operating systems and alternative Python implementations are not officially supported for ForgePy v1.0.
16
+
17
+ Repository CI tests ForgePy on GitHub-hosted `windows-latest` runners using CPython 3.12, 3.13, and 3.14. This verifies compatibility with the hosted Windows environment; it does not literally test native Windows 10 and Windows 11 client installations.
18
+
19
+ ## Installation
20
+
21
+ ForgePy is prepared for PyPI publication under the distribution name
22
+ `forgepy-cli`. After that first publication, install it with:
23
+
24
+ ```powershell
25
+ python -m pip install forgepy-cli
26
+ ```
27
+
28
+ The PyPI upload is still pending. Until it is completed, install from source as
29
+ described below or use the existing GitHub v1.0.0 release artifacts.
30
+
31
+ From a ForgePy source checkout, install the command with:
32
+
33
+ ```powershell
34
+ python -m pip install .
35
+ ```
36
+
37
+ For editable development work, use:
38
+
39
+ ```powershell
40
+ python -m pip install -e .
41
+ ```
42
+
43
+ ## Quick Start
44
+
45
+ Check the installed versions and available templates:
46
+
47
+ ```powershell
48
+ forgepy version
49
+ forgepy list
50
+ ```
51
+
52
+ Create a basic project below an existing parent directory:
53
+
54
+ ```powershell
55
+ forgepy create MyProject --location C:\Projects --template basic
56
+ cd C:\Projects\MyProject
57
+ ```
58
+
59
+ The destination must not already exist. Omitting the project name or location starts the corresponding prompt; an omitted template uses the configured default and then falls back to `basic`.
60
+
61
+ ## Available Templates
62
+
63
+ - `basic` - a basic application starter with a structured directory layout, `app.py`, project metadata, environment files, and generated requirements.
64
+ - `library` - a minimal reusable Python package with a normalized import-package directory and a `tests` package.
65
+ - `cli` - a minimal command-line package with `__main__.py`, an argparse interface, help and version behavior, and a `tests` package.
66
+
67
+ List the registered templates at any time with `forgepy list`.
68
+
69
+ ## Components
70
+
71
+ Components add one focused configuration file to an explicitly supplied existing project directory. ForgePy records successful component installations in project-local state.
72
+
73
+ Available components are:
74
+
75
+ - `pytest` - adds `pytest.ini`.
76
+ - `ruff` - adds `ruff.toml`.
77
+ - `github-actions` - adds a minimal `.github/workflows/ci.yml` for the generated project.
78
+
79
+ Use the verified component commands:
80
+
81
+ ```powershell
82
+ forgepy component list
83
+ forgepy component add pytest --project C:\Projects\MyProject
84
+ forgepy component installed --project C:\Projects\MyProject
85
+ ```
86
+
87
+ Component installation refuses an owned target that already exists. The generated-project `github-actions` component is separate from ForgePy's own repository CI workflow.
88
+
89
+ ## Configuration
90
+
91
+ ForgePy stores user configuration under `~/.forgepy/config.json`. Supported settings are `default_template`, `default_location`, `author`, and `license`.
92
+
93
+ ```powershell
94
+ forgepy config show
95
+ forgepy config set default_template library
96
+ forgepy config set default_location C:\Projects
97
+ forgepy config reset
98
+ ```
99
+
100
+ Only `default_template` and `default_location` currently affect project creation. `author` and `license` are persisted but are not applied to generated files.
101
+
102
+ Explicit `create` options take priority over configuration. See all supported syntax with:
103
+
104
+ ```powershell
105
+ forgepy create --help
106
+ forgepy config --help
107
+ ```
108
+
109
+ ## Project Creation Lifecycle
110
+
111
+ A successful `forgepy create` runs these stages in order:
112
+
113
+ 1. Generate the selected template.
114
+ 2. Create `.venv`.
115
+ 3. Update `pip`, `setuptools`, and `wheel` in that environment.
116
+ 4. Install the generated `requirements.txt`.
117
+ 5. Write VS Code configuration.
118
+ 6. Run `git init`.
119
+ 7. Run `git add .`.
120
+ 8. Create the initial Git commit.
121
+ 9. Report full success.
122
+
123
+ Git is a required part of successful project creation. Packaging-tool updates and dependency installation may require network access.
124
+
125
+ ## Failure and Partial Projects
126
+
127
+ If creation fails after ForgePy creates the destination, later stages stop and full success is not reported. Files generated by earlier stages may remain in the destination because ForgePy does not automatically roll back or clean up a partial project.
128
+
129
+ Inspect the destination and remove it when appropriate before retrying. ForgePy project creation is not transactional or atomic.
130
+
131
+ ## Development
132
+
133
+ Run the standard local validation from the repository root:
134
+
135
+ ```powershell
136
+ python -m unittest discover -s tests -v
137
+ python -m compileall -q components cli templates core config builders models tests
138
+ ```
139
+
140
+ Repository CI runs the test suite, compilation check, and packaging/support tests on `windows-latest` with CPython 3.12, 3.13, and 3.14. Its Python 3.12 job also builds and inspects the wheel and sdist, installs the wheel in isolation, and exercises the installed CLI.
141
+
142
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for repository workflow and review expectations.
143
+
144
+ ## Current Status
145
+
146
+ ForgePy v1.0.0 is the current stable Git tag and GitHub Release. The application
147
+ and command remain named ForgePy and `forgepy`; only the prepared PyPI
148
+ distribution name is `forgepy-cli`. Trusted Publishing is configured in the
149
+ repository, but the first PyPI upload has not occurred.
150
+
151
+ ## License
152
+
153
+ ForgePy is licensed under the [MIT License](LICENSE).
File without changes
@@ -0,0 +1,17 @@
1
+ """
2
+ ==================================================
3
+ ForgePy
4
+ Module : Base Builder
5
+ ==================================================
6
+ """
7
+
8
+
9
+ class BaseBuilder:
10
+ """
11
+ Parent class seluruh Builder ForgePy.
12
+
13
+ Digunakan sebagai parent agar seluruh Builder
14
+ mempunyai struktur yang konsisten.
15
+ """
16
+
17
+ pass
@@ -0,0 +1,31 @@
1
+ """
2
+ ==================================================
3
+ ForgePy
4
+ Module : File Builder
5
+ ==================================================
6
+ """
7
+
8
+ from pathlib import Path
9
+
10
+ from builders.base_builder import BaseBuilder
11
+
12
+
13
+ class FileBuilder(BaseBuilder):
14
+
15
+ def write(
16
+ self,
17
+ path: Path,
18
+ content: str,
19
+ ) -> None:
20
+
21
+ path.parent.mkdir(
22
+ parents=True,
23
+ exist_ok=True,
24
+ )
25
+
26
+ path.write_text(
27
+ content,
28
+ encoding="utf-8",
29
+ )
30
+
31
+ print(f"[OK] File dibuat : {path}")
@@ -0,0 +1,30 @@
1
+ """
2
+ ==================================================
3
+ ForgePy
4
+ Module : Folder Builder
5
+ ==================================================
6
+ """
7
+
8
+ from pathlib import Path
9
+
10
+ from builders.base_builder import BaseBuilder
11
+
12
+
13
+ class FolderBuilder(BaseBuilder):
14
+
15
+ def create(
16
+ self,
17
+ root: Path,
18
+ folders: list[str],
19
+ ) -> None:
20
+
21
+ for folder in folders:
22
+
23
+ path = root / folder
24
+
25
+ path.mkdir(
26
+ parents=True,
27
+ exist_ok=True,
28
+ )
29
+
30
+ print(f"[OK] Folder dibuat : {path}")
@@ -0,0 +1,64 @@
1
+ """
2
+ ==================================================
3
+ ForgePy
4
+ Module : Python Tools Builder
5
+ ==================================================
6
+ """
7
+
8
+ import subprocess
9
+ from pathlib import Path
10
+
11
+ from builders.base_builder import BaseBuilder
12
+
13
+
14
+ PACKAGE_TOOL_UPDATE_TIMEOUT_SECONDS = 300
15
+
16
+
17
+ class PythonToolsBuilder(BaseBuilder):
18
+ """
19
+ Mengupdate pip, setuptools, dan wheel
20
+ pada Virtual Environment.
21
+ """
22
+
23
+ def update(
24
+ self,
25
+ project_path: Path,
26
+ ) -> None:
27
+
28
+ python = project_path / ".venv" / "Scripts" / "python.exe"
29
+
30
+ if not python.exists():
31
+ print("[WARNING] Virtual Environment belum tersedia.")
32
+ return
33
+
34
+ packages = [
35
+ "pip",
36
+ "setuptools",
37
+ "wheel",
38
+ ]
39
+
40
+ for package in packages:
41
+
42
+ print(f"[INFO] Mengupdate {package}...")
43
+
44
+ try:
45
+ subprocess.run(
46
+ [
47
+ str(python),
48
+ "-m",
49
+ "pip",
50
+ "install",
51
+ "--upgrade",
52
+ package,
53
+ ],
54
+ check=True,
55
+ timeout=PACKAGE_TOOL_UPDATE_TIMEOUT_SECONDS,
56
+ )
57
+ except subprocess.SubprocessError as error:
58
+ print(
59
+ "[ERROR] Packaging-tool update failed for "
60
+ f"'{package}': {error}"
61
+ )
62
+ raise
63
+
64
+ print(f"[OK] {package} berhasil diupdate.")
@@ -0,0 +1,3 @@
1
+ """
2
+ ForgePy CLI Package
3
+ """
@@ -0,0 +1,52 @@
1
+ """
2
+ ==================================================
3
+ ForgePy
4
+ Module : Base Command
5
+ ==================================================
6
+ """
7
+
8
+ from abc import ABC, abstractmethod
9
+ from argparse import ArgumentParser, Namespace
10
+
11
+
12
+ class Command(ABC):
13
+ """
14
+ Kontrak dasar untuk seluruh command ForgePy.
15
+ """
16
+
17
+ name: str = ""
18
+ summary: str = ""
19
+ description: str = ""
20
+
21
+ def validate_registration(self) -> None:
22
+ """
23
+ Memastikan metadata command lengkap sebelum didaftarkan.
24
+ """
25
+
26
+ for field in (
27
+ "name",
28
+ "summary",
29
+ "description",
30
+ ):
31
+ if not getattr(self, field):
32
+ raise ValueError(
33
+ f"Command '{type(self).__name__}' harus memiliki {field}."
34
+ )
35
+
36
+ def configure_parser(
37
+ self,
38
+ parser: ArgumentParser,
39
+ ) -> None:
40
+ """
41
+ Mendaftarkan argumen khusus command.
42
+
43
+ Command tanpa argumen dapat menggunakan implementasi default.
44
+ """
45
+ del parser
46
+
47
+ @abstractmethod
48
+ def execute(self, args: Namespace) -> int:
49
+ """
50
+ Menjalankan command dan mengembalikan status proses CLI.
51
+ """
52
+ raise NotImplementedError
@@ -0,0 +1,32 @@
1
+ """
2
+ ForgePy Commands
3
+
4
+ Seluruh command bawaan didaftarkan pada module ini.
5
+ """
6
+
7
+ from cli.command import Command
8
+ from cli.commands.component_command import ComponentCommand
9
+ from cli.commands.config_command import ConfigCommand
10
+ from cli.commands.create_command import CreateCommand
11
+ from cli.commands.list_command import ListCommand
12
+ from cli.commands.version_command import VersionCommand
13
+
14
+
15
+ DEFAULT_COMMAND = "create"
16
+
17
+
18
+ def create_commands() -> tuple[Command, ...]:
19
+ """
20
+ Membuat seluruh command bawaan dalam urutan tampilan CLI.
21
+
22
+ Command baru hanya perlu ditambahkan pada catalog ini agar parser
23
+ dan dispatcher menggunakan registrasi yang sama.
24
+ """
25
+
26
+ return (
27
+ CreateCommand(),
28
+ VersionCommand(),
29
+ ListCommand(),
30
+ ConfigCommand(),
31
+ ComponentCommand(),
32
+ )