terp-cli 0.42.0__tar.gz → 0.44.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.
- {terp_cli-0.42.0 → terp_cli-0.44.0}/PKG-INFO +9 -9
- {terp_cli-0.42.0 → terp_cli-0.44.0}/pyproject.toml +9 -9
- {terp_cli-0.42.0 → terp_cli-0.44.0}/signer/Dockerfile +3 -3
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/__init__.py +30 -305
- terp_cli-0.44.0/src/terp/cli/audit_findings.py +156 -0
- terp_cli-0.44.0/src/terp/cli/dependency_risk.py +348 -0
- terp_cli-0.44.0/src/terp/cli/dependency_scan.py +115 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/deployment_adopt.py +2 -1
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/envschema.py +2 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/guide_deployment.py +27 -15
- terp_cli-0.44.0/src/terp/cli/guide_files.py +102 -0
- terp_cli-0.44.0/src/terp/cli/guide_maintenance.py +134 -0
- terp_cli-0.44.0/src/terp/cli/guide_migrations.py +216 -0
- terp_cli-0.44.0/src/terp/cli/maintenance/__init__.py +203 -0
- terp_cli-0.44.0/src/terp/cli/maintenance/_images.py +156 -0
- terp_cli-0.44.0/src/terp/cli/maintenance/_packages.py +270 -0
- terp_cli-0.44.0/src/terp/cli/maintenance/_platform.py +330 -0
- terp_cli-0.44.0/src/terp/cli/maintenance/_report.py +210 -0
- terp_cli-0.44.0/src/terp/cli/maintenance/_vulnerabilities.py +357 -0
- terp_cli-0.44.0/src/terp/cli/python_audit.py +62 -0
- terp_cli-0.44.0/src/terp/cli/release/_archives.py +67 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/_common.py +70 -9
- terp_cli-0.44.0/src/terp/cli/release/_history.py +203 -0
- terp_cli-0.44.0/src/terp/cli/release/_image.py +448 -0
- terp_cli-0.44.0/src/terp/cli/release/_migrations.py +378 -0
- terp_cli-0.44.0/src/terp/cli/release/_osv.py +126 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/_plan.py +106 -15
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/_render.py +104 -16
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/_sandbox.py +38 -43
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/cli.py +13 -3
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/dsse.py +9 -9
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/gate.py +75 -17
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/manifest.py +70 -9
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/promote.py +105 -21
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/sign.py +170 -11
- terp_cli-0.44.0/src/terp/cli/risk_authority.py +100 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/scaffold.py +50 -123
- terp_cli-0.44.0/src/terp/cli/scaffold_frontend.py +101 -0
- terp_cli-0.44.0/src/terp/cli/upgrade_recipes.py +157 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/verify.py +30 -51
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/version.py +10 -124
- terp_cli-0.42.0/src/terp/cli/release/_image.py +0 -199
- {terp_cli-0.42.0 → terp_cli-0.44.0}/.gitignore +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/signer/terp-arch-releases.json +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/_appref.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/_cors_view.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/_engine.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/_output.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/_subjects.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/access.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/api_contract.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/api_contract_bounds.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/api_contract_check.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/api_contract_schemas.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/api_contract_shapes.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/apidocs.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/authz_surface.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/capabilities.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/dependency_audit.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/deploy_safety.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/deployment_app.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/deployment_check.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/deployment_declare.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/deployment_render.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/dev.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/docker.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/docker_masks.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/envfile.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/envrequired.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/envseams.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/fmt.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/grants.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/guide_capability.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/guide_passwords.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/heartbeat.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/jobs.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/leases.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/locks.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/module_roles.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/npm_tree.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/openapi.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/outbox.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/ports.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/profiles.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/py.typed +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/__init__.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/_compare.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/_dockerfile.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/_git.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/_locks.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/_npm_lock.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/_registry.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/release/build.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/reseal.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/reseal_report.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/routes.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/schema.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/seed.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/service_accounts.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/smoke.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/users.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/workbench.py +0 -0
- {terp_cli-0.42.0 → terp_cli-0.44.0}/src/terp/cli/workbench_adopt.py +0 -0
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: terp-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.44.0
|
|
4
4
|
Summary: Terp command-line tool — inspect, scaffolding, migrations, checks, api-docs.
|
|
5
5
|
Project-URL: Repository, https://github.com/AITT-NL/terp-framework
|
|
6
6
|
Project-URL: Changelog, https://github.com/AITT-NL/terp-framework/blob/main/CHANGELOG.md
|
|
7
7
|
License-Expression: Apache-2.0
|
|
8
8
|
Requires-Python: >=3.13
|
|
9
9
|
Requires-Dist: pyyaml>=6.0
|
|
10
|
-
Requires-Dist: terp-arch==0.
|
|
11
|
-
Requires-Dist: terp-core==0.
|
|
12
|
-
Requires-Dist: terp-migrations==0.
|
|
10
|
+
Requires-Dist: terp-arch==0.44.0
|
|
11
|
+
Requires-Dist: terp-core==0.44.0
|
|
12
|
+
Requires-Dist: terp-migrations==0.44.0
|
|
13
13
|
Provides-Extra: jobs
|
|
14
|
-
Requires-Dist: terp-cap-outbox==0.
|
|
15
|
-
Requires-Dist: terp-cap-scheduler-apscheduler==0.
|
|
14
|
+
Requires-Dist: terp-cap-outbox==0.44.0; extra == 'jobs'
|
|
15
|
+
Requires-Dist: terp-cap-scheduler-apscheduler==0.44.0; extra == 'jobs'
|
|
16
16
|
Provides-Extra: release
|
|
17
17
|
Requires-Dist: cryptography>=46; extra == 'release'
|
|
18
18
|
Requires-Dist: packaging>=24; extra == 'release'
|
|
19
|
-
Requires-Dist: terp-cap-egress==0.
|
|
19
|
+
Requires-Dist: terp-cap-egress==0.44.0; extra == 'release'
|
|
20
20
|
Provides-Extra: scheduler
|
|
21
|
-
Requires-Dist: terp-cap-scheduler-apscheduler==0.
|
|
21
|
+
Requires-Dist: terp-cap-scheduler-apscheduler==0.44.0; extra == 'scheduler'
|
|
22
22
|
Provides-Extra: worker
|
|
23
|
-
Requires-Dist: terp-cap-outbox==0.
|
|
23
|
+
Requires-Dist: terp-cap-outbox==0.44.0; extra == 'worker'
|
|
@@ -4,18 +4,18 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "terp-cli"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.44.0"
|
|
8
8
|
description = "Terp command-line tool — inspect, scaffolding, migrations, checks, api-docs."
|
|
9
9
|
requires-python = ">=3.13"
|
|
10
10
|
license = "Apache-2.0"
|
|
11
11
|
dependencies = [
|
|
12
|
-
"terp-core==0.
|
|
12
|
+
"terp-core==0.44.0",
|
|
13
13
|
# `terp migrate` delegates to terp-migrations (lazily imported), keeping Alembic
|
|
14
14
|
# off the path for `terp inspect` / `terp guide` while making migrations work.
|
|
15
|
-
"terp-migrations==0.
|
|
15
|
+
"terp-migrations==0.44.0",
|
|
16
16
|
# `terp guide rules` projects the live rule registry; terp-arch is imported lazily
|
|
17
17
|
# (only when that topic is rendered), so it stays off the common `terp guide` path.
|
|
18
|
-
"terp-arch==0.
|
|
18
|
+
"terp-arch==0.44.0",
|
|
19
19
|
# `terp verify --only env-seams` and `terp smoke` read the compose profiles as data
|
|
20
20
|
# (anchors and `<<:` merge keys resolved), so both answer without a Docker daemon or
|
|
21
21
|
# even the `docker` binary. Declared explicitly rather than leant on: every app
|
|
@@ -29,11 +29,11 @@ dependencies = [
|
|
|
29
29
|
# or a scheduler engine into apps that only use inspect/check/migrate. Deployments can select
|
|
30
30
|
# one process role, while `jobs` is the convenient complete jobs-process bundle.
|
|
31
31
|
[project.optional-dependencies]
|
|
32
|
-
worker = ["terp-cap-outbox==0.
|
|
33
|
-
scheduler = ["terp-cap-scheduler-apscheduler==0.
|
|
32
|
+
worker = ["terp-cap-outbox==0.44.0"]
|
|
33
|
+
scheduler = ["terp-cap-scheduler-apscheduler==0.44.0"]
|
|
34
34
|
jobs = [
|
|
35
|
-
"terp-cap-outbox==0.
|
|
36
|
-
"terp-cap-scheduler-apscheduler==0.
|
|
35
|
+
"terp-cap-outbox==0.44.0",
|
|
36
|
+
"terp-cap-scheduler-apscheduler==0.44.0",
|
|
37
37
|
]
|
|
38
38
|
# `terp release` and `terp promote` (ADR 0187): the DSSE signature (cryptography), the lock's
|
|
39
39
|
# markers (packaging), and the one declared way to a registry, an index and the vulnerability
|
|
@@ -42,7 +42,7 @@ jobs = [
|
|
|
42
42
|
release = [
|
|
43
43
|
"cryptography>=46",
|
|
44
44
|
"packaging>=24",
|
|
45
|
-
"terp-cap-egress==0.
|
|
45
|
+
"terp-cap-egress==0.44.0",
|
|
46
46
|
]
|
|
47
47
|
|
|
48
48
|
[project.scripts]
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
# release lane's, is reached with `--network host`. The release lane runs it exactly so
|
|
26
26
|
# (tests/release_lane/).
|
|
27
27
|
|
|
28
|
-
# python:3.
|
|
29
|
-
FROM python@sha256:
|
|
28
|
+
# python:3.15-slim, the base-image table's interpreter (terp-arch's base-images.json).
|
|
29
|
+
FROM python@sha256:65a65fc7b30b06cb6df4930fd4650697cb23f4c2698ab81fc87e4b031bc36928 AS install
|
|
30
30
|
COPY wheels/ /wheels/
|
|
31
31
|
COPY requirements.txt /requirements.txt
|
|
32
32
|
# Every distribution by its hash: the third-party ones as uv.lock pins them, the framework's as
|
|
@@ -41,7 +41,7 @@ FROM zricethezav/gitleaks@sha256:c00b6bd0aeb3071cbcb79009cb16a60dd9e0a7c60e2be9a
|
|
|
41
41
|
# The docker client 29.9.2, by digest (docker:29.9.2-cli, read 2026-10-22).
|
|
42
42
|
FROM docker@sha256:5e6baf67325a79f64ed3bed6863954d5e05d0f3d4e57cbdb14809346814bbfdb AS docker
|
|
43
43
|
|
|
44
|
-
FROM python@sha256:
|
|
44
|
+
FROM python@sha256:65a65fc7b30b06cb6df4930fd4650697cb23f4c2698ab81fc87e4b031bc36928
|
|
45
45
|
RUN apt-get update \
|
|
46
46
|
&& apt-get install -y --no-install-recommends git \
|
|
47
47
|
&& rm -rf /var/lib/apt/lists/* \
|
|
@@ -58,7 +58,14 @@ from terp.cli.module_roles import (
|
|
|
58
58
|
module_role_list_command,
|
|
59
59
|
module_role_revoke_command,
|
|
60
60
|
)
|
|
61
|
-
from terp.cli import
|
|
61
|
+
from terp.cli import (
|
|
62
|
+
guide_capability,
|
|
63
|
+
guide_deployment,
|
|
64
|
+
guide_files,
|
|
65
|
+
guide_maintenance,
|
|
66
|
+
guide_migrations,
|
|
67
|
+
guide_passwords,
|
|
68
|
+
)
|
|
62
69
|
from terp.cli.grants import (
|
|
63
70
|
grant_add_command,
|
|
64
71
|
grant_list_command,
|
|
@@ -1818,79 +1825,7 @@ Realtime push (realtime capability)
|
|
|
1818
1825
|
carries 3s and takes --shutdown-timeout. Yours must be under whatever stops your
|
|
1819
1826
|
container, or the bound never takes effect. ADR 0108.
|
|
1820
1827
|
""",
|
|
1821
|
-
"files":
|
|
1822
|
-
File objects (files capability, ADR 0056/0057)
|
|
1823
|
-
|
|
1824
|
-
- Upload/download/list/rename/delete ride the admin-only discovered router at
|
|
1825
|
-
/api/v1/files; File composes OwnedMixin, so rename/delete are owner-gated centrally.
|
|
1826
|
-
- Bytes live behind the StorageBackend port (put/open/delete, streamed via file-like
|
|
1827
|
-
objects, and open_range for a Range request: its default reads forward to the offset, so an
|
|
1828
|
-
adapter whose store reads a range overrides it) in a NAMED-PROFILE registry;
|
|
1829
|
-
metadata (name, type, size, sha256, storage_key, storage_profile) lives in the platform
|
|
1830
|
-
DB. FileRead omits storage_key and storage_profile, and the API's routes never show them;
|
|
1831
|
-
a store's signed link carries the key as its URL path, which opens nothing on a private
|
|
1832
|
-
store without the signature.
|
|
1833
|
-
- Any provider is an adapter subclass (local ships; a NAS mount is the local adapter on
|
|
1834
|
-
another root). Two object-store adapters ship behind extras (ADR 0201): S3Storage
|
|
1835
|
-
(terp-cap-files[s3]) takes the SDK's own client and a bucket; AzureBlobStorage
|
|
1836
|
-
(terp-cap-files[azure]) takes the SDK's ContainerClient and, for user-delegation SAS
|
|
1837
|
-
links, a BlobServiceClient under an Entra credential. Register each store once at the
|
|
1838
|
-
composition root:
|
|
1839
|
-
register_storage_backend("s3-media", S3Storage(boto3.client("s3"), bucket="app-media"))
|
|
1840
|
-
register_storage_backend("azure-invoices", AzureBlobStorage(invoices_container))
|
|
1841
|
-
register_storage_backend("azure-hr", AzureBlobStorage(hr_container, delegation=service))
|
|
1842
|
-
Keep credentials in settings / sealed config — never in module code. Building the Azure
|
|
1843
|
-
adapter without its extra fails at boot with the install line (StorageSdkMissingError);
|
|
1844
|
-
the S3 adapter takes the SDK's client, so a missing extra fails where that is built.
|
|
1845
|
-
- A client that cannot send a bearer (an <audio>/<video> element, a PDF viewer, a native
|
|
1846
|
-
client's media stack) gets a short-lived LINK to one file's bytes instead (ADR 0201):
|
|
1847
|
-
GET /api/v1/files/{id}/link?ttl_seconds=600&inline=true -> {url, expires_at}
|
|
1848
|
-
The link is minted where a download is authorized (row scope, then quarantine), by the
|
|
1849
|
-
store the ROW names: an S3 presigned GET or an Azure SAS where the store can sign, else
|
|
1850
|
-
an app-signed token the capability serves itself at GET /api/v1/files/link/{token} —
|
|
1851
|
-
its one public route, rate-limited, answering 404 to an expired, altered or foreign
|
|
1852
|
-
token. The default lifetime is an hour, the longest 24 hours; a link is not single-use
|
|
1853
|
-
(a player makes many range requests), its expiry is the control. inline is honoured only
|
|
1854
|
-
for a type a browser renders without running it (image, audio, video, PDF — not an XML
|
|
1855
|
-
image such as SVG, which is a document with script in it). From a module, mint through
|
|
1856
|
-
your own authorized row and a declared FileRef:
|
|
1857
|
-
link = FileService().link_for(session, invoice, "attachment_file_id", ttl=timedelta(minutes=10))
|
|
1858
|
-
Both content routes honour one bytes= Range (206 / 416); the local adapter seeks, an
|
|
1859
|
-
object store's stream is read forward. A link from a store that signs never streams
|
|
1860
|
-
through the API; the authenticated content route still serves any store's bytes to a
|
|
1861
|
-
caller who asks it to.
|
|
1862
|
-
- Pick the store per module (subclass default) or per call — never from a client:
|
|
1863
|
-
class InvoiceFileService(FileService):
|
|
1864
|
-
storage_profile = "azure-invoices"
|
|
1865
|
-
service.store(session, filename=..., content_type=..., source=..., profile="azure-hr")
|
|
1866
|
-
Resolution is FAIL-CLOSED: an unknown profile raises (UnknownStorageProfileError)
|
|
1867
|
-
before any byte lands; load/remove always resolve the store the ROW itself names.
|
|
1868
|
-
- Uploads stream (never fully buffered) under a 25 MiB default cap; the files spec
|
|
1869
|
-
declares its own request-body allowance so the kernel's global max_request_bytes
|
|
1870
|
-
(1 MiB default) is lifted for /api/v1/files ONLY (ADR 0067). Retune per deployment
|
|
1871
|
-
with two composition-root lines (the request allowance must exceed the stored cap
|
|
1872
|
-
by multipart framing headroom):
|
|
1873
|
-
configure_upload_limit(100 * 1024 * 1024)
|
|
1874
|
-
create_app(..., request_size_overrides={"files": 100 * 1024 * 1024 + 65536})
|
|
1875
|
-
- Content types are allowed by default (descriptive metadata); a deployment narrows
|
|
1876
|
-
uploads to an allowlist with one composition-root line — enforced in the service
|
|
1877
|
-
chokepoint (typed 415, before any byte lands), so no upload path can bypass it:
|
|
1878
|
-
configure_allowed_content_types(["application/pdf", "image/*"])
|
|
1879
|
-
- Referencing a file from your own model? Declare it — never a bare uuid column (the
|
|
1880
|
-
no_raw_file_references rule enforces this on table models):
|
|
1881
|
-
class Invoice(BaseTable, table=True):
|
|
1882
|
-
attachment_file_id: uuid.UUID | None = FileRef()
|
|
1883
|
-
Serve it THROUGH your own already-authorized row (serve-through delegation): load the
|
|
1884
|
-
invoice via your own service (its policy + row scope decide visibility), then
|
|
1885
|
-
row, data = FileService().load_for(session, invoice, "attachment_file_id")
|
|
1886
|
-
load_for fail-closes on an undeclared reference; /api/v1/files itself stays ADMIN-only.
|
|
1887
|
-
- The local profile's bytes need a volume in production, or they live in the container and
|
|
1888
|
-
go with it. The template's production profile (use_files) mounts the files-data volume at
|
|
1889
|
-
var/files on api, and deployment.json declares it with its backup policy, so a deploy tool
|
|
1890
|
-
backs it up. A unit of your own that reads stored bytes (a worker) mounts the same volume:
|
|
1891
|
-
add it to the profile and to the volume's "mount": {"units": [...]}. A store behind
|
|
1892
|
-
another adapter needs no volume. `terp guide deployment` has the rest.
|
|
1893
|
-
""",
|
|
1828
|
+
"files": guide_files.TOPIC,
|
|
1894
1829
|
"capability": guide_capability.TOPIC,
|
|
1895
1830
|
"mail": """\
|
|
1896
1831
|
Sending e-mail (terp-cap-mail)
|
|
@@ -1999,193 +1934,7 @@ Sending e-mail (terp-cap-mail)
|
|
|
1999
1934
|
same place: configure_mail(settings, transport=<a callable built on
|
|
2000
1935
|
terp.capabilities.egress>). Call sites stay send_mail either way.
|
|
2001
1936
|
""",
|
|
2002
|
-
"migrations":
|
|
2003
|
-
Database migrations (terp migrate)
|
|
2004
|
-
|
|
2005
|
-
- Each table-owning package (capability or app module) owns an INDEPENDENT, linear
|
|
2006
|
-
Alembic history with its own alembic_version_<label> table - no shared graph and no
|
|
2007
|
-
CROSS-package merges. Terp discovers them; you never hand-write env.py.
|
|
2008
|
-
- Author a revision after changing a model (autogenerated, scoped to that package so
|
|
2009
|
-
it never proposes another package's tables):
|
|
2010
|
-
terp migrate make <label> -m "add invoice.status" # <label> e.g. invoices
|
|
2011
|
-
Autogenerate DIFFS A LIVE DATABASE AT HEAD, so it needs two things the default
|
|
2012
|
-
environment does not give you: a database that outlives the process (the settings
|
|
2013
|
-
default is in-memory SQLite) and one that is already at head (a fresh file database
|
|
2014
|
-
is behind). Both, in one paste, with a throwaway file you delete afterwards:
|
|
2015
|
-
DATABASE_URL="sqlite:///./.migrate-scratch.db" terp migrate upgrade
|
|
2016
|
-
DATABASE_URL="sqlite:///./.migrate-scratch.db" terp migrate make <label>
|
|
2017
|
-
(PowerShell: $env:DATABASE_URL='sqlite:///./.migrate-scratch.db')
|
|
2018
|
-
Point it at your real Postgres URL instead when the revision must diff against real
|
|
2019
|
-
schema, or pass --no-autogenerate to author an empty revision by hand.
|
|
2020
|
-
Cross-module / cross-package foreign keys just work: every package's models are
|
|
2021
|
-
imported so an FK target (a sibling module, or identity_user) resolves at make time,
|
|
2022
|
-
and upgrade is ordered by FK dependencies so a referenced table is always created
|
|
2023
|
-
before the table that references it - regardless of label ordering. (A cross-package
|
|
2024
|
-
FK *cycle* cannot be ordered and fails closed; break it with a nullable FK populated
|
|
2025
|
-
in a later migration.)
|
|
2026
|
-
- Apply / inspect / walk back across every package:
|
|
2027
|
-
terp migrate upgrade # each package to head (run on deploy)
|
|
2028
|
-
terp migrate upgrade --sql > release.sql # render DBA-reviewable offline SQL
|
|
2029
|
-
# instead (nothing connects; flat layout)
|
|
2030
|
-
terp migrate status # current-vs-head per package
|
|
2031
|
-
terp migrate check # exit 0 only at head or inside the window
|
|
2032
|
-
terp migrate downgrade # every package back to base (or -N)
|
|
2033
|
-
terp migrate downgrade --label notes --revision <rev> # one package only
|
|
2034
|
-
A concrete revision is package-specific, so the all-package downgrade takes only
|
|
2035
|
-
base or a relative -N; pass --label to roll one package to any of its own revisions.
|
|
2036
|
-
A downgrade is for walking a history back while developing. A production rollback
|
|
2037
|
-
never migrates (next point).
|
|
2038
|
-
- ROLLING BACK A RELEASE (ADR 0185). Each revision says whether it is expand-only:
|
|
2039
|
-
expand_only = True # the previous release still runs on the schema this leaves
|
|
2040
|
-
`terp migrate make` always writes `expand_only = False` (a contract revision), and adds
|
|
2041
|
-
a comment where every operation it generated is on the expand list. Raise the mark
|
|
2042
|
-
yourself, once the previous release may run without what the revision adds: a NOT NULL
|
|
2043
|
-
scan state with a default, or a token epoch, is on the list and still carries a
|
|
2044
|
-
restriction a rollback would drop. The expand list is closed: create_table (a key from
|
|
2045
|
-
it only with CASCADE or SET NULL, never onto a soft-deleted table) and bulk_insert into
|
|
2046
|
-
it; add_column that is nullable, has a server_default or is Computed, with no unique, no
|
|
2047
|
-
check and at most a SET NULL key on a nullable column; create_index that is not unique;
|
|
2048
|
-
a batch block of those, never recreate="always". Anything else (a drop, a rename,
|
|
2049
|
-
tightening, execute(), a statement through op.get_bind(), a back-fill of an existing
|
|
2050
|
-
table) is refused by `terp check` (expand_revisions_only_expand, no opt-out) and again
|
|
2051
|
-
by the migration run, before its DDL. A back-fill runs as a job: the expand release
|
|
2052
|
-
already handles rows it has not filled.
|
|
2053
|
-
When every revision release N applied is expand-only, release N-1 starts again on N's
|
|
2054
|
-
database: its boot guard admits a database one migration run ahead (it logs which
|
|
2055
|
-
revisions it runs behind), and its `migrate` finds nothing to apply and runs no DDL. The
|
|
2056
|
-
rollback check is the target's own `terp migrate check`, run from the target's image
|
|
2057
|
-
against the live database: exit 0 is restore-free, anything else is a restore. Two
|
|
2058
|
-
expanding releases in a row are one too many, a contract revision or another Terp
|
|
2059
|
-
version is never crossed, and a migration applied from an offline script is not in
|
|
2060
|
-
the record, so each of those rolls back by restore.
|
|
2061
|
-
Until the contract release, N keeps writing the old shape N-1 reads, treats it as the
|
|
2062
|
-
truth for what N-1 writes (compute a derived value on read, or make it a generated
|
|
2063
|
-
column), and handles NULL in its new columns.
|
|
2064
|
-
Every release after a rollback keeps N's revision files and the model fields and tables
|
|
2065
|
-
they create, and reverts behaviour only; removing them is a later contract release. A
|
|
2066
|
-
release cut from N-1 that adds a revision of its own is refused by `migrate`.
|
|
2067
|
-
- CONTRACT STEPS GO INTO A LATER RELEASE than the one that expanded: drop, rename or
|
|
2068
|
-
tighten once nothing in the release before still needs the old shape. A release that
|
|
2069
|
-
mixes expand and contract revisions is legal and rolls back by restore.
|
|
2070
|
-
- Removing a module or capability from the app RETIRES it, in the same release: list its
|
|
2071
|
-
label in <app root>/modules/__init__.py, read without importing the app,
|
|
2072
|
-
RETIRED_MIGRATIONS = ("invoices",)
|
|
2073
|
-
a literal tuple of strings (anything else refuses). Its tables stay yours. A package
|
|
2074
|
-
that comes back takes a new label.
|
|
2075
|
-
- Two developers branched the same package? Resolve the within-package divergence:
|
|
2076
|
-
terp migrate heads # more than one head = diverged
|
|
2077
|
-
terp migrate merge <label> -m "merge"
|
|
2078
|
-
Before a release, re-parent one unreleased revision onto the other instead: a merge
|
|
2079
|
-
revision is a contract revision.
|
|
2080
|
-
- Locks: `migrate` runs before `api` is recreated, so the previous release still serves
|
|
2081
|
-
while it runs. A create_index without postgresql_concurrently (inside
|
|
2082
|
-
op.get_context().autocommit_block()), a volatile default and a generated column (stored,
|
|
2083
|
-
so the table is rewritten) hold a lock that long; on a large table compute a derived
|
|
2084
|
-
value on read. A new child table of a soft-deleted parent is a contract revision:
|
|
2085
|
-
neither CASCADE nor SET NULL can fire onto it.
|
|
2086
|
-
- A STEP THAT IS SAFE ONLY AGAINST AN EMPTY DATABASE is refused by `terp check`
|
|
2087
|
-
(`no_destructive_migrations`). A deploy migrates while the previous release still
|
|
2088
|
-
serves, and a rollback runs that release on the migrated schema, so a revision has two
|
|
2089
|
-
audiences your scratch database never shows: the rows production holds, and the
|
|
2090
|
-
release still running. Five kinds of step fail one of them:
|
|
2091
|
-
drop drop_table / drop_column / TRUNCATE / DELETE FROM / DROP SCHEMA
|
|
2092
|
-
rename rename_table / alter_column(new_column_name=...) / ALTER TABLE .. RENAME
|
|
2093
|
-
type change alter_column(type_=...) / ALTER COLUMN .. TYPE
|
|
2094
|
-
NOT NULL alter_column(nullable=False) on an existing table / SET NOT NULL
|
|
2095
|
-
constraint create_unique_constraint / create_check_constraint /
|
|
2096
|
-
create_foreign_key / create_primary_key / create_index(unique=True) /
|
|
2097
|
-
ADD CONSTRAINT / CREATE UNIQUE INDEX / VALIDATE CONSTRAINT
|
|
2098
|
-
on `op`, a batch block or any alias, imported by name (from alembic.op import
|
|
2099
|
-
drop_column) or looked up by a literal getattr, in upgrade() and in every function of
|
|
2100
|
-
the revision it calls, and through execute(...) whenever the statement is readable in
|
|
2101
|
-
the source, one statement at a time. Do this instead, and every finding says which:
|
|
2102
|
-
EXPAND (add the new column, nullable, or the new table beside the old one), BACKFILL
|
|
2103
|
-
(copy or clean the rows with a job, not a statement in the revision, and write both),
|
|
2104
|
-
then CONTRACT in a LATER release (drop the old name, tighten, add the constraint). The
|
|
2105
|
-
contract step is the destructive one, so it carries
|
|
2106
|
-
`# arch-allow-no-destructive-migrations: <reason>` on (or immediately above) its line,
|
|
2107
|
-
after review, budgeted by the escape-hatch ratchet. Not refused: anything on a table
|
|
2108
|
-
this upgrade() creates (it holds no rows yet), and a unique, foreign-key or
|
|
2109
|
-
unique-index constraint on columns this upgrade() adds nullable with no server_default
|
|
2110
|
-
(every existing row holds NULL, which those accept) - the shape autogenerate writes for
|
|
2111
|
-
a new reference column. Not refused is not the same as an expand step: a constraint on
|
|
2112
|
-
an existing table, or any execute(), is never one. A type WIDENING is still reported,
|
|
2113
|
-
because nothing in the revision says what the old type was: justify it with the marker.
|
|
2114
|
-
- ADDING A NOT NULL COLUMN is the revision that passes everything you can run and then
|
|
2115
|
-
fails in production. For a new non-nullable field autogenerate writes
|
|
2116
|
-
`add_column(sa.Column('rank', sa.Integer(), nullable=False))`, and that statement
|
|
2117
|
-
succeeds against an empty database and fails against one that holds rows - the rows
|
|
2118
|
-
already there need a value it never supplies. Nothing local catches it, because a
|
|
2119
|
-
migration test upgrades a FRESH scratch database, where the statement is correct.
|
|
2120
|
-
Give the column a server_default and the database back-fills the existing rows as it
|
|
2121
|
-
adds it; new rows still take the model-side default:
|
|
2122
|
-
op.add_column('note', sa.Column('rank', sa.Integer(), nullable=False,
|
|
2123
|
-
server_default='0'))
|
|
2124
|
-
Where no literal default is right, expand/contract instead - add the column nullable,
|
|
2125
|
-
back-fill it with a job in the same release, tighten it in a LATER release (that
|
|
2126
|
-
tightening is a contract step: it takes the destructive-migration marker above). `terp check`
|
|
2127
|
-
refuses the unbackfilled form (`not_null_columns_are_backfilled`); a table that
|
|
2128
|
-
genuinely holds no rows yet opts out with
|
|
2129
|
-
`# arch-allow-not-null-columns-are-backfilled: <reason>`.
|
|
2130
|
-
- MOVING A MODEL TO ANOTHER MODULE is the one edit that looks free and is not. Just
|
|
2131
|
-
moving the class emits NO ddl at all - the losing package stops owning the table so
|
|
2132
|
-
its scoped autogenerate cannot propose a drop, and the gaining package diffs against
|
|
2133
|
-
a database where the table already exists so it proposes no create. Your database
|
|
2134
|
-
keeps upgrading; CI and staging stay green. Then the NEXT ordinary change to that
|
|
2135
|
-
model (an added column) is authored into the gaining package's INDEPENDENT history,
|
|
2136
|
-
which - with no foreign key between the two packages - a fresh install may run
|
|
2137
|
-
BEFORE the history that creates the table: "no such table", months later, in a new
|
|
2138
|
-
environment, blamed on an innocent add_column. Terp refuses the split at `terp
|
|
2139
|
-
migrate make` and in the build-time guard. Move a table properly, expand/contract:
|
|
2140
|
-
1. Give the new module its own model with its own __tablename__;
|
|
2141
|
-
`terp migrate make <new>` creates it.
|
|
2142
|
-
2. Copy the rows in that same release (a data migration, or a backfill job),
|
|
2143
|
-
and write to both tables while the old one still has readers.
|
|
2144
|
-
3. In a LATER release, once nothing reads the old table, drop it - with
|
|
2145
|
-
`# arch-allow-no-destructive-migrations: <reason>` and a human reviewer.
|
|
2146
|
-
Step 3 stays human-reviewed on purpose: dropping a populated table is a genuine,
|
|
2147
|
-
irreversible risk, and the one place where a second pair of eyes is worth the
|
|
2148
|
-
friction. If the model is simply in the wrong module and holds no data you care
|
|
2149
|
-
about, the cheap fix is to move the class BACK and rename the module instead.
|
|
2150
|
-
Already shipped the move and planning the expand/contract for a later release? The
|
|
2151
|
-
owning package's models.py may carry `# arch-allow-table-ownership-is-not-split:
|
|
2152
|
-
<reason>`, counted by the escape-hatch budget like any other opt-out.
|
|
2153
|
-
- Adopt Terp on an EXISTING database (built by create_all or by hand) without dropping
|
|
2154
|
-
data - baseline each history at head, then only genuinely new migrations apply:
|
|
2155
|
-
terp migrate stamp # records head, runs no DDL
|
|
2156
|
-
- Want physical per-module separation on PostgreSQL (each package's tables in its own
|
|
2157
|
-
schema, the groundwork for per-schema GRANTs)? Set DB_SCHEMA_LAYOUT=per-module for a
|
|
2158
|
-
fresh database, or move an existing flat one in place (idempotent, data moves with
|
|
2159
|
-
the tables, version tables stay put):
|
|
2160
|
-
terp migrate adopt-schemas # one-time; ADR 0070
|
|
2161
|
-
- Least-privilege runtime (ADR 0071): migrate as the owning role, run the app as a
|
|
2162
|
-
separate login that holds ONLY DML - the database itself then refuses DDL and
|
|
2163
|
-
(per-module) any tampering with migration state. Provision the login yourself, then:
|
|
2164
|
-
terp migrate grant-runtime <role> # idempotent; run after upgrade/adopt
|
|
2165
|
-
Run it as the role that runs `terp migrate` - or pass --owner-role <role> so the
|
|
2166
|
-
ALTER DEFAULT PRIVILEGES it emits covers tables that future upgrades create.
|
|
2167
|
-
Module-to-module DML is deliberately NOT database-blocked (one runtime role spans
|
|
2168
|
-
every write schema; audit/outbox ride the business write's single session).
|
|
2169
|
-
- Operate safely: run `terp migrate upgrade` ONCE per deploy (e.g. a release job), not
|
|
2170
|
-
on every replica - it takes no lock, so concurrent runs race. The boot guard below is
|
|
2171
|
-
read-only and safe on every replica. The migration engine is built from DATABASE_URL,
|
|
2172
|
-
so put URL-expressible options (e.g. sslmode) there.
|
|
2173
|
-
- Run from your app root so app/ is importable (app modules ship their history in
|
|
2174
|
-
app/modules/<name>/migrations/; a capability declares a terp.migrations entry point).
|
|
2175
|
-
- Make upgrading non-optional: wire the fail-closed boot guard so the app refuses to
|
|
2176
|
-
start against a stale schema (a deploy that skipped the upgrade fails loudly). Pass an
|
|
2177
|
-
app_root so it guards your app modules too, not only capabilities:
|
|
2178
|
-
from functools import partial
|
|
2179
|
-
from pathlib import Path
|
|
2180
|
-
from terp.migrations import assert_migrations_current
|
|
2181
|
-
create_app(specs, ..., migration_check=partial(
|
|
2182
|
-
assert_migrations_current, app_root=Path(__file__).parent))
|
|
2183
|
-
Gate it on production if local dev builds the schema with create_all / SQLite.
|
|
2184
|
-
- Test the REAL migration path (not only create_all) so a model change with no
|
|
2185
|
-
migration fails CI, not production:
|
|
2186
|
-
from terp.migrations import upgrade, assert_migrations_match_models
|
|
2187
|
-
upgrade(db_url, app_root); assert_migrations_match_models(db_url, app_root)
|
|
2188
|
-
""",
|
|
1937
|
+
"migrations": guide_migrations.TOPIC,
|
|
2189
1938
|
"frontend": """\
|
|
2190
1939
|
Frontend module screens (@terpjs/react-core)
|
|
2191
1940
|
|
|
@@ -2201,14 +1950,14 @@ Frontend module screens (@terpjs/react-core)
|
|
|
2201
1950
|
raw <form> -> Stack as="form" (terp guide forms)
|
|
2202
1951
|
raw fetch / XMLHttpRequest -> useTerpClient() + unwrap (typed client)
|
|
2203
1952
|
WebSocket / EventSource / sendBeacon -> the generated client (one egress path)
|
|
2204
|
-
style
|
|
1953
|
+
inline style / global classes -> primitives or a sibling CSS Module
|
|
2205
1954
|
<a href="/..."> -> the router's Link (role-aware, no reload)
|
|
2206
1955
|
deep imports (@terpjs/*/src, @terpjs/*/dist) -> import from the package root only
|
|
2207
1956
|
data-terp / data-terp-* anywhere in src -> compose the component that renders it
|
|
2208
1957
|
The data-terp markers are react-core's own: its stylesheet and the runtime layout check
|
|
2209
1958
|
trust them. A framework screen you replace (renderTerpApp({ login })) is yours, so its
|
|
2210
1959
|
tests find it by role and accessible name, not by the framework screen's markers.
|
|
2211
|
-
The bootstrap (src/main.tsx) is the one file that imports stylesheets, and only the token
|
|
1960
|
+
The bootstrap (src/main.tsx) is the one file that imports global stylesheets, and only the token
|
|
2212
1961
|
pipeline's three: @terpjs/contract/tokens.css, ./house-style.css and ./theme.css. A
|
|
2213
1962
|
library's stylesheet is refused there too: it would paint outside the palettes. A
|
|
2214
1963
|
stylesheet loaded through import() or import.meta.glob is refused the same way.
|
|
@@ -2296,7 +2045,7 @@ Forms (react-core primitives)
|
|
|
2296
2045
|
<Button type="submit" variant="primary">Save</Button>
|
|
2297
2046
|
</Stack>
|
|
2298
2047
|
- Field wraps label + control + hint/error for one field; Stack (vertical by default)
|
|
2299
|
-
|
|
2048
|
+
lays out fields. A custom layout can use a sibling CSS Module.
|
|
2300
2049
|
- Submit through the typed client: const client = useTerpClient();
|
|
2301
2050
|
await unwrap(client.POST("/api/v1/invoices/", { body })); a failure throws ApiError
|
|
2302
2051
|
({code, status, requestId, fields}) — map codes to copy with useErrorMessage, show
|
|
@@ -2359,10 +2108,9 @@ Forms (react-core primitives)
|
|
|
2359
2108
|
"theming": """\
|
|
2360
2109
|
Theming and branding (design tokens, palettes, the brand mark)
|
|
2361
2110
|
|
|
2362
|
-
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
itself would not follow the palette. Modules never need theme-specific code.
|
|
2111
|
+
- Use the shared tokens for palette, typography and spacing. For a custom screen, use a
|
|
2112
|
+
plain Page and import styles from "./Board.module.css". Apply className={styles.board}
|
|
2113
|
+
and define .board in that file. Global stylesheets belong to the bootstrap token pipeline.
|
|
2366
2114
|
- THE SHIPPED PALETTES, plus "system":
|
|
2367
2115
|
midday twilight evening night contrast
|
|
2368
2116
|
Named for the time of day they suit: midday is the light set, twilight a dimmed dark,
|
|
@@ -2756,7 +2504,7 @@ else. A `"format": "secret"` declaration must appear with an EMPTY value: this f
|
|
|
2756
2504
|
committed, .app.env is not.
|
|
2757
2505
|
|
|
2758
2506
|
Never write a secret value into the manifest, .env.example, .app.env.example, source,
|
|
2759
|
-
tests, prompts or logs. Platform-owned names (SECRET_KEY, POSTGRES_PASSWORD, DATABASE_URL,
|
|
2507
|
+
tests, prompts or logs. Platform-owned names (SECRET_KEY, POSTGRES_PASSWORD, TERP_RUNTIME_DB_PASSWORD, TERP_MIGRATION_DATABASE_URL, DATABASE_URL,
|
|
2760
2508
|
ENVIRONMENT, WEB_PORT, BACKEND_CORS_ORIGINS) are refused in the manifest: they already
|
|
2761
2509
|
have an owner.
|
|
2762
2510
|
|
|
@@ -2775,6 +2523,7 @@ scoped app uses `terp env init` rather than `cp`; and a service that adds its ow
|
|
|
2775
2523
|
not concatenate sequences), so both files have to be listed.
|
|
2776
2524
|
""",
|
|
2777
2525
|
"deployment": guide_deployment.TOPIC,
|
|
2526
|
+
"maintenance": guide_maintenance.TOPIC,
|
|
2778
2527
|
}
|
|
2779
2528
|
|
|
2780
2529
|
# Topics whose body is generated from a live registry (not a static recipe above).
|
|
@@ -2916,6 +2665,7 @@ More: terp guide <topic> (topics: {_TOPIC_NAMES})
|
|
|
2916
2665
|
terp guide theming (palettes, design tokens, the brand mark)
|
|
2917
2666
|
terp guide changelog (what changed — read this before and after a bump)
|
|
2918
2667
|
terp upgrade --check (is there a newer release for the whole set?)
|
|
2668
|
+
terp maintenance (what to maintain: platform, advisories, bases; a report)
|
|
2919
2669
|
terp inspect capabilities (what the platform offers: installed vs adoptable)
|
|
2920
2670
|
terp inspect control-plane (your roles / permissions / module authority map)
|
|
2921
2671
|
terp inspect access (the full access graph: modules, endpoints, data traits)
|
|
@@ -3834,23 +3584,9 @@ def _build_parser() -> argparse.ArgumentParser:
|
|
|
3834
3584
|
"led by its Security and Upgrade notes. Pass the version this app is on",
|
|
3835
3585
|
)
|
|
3836
3586
|
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
)
|
|
3841
|
-
upgrade_parser.add_argument(
|
|
3842
|
-
"--check",
|
|
3843
|
-
action="store_true",
|
|
3844
|
-
help="Report the available release and the bump recipe (the only mode: "
|
|
3845
|
-
"Terp reports, it does not edit your manifests)",
|
|
3846
|
-
)
|
|
3847
|
-
upgrade_parser.add_argument(
|
|
3848
|
-
"--format",
|
|
3849
|
-
choices=("text", "json"),
|
|
3850
|
-
default="text",
|
|
3851
|
-
help="Output format: text (the recipe) or json (the same facts as data — "
|
|
3852
|
-
"installed, current, target, covers_whole_set, stragglers, rerender_blocker)",
|
|
3853
|
-
)
|
|
3587
|
+
from terp.cli.maintenance import add_parsers as add_maintenance_parsers
|
|
3588
|
+
|
|
3589
|
+
add_maintenance_parsers(subcommands)
|
|
3854
3590
|
|
|
3855
3591
|
migrate_parser = subcommands.add_parser(
|
|
3856
3592
|
"migrate",
|
|
@@ -4257,7 +3993,7 @@ def _build_parser() -> argparse.ArgumentParser:
|
|
|
4257
3993
|
)
|
|
4258
3994
|
module_parser.add_argument("name", help="Module name (lowercase identifier, e.g. invoices)")
|
|
4259
3995
|
module_parser.add_argument("--root", default=".", help="App root to scaffold into (default: .)")
|
|
4260
|
-
module_parser.add_argument("--package", default="app", help="
|
|
3996
|
+
module_parser.add_argument("--package", default="app", help="Top-level Python package (default: app)")
|
|
4261
3997
|
module_parser.add_argument(
|
|
4262
3998
|
"--no-frontend",
|
|
4263
3999
|
action="store_true",
|
|
@@ -4741,17 +4477,11 @@ def main(argv: Sequence[str] | None = None) -> None:
|
|
|
4741
4477
|
)
|
|
4742
4478
|
emit(guide(args.topic, since=args.since))
|
|
4743
4479
|
return
|
|
4744
|
-
if args.command
|
|
4745
|
-
from terp.cli.
|
|
4480
|
+
if args.command in ("upgrade", "maintenance"):
|
|
4481
|
+
from terp.cli.maintenance import run as run_maintenance
|
|
4746
4482
|
|
|
4747
|
-
if
|
|
4748
|
-
raise SystemExit(
|
|
4749
|
-
"terp upgrade: run `terp upgrade --check`. Terp reports what is "
|
|
4750
|
-
"available and how to bump; it does not edit your manifests, because "
|
|
4751
|
-
"a lockstep bump spans pyproject.toml and frontend/package.json and "
|
|
4752
|
-
"must be reviewed as one change."
|
|
4753
|
-
)
|
|
4754
|
-
emit(render_upgrade_check(fmt=args.format))
|
|
4483
|
+
if code := run_maintenance(args):
|
|
4484
|
+
raise SystemExit(code)
|
|
4755
4485
|
return
|
|
4756
4486
|
if args.command == "migrate":
|
|
4757
4487
|
from terp.migrations import migrate_main
|
|
@@ -4882,14 +4612,9 @@ def main(argv: Sequence[str] | None = None) -> None:
|
|
|
4882
4612
|
raise SystemExit(status)
|
|
4883
4613
|
return
|
|
4884
4614
|
if args.command == "new" and args.new_command == "module":
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
package=args.package,
|
|
4889
|
-
frontend=not args.no_frontend,
|
|
4890
|
-
profile=args.profile,
|
|
4891
|
-
)
|
|
4892
|
-
emit(new_module_message(args.name, paths, profile=args.profile))
|
|
4615
|
+
options = {"root": args.root, "package": args.package, "profile": args.profile}
|
|
4616
|
+
paths = new_module(args.name, frontend=not args.no_frontend, **options)
|
|
4617
|
+
emit(new_module_message(args.name, paths, **options))
|
|
4893
4618
|
return
|
|
4894
4619
|
if args.command == "api-docs":
|
|
4895
4620
|
for path in api_docs(args.out):
|