workpeg 0.149.1__tar.gz → 0.151.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.
- {workpeg-0.149.1/src/workpeg.egg-info → workpeg-0.151.0}/PKG-INFO +4 -2
- {workpeg-0.149.1 → workpeg-0.151.0}/README.md +3 -1
- {workpeg-0.149.1 → workpeg-0.151.0}/pyproject.toml +5 -2
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/cli.py +208 -42
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/doctor.py +1 -1
- workpeg-0.151.0/src/workpeg/terminal.py +80 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/build.py +432 -38
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/compiler/ast_parser.py +862 -67
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/compiler/js_generator.py +111 -37
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/create.py +5 -3
- workpeg-0.151.0/src/workpeg/ui/dev_refused_names.json +32 -0
- workpeg-0.151.0/src/workpeg/ui/devmode.py +195 -0
- workpeg-0.151.0/src/workpeg/ui/devserve.py +438 -0
- workpeg-0.151.0/src/workpeg/ui/devsite.py +191 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/fake_cloud.py +172 -19
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/render_nodes.py +1 -1
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/ai.js +53 -3
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/scaffold.js +116 -21
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/workpeg-runtime.js +527 -49
- workpeg-0.151.0/src/workpeg/ui/serve.py +971 -0
- {workpeg-0.149.1 → workpeg-0.151.0/src/workpeg.egg-info}/PKG-INFO +4 -2
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg.egg-info/SOURCES.txt +5 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_cli.py +0 -19
- workpeg-0.149.1/src/workpeg/ui/serve.py +0 -608
- {workpeg-0.149.1 → workpeg-0.151.0}/LICENSE +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/MANIFEST.in +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/setup.cfg +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/__init__.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/auth.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/build.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/cdn.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/config.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/context.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/create_new.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/project.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/run.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/runtime.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/sandbox/__init__.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/sandbox/docker_driver.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/sandbox/driver.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/submit.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/templates/__init__.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/templates/functions/Dockerfile +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/templates/functions/LICENSE +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/templates/functions/README.md +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/templates/functions/app/__init__.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/templates/functions/app/main.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/templates/functions/requirements.txt +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/templates/project/README.md +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/templates/project/function/Dockerfile +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/templates/project/function/app/__init__.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/templates/project/function/app/main.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/templates/project/function/requirements.txt +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/templates/project/ui/main.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/templates/project/workpeg.json +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/__init__.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/actions.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/actions_manifest.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/app.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/calendar.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/compiler/__init__.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/compiler/ir.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/dates.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/minify.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/renderers_manifest.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/ai-concurrent-replies.md +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/ai-prompt-queue.md +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/ai-question-frame.md +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/ai-subagent-frame.md +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/editor.js +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/fonts/OFL.txt +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/fonts/geist-italic-cyrillic-ext.af944491.woff2 +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/fonts/geist-italic-cyrillic.88be6946.woff2 +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/fonts/geist-italic-latin-ext.370a8962.woff2 +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/fonts/geist-italic-latin.7611b95c.woff2 +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/fonts/geist-italic-vietnamese.8dfcf303.woff2 +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/fonts/geist-normal-cyrillic-ext.b7a545bb.woff2 +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/fonts/geist-normal-cyrillic.6129fc85.woff2 +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/fonts/geist-normal-latin-ext.58a6b173.woff2 +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/fonts/geist-normal-latin.9b6f5ff4.woff2 +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/fonts/geist-normal-vietnamese.f689f638.woff2 +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/icons.css.gz +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/overlay.js +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/runtime/pegment.css +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/scaffold.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/search_manifest.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/skills_manifest.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/state.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/validators.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/watcher.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/widgets/__init__.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/widgets/base.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/widgets/canvas.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/widgets/display.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/widgets/fields.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/widgets/forms.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/widgets/futures.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/widgets/gestures.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/widgets/interactive.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/widgets/layout.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/ui/widgets/pickers.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg/utils.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg.egg-info/dependency_links.txt +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg.egg-info/entry_points.txt +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg.egg-info/requires.txt +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/src/workpeg.egg-info/top_level.txt +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_auth.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_build.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_cdn.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_cdn_publish.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_changelog.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_changelog_guard.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_config.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_context.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_create_new.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_doctor.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_project_create.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_release_script.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_run.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_runtime.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_submit.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_utils.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_version.py +0 -0
- {workpeg-0.149.1 → workpeg-0.151.0}/tests/test_watch_pipeline.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: workpeg
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.151.0
|
|
4
4
|
Summary: Workpeg function runtime and SDK
|
|
5
5
|
Author-email: Workpeg <support@workpeg.com>
|
|
6
6
|
License: MIT
|
|
@@ -392,6 +392,7 @@ Full reference: [docs/schema-ui.md](https://gitlab.com/workpeg/workpeg-sdk/-/blo
|
|
|
392
392
|
| [docs/functions.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/functions.md) | Function contract, context, runtime, Docker, publishing |
|
|
393
393
|
| [docs/cdn.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/cdn.md) | CDN uploads, paths, authentication, asset structure |
|
|
394
394
|
| [docs/getting-started.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/getting-started.md) | Peg UI: how it works, quick start, CLI, live reload |
|
|
395
|
+
| [docs/dev-install.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/dev-install.md) | Test a peg before release: `workpeg ui serve --dev`, `workpeg ui dev-clean`, the separate development account |
|
|
395
396
|
| [docs/core-concepts.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/core-concepts.md) | `App`, `State`, `build()`, supported Python, lists, reactivity |
|
|
396
397
|
| [docs/widgets.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/widgets.md) | Widget gallery + full per-widget reference |
|
|
397
398
|
| [docs/routing.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/routing.md) · [data-realtime.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/data-realtime.md) · [state-components.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/state-components.md) · [styling.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/styling.md) | Routing, data/realtime, global state, theming |
|
|
@@ -474,7 +475,8 @@ Optional `workpeg.json` in your project root. `namespace` records the peg the pr
|
|
|
474
475
|
| Method local variables (`step = 5; self.count += step`) | Available |
|
|
475
476
|
| Console logging (`print()` → `console.log()`) | Available |
|
|
476
477
|
| Dev error overlay (compile + runtime errors in the browser) | Available |
|
|
477
|
-
|
|
|
478
|
+
| Dev install (`workpeg ui serve --dev`: the release build at `https://<namespace>.dev.workpeg.com`, from your own computer, to it only; [guide](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/dev-install.md)) | Available |
|
|
479
|
+
| Fake cloud (`--fake-cloud`: the older way to serve a build at `https://<app>.dev.workpeg.com`, kept and fenced like the dev install; to test a peg before release, use `workpeg ui serve --dev`) | Available |
|
|
478
480
|
| Widget categories — layout / display / interactive (Flutter-style) | Available |
|
|
479
481
|
| `ListView` with lazy, virtualized `ListView.builder` | Available |
|
|
480
482
|
| `Center` layout widget | Available |
|
|
@@ -367,6 +367,7 @@ Full reference: [docs/schema-ui.md](https://gitlab.com/workpeg/workpeg-sdk/-/blo
|
|
|
367
367
|
| [docs/functions.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/functions.md) | Function contract, context, runtime, Docker, publishing |
|
|
368
368
|
| [docs/cdn.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/cdn.md) | CDN uploads, paths, authentication, asset structure |
|
|
369
369
|
| [docs/getting-started.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/getting-started.md) | Peg UI: how it works, quick start, CLI, live reload |
|
|
370
|
+
| [docs/dev-install.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/dev-install.md) | Test a peg before release: `workpeg ui serve --dev`, `workpeg ui dev-clean`, the separate development account |
|
|
370
371
|
| [docs/core-concepts.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/core-concepts.md) | `App`, `State`, `build()`, supported Python, lists, reactivity |
|
|
371
372
|
| [docs/widgets.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/widgets.md) | Widget gallery + full per-widget reference |
|
|
372
373
|
| [docs/routing.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/routing.md) · [data-realtime.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/data-realtime.md) · [state-components.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/state-components.md) · [styling.md](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/styling.md) | Routing, data/realtime, global state, theming |
|
|
@@ -449,7 +450,8 @@ Optional `workpeg.json` in your project root. `namespace` records the peg the pr
|
|
|
449
450
|
| Method local variables (`step = 5; self.count += step`) | Available |
|
|
450
451
|
| Console logging (`print()` → `console.log()`) | Available |
|
|
451
452
|
| Dev error overlay (compile + runtime errors in the browser) | Available |
|
|
452
|
-
|
|
|
453
|
+
| Dev install (`workpeg ui serve --dev`: the release build at `https://<namespace>.dev.workpeg.com`, from your own computer, to it only; [guide](https://gitlab.com/workpeg/workpeg-sdk/-/blob/main/docs/dev-install.md)) | Available |
|
|
454
|
+
| Fake cloud (`--fake-cloud`: the older way to serve a build at `https://<app>.dev.workpeg.com`, kept and fenced like the dev install; to test a peg before release, use `workpeg ui serve --dev`) | Available |
|
|
453
455
|
| Widget categories — layout / display / interactive (Flutter-style) | Available |
|
|
454
456
|
| `ListView` with lazy, virtualized `ListView.builder` | Available |
|
|
455
457
|
| `Center` layout widget | Available |
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "workpeg"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.151.0"
|
|
8
8
|
description = "Workpeg function runtime and SDK"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -51,7 +51,10 @@ workpeg = "workpeg.cli:main"
|
|
|
51
51
|
package-dir = {"" = "src"}
|
|
52
52
|
|
|
53
53
|
[tool.setuptools.package-data]
|
|
54
|
-
|
|
54
|
+
# ui/dev_refused_names.json is the SDK's copy of the API's list of names no
|
|
55
|
+
# dev install may use. `serve --dev` reads it on every start and refuses every
|
|
56
|
+
# name when it is missing, so a wheel without it could test no peg at all.
|
|
57
|
+
workpeg = ["templates/**", "ui/runtime/**", "ui/dev_refused_names.json"]
|
|
55
58
|
|
|
56
59
|
|
|
57
60
|
[tool.setuptools.packages.find]
|
|
@@ -3,6 +3,7 @@ import os
|
|
|
3
3
|
import sys
|
|
4
4
|
|
|
5
5
|
from workpeg import build, cdn, create_new, run, runtime, submit
|
|
6
|
+
from workpeg.terminal import BOLD_RED, DEV_PAGE, RESET, shown_lines
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
# The package's, not a second copy of the same lookup. Keeping its own was
|
|
@@ -254,7 +255,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
254
255
|
|
|
255
256
|
ui_sub = ui_p.add_subparsers(
|
|
256
257
|
dest="command",
|
|
257
|
-
metavar="{new,build,serve}",
|
|
258
|
+
metavar="{new,build,serve,dev-clean}",
|
|
258
259
|
)
|
|
259
260
|
|
|
260
261
|
ui_new_p = ui_sub.add_parser(
|
|
@@ -312,7 +313,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
312
313
|
epilog=(
|
|
313
314
|
"Examples:\n"
|
|
314
315
|
" workpeg ui build counter/\n"
|
|
315
|
-
" workpeg ui build counter/ --out
|
|
316
|
+
" workpeg ui build counter/ --out build\n"
|
|
316
317
|
" workpeg ui build counter/main.py\n"
|
|
317
318
|
),
|
|
318
319
|
)
|
|
@@ -333,7 +334,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
333
334
|
),
|
|
334
335
|
)
|
|
335
336
|
|
|
336
|
-
# Read from the environment so
|
|
337
|
+
# Read from the environment so a dev image or test job sets this once
|
|
337
338
|
# instead of every build remembering the flag. Read by the CLI, never by
|
|
338
339
|
# the browser. argparse does not validate an env-supplied default against
|
|
339
340
|
# choices=, so the ui.build handler re-checks args.chrome itself.
|
|
@@ -346,9 +347,9 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
346
347
|
" auto (default) the CDN's current copy, with the app's\n"
|
|
347
348
|
" bundled copy as the fallback — the Workpeg team's\n"
|
|
348
349
|
" chrome updates reach the app without a rebuild\n"
|
|
349
|
-
" bundled same-origin only, never the network:
|
|
350
|
-
"
|
|
351
|
-
"
|
|
350
|
+
" bundled same-origin only, never the network: for local\n"
|
|
351
|
+
" development and tests. A released peg is never built\n"
|
|
352
|
+
" this way: it would never receive a chrome update\n"
|
|
352
353
|
"Env: WORKPEG_CHROME."
|
|
353
354
|
),
|
|
354
355
|
)
|
|
@@ -366,6 +367,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
366
367
|
" workpeg ui serve counter/main.py\n"
|
|
367
368
|
" workpeg ui serve counter/dist/\n"
|
|
368
369
|
" workpeg ui serve counter/ --fake-cloud\n"
|
|
370
|
+
" workpeg ui serve counter/ --dev\n"
|
|
369
371
|
),
|
|
370
372
|
)
|
|
371
373
|
|
|
@@ -382,7 +384,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
382
384
|
"--port",
|
|
383
385
|
type=int,
|
|
384
386
|
default=0,
|
|
385
|
-
help="Port for the local server (default: auto)",
|
|
387
|
+
help="Port for the local server (default: auto). With --dev, 443 only",
|
|
386
388
|
)
|
|
387
389
|
|
|
388
390
|
ui_serve_p.add_argument(
|
|
@@ -416,8 +418,59 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
416
418
|
),
|
|
417
419
|
)
|
|
418
420
|
|
|
421
|
+
ui_serve_p.add_argument(
|
|
422
|
+
"--dev",
|
|
423
|
+
action="store_true",
|
|
424
|
+
help=(
|
|
425
|
+
"Dev install: build the project exactly as `workpeg ui build`\n"
|
|
426
|
+
"does and serve only that build at\n"
|
|
427
|
+
"https://<namespace>.dev.workpeg.com, the namespace its\n"
|
|
428
|
+
"workpeg.json declares, on port 443 and to this computer\n"
|
|
429
|
+
"only. Needs mkcert. Reads no token. Before anything is\n"
|
|
430
|
+
"bound it refuses a name Workpeg keeps, a pre-built folder,\n"
|
|
431
|
+
"--fake-cloud, --peg-namespace, a --port other than 443 and\n"
|
|
432
|
+
"WORKPEG_BIND_HOST.\n"
|
|
433
|
+
"Guide: docs/dev-install.md"
|
|
434
|
+
),
|
|
435
|
+
)
|
|
436
|
+
|
|
419
437
|
ui_serve_p.set_defaults(_handler="ui.serve")
|
|
420
438
|
|
|
439
|
+
ui_dev_clean_p = ui_sub.add_parser(
|
|
440
|
+
"dev-clean",
|
|
441
|
+
help=(
|
|
442
|
+
"Remove the hosts lines and certificates serve --dev and "
|
|
443
|
+
"--fake-cloud wrote"
|
|
444
|
+
),
|
|
445
|
+
formatter_class=argparse.RawTextHelpFormatter,
|
|
446
|
+
epilog=(
|
|
447
|
+
"Examples:\n"
|
|
448
|
+
" workpeg ui dev-clean counter/\n"
|
|
449
|
+
" workpeg ui dev-clean # the current directory\n"
|
|
450
|
+
" workpeg ui dev-clean --all\n"
|
|
451
|
+
"\n"
|
|
452
|
+
"Only hosts lines marked '# workpeg-fake-cloud' are removed; a\n"
|
|
453
|
+
"line you wrote yourself stays, even for the same name. mkcert's\n"
|
|
454
|
+
"root CA stays too: `mkcert -uninstall` removes it.\n"
|
|
455
|
+
),
|
|
456
|
+
)
|
|
457
|
+
ui_dev_clean_p.add_argument(
|
|
458
|
+
"project",
|
|
459
|
+
nargs="?",
|
|
460
|
+
default=None,
|
|
461
|
+
help=(
|
|
462
|
+
"Project directory, its main.py or its dist/ (default: .). "
|
|
463
|
+
"It need not exist any more"
|
|
464
|
+
),
|
|
465
|
+
)
|
|
466
|
+
ui_dev_clean_p.add_argument(
|
|
467
|
+
"--all",
|
|
468
|
+
action="store_true",
|
|
469
|
+
dest="all_names",
|
|
470
|
+
help="Every marked hosts line and every dev certificate, any project",
|
|
471
|
+
)
|
|
472
|
+
ui_dev_clean_p.set_defaults(_handler="ui.dev-clean")
|
|
473
|
+
|
|
421
474
|
#
|
|
422
475
|
# DOCTOR
|
|
423
476
|
#
|
|
@@ -488,20 +541,24 @@ def _fake_cloud_setup(app_name: str, explicit_port: int) -> "tuple[int, dict]":
|
|
|
488
541
|
certificate (mkcert when available, openssl self-signed otherwise), and
|
|
489
542
|
picks an HTTPS port (443 when bindable).
|
|
490
543
|
|
|
491
|
-
Returns ``(port, serve_kwargs)`` for serve_blocking.
|
|
544
|
+
Returns ``(port, serve_kwargs)`` for serve_blocking. The kwargs ask for
|
|
545
|
+
a fake cloud, so the server answers this computer only and serves only
|
|
546
|
+
what its build wrote, whatever interface it binds.
|
|
492
547
|
"""
|
|
493
548
|
import subprocess
|
|
494
549
|
|
|
495
550
|
from workpeg.ui import fake_cloud
|
|
496
551
|
from workpeg.ui.serve import _format_url
|
|
497
552
|
|
|
498
|
-
# Fake-cloud
|
|
499
|
-
#
|
|
500
|
-
#
|
|
501
|
-
#
|
|
502
|
-
#
|
|
503
|
-
#
|
|
504
|
-
#
|
|
553
|
+
# Fake-cloud binds ALL interfaces (0.0.0.0) by default, unlike plain
|
|
554
|
+
# `serve`, which stays on loopback: on macOS that is the only way a
|
|
555
|
+
# non-root process can bind a privileged port like 443, so the clean
|
|
556
|
+
# no-port URL works without sudo or an extra env var. It still answers
|
|
557
|
+
# this computer only: the server closes every other peer before TLS
|
|
558
|
+
# (serve.LoopbackTLSServer), and nothing here can turn that off. An
|
|
559
|
+
# explicit WORKPEG_BIND_HOST picks the interface. Passed through explicitly
|
|
560
|
+
# (not via os.environ) so it can't leak between runs, and given to
|
|
561
|
+
# pick_https_port so it probes the host we'll actually bind.
|
|
505
562
|
bind_host = os.environ.get("WORKPEG_BIND_HOST") or "0.0.0.0"
|
|
506
563
|
|
|
507
564
|
try:
|
|
@@ -510,10 +567,11 @@ def _fake_cloud_setup(app_name: str, explicit_port: int) -> "tuple[int, dict]":
|
|
|
510
567
|
cert, key, kind = fake_cloud.ensure_certificate(domain)
|
|
511
568
|
port = explicit_port or fake_cloud.pick_https_port(bind_host=bind_host)
|
|
512
569
|
except fake_cloud.FakeCloudError as e:
|
|
513
|
-
print(f"ERROR: {e}", file=sys.stderr)
|
|
570
|
+
print(f"ERROR: {shown_lines(e)}", file=sys.stderr)
|
|
514
571
|
raise SystemExit(2)
|
|
515
572
|
except subprocess.CalledProcessError as e:
|
|
516
|
-
print(f"ERROR: certificate generation failed: {e}",
|
|
573
|
+
print(f"ERROR: certificate generation failed: {shown_lines(e)}",
|
|
574
|
+
file=sys.stderr)
|
|
517
575
|
raise SystemExit(2)
|
|
518
576
|
|
|
519
577
|
# MIGRATION: the dev host used to be dev.<slug>.workpeg.com, and renaming it
|
|
@@ -531,7 +589,7 @@ def _fake_cloud_setup(app_name: str, explicit_port: int) -> "tuple[int, dict]":
|
|
|
531
589
|
try:
|
|
532
590
|
pruned = fake_cloud.prune_legacy_hosts_entry(app_name)
|
|
533
591
|
except fake_cloud.FakeCloudError as e:
|
|
534
|
-
print(f"WARNING: {e}", file=sys.stderr)
|
|
592
|
+
print(f"WARNING: {shown_lines(e)}", file=sys.stderr)
|
|
535
593
|
|
|
536
594
|
hosts_note = "added" if added else "already present"
|
|
537
595
|
tls_note = (
|
|
@@ -540,10 +598,9 @@ def _fake_cloud_setup(app_name: str, explicit_port: int) -> "tuple[int, dict]":
|
|
|
540
598
|
else "self-signed (browser will warn; install mkcert to avoid)"
|
|
541
599
|
)
|
|
542
600
|
bind_note = (
|
|
543
|
-
f"{bind_host} (
|
|
544
|
-
f"WORKPEG_BIND_HOST=127.0.0.1 for loopback only)"
|
|
601
|
+
f"{bind_host} (every interface; answers this computer only)"
|
|
545
602
|
if bind_host == "0.0.0.0"
|
|
546
|
-
else bind_host
|
|
603
|
+
else f"{bind_host} (answers this computer only)"
|
|
547
604
|
)
|
|
548
605
|
# Through _format_url, not f"https://{domain}", so this line carries the
|
|
549
606
|
# port whenever pick_https_port could not get 443 — which is exactly when
|
|
@@ -562,14 +619,22 @@ def _fake_cloud_setup(app_name: str, explicit_port: int) -> "tuple[int, dict]":
|
|
|
562
619
|
_print_fake_cloud_warning(bind_host)
|
|
563
620
|
|
|
564
621
|
return port, {"ssl_cert": cert, "ssl_key": key, "url_host": domain,
|
|
565
|
-
"bind_host": bind_host}
|
|
622
|
+
"bind_host": bind_host, "fake_cloud": True}
|
|
566
623
|
|
|
567
624
|
|
|
568
625
|
#: Bold red, and reset. Emitted only to a TTY — a redirected log or a CI
|
|
569
626
|
#: capture gets the words without the escape codes, which is the point of
|
|
570
627
|
#: checking rather than always colouring.
|
|
571
|
-
_BOLD_RED =
|
|
572
|
-
_RESET =
|
|
628
|
+
_BOLD_RED = BOLD_RED
|
|
629
|
+
_RESET = RESET
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
def _quoted(name) -> str:
|
|
633
|
+
"""A path the developer gave, as an error repeats it: quoted, or
|
|
634
|
+
escaped whole when it holds anything unprintable."""
|
|
635
|
+
from workpeg.ui.devmode import _q
|
|
636
|
+
|
|
637
|
+
return _q(name)
|
|
573
638
|
|
|
574
639
|
|
|
575
640
|
def _tty() -> bool:
|
|
@@ -600,11 +665,19 @@ def _print_fake_cloud_warning(bind_host: str) -> None:
|
|
|
600
665
|
"This is NOT a sandbox. It serves a real *.workpeg.com origin, so",
|
|
601
666
|
"your browser sends your Workpeg session and this build talks to the",
|
|
602
667
|
"PRODUCTION API as you. Anything it writes is written for real.",
|
|
603
|
-
|
|
668
|
+
# The owner's words, the same as serve --dev's, each whole on a line
|
|
669
|
+
# of its own so that it reads, and greps, as one sentence.
|
|
670
|
+
*DEV_PAGE,
|
|
604
671
|
]
|
|
672
|
+
# The line that used to say anyone on the network could open it. The
|
|
673
|
+
# server now closes every connection that is not from this computer, so
|
|
674
|
+
# a phone that opened the page before gets no answer, and this says why.
|
|
605
675
|
if bind_host == "0.0.0.0":
|
|
606
|
-
lines.append(
|
|
607
|
-
|
|
676
|
+
lines.append("Bound to every interface, but it answers this "
|
|
677
|
+
"computer only:")
|
|
678
|
+
else:
|
|
679
|
+
lines.append("It answers this computer only:")
|
|
680
|
+
lines.append("a phone or another computer gets no answer.")
|
|
608
681
|
|
|
609
682
|
out = sys.stderr
|
|
610
683
|
print(file=out)
|
|
@@ -616,6 +689,43 @@ def _print_fake_cloud_warning(bind_host: str) -> None:
|
|
|
616
689
|
print(f"{prefix}{line}", file=out)
|
|
617
690
|
|
|
618
691
|
|
|
692
|
+
def _dev_clean(args) -> None:
|
|
693
|
+
"""``workpeg ui dev-clean``: print what went, each name once and escaped,
|
|
694
|
+
then the one thing that stays (mkcert's root CA)."""
|
|
695
|
+
from workpeg.ui import fake_cloud
|
|
696
|
+
|
|
697
|
+
if args.all_names and args.project is not None:
|
|
698
|
+
print("ERROR: give either a project or --all, not both.",
|
|
699
|
+
file=sys.stderr)
|
|
700
|
+
raise SystemExit(2)
|
|
701
|
+
project = None if args.all_names else (args.project or ".")
|
|
702
|
+
shown = fake_cloud.escaped
|
|
703
|
+
try:
|
|
704
|
+
domains = None if project is None else fake_cloud.project_domains(
|
|
705
|
+
project)
|
|
706
|
+
removed, left = fake_cloud.dev_clean(domains)
|
|
707
|
+
except (fake_cloud.FakeCloudError, OSError) as e:
|
|
708
|
+
# OSError: a certificate folder that cannot be deleted, or a hosts
|
|
709
|
+
# file that cannot be read, is one line, not a traceback.
|
|
710
|
+
print(f"ERROR: {shown(e)}", file=sys.stderr)
|
|
711
|
+
raise SystemExit(2)
|
|
712
|
+
|
|
713
|
+
# A removed name passed the hostname check, so it is printable as is.
|
|
714
|
+
for domain, what in removed:
|
|
715
|
+
print(f" Removed {domain} ({', '.join(what)})")
|
|
716
|
+
for domain in left:
|
|
717
|
+
print(
|
|
718
|
+
f"WARNING: left {shown(domain)}: its marked line names a host "
|
|
719
|
+
f"the SDK never writes, so it was edited by hand. Delete it "
|
|
720
|
+
f"yourself if you no longer want it.",
|
|
721
|
+
file=sys.stderr,
|
|
722
|
+
)
|
|
723
|
+
if not removed:
|
|
724
|
+
whose = "any project" if project is None else shown(project)
|
|
725
|
+
print(f" Nothing the dev loop wrote is left for {whose}.")
|
|
726
|
+
print(f"\n {fake_cloud.MKCERT_STAYS}")
|
|
727
|
+
|
|
728
|
+
|
|
619
729
|
def _run_server(serve_fn, *args, **kwargs) -> None:
|
|
620
730
|
"""Run a blocking dev server, turning a ServeError (e.g. a privileged or
|
|
621
731
|
in-use port) into a clean CLI error instead of a raw traceback."""
|
|
@@ -624,7 +734,7 @@ def _run_server(serve_fn, *args, **kwargs) -> None:
|
|
|
624
734
|
try:
|
|
625
735
|
serve_fn(*args, **kwargs)
|
|
626
736
|
except ServeError as e:
|
|
627
|
-
print(f"ERROR: {e}", file=sys.stderr)
|
|
737
|
+
print(f"ERROR: {shown_lines(e)}", file=sys.stderr)
|
|
628
738
|
raise SystemExit(1)
|
|
629
739
|
|
|
630
740
|
|
|
@@ -683,7 +793,7 @@ def main(argv=None) -> None:
|
|
|
683
793
|
)
|
|
684
794
|
print(str(out))
|
|
685
795
|
except create_new.TemplateError as e:
|
|
686
|
-
print(f"ERROR: {e}", file=sys.stderr)
|
|
796
|
+
print(f"ERROR: {shown_lines(e)}", file=sys.stderr)
|
|
687
797
|
raise SystemExit(2)
|
|
688
798
|
return
|
|
689
799
|
|
|
@@ -740,7 +850,7 @@ def main(argv=None) -> None:
|
|
|
740
850
|
)
|
|
741
851
|
print(image)
|
|
742
852
|
except (FileNotFoundError, NotADirectoryError, RuntimeError) as e:
|
|
743
|
-
print(f"ERROR: {e}", file=sys.stderr)
|
|
853
|
+
print(f"ERROR: {shown_lines(e)}", file=sys.stderr)
|
|
744
854
|
raise SystemExit(2)
|
|
745
855
|
return
|
|
746
856
|
|
|
@@ -774,7 +884,7 @@ def main(argv=None) -> None:
|
|
|
774
884
|
try:
|
|
775
885
|
run.main(run_argv)
|
|
776
886
|
except (FileNotFoundError, NotADirectoryError, RuntimeError, NotImplementedError) as e:
|
|
777
|
-
print(f"ERROR: {e}", file=sys.stderr)
|
|
887
|
+
print(f"ERROR: {shown_lines(e)}", file=sys.stderr)
|
|
778
888
|
raise SystemExit(2)
|
|
779
889
|
except subprocess.CalledProcessError as e:
|
|
780
890
|
print(
|
|
@@ -824,6 +934,7 @@ def main(argv=None) -> None:
|
|
|
824
934
|
#
|
|
825
935
|
|
|
826
936
|
if args._handler == "ui.new":
|
|
937
|
+
from workpeg.ui.build import PublicAssetError
|
|
827
938
|
from workpeg.ui.create import ProjectExistsError, create_ui_project
|
|
828
939
|
from workpeg.ui.compiler.ast_parser import UnsupportedSyntaxError
|
|
829
940
|
|
|
@@ -836,10 +947,10 @@ def main(argv=None) -> None:
|
|
|
836
947
|
name, force=args.force
|
|
837
948
|
)
|
|
838
949
|
except ProjectExistsError as e:
|
|
839
|
-
print(f"ERROR: {e}", file=sys.stderr)
|
|
950
|
+
print(f"ERROR: {shown_lines(e)}", file=sys.stderr)
|
|
840
951
|
raise SystemExit(2)
|
|
841
|
-
except (UnsupportedSyntaxError, SyntaxError) as e:
|
|
842
|
-
print(f"ERROR: {e}", file=sys.stderr)
|
|
952
|
+
except (UnsupportedSyntaxError, SyntaxError, PublicAssetError) as e:
|
|
953
|
+
print(f"ERROR: {shown_lines(e)}", file=sys.stderr)
|
|
843
954
|
raise SystemExit(2)
|
|
844
955
|
|
|
845
956
|
rel = project_dir.name
|
|
@@ -884,9 +995,14 @@ def main(argv=None) -> None:
|
|
|
884
995
|
# ui serve
|
|
885
996
|
#
|
|
886
997
|
|
|
998
|
+
if args._handler == "ui.dev-clean":
|
|
999
|
+
_dev_clean(args)
|
|
1000
|
+
return
|
|
1001
|
+
|
|
887
1002
|
if args._handler == "ui.serve":
|
|
888
1003
|
import pathlib
|
|
889
1004
|
|
|
1005
|
+
from workpeg.ui.build import PublicAssetError
|
|
890
1006
|
from workpeg.ui.compiler.ast_parser import UnsupportedSyntaxError
|
|
891
1007
|
from workpeg.ui.actions_manifest import ActionValidationError
|
|
892
1008
|
from workpeg.ui.search_manifest import ManifestValidationError
|
|
@@ -897,21 +1013,69 @@ def main(argv=None) -> None:
|
|
|
897
1013
|
_BUILD_ERRORS = (
|
|
898
1014
|
UnsupportedSyntaxError, SyntaxError,
|
|
899
1015
|
ManifestValidationError, ActionValidationError,
|
|
1016
|
+
PublicAssetError,
|
|
900
1017
|
)
|
|
901
1018
|
from workpeg.ui.serve import serve_blocking
|
|
902
1019
|
|
|
1020
|
+
if args.dev:
|
|
1021
|
+
from workpeg.ui import devmode, devserve, devsite
|
|
1022
|
+
|
|
1023
|
+
# Before anything else, and before any socket: a refusal binds
|
|
1024
|
+
# nothing and sends nothing.
|
|
1025
|
+
try:
|
|
1026
|
+
plan = devmode.preflight(
|
|
1027
|
+
args.source, fake_cloud=args.fake_cloud,
|
|
1028
|
+
peg_namespace=args.peg_namespace, port=args.port,
|
|
1029
|
+
environ=os.environ)
|
|
1030
|
+
except devmode.DevModeRefused as refusal:
|
|
1031
|
+
print(f"ERROR: {shown_lines(refusal)}", file=sys.stderr)
|
|
1032
|
+
raise SystemExit(2)
|
|
1033
|
+
|
|
1034
|
+
out_dir = args.out or str(plan.entry.parent / "dist")
|
|
1035
|
+
try:
|
|
1036
|
+
# The release's build, not plain serve's, whatever
|
|
1037
|
+
# WORKPEG_CHROME says: the page tested is the page shipped.
|
|
1038
|
+
devsite.release_build(plan.entry, out_dir)
|
|
1039
|
+
except _BUILD_ERRORS as e:
|
|
1040
|
+
print(f"ERROR: {shown_lines(e)}", file=sys.stderr)
|
|
1041
|
+
raise SystemExit(2)
|
|
1042
|
+
|
|
1043
|
+
# mkcert, the hosts line and the certificate, after the build so
|
|
1044
|
+
# that a build that fails changes nothing on this computer. Then
|
|
1045
|
+
# port 443 on this OS's address, behind the peer check, and no
|
|
1046
|
+
# other port: nothing here reads the environment or --port.
|
|
1047
|
+
try:
|
|
1048
|
+
tls = devserve.prepare(plan)
|
|
1049
|
+
except devserve.DevServeRefused as refusal:
|
|
1050
|
+
print(f"ERROR: {shown_lines(refusal)}", file=sys.stderr)
|
|
1051
|
+
raise SystemExit(2)
|
|
1052
|
+
_run_server(devserve.run, plan, out_dir, tls)
|
|
1053
|
+
return
|
|
1054
|
+
|
|
1055
|
+
extra: dict = {}
|
|
903
1056
|
source = pathlib.Path(args.source)
|
|
904
1057
|
|
|
905
1058
|
if not source.exists():
|
|
906
|
-
print(f"ERROR:
|
|
1059
|
+
print(f"ERROR: {_quoted(source)} does not exist.", file=sys.stderr)
|
|
907
1060
|
raise SystemExit(2)
|
|
908
1061
|
|
|
909
1062
|
port = args.port
|
|
910
1063
|
peg_ns = args.peg_namespace
|
|
911
|
-
extra: dict = {}
|
|
912
1064
|
if args.fake_cloud:
|
|
1065
|
+
from workpeg.ui import devmode
|
|
913
1066
|
from workpeg.ui.fake_cloud import derive_app_name
|
|
914
1067
|
|
|
1068
|
+
# Before the hosts file, the certificate or a port. A folder with
|
|
1069
|
+
# no main.py would be served as it stands, hand-written HTML and
|
|
1070
|
+
# script on a .dev.workpeg.com name that holds the visitor's
|
|
1071
|
+
# session, so --fake-cloud takes only Python it builds itself,
|
|
1072
|
+
# refused in the words dev mode uses.
|
|
1073
|
+
try:
|
|
1074
|
+
devmode._source(args.source)
|
|
1075
|
+
except devmode.DevModeRefused as refusal:
|
|
1076
|
+
print(f"ERROR: {shown_lines(refusal)}", file=sys.stderr)
|
|
1077
|
+
raise SystemExit(2)
|
|
1078
|
+
|
|
915
1079
|
# --peg-namespace also picks the fake-cloud domain, so the page is
|
|
916
1080
|
# served at <namespace>.dev.workpeg.com. That matters: the runtime
|
|
917
1081
|
# resolves the namespace from the host *before* the baked <meta>, so
|
|
@@ -938,7 +1102,7 @@ def main(argv=None) -> None:
|
|
|
938
1102
|
build_ui(str(main_py), out_dir, peg_namespace=peg_ns,
|
|
939
1103
|
bundle_icons=True, chrome_source="bundled")
|
|
940
1104
|
except _BUILD_ERRORS as e:
|
|
941
|
-
print(f"ERROR: {e}", file=sys.stderr)
|
|
1105
|
+
print(f"ERROR: {shown_lines(e)}", file=sys.stderr)
|
|
942
1106
|
raise SystemExit(2)
|
|
943
1107
|
|
|
944
1108
|
# Watch the project directory, not just main.py, so edits to
|
|
@@ -948,8 +1112,9 @@ def main(argv=None) -> None:
|
|
|
948
1112
|
peg_namespace=peg_ns, **extra)
|
|
949
1113
|
else:
|
|
950
1114
|
# No main.py — treat as a pre-built dist directory and serve
|
|
951
|
-
# as-is
|
|
952
|
-
#
|
|
1115
|
+
# as-is, on localhost: --fake-cloud refused this above. There's
|
|
1116
|
+
# no recompile, so --peg-namespace can't apply (the namespace
|
|
1117
|
+
# baked at build time stands).
|
|
953
1118
|
if peg_ns:
|
|
954
1119
|
print(" Note: --peg-namespace is ignored for a pre-built "
|
|
955
1120
|
"dist (rebuild to change it).", file=sys.stderr)
|
|
@@ -966,7 +1131,7 @@ def main(argv=None) -> None:
|
|
|
966
1131
|
build_ui(str(source), out_dir, peg_namespace=peg_ns,
|
|
967
1132
|
bundle_icons=True, chrome_source="bundled")
|
|
968
1133
|
except _BUILD_ERRORS as e:
|
|
969
|
-
print(f"ERROR: {e}", file=sys.stderr)
|
|
1134
|
+
print(f"ERROR: {shown_lines(e)}", file=sys.stderr)
|
|
970
1135
|
raise SystemExit(2)
|
|
971
1136
|
|
|
972
1137
|
_run_server(serve_blocking, out_dir, port,
|
|
@@ -975,7 +1140,7 @@ def main(argv=None) -> None:
|
|
|
975
1140
|
|
|
976
1141
|
else:
|
|
977
1142
|
print(
|
|
978
|
-
f"ERROR:
|
|
1143
|
+
f"ERROR: {_quoted(source)} is not a .py file or a directory. "
|
|
979
1144
|
"Pass a project directory, a .py source file, or a pre-built dist/ directory.",
|
|
980
1145
|
file=sys.stderr,
|
|
981
1146
|
)
|
|
@@ -1025,7 +1190,7 @@ def main(argv=None) -> None:
|
|
|
1025
1190
|
)
|
|
1026
1191
|
raise SystemExit(2)
|
|
1027
1192
|
|
|
1028
|
-
from workpeg.ui.build import build_ui
|
|
1193
|
+
from workpeg.ui.build import PublicAssetError, build_ui
|
|
1029
1194
|
from workpeg.ui.compiler.ast_parser import UnsupportedSyntaxError
|
|
1030
1195
|
from workpeg.ui.actions_manifest import ActionValidationError
|
|
1031
1196
|
from workpeg.ui.search_manifest import ManifestValidationError
|
|
@@ -1036,6 +1201,7 @@ def main(argv=None) -> None:
|
|
|
1036
1201
|
_BUILD_ERRORS = (
|
|
1037
1202
|
UnsupportedSyntaxError, SyntaxError,
|
|
1038
1203
|
ManifestValidationError, ActionValidationError,
|
|
1204
|
+
PublicAssetError,
|
|
1039
1205
|
)
|
|
1040
1206
|
|
|
1041
1207
|
source_path = pathlib.Path(args.source)
|
|
@@ -468,7 +468,7 @@ def _check_env_overrides(ctx: Context) -> Result:
|
|
|
468
468
|
f"WORKPEG_CHROME={chrome} is set — every 'workpeg ui build' "
|
|
469
469
|
f"on this machine defaults to --chrome {chrome}",
|
|
470
470
|
"unset WORKPEG_CHROME (keep it only if this machine "
|
|
471
|
-
"
|
|
471
|
+
"builds for local development or tests, never a release)",
|
|
472
472
|
))
|
|
473
473
|
else:
|
|
474
474
|
findings.append((
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""What a command prints that someone else chose, made safe for a terminal.
|
|
2
|
+
|
|
3
|
+
A namespace, a file or folder name, a build error quoting the source, a
|
|
4
|
+
title from a manifest: each was written by a developer or read off the file
|
|
5
|
+
system, and the person running the command may not be the person who wrote
|
|
6
|
+
it. Printed as it is, ``ESC[2J`` clears their screen, a carriage return
|
|
7
|
+
writes over the line before it, a backspace rubs out what a line says, and
|
|
8
|
+
U+202E makes a name read as another. So every such string goes through
|
|
9
|
+
:func:`shown`, or :func:`shown_lines` for text of several lines, before it
|
|
10
|
+
is printed. ``workpeg ui serve --dev``, ``--fake-cloud`` and the build use
|
|
11
|
+
these, and so does ``workpeg function listen``, so there is one rule.
|
|
12
|
+
|
|
13
|
+
The rule is the one the build has always used for a path: a string that is
|
|
14
|
+
all printable is shown as it is, accents and all; one that holds anything
|
|
15
|
+
unprintable is shown as ``ascii()`` of it, quoted, every character that is
|
|
16
|
+
not ASCII escaped, so what the line says is one spelling whatever the
|
|
17
|
+
terminal would have done with the rest.
|
|
18
|
+
|
|
19
|
+
The only escape codes the SDK itself prints are the warning colour below,
|
|
20
|
+
and only when the stream is a terminal (:func:`warn`).
|
|
21
|
+
"""
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
from typing import Iterable, TextIO
|
|
25
|
+
|
|
26
|
+
#: Bold red, and reset.
|
|
27
|
+
BOLD_RED = "\033[1;31m"
|
|
28
|
+
RESET = "\033[0m"
|
|
29
|
+
|
|
30
|
+
#: What every dev command says about the account it runs as, in the owner's
|
|
31
|
+
#: words: a dev page and a dev function act with the signed-in person's
|
|
32
|
+
#: real access.
|
|
33
|
+
DEVELOPMENT_ONLY = (
|
|
34
|
+
"This account is for development only, not the account you use for "
|
|
35
|
+
"your company.")
|
|
36
|
+
|
|
37
|
+
#: The banner of a command that serves a dev page (``serve --dev`` and
|
|
38
|
+
#: ``--fake-cloud``), each sentence whole on a line of its own.
|
|
39
|
+
DEV_PAGE = (
|
|
40
|
+
DEVELOPMENT_ONLY,
|
|
41
|
+
"Your browser gives this page your Workpeg session, with every scope "
|
|
42
|
+
"this peg declares.",
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def shown(text: object) -> str:
|
|
47
|
+
"""*text* as it may be printed: as it is when every character is
|
|
48
|
+
printable, ``ascii()`` of it when any is not."""
|
|
49
|
+
value = str(text)
|
|
50
|
+
return value if value.isprintable() else ascii(value)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def shown_lines(text: object) -> str:
|
|
54
|
+
"""Text of several lines, a build error say, as it may be printed: each
|
|
55
|
+
line, split at ``\\n`` and nowhere else, through :func:`shown`. A
|
|
56
|
+
carriage return or a vertical tab stays inside its line, and so is
|
|
57
|
+
escaped with it."""
|
|
58
|
+
return "\n".join(shown(line) for line in str(text).split("\n"))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def is_tty(stream: TextIO) -> bool:
|
|
62
|
+
"""Whether *stream* is a terminal. A stream that cannot say is not."""
|
|
63
|
+
try:
|
|
64
|
+
return bool(stream.isatty())
|
|
65
|
+
except Exception: # noqa: BLE001
|
|
66
|
+
return False
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def warn(lines: Iterable[str], stream: TextIO, *, first: str = " ⚠ ",
|
|
70
|
+
rest: str = " ") -> None:
|
|
71
|
+
"""Print *lines*, the SDK's own words, after a blank line: in bold red
|
|
72
|
+
on a terminal, and plain anywhere else, so a log or a CI capture holds
|
|
73
|
+
the words without the codes. The first line carries *first* in front of
|
|
74
|
+
it, the others *rest*."""
|
|
75
|
+
colour = is_tty(stream)
|
|
76
|
+
print(file=stream)
|
|
77
|
+
for index, line in enumerate(lines):
|
|
78
|
+
text = (first if index == 0 else rest) + line
|
|
79
|
+
print(f"{BOLD_RED}{text}{RESET}" if colour else text, file=stream)
|
|
80
|
+
stream.flush()
|