framework-m-studio 0.2.3__py3-none-any.whl → 0.3.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.
framework_m_studio/cli.py DELETED
@@ -1,247 +0,0 @@
1
- """Framework M Studio CLI Commands.
2
-
3
- This module provides CLI commands that are registered via entry points
4
- when framework-m-studio is installed. These extend the base `m` CLI
5
- with developer tools.
6
-
7
- Entry Point Registration (pyproject.toml):
8
- [project.entry-points."framework_m.cli_commands"]
9
- codegen = "framework_m_studio.cli:codegen_app"
10
- """
11
-
12
- from __future__ import annotations
13
-
14
- from typing import Annotated
15
-
16
- import cyclopts
17
-
18
- # =============================================================================
19
- # Codegen Sub-App
20
- # =============================================================================
21
-
22
- codegen_app = cyclopts.App(
23
- name="codegen",
24
- help="Code generation tools for Framework M",
25
- )
26
-
27
-
28
- @codegen_app.command(name="client")
29
- def codegen_client(
30
- lang: Annotated[
31
- str,
32
- cyclopts.Parameter(
33
- name="--lang",
34
- help="Target language: ts (TypeScript) or py (Python)",
35
- ),
36
- ] = "ts",
37
- out: Annotated[
38
- str,
39
- cyclopts.Parameter(
40
- name="--out",
41
- help="Output directory for generated code",
42
- ),
43
- ] = "./generated",
44
- openapi_url: Annotated[
45
- str,
46
- cyclopts.Parameter(
47
- name="--openapi-url",
48
- help="URL to fetch OpenAPI schema from",
49
- ),
50
- ] = "http://localhost:8000/schema/openapi.json",
51
- ) -> None:
52
- """Generate API client from OpenAPI schema.
53
-
54
- Examples:
55
- m codegen client --lang ts --out ./frontend/src/api
56
- m codegen client --lang py --out ./scripts/api_client
57
- """
58
- from pathlib import Path
59
-
60
- from framework_m_studio.sdk_generator import (
61
- fetch_openapi_schema,
62
- generate_typescript_client,
63
- generate_typescript_types,
64
- )
65
-
66
- print(f"Generating {lang.upper()} client...")
67
- print(f" OpenAPI URL: {openapi_url}")
68
- print(f" Output: {out}")
69
-
70
- # Create output directory
71
- output_path = Path(out)
72
- output_path.mkdir(parents=True, exist_ok=True)
73
-
74
- # Fetch schema and generate
75
- schema = fetch_openapi_schema(openapi_url)
76
- if lang.lower() == "ts":
77
- types_code = generate_typescript_types(schema)
78
- client_code = generate_typescript_client(schema)
79
- (output_path / "types.ts").write_text(types_code)
80
- (output_path / "client.ts").write_text(client_code)
81
-
82
-
83
- @codegen_app.command(name="doctype")
84
- def codegen_doctype(
85
- name: Annotated[
86
- str,
87
- cyclopts.Parameter(help="DocType class name (PascalCase)"),
88
- ],
89
- app: Annotated[
90
- str | None,
91
- cyclopts.Parameter(
92
- name="--app",
93
- help="Target app directory",
94
- ),
95
- ] = None,
96
- ) -> None:
97
- """Generate DocType Python code from schema.
98
-
99
- This is the programmatic version of the Studio UI's
100
- DocType builder. Useful for CI/CD pipelines.
101
-
102
- Examples:
103
- m codegen doctype Invoice --app apps/billing
104
- """
105
- print(f"Generating DocType: {name}")
106
- if app:
107
- print(f" Target app: {app}")
108
- print()
109
- print("⚠️ Not yet implemented. Coming in Phase 07.")
110
- print(" Will use LibCST for code generation")
111
-
112
-
113
- # =============================================================================
114
- # Docs Sub-App (Optional - registered via separate entry point if needed)
115
- # =============================================================================
116
-
117
- docs_app = cyclopts.App(
118
- name="docs",
119
- help="Documentation generation tools",
120
- )
121
-
122
-
123
- @docs_app.command(name="generate")
124
- def docs_generate(
125
- output: Annotated[
126
- str,
127
- cyclopts.Parameter(
128
- name="--output",
129
- help="Output directory for documentation",
130
- ),
131
- ] = "./docs/api",
132
- openapi_url: Annotated[
133
- str | None,
134
- cyclopts.Parameter(
135
- name="--openapi-url",
136
- help="URL to fetch OpenAPI schema from (optional)",
137
- ),
138
- ] = None,
139
- ) -> None:
140
- """Generate API documentation from DocTypes.
141
-
142
- Examples:
143
- m docs generate --output ./docs/api
144
- """
145
- from pathlib import Path
146
-
147
- from framework_m_studio.docs_generator import run_docs_generate
148
-
149
- # Use current working directory as project root
150
- project_root = Path.cwd()
151
-
152
- # Look in src/doctypes if it exists, otherwise use project root
153
- doctypes_dir = project_root / "src" / "doctypes"
154
- scan_root = project_root / "src" if doctypes_dir.exists() else project_root
155
-
156
- run_docs_generate(
157
- output=output,
158
- project_root=str(scan_root),
159
- openapi_url=openapi_url,
160
- )
161
-
162
-
163
- # =============================================================================
164
- # Studio Sub-App (Main command to start Studio server)
165
- # =============================================================================
166
-
167
- studio_app = cyclopts.App(
168
- name="studio",
169
- help="Start Framework M Studio visual editor",
170
- )
171
-
172
-
173
- @studio_app.default
174
- def studio_serve(
175
- port: Annotated[
176
- int,
177
- cyclopts.Parameter(
178
- name="--port",
179
- help="Port to run Studio on",
180
- ),
181
- ] = 9000,
182
- host: Annotated[
183
- str,
184
- cyclopts.Parameter(
185
- name="--host",
186
- help="Host to bind to",
187
- ),
188
- ] = "127.0.0.1",
189
- reload: Annotated[
190
- bool,
191
- cyclopts.Parameter(
192
- name="--reload",
193
- help="Enable auto-reload for development",
194
- ),
195
- ] = False,
196
- cloud: Annotated[
197
- bool,
198
- cyclopts.Parameter(
199
- name="--cloud",
200
- help="Enable cloud mode (Git-backed workspaces)",
201
- ),
202
- ] = False,
203
- ) -> None:
204
- """Start Framework M Studio.
205
-
206
- Examples:
207
- m studio # Start on port 9000
208
- m studio --port 8000 # Custom port
209
- m studio --reload # Development mode
210
- m studio --cloud # Enable cloud mode
211
- """
212
- import os
213
-
214
- import uvicorn
215
-
216
- # Print startup banner
217
- print()
218
- print("🎨 Starting Framework M Studio")
219
- print(f" ➜ Local: http://{host}:{port}/studio/")
220
- print(f" ➜ API: http://{host}:{port}/studio/api/")
221
- print(f" 🔌 API Health: http://{host}:{port}/studio/api/health")
222
- print()
223
-
224
- if cloud:
225
- print("☁️ Cloud mode enabled - Git-backed workspaces")
226
- os.environ["STUDIO_CLOUD_MODE"] = "1"
227
- print()
228
-
229
- # Start uvicorn
230
- uvicorn.run(
231
- "framework_m_studio.app:app",
232
- host=host,
233
- port=port,
234
- reload=reload,
235
- log_level="info",
236
- )
237
-
238
-
239
- __all__ = [
240
- "codegen_app",
241
- "codegen_client",
242
- "codegen_doctype",
243
- "docs_app",
244
- "docs_generate",
245
- "studio_app",
246
- "studio_serve",
247
- ]