fastpluggy-cli 0.1.1__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 (34) hide show
  1. fastpluggy_cli-0.1.1/MANIFEST.in +1 -0
  2. fastpluggy_cli-0.1.1/PKG-INFO +20 -0
  3. fastpluggy_cli-0.1.1/README.md +199 -0
  4. fastpluggy_cli-0.1.1/fastpluggy_cli/__init__.py +0 -0
  5. fastpluggy_cli-0.1.1/fastpluggy_cli/cli.py +1000 -0
  6. fastpluggy_cli-0.1.1/fastpluggy_cli/scaffold_templates/main.py.j2 +21 -0
  7. fastpluggy_cli-0.1.1/fastpluggy_cli/scaffold_templates/plugin/config.py.j2 +22 -0
  8. fastpluggy_cli-0.1.1/fastpluggy_cli/scaffold_templates/plugin/index.html.j2 +10 -0
  9. fastpluggy_cli-0.1.1/fastpluggy_cli/scaffold_templates/plugin/models/__init__.py.j2 +1 -0
  10. fastpluggy_cli-0.1.1/fastpluggy_cli/scaffold_templates/plugin/models/context.py.j2 +37 -0
  11. fastpluggy_cli-0.1.1/fastpluggy_cli/scaffold_templates/plugin/models/report.py.j2 +27 -0
  12. fastpluggy_cli-0.1.1/fastpluggy_cli/scaffold_templates/plugin/models/scheduled.py.j2 +38 -0
  13. fastpluggy_cli-0.1.1/fastpluggy_cli/scaffold_templates/plugin/plugin.py.j2 +49 -0
  14. fastpluggy_cli-0.1.1/fastpluggy_cli/scaffold_templates/plugin/pyproject.toml.j2 +34 -0
  15. fastpluggy_cli-0.1.1/fastpluggy_cli/scaffold_templates/plugin/router.py.j2 +37 -0
  16. fastpluggy_cli-0.1.1/fastpluggy_cli/scaffold_templates/plugin/runner.py.j2 +171 -0
  17. fastpluggy_cli-0.1.1/fastpluggy_cli/scaffold_templates/plugin/tasks/__init__.py.j2 +1 -0
  18. fastpluggy_cli-0.1.1/fastpluggy_cli/scaffold_templates/plugin/tasks/maintenance.py.j2 +50 -0
  19. fastpluggy_cli-0.1.1/fastpluggy_cli/scaffold_templates/plugin/tasks/plugin_update.py.j2 +53 -0
  20. fastpluggy_cli-0.1.1/fastpluggy_cli/scaffold_templates/plugin/tasks/scheduler.py.j2 +73 -0
  21. fastpluggy_cli-0.1.1/fastpluggy_cli.egg-info/PKG-INFO +20 -0
  22. fastpluggy_cli-0.1.1/fastpluggy_cli.egg-info/SOURCES.txt +32 -0
  23. fastpluggy_cli-0.1.1/fastpluggy_cli.egg-info/dependency_links.txt +1 -0
  24. fastpluggy_cli-0.1.1/fastpluggy_cli.egg-info/entry_points.txt +3 -0
  25. fastpluggy_cli-0.1.1/fastpluggy_cli.egg-info/requires.txt +17 -0
  26. fastpluggy_cli-0.1.1/fastpluggy_cli.egg-info/top_level.txt +1 -0
  27. fastpluggy_cli-0.1.1/pyproject.toml +43 -0
  28. fastpluggy_cli-0.1.1/setup.cfg +4 -0
  29. fastpluggy_cli-0.1.1/tests/test_cli.py +28 -0
  30. fastpluggy_cli-0.1.1/tests/test_cli_commands.py +65 -0
  31. fastpluggy_cli-0.1.1/tests/test_fix.py +241 -0
  32. fastpluggy_cli-0.1.1/tests/test_new_plugin.py +327 -0
  33. fastpluggy_cli-0.1.1/tests/test_plugin_commands.py +168 -0
  34. fastpluggy_cli-0.1.1/tests/test_validate.py +138 -0
@@ -0,0 +1 @@
1
+ recursive-include fastpluggy_cli/scaffold_templates *
@@ -0,0 +1,20 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastpluggy-cli
3
+ Version: 0.1.1
4
+ Summary: A CLI tool to scaffold FastPluggy projects
5
+ Author: Jerome Vaillant
6
+ License-Expression: MIT
7
+ Requires-Dist: click==8.3.1
8
+ Requires-Dist: jinja2
9
+ Requires-Dist: requests
10
+ Requires-Dist: questionary
11
+ Requires-Dist: uvicorn[standard]
12
+ Requires-Dist: fastpluggy>=0.4.15
13
+ Requires-Dist: fastapi
14
+ Provides-Extra: e2e
15
+ Requires-Dist: playwright; extra == "e2e"
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest==9.0.2; extra == "dev"
18
+ Requires-Dist: pytest-cov==7.0.0; extra == "dev"
19
+ Provides-Extra: ssl
20
+ Requires-Dist: cryptography==46.0.5; extra == "ssl"
@@ -0,0 +1,199 @@
1
+ # FastPluggy CLI
2
+
3
+ A CLI tool to scaffold projects, plugins, and auto-fix compliance issues for the [FastPluggy](https://github.com/jeromevaillant/fastpluggy) framework.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ cd fastpluggy-cli
9
+ pip install -e .
10
+ ```
11
+
12
+ ## Available Commands
13
+
14
+ ### Create a new project
15
+
16
+ ```bash
17
+ fastpluggy new [my_app]
18
+ ```
19
+
20
+ Generates a FastPluggy project skeleton in the `my_app` directory. If no name is provided, the CLI prompts interactively.
21
+
22
+ The generated project includes:
23
+ - A modern FastAPI app structure with CORS middleware
24
+ - Environment variables for FastPluggy configuration
25
+ - Optional SSL certificate generation
26
+ - A `.env` file for configuration
27
+ - A `pyproject.toml` for dependency management
28
+ - An optional example module
29
+
30
+ ### Create a new plugin
31
+
32
+ ```bash
33
+ fastpluggy new-plugin [plugin_name]
34
+ ```
35
+
36
+ Scaffolds a new plugin with source layout, tests, templates, and standard files.
37
+
38
+ ### Fix plugin compliance issues
39
+
40
+ ```bash
41
+ fastpluggy fix-plugin [plugin_dir]
42
+ ```
43
+
44
+ Runs compliance checks and interactively lets you select which issues to fix. Shows each failing rule with a description and lets you pick from a checkbox list.
45
+
46
+ Options:
47
+ - `--all` — apply all fixes without prompting
48
+ - `--rule R4 --rule R6` — only fix specific rules
49
+ - `--dry-run` — preview changes without writing files
50
+
51
+ Auto-fixable rules:
52
+
53
+ | Rule | What it fixes |
54
+ |------|---------------|
55
+ | R1 | Create `docs/` directory |
56
+ | R2 | Create `README.md` |
57
+ | R3 | Add `[e2e]` optional deps to `pyproject.toml` |
58
+ | R4 | Create `e2e/` directory with `.gitkeep` |
59
+ | R6 | Create `docs/screenshots/e2e/` with `.gitkeep` |
60
+ | R9 | Create `tests/` with stub test |
61
+ | R10 | Create or update `.gitignore` |
62
+ | R12 | Create `e2e/routes.json` skeleton |
63
+
64
+ Example:
65
+
66
+ ```bash
67
+ # Interactive — pick which fixes to apply
68
+ fastpluggy fix-plugin plugins/my_plugin
69
+
70
+ # Fix everything at once
71
+ fastpluggy fix-plugin --all plugins/my_plugin
72
+
73
+ # Preview only
74
+ fastpluggy fix-plugin --dry-run .
75
+ ```
76
+
77
+ ### Start dev server
78
+
79
+ ```bash
80
+ fastpluggy start-dev-server [--port PORT] [--host HOST] [--reload]
81
+ ```
82
+
83
+ Auto-discovers all installed plugins via entry points. Defaults `DATABASE_URL` to SQLite if not set.
84
+
85
+ ### Show help
86
+
87
+ ```bash
88
+ fastpluggy help
89
+ ```
90
+
91
+ ## Dependencies
92
+
93
+ - Python 3.9+
94
+ - click
95
+ - questionary
96
+ - jinja2
97
+ - requests
98
+ - cryptography (optional, for SSL certificate generation)
99
+
100
+ ```bash
101
+ pip install -e .
102
+ # For SSL certificate generation
103
+ pip install -e ".[ssl]"
104
+ ```
105
+
106
+ ## Plugin CLI Extensions
107
+
108
+ Plugins can inject their own CLI commands under the `fastpluggy` group. Plugin commands appear in a separate **Plugin Commands** section in `fastpluggy --help`.
109
+
110
+ ### How it works
111
+
112
+ At startup, the CLI discovers entry points registered under the `fastpluggy.cli` group and registers each as a subcommand. Each entry point **must** be a `click.Group` (not a flat command) to avoid name collisions.
113
+
114
+ ### Registering a plugin command group
115
+
116
+ In your plugin's `pyproject.toml`:
117
+
118
+ ```toml
119
+ [project.entry-points."fastpluggy.cli"]
120
+ my-plugin = "my_package.cli:my_group"
121
+ ```
122
+
123
+ In your plugin's `cli.py`:
124
+
125
+ ```python
126
+ import click
127
+
128
+ @click.group("my-plugin")
129
+ def my_group():
130
+ """My plugin commands."""
131
+ pass
132
+
133
+ @my_group.command()
134
+ def do_something():
135
+ """Run my plugin task."""
136
+ click.echo("Done!")
137
+ ```
138
+
139
+ This gives the user `fastpluggy my-plugin do-something`.
140
+
141
+ ### Contract
142
+
143
+ | Item | Requirement |
144
+ |------|-------------|
145
+ | Entry point group | `fastpluggy.cli` |
146
+ | Entry point value | A `click.Group` instance (or zero-arg callable returning one) |
147
+ | Naming convention | Use the plugin name with hyphens (e.g. `auth-user`, `tasks-worker`) |
148
+ | Collision handling | First registered wins; conflicts produce a stderr warning |
149
+ | Import errors | Swallowed gracefully with a stderr warning — the CLI never crashes |
150
+
151
+ ### Help output
152
+
153
+ ```
154
+ $ fastpluggy --help
155
+
156
+ Core Commands:
157
+ fix-plugin Interactive auto-fix for failing compliance checks
158
+ help Show available commands
159
+ new Create a new FastPluggy project
160
+ new-plugin Scaffold a new plugin
161
+ start-dev-server Start a FastPluggy dev server with auto-discovered plugins
162
+
163
+ Plugin Commands:
164
+ auth-user Auth user management commands
165
+ tasks-worker Background task worker commands
166
+ ```
167
+
168
+ ## Migration: `--start-worker` removed
169
+
170
+ The `--start-worker` flag on `fastpluggy start-dev-server` has been **removed**.
171
+ Background workers are now started via the plugin CLI extension:
172
+
173
+ ```bash
174
+ # Before (removed)
175
+ fastpluggy start-dev-server --start-worker
176
+
177
+ # After
178
+ fastpluggy tasks-worker start
179
+ # Or with a custom worker count:
180
+ fastpluggy tasks-worker start -n 4
181
+ ```
182
+
183
+ The `tasks-worker` group is auto-discovered from the `fastpluggy-tasks-worker`
184
+ package when installed.
185
+
186
+ ## Tests
187
+
188
+ ```bash
189
+ # Install dev dependencies
190
+ pip install -e ".[dev]"
191
+
192
+ # Run tests
193
+ pytest
194
+
195
+ # Run tests with coverage
196
+ pytest --cov=fastpluggy_cli
197
+ ```
198
+
199
+ Tests verify CLI commands and are also run automatically in the CI/CD pipeline.
File without changes