@mriekki/lean 0.1.0 → 0.1.1
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.
- package/README.md +67 -67
- package/assets/components.json +33 -33
- package/assets/core/distribution.json +51 -51
- package/assets/deployment/distribution.json +34 -34
- package/assets/generated/ASSEMBLY.json +28 -28
- package/assets/generated/deployment/distribution/lean-poc-deploy.py +8 -8
- package/assets/generated/deployment/src/lean_poc_deployment/__init__.py +3 -3
- package/assets/generated/deployment/src/lean_poc_deployment/__main__.py +3 -3
- package/assets/generated/deployment/src/lean_poc_deployment/app_cli.py +140 -140
- package/assets/generated/deployment/src/lean_poc_deployment/app_runtime.py +455 -455
- package/assets/generated/deployment/src/lean_poc_deployment/app_runtime_remote.py +415 -415
- package/assets/generated/deployment/src/lean_poc_deployment/box_platform.py +208 -208
- package/assets/generated/deployment/src/lean_poc_deployment/box_platform_assets.py +100 -100
- package/assets/generated/deployment/src/lean_poc_deployment/box_platform_remote.py +271 -271
- package/assets/generated/deployment/src/lean_poc_deployment/cli.py +437 -437
- package/assets/generated/deployment/src/lean_poc_deployment/doctor.py +121 -121
- package/assets/generated/deployment/src/lean_poc_deployment/entrypoint.py +25 -25
- package/assets/generated/deployment/src/lean_poc_deployment/errors.py +5 -5
- package/assets/generated/deployment/src/lean_poc_deployment/keys.py +171 -171
- package/assets/generated/deployment/src/lean_poc_deployment/profiles.py +204 -204
- package/assets/generated/deployment/src/lean_poc_deployment/route_registry.py +367 -367
- package/assets/generated/deployment/src/lean_poc_deployment/route_registry_remote.py +443 -443
- package/assets/generated/deployment/src/lean_poc_deployment/security.py +290 -290
- package/assets/generated/deployment/src/lean_poc_deployment/sqlite_adapter.py +334 -334
- package/assets/generated/deployment/src/lean_poc_deployment/sqlite_adapter_remote.py +339 -339
- package/assets/generated/deployment/src/lean_poc_deployment/sqlite_cli.py +85 -85
- package/assets/generated/deployment/src/lean_poc_deployment/sqlite_import_recovery.py +437 -437
- package/assets/generated/deployment/src/lean_poc_deployment/ssh.py +118 -118
- package/assets/generated/deployment/src/lean_poc_deployment/teardown.py +286 -286
- package/assets/generated/deployment/src/lean_poc_deployment/teardown_cli.py +120 -120
- package/assets/generated/deployment/src/lean_poc_deployment/teardown_remote.py +100 -100
- package/assets/generated/deployment/src/lean_poc_deployment/trust.py +278 -278
- package/bin/lean.mjs +9 -9
- package/package.json +33 -33
- package/src/cli.mjs +131 -131
- package/src/engine.mjs +243 -243
- package/src/package-data.mjs +18 -18
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
"""CLI for generic immutable application runtime deployment."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
import argparse
|
|
6
|
-
import json
|
|
7
|
-
import sys
|
|
8
|
-
from typing import Any
|
|
9
|
-
|
|
10
|
-
from .app_runtime import (
|
|
11
|
-
APP_DEPLOY_WRITE_PHRASE,
|
|
12
|
-
PRODUCTION_APP_DEPLOY_WRITE_PHRASE,
|
|
13
|
-
app_inventory,
|
|
14
|
-
apply_app_deploy,
|
|
15
|
-
deploy_write_phrase,
|
|
16
|
-
normalize_app_spec,
|
|
17
|
-
plan_app_deploy,
|
|
18
|
-
)
|
|
19
|
-
from .errors import DeploymentKitError
|
|
20
|
-
from .sqlite_adapter import assert_app_spec_matches_persistence
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def _print(value: Any, *, as_json: bool) -> None:
|
|
24
|
-
if as_json:
|
|
25
|
-
print(json.dumps(value, indent=2, sort_keys=True))
|
|
26
|
-
return
|
|
27
|
-
if isinstance(value, dict):
|
|
28
|
-
for key, item in value.items():
|
|
29
|
-
if isinstance(item, (dict, list)):
|
|
30
|
-
print(f"{key}: {json.dumps(item, sort_keys=True)}")
|
|
31
|
-
else:
|
|
32
|
-
print(f"{key}: {item}")
|
|
33
|
-
return
|
|
34
|
-
print(value)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def _parse_env(items: list[str]) -> list[tuple[str, str]]:
|
|
38
|
-
result: list[tuple[str, str]] = []
|
|
39
|
-
for item in items:
|
|
40
|
-
if "=" not in item:
|
|
41
|
-
raise DeploymentKitError("--env entries must use NAME=value form.")
|
|
42
|
-
key, value = item.split("=", 1)
|
|
43
|
-
result.append((key, value))
|
|
44
|
-
return result
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
def _confirm(args: argparse.Namespace, phrase: str, action: str) -> None:
|
|
48
|
-
if args.yes:
|
|
49
|
-
return
|
|
50
|
-
entered = input(f"Type {phrase} to {action}: ").strip()
|
|
51
|
-
if entered != phrase:
|
|
52
|
-
raise DeploymentKitError(f"{action.capitalize()} was not authorized.")
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def build_parser() -> argparse.ArgumentParser:
|
|
56
|
-
parser = argparse.ArgumentParser(prog="lean-poc-deploy app")
|
|
57
|
-
sub = parser.add_subparsers(dest="command", required=True)
|
|
58
|
-
|
|
59
|
-
inventory = sub.add_parser(
|
|
60
|
-
"inventory",
|
|
61
|
-
help="Read Kit-managed application runtime ownership/readiness without writes",
|
|
62
|
-
)
|
|
63
|
-
inventory.add_argument("name")
|
|
64
|
-
inventory.add_argument("--json", action="store_true")
|
|
65
|
-
|
|
66
|
-
deploy = sub.add_parser(
|
|
67
|
-
"deploy",
|
|
68
|
-
help="Deploy one immutable application runtime without modifying routes",
|
|
69
|
-
)
|
|
70
|
-
deploy.add_argument("name")
|
|
71
|
-
deploy.add_argument("--owner-repo", required=True)
|
|
72
|
-
deploy.add_argument("--environment", required=True)
|
|
73
|
-
deploy.add_argument("--app-slug", required=True)
|
|
74
|
-
deploy.add_argument("--container-name", required=True)
|
|
75
|
-
deploy.add_argument("--image", required=True)
|
|
76
|
-
deploy.add_argument("--runtime-port", type=int, required=True)
|
|
77
|
-
deploy.add_argument("--health-path", required=True)
|
|
78
|
-
deploy.add_argument("--run-as", required=True)
|
|
79
|
-
deploy.add_argument(
|
|
80
|
-
"--persistence-mode",
|
|
81
|
-
choices=("none", "directory"),
|
|
82
|
-
required=True,
|
|
83
|
-
)
|
|
84
|
-
deploy.add_argument("--data-container-path")
|
|
85
|
-
deploy.add_argument(
|
|
86
|
-
"--env",
|
|
87
|
-
action="append",
|
|
88
|
-
default=[],
|
|
89
|
-
help="Non-secret runtime environment value in NAME=value form; repeat as needed",
|
|
90
|
-
)
|
|
91
|
-
deploy.add_argument("--json", action="store_true")
|
|
92
|
-
deploy.add_argument("--yes", action="store_true")
|
|
93
|
-
return parser
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
def main(argv: list[str] | None = None) -> int:
|
|
97
|
-
args = build_parser().parse_args(argv)
|
|
98
|
-
try:
|
|
99
|
-
if args.command == "inventory":
|
|
100
|
-
_print(app_inventory(args.name), as_json=args.json)
|
|
101
|
-
return 0
|
|
102
|
-
|
|
103
|
-
spec = normalize_app_spec(
|
|
104
|
-
owner_repo=args.owner_repo,
|
|
105
|
-
environment=args.environment,
|
|
106
|
-
app_slug=args.app_slug,
|
|
107
|
-
container_name=args.container_name,
|
|
108
|
-
image=args.image,
|
|
109
|
-
runtime_port=args.runtime_port,
|
|
110
|
-
health_path=args.health_path,
|
|
111
|
-
run_as=args.run_as,
|
|
112
|
-
persistence_mode=args.persistence_mode,
|
|
113
|
-
data_container_path=args.data_container_path,
|
|
114
|
-
environment_variables=_parse_env(args.env),
|
|
115
|
-
)
|
|
116
|
-
assert_app_spec_matches_persistence(args.name, spec)
|
|
117
|
-
plan = plan_app_deploy(args.name, spec)
|
|
118
|
-
_print(
|
|
119
|
-
{key: value for key, value in plan.items() if key != "spec"},
|
|
120
|
-
as_json=False,
|
|
121
|
-
)
|
|
122
|
-
phrase = deploy_write_phrase(plan)
|
|
123
|
-
_confirm(
|
|
124
|
-
args,
|
|
125
|
-
phrase,
|
|
126
|
-
f"deploy {plan['appSlug']} ({plan['environment']}) on target {args.name}",
|
|
127
|
-
)
|
|
128
|
-
_print(apply_app_deploy(plan), as_json=args.json)
|
|
129
|
-
return 0
|
|
130
|
-
except DeploymentKitError as error:
|
|
131
|
-
print(f"ERROR: {error}", file=sys.stderr)
|
|
132
|
-
return 2
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
__all__ = [
|
|
136
|
-
"APP_DEPLOY_WRITE_PHRASE",
|
|
137
|
-
"PRODUCTION_APP_DEPLOY_WRITE_PHRASE",
|
|
138
|
-
"build_parser",
|
|
139
|
-
"main",
|
|
140
|
-
]
|
|
1
|
+
"""CLI for generic immutable application runtime deployment."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from .app_runtime import (
|
|
11
|
+
APP_DEPLOY_WRITE_PHRASE,
|
|
12
|
+
PRODUCTION_APP_DEPLOY_WRITE_PHRASE,
|
|
13
|
+
app_inventory,
|
|
14
|
+
apply_app_deploy,
|
|
15
|
+
deploy_write_phrase,
|
|
16
|
+
normalize_app_spec,
|
|
17
|
+
plan_app_deploy,
|
|
18
|
+
)
|
|
19
|
+
from .errors import DeploymentKitError
|
|
20
|
+
from .sqlite_adapter import assert_app_spec_matches_persistence
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _print(value: Any, *, as_json: bool) -> None:
|
|
24
|
+
if as_json:
|
|
25
|
+
print(json.dumps(value, indent=2, sort_keys=True))
|
|
26
|
+
return
|
|
27
|
+
if isinstance(value, dict):
|
|
28
|
+
for key, item in value.items():
|
|
29
|
+
if isinstance(item, (dict, list)):
|
|
30
|
+
print(f"{key}: {json.dumps(item, sort_keys=True)}")
|
|
31
|
+
else:
|
|
32
|
+
print(f"{key}: {item}")
|
|
33
|
+
return
|
|
34
|
+
print(value)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _parse_env(items: list[str]) -> list[tuple[str, str]]:
|
|
38
|
+
result: list[tuple[str, str]] = []
|
|
39
|
+
for item in items:
|
|
40
|
+
if "=" not in item:
|
|
41
|
+
raise DeploymentKitError("--env entries must use NAME=value form.")
|
|
42
|
+
key, value = item.split("=", 1)
|
|
43
|
+
result.append((key, value))
|
|
44
|
+
return result
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _confirm(args: argparse.Namespace, phrase: str, action: str) -> None:
|
|
48
|
+
if args.yes:
|
|
49
|
+
return
|
|
50
|
+
entered = input(f"Type {phrase} to {action}: ").strip()
|
|
51
|
+
if entered != phrase:
|
|
52
|
+
raise DeploymentKitError(f"{action.capitalize()} was not authorized.")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
56
|
+
parser = argparse.ArgumentParser(prog="lean-poc-deploy app")
|
|
57
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
58
|
+
|
|
59
|
+
inventory = sub.add_parser(
|
|
60
|
+
"inventory",
|
|
61
|
+
help="Read Kit-managed application runtime ownership/readiness without writes",
|
|
62
|
+
)
|
|
63
|
+
inventory.add_argument("name")
|
|
64
|
+
inventory.add_argument("--json", action="store_true")
|
|
65
|
+
|
|
66
|
+
deploy = sub.add_parser(
|
|
67
|
+
"deploy",
|
|
68
|
+
help="Deploy one immutable application runtime without modifying routes",
|
|
69
|
+
)
|
|
70
|
+
deploy.add_argument("name")
|
|
71
|
+
deploy.add_argument("--owner-repo", required=True)
|
|
72
|
+
deploy.add_argument("--environment", required=True)
|
|
73
|
+
deploy.add_argument("--app-slug", required=True)
|
|
74
|
+
deploy.add_argument("--container-name", required=True)
|
|
75
|
+
deploy.add_argument("--image", required=True)
|
|
76
|
+
deploy.add_argument("--runtime-port", type=int, required=True)
|
|
77
|
+
deploy.add_argument("--health-path", required=True)
|
|
78
|
+
deploy.add_argument("--run-as", required=True)
|
|
79
|
+
deploy.add_argument(
|
|
80
|
+
"--persistence-mode",
|
|
81
|
+
choices=("none", "directory"),
|
|
82
|
+
required=True,
|
|
83
|
+
)
|
|
84
|
+
deploy.add_argument("--data-container-path")
|
|
85
|
+
deploy.add_argument(
|
|
86
|
+
"--env",
|
|
87
|
+
action="append",
|
|
88
|
+
default=[],
|
|
89
|
+
help="Non-secret runtime environment value in NAME=value form; repeat as needed",
|
|
90
|
+
)
|
|
91
|
+
deploy.add_argument("--json", action="store_true")
|
|
92
|
+
deploy.add_argument("--yes", action="store_true")
|
|
93
|
+
return parser
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def main(argv: list[str] | None = None) -> int:
|
|
97
|
+
args = build_parser().parse_args(argv)
|
|
98
|
+
try:
|
|
99
|
+
if args.command == "inventory":
|
|
100
|
+
_print(app_inventory(args.name), as_json=args.json)
|
|
101
|
+
return 0
|
|
102
|
+
|
|
103
|
+
spec = normalize_app_spec(
|
|
104
|
+
owner_repo=args.owner_repo,
|
|
105
|
+
environment=args.environment,
|
|
106
|
+
app_slug=args.app_slug,
|
|
107
|
+
container_name=args.container_name,
|
|
108
|
+
image=args.image,
|
|
109
|
+
runtime_port=args.runtime_port,
|
|
110
|
+
health_path=args.health_path,
|
|
111
|
+
run_as=args.run_as,
|
|
112
|
+
persistence_mode=args.persistence_mode,
|
|
113
|
+
data_container_path=args.data_container_path,
|
|
114
|
+
environment_variables=_parse_env(args.env),
|
|
115
|
+
)
|
|
116
|
+
assert_app_spec_matches_persistence(args.name, spec)
|
|
117
|
+
plan = plan_app_deploy(args.name, spec)
|
|
118
|
+
_print(
|
|
119
|
+
{key: value for key, value in plan.items() if key != "spec"},
|
|
120
|
+
as_json=False,
|
|
121
|
+
)
|
|
122
|
+
phrase = deploy_write_phrase(plan)
|
|
123
|
+
_confirm(
|
|
124
|
+
args,
|
|
125
|
+
phrase,
|
|
126
|
+
f"deploy {plan['appSlug']} ({plan['environment']}) on target {args.name}",
|
|
127
|
+
)
|
|
128
|
+
_print(apply_app_deploy(plan), as_json=args.json)
|
|
129
|
+
return 0
|
|
130
|
+
except DeploymentKitError as error:
|
|
131
|
+
print(f"ERROR: {error}", file=sys.stderr)
|
|
132
|
+
return 2
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
__all__ = [
|
|
136
|
+
"APP_DEPLOY_WRITE_PHRASE",
|
|
137
|
+
"PRODUCTION_APP_DEPLOY_WRITE_PHRASE",
|
|
138
|
+
"build_parser",
|
|
139
|
+
"main",
|
|
140
|
+
]
|