webcompy-cli 0.0.14__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.
- webcompy_cli/__init__.py +20 -0
- webcompy_cli/_argparser.py +232 -0
- webcompy_cli/_browser_probes.py +648 -0
- webcompy_cli/_browser_test_harness.py +554 -0
- webcompy_cli/_build.py +425 -0
- webcompy_cli/_console_types.py +15 -0
- webcompy_cli/_dependency_resolver.py +301 -0
- webcompy_cli/_dualrun_pytest_plugin.py +130 -0
- webcompy_cli/_exception.py +9 -0
- webcompy_cli/_generate.py +224 -0
- webcompy_cli/_init_project.py +54 -0
- webcompy_cli/_inspect.py +741 -0
- webcompy_cli/_inspect_pyexec.py +244 -0
- webcompy_cli/_lock.py +82 -0
- webcompy_cli/_lockfile.py +396 -0
- webcompy_cli/_lockfile_sync.py +343 -0
- webcompy_cli/_output.py +150 -0
- webcompy_cli/_prebuild.py +661 -0
- webcompy_cli/_pwa.py +474 -0
- webcompy_cli/_pyodide_downloader.py +113 -0
- webcompy_cli/_pyodide_lock.py +74 -0
- webcompy_cli/_runtime_downloader.py +222 -0
- webcompy_cli/_server.py +568 -0
- webcompy_cli/_static_files.py +27 -0
- webcompy_cli/_utils.py +72 -0
- webcompy_cli/_version_sweep.py +213 -0
- webcompy_cli/_wheel_builder.py +509 -0
- webcompy_cli/config/__init__.py +23 -0
- webcompy_cli/config/_build_config.py +168 -0
- webcompy_cli/config/_pwa_config.py +203 -0
- webcompy_cli/config/_server_config.py +53 -0
- webcompy_cli/py.typed +0 -0
- webcompy_cli/template_data/app/__init__.py +0 -0
- webcompy_cli/template_data/app/app.py +22 -0
- webcompy_cli/template_data/app/components/__init__.py +0 -0
- webcompy_cli/template_data/app/components/fizzbuzz.py +117 -0
- webcompy_cli/template_data/app/components/home.py +15 -0
- webcompy_cli/template_data/app/components/input.py +34 -0
- webcompy_cli/template_data/app/components/navigation.py +36 -0
- webcompy_cli/template_data/app/components/not_found.py +22 -0
- webcompy_cli/template_data/app/components/root.py +16 -0
- webcompy_cli/template_data/app/router.py +17 -0
- webcompy_cli/template_data/webcompy_config.py +12 -0
- webcompy_cli-0.0.14.dist-info/METADATA +53 -0
- webcompy_cli-0.0.14.dist-info/RECORD +47 -0
- webcompy_cli-0.0.14.dist-info/WHEEL +4 -0
- webcompy_cli-0.0.14.dist-info/licenses/LICENSE +21 -0
webcompy_cli/__init__.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Public entry points for the ``webcompy_cli`` package.
|
|
2
|
+
|
|
3
|
+
LLM-friendly documentation is published at https://webcompy.net/llms.txt
|
|
4
|
+
(compact: https://webcompy.net/llms-small.txt, full: https://webcompy.net/llms-full.txt).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from webcompy_cli._generate import generate_static_site
|
|
8
|
+
from webcompy_cli._inspect import run_inspect
|
|
9
|
+
from webcompy_cli._prebuild import prebuild_app
|
|
10
|
+
from webcompy_cli._server import create_asgi_app, run_server
|
|
11
|
+
from webcompy_cli._utils import discover_config
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"create_asgi_app",
|
|
15
|
+
"discover_config",
|
|
16
|
+
"generate_static_site",
|
|
17
|
+
"prebuild_app",
|
|
18
|
+
"run_inspect",
|
|
19
|
+
"run_server",
|
|
20
|
+
]
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"""Command-line argument parsing for the ``webcompy`` CLI."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from argparse import ArgumentParser
|
|
5
|
+
from typing import Any, Literal
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _add_shared_build_args(parser: ArgumentParser) -> None:
|
|
9
|
+
parser.add_argument(
|
|
10
|
+
"--config",
|
|
11
|
+
type=str,
|
|
12
|
+
help="Python import path for config module (e.g., my_project.webcompy_config)",
|
|
13
|
+
)
|
|
14
|
+
serve_all_deps_flags = parser.add_mutually_exclusive_group()
|
|
15
|
+
serve_all_deps_flags.add_argument(
|
|
16
|
+
"--serve-all-deps",
|
|
17
|
+
action="store_true",
|
|
18
|
+
default=None,
|
|
19
|
+
dest="serve_all_deps",
|
|
20
|
+
help="bundle all pure-Python deps into app wheel (default)",
|
|
21
|
+
)
|
|
22
|
+
serve_all_deps_flags.add_argument(
|
|
23
|
+
"--no-serve-all-deps",
|
|
24
|
+
action="store_false",
|
|
25
|
+
dest="serve_all_deps",
|
|
26
|
+
help="load CDN-available pure-Python deps from Pyodide CDN",
|
|
27
|
+
)
|
|
28
|
+
parser.add_argument(
|
|
29
|
+
"--wasm-serving",
|
|
30
|
+
choices=["cdn", "local"],
|
|
31
|
+
default=None,
|
|
32
|
+
help="WASM package serving mode: 'cdn' (default) or 'local'",
|
|
33
|
+
)
|
|
34
|
+
parser.add_argument(
|
|
35
|
+
"--runtime-serving",
|
|
36
|
+
choices=["cdn", "local"],
|
|
37
|
+
default=None,
|
|
38
|
+
help="PyScript/Pyodide runtime serving mode: 'cdn' (default) or 'local'",
|
|
39
|
+
)
|
|
40
|
+
standalone_flags = parser.add_mutually_exclusive_group()
|
|
41
|
+
standalone_flags.add_argument(
|
|
42
|
+
"--standalone",
|
|
43
|
+
action="store_true",
|
|
44
|
+
default=None,
|
|
45
|
+
dest="standalone",
|
|
46
|
+
help="enable standalone mode (all assets served locally)",
|
|
47
|
+
)
|
|
48
|
+
standalone_flags.add_argument(
|
|
49
|
+
"--no-standalone",
|
|
50
|
+
action="store_false",
|
|
51
|
+
dest="standalone",
|
|
52
|
+
help="disable standalone mode (default)",
|
|
53
|
+
)
|
|
54
|
+
parser.add_argument(
|
|
55
|
+
"--wheel-mode",
|
|
56
|
+
choices=["bundled", "split"],
|
|
57
|
+
default=None,
|
|
58
|
+
help="wheel bundling mode: 'bundled' (default) or 'split'",
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def get_params() -> tuple[Literal["start", "generate", "prebuild", "init", "lock", "inspect"], dict[str, Any]]:
|
|
63
|
+
def _command(subcommand_name: str):
|
|
64
|
+
return lambda: subcommand_name
|
|
65
|
+
|
|
66
|
+
maincommand = "python -m webcompy"
|
|
67
|
+
parser = ArgumentParser(
|
|
68
|
+
prog=maincommand,
|
|
69
|
+
add_help=True,
|
|
70
|
+
epilog="Documentation: https://webcompy.net/documents/ | LLM docs: https://webcompy.net/llms.txt",
|
|
71
|
+
)
|
|
72
|
+
subparsers = parser.add_subparsers()
|
|
73
|
+
|
|
74
|
+
# start
|
|
75
|
+
subcommand_name = "start"
|
|
76
|
+
parser_start = subparsers.add_parser(
|
|
77
|
+
subcommand_name,
|
|
78
|
+
help=f"Starts HTTP server. See `{maincommand} {subcommand_name} --help` for options.",
|
|
79
|
+
)
|
|
80
|
+
parser_start.add_argument(
|
|
81
|
+
"--dev",
|
|
82
|
+
action="store_true",
|
|
83
|
+
help="launch dev server with hot-reload",
|
|
84
|
+
)
|
|
85
|
+
parser_start.add_argument(
|
|
86
|
+
"--port",
|
|
87
|
+
type=int,
|
|
88
|
+
help="server port",
|
|
89
|
+
)
|
|
90
|
+
parser_start.add_argument(
|
|
91
|
+
"--prebuilt",
|
|
92
|
+
nargs="?",
|
|
93
|
+
const="",
|
|
94
|
+
default=None,
|
|
95
|
+
metavar="DIR",
|
|
96
|
+
help="serve from prebuilt artifacts without build-time resolution",
|
|
97
|
+
)
|
|
98
|
+
parser_start.add_argument(
|
|
99
|
+
"--no-serve-assets",
|
|
100
|
+
action="store_true",
|
|
101
|
+
help="disable serving framework assets and static files (for CDN / asset offloading)",
|
|
102
|
+
)
|
|
103
|
+
_add_shared_build_args(parser_start)
|
|
104
|
+
parser_start.set_defaults(__command_getter__=_command(subcommand_name))
|
|
105
|
+
|
|
106
|
+
# generate
|
|
107
|
+
subcommand_name = "generate"
|
|
108
|
+
parser_generate = subparsers.add_parser(
|
|
109
|
+
subcommand_name,
|
|
110
|
+
help=f"Generates static html files. See `{maincommand} {subcommand_name} --help` for options.",
|
|
111
|
+
)
|
|
112
|
+
parser_generate.add_argument(
|
|
113
|
+
"--dist",
|
|
114
|
+
type=str,
|
|
115
|
+
help="dist dir",
|
|
116
|
+
)
|
|
117
|
+
_add_shared_build_args(parser_generate)
|
|
118
|
+
parser_generate.set_defaults(__command_getter__=_command(subcommand_name))
|
|
119
|
+
|
|
120
|
+
# prebuild
|
|
121
|
+
subcommand_name = "prebuild"
|
|
122
|
+
parser_prebuild = subparsers.add_parser(
|
|
123
|
+
subcommand_name,
|
|
124
|
+
help=f"Materializes deployable prebuilt artifacts. See `{maincommand} {subcommand_name} --help` for options.",
|
|
125
|
+
)
|
|
126
|
+
parser_prebuild.add_argument(
|
|
127
|
+
"--out",
|
|
128
|
+
type=str,
|
|
129
|
+
default=None,
|
|
130
|
+
help="prebuild output directory (relative to CWD)",
|
|
131
|
+
)
|
|
132
|
+
parser_prebuild.add_argument(
|
|
133
|
+
"--prerender",
|
|
134
|
+
choices=["none", "static", "all"],
|
|
135
|
+
default=None,
|
|
136
|
+
help="prerender depth policy: 'none', 'static', or 'all'",
|
|
137
|
+
)
|
|
138
|
+
parser_prebuild.add_argument(
|
|
139
|
+
"--emit-python",
|
|
140
|
+
type=str,
|
|
141
|
+
default=None,
|
|
142
|
+
help="emit standalone Python module defining PREBUILD: PrebuildManifest",
|
|
143
|
+
)
|
|
144
|
+
embed_flags = parser_prebuild.add_mutually_exclusive_group()
|
|
145
|
+
embed_flags.add_argument(
|
|
146
|
+
"--embed-resources",
|
|
147
|
+
action="store_true",
|
|
148
|
+
default=None,
|
|
149
|
+
dest="embed_resources",
|
|
150
|
+
help="embed allow-listed resources into --emit-python output (default)",
|
|
151
|
+
)
|
|
152
|
+
embed_flags.add_argument(
|
|
153
|
+
"--no-embed-resources",
|
|
154
|
+
action="store_false",
|
|
155
|
+
dest="embed_resources",
|
|
156
|
+
help="omit in-memory resource bytes from --emit-python output",
|
|
157
|
+
)
|
|
158
|
+
_add_shared_build_args(parser_prebuild)
|
|
159
|
+
parser_prebuild.set_defaults(__command_getter__=_command(subcommand_name))
|
|
160
|
+
|
|
161
|
+
# init
|
|
162
|
+
subcommand_name = "init"
|
|
163
|
+
parser_init = subparsers.add_parser(
|
|
164
|
+
subcommand_name,
|
|
165
|
+
help="Creates new project on current dir.",
|
|
166
|
+
)
|
|
167
|
+
parser_init.set_defaults(__command_getter__=_command(subcommand_name))
|
|
168
|
+
|
|
169
|
+
# lock
|
|
170
|
+
subcommand_name = "lock"
|
|
171
|
+
parser_lock = subparsers.add_parser(
|
|
172
|
+
subcommand_name,
|
|
173
|
+
help="Generates or updates webcompy-lock.json.",
|
|
174
|
+
)
|
|
175
|
+
parser_lock.add_argument(
|
|
176
|
+
"--config",
|
|
177
|
+
type=str,
|
|
178
|
+
help="Python import path for config module (e.g., my_project.webcompy_config)",
|
|
179
|
+
)
|
|
180
|
+
lock_flags = parser_lock.add_mutually_exclusive_group()
|
|
181
|
+
lock_flags.add_argument(
|
|
182
|
+
"--export",
|
|
183
|
+
action="store_true",
|
|
184
|
+
help="Export lock file dependencies to requirements.txt",
|
|
185
|
+
)
|
|
186
|
+
lock_flags.add_argument(
|
|
187
|
+
"--sync",
|
|
188
|
+
action="store_true",
|
|
189
|
+
help="Compare lock file with requirements.txt/pyproject.toml",
|
|
190
|
+
)
|
|
191
|
+
lock_flags.add_argument(
|
|
192
|
+
"--install",
|
|
193
|
+
action="store_true",
|
|
194
|
+
help="Export and install lock file dependencies",
|
|
195
|
+
)
|
|
196
|
+
parser_lock.set_defaults(__command_getter__=_command(subcommand_name))
|
|
197
|
+
|
|
198
|
+
# inspect (delegates to _inspect.py for sub-subcommand parsing)
|
|
199
|
+
subcommand_name = "inspect"
|
|
200
|
+
parser_inspect = subparsers.add_parser(
|
|
201
|
+
subcommand_name,
|
|
202
|
+
help=f"Inspect a WebComPy application. See `{maincommand} {subcommand_name} --help` for subcommands.",
|
|
203
|
+
)
|
|
204
|
+
parser_inspect.set_defaults(__command_getter__=_command(subcommand_name))
|
|
205
|
+
|
|
206
|
+
# parse
|
|
207
|
+
args = parser.parse_args()
|
|
208
|
+
if hasattr(args, "__command_getter__"):
|
|
209
|
+
subcommand_name = args.__command_getter__()
|
|
210
|
+
args_dict = {n: getattr(args, n) for n in dir(args) if not n.startswith("_")}
|
|
211
|
+
if (
|
|
212
|
+
subcommand_name == "prebuild"
|
|
213
|
+
and args_dict.get("embed_resources") is not None
|
|
214
|
+
and not args_dict.get("emit_python")
|
|
215
|
+
):
|
|
216
|
+
parser.error("--embed-resources and --no-embed-resources require --emit-python")
|
|
217
|
+
if subcommand_name == "start" and args_dict.get("prebuilt") is not None:
|
|
218
|
+
incompatible: list[tuple[str, bool]] = [
|
|
219
|
+
("--dev", bool(args_dict.get("dev"))),
|
|
220
|
+
("--serve-all-deps / --no-serve-all-deps", args_dict.get("serve_all_deps") is not None),
|
|
221
|
+
("--wasm-serving", args_dict.get("wasm_serving") is not None),
|
|
222
|
+
("--runtime-serving", args_dict.get("runtime_serving") is not None),
|
|
223
|
+
("--standalone / --no-standalone", args_dict.get("standalone") is not None),
|
|
224
|
+
("--wheel-mode", args_dict.get("wheel_mode") is not None),
|
|
225
|
+
]
|
|
226
|
+
for flag_name, is_set in incompatible:
|
|
227
|
+
if is_set:
|
|
228
|
+
parser.error(f"Cannot combine --prebuilt with {flag_name}")
|
|
229
|
+
return subcommand_name, args_dict
|
|
230
|
+
else:
|
|
231
|
+
parser.print_help()
|
|
232
|
+
sys.exit()
|