uns-kit 0.0.7__py3-none-any.whl → 0.0.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- uns_kit/cli.py +13 -4
- uns_kit/config.py +21 -3
- uns_kit/templates/default/package.json +6 -0
- {uns_kit-0.0.7.dist-info → uns_kit-0.0.8.dist-info}/METADATA +1 -1
- {uns_kit-0.0.7.dist-info → uns_kit-0.0.8.dist-info}/RECORD +7 -6
- {uns_kit-0.0.7.dist-info → uns_kit-0.0.8.dist-info}/WHEEL +0 -0
- {uns_kit-0.0.7.dist-info → uns_kit-0.0.8.dist-info}/entry_points.txt +0 -0
uns_kit/cli.py
CHANGED
|
@@ -128,6 +128,8 @@ async def _run_subscribe(
|
|
|
128
128
|
def create(dest: str):
|
|
129
129
|
template_root = importlib.resources.files("uns_kit").joinpath("templates/default")
|
|
130
130
|
dest_path = os.path.abspath(dest)
|
|
131
|
+
project_name = Path(dest_path).name
|
|
132
|
+
package_version = "0.0.0"
|
|
131
133
|
if os.path.exists(dest_path):
|
|
132
134
|
raise click.ClickException(f"Destination already exists: {dest_path}")
|
|
133
135
|
shutil.copytree(template_root, dest_path)
|
|
@@ -136,11 +138,20 @@ def create(dest: str):
|
|
|
136
138
|
if config_path.exists():
|
|
137
139
|
try:
|
|
138
140
|
data = json.loads(config_path.read_text())
|
|
139
|
-
|
|
140
|
-
data.setdefault("uns", {})["packageName"] = project_name
|
|
141
|
+
data.setdefault("uns", {}) # keep structure for processName, etc.
|
|
141
142
|
config_path.write_text(json.dumps(data, indent=2))
|
|
142
143
|
except Exception:
|
|
143
144
|
pass
|
|
145
|
+
# personalize package.json for PM2 metadata
|
|
146
|
+
pkg_path = Path(dest_path) / "package.json"
|
|
147
|
+
if pkg_path.exists():
|
|
148
|
+
try:
|
|
149
|
+
pkg_data = json.loads(pkg_path.read_text())
|
|
150
|
+
pkg_data["name"] = project_name
|
|
151
|
+
pkg_data["version"] = package_version
|
|
152
|
+
pkg_path.write_text(json.dumps(pkg_data, indent=2))
|
|
153
|
+
except Exception:
|
|
154
|
+
pass
|
|
144
155
|
click.echo(f"Created UNS Python app at {dest_path}")
|
|
145
156
|
click.echo("Next steps:")
|
|
146
157
|
click.echo(f" 1) cd {dest_path}")
|
|
@@ -166,8 +177,6 @@ def write_config(path: str):
|
|
|
166
177
|
"clean": True
|
|
167
178
|
},
|
|
168
179
|
"uns": {
|
|
169
|
-
"packageName": project_name,
|
|
170
|
-
"packageVersion": "0.0.1",
|
|
171
180
|
"processName": "uns-process"
|
|
172
181
|
}
|
|
173
182
|
}
|
uns_kit/config.py
CHANGED
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import json
|
|
4
4
|
from dataclasses import dataclass
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import List, Optional
|
|
6
|
+
from typing import List, Optional, Tuple
|
|
7
7
|
|
|
8
8
|
from .topic_builder import TopicBuilder
|
|
9
9
|
from .version import __version__
|
|
@@ -34,6 +34,7 @@ class UnsConfig:
|
|
|
34
34
|
|
|
35
35
|
infra = data.get("infra", {}) or {}
|
|
36
36
|
uns_section = data.get("uns", {}) or {}
|
|
37
|
+
pkg_name, pkg_version = _read_package_metadata(path)
|
|
37
38
|
|
|
38
39
|
proto = (infra.get("protocol") or "").lower()
|
|
39
40
|
tls = proto in ("mqtts", "ssl", "wss")
|
|
@@ -52,8 +53,8 @@ class UnsConfig:
|
|
|
52
53
|
mqtt_sub_to_topics=infra.get("mqttSubToTopics"),
|
|
53
54
|
keepalive=infra.get("keepalive", 60),
|
|
54
55
|
clean_session=infra.get("clean", True),
|
|
55
|
-
package_name=uns_section.get("packageName"
|
|
56
|
-
package_version=uns_section.get("packageVersion") or __version__,
|
|
56
|
+
package_name=uns_section.get("packageName") or pkg_name or "uns-kit",
|
|
57
|
+
package_version=uns_section.get("packageVersion") or pkg_version or __version__,
|
|
57
58
|
process_name=uns_section.get("processName", "uns-process"),
|
|
58
59
|
)
|
|
59
60
|
|
|
@@ -88,3 +89,20 @@ class UnsConfig:
|
|
|
88
89
|
|
|
89
90
|
def _none_if_empty(value: Optional[str]) -> Optional[str]:
|
|
90
91
|
return None if value == "" else value
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _read_package_metadata(config_path: Path) -> Tuple[Optional[str], Optional[str]]:
|
|
95
|
+
"""
|
|
96
|
+
Read name/version from the nearest package.json beside the config (if present).
|
|
97
|
+
Falls back to None when not available or invalid.
|
|
98
|
+
"""
|
|
99
|
+
pkg_path = config_path.parent / "package.json"
|
|
100
|
+
if not pkg_path.exists():
|
|
101
|
+
return None, None
|
|
102
|
+
try:
|
|
103
|
+
pkg = json.loads(pkg_path.read_text())
|
|
104
|
+
name = pkg.get("name")
|
|
105
|
+
version = pkg.get("version")
|
|
106
|
+
return (name if isinstance(name, str) else None, version if isinstance(version, str) else None)
|
|
107
|
+
except Exception:
|
|
108
|
+
return None, None
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
uns_kit/__init__.py,sha256=oLhYBOJkoYXBJGN7VDtJpMXAb1v5qFVphun5QgFwthw,564
|
|
2
|
-
uns_kit/cli.py,sha256=
|
|
2
|
+
uns_kit/cli.py,sha256=3yv6gnYoTJmGiT0Zgsuru8ylbtOcjtFTVFUGRBvWLjA,6546
|
|
3
3
|
uns_kit/client.py,sha256=GjlGOTPuaxeLlgkfcJWpxMId6nLeZNsZTNBfOYAe8YY,14892
|
|
4
|
-
uns_kit/config.py,sha256=
|
|
4
|
+
uns_kit/config.py,sha256=2pkQjH4m7WnqmitLrtaJM_EyQspXcgLg2jp-SfR46xQ,3621
|
|
5
5
|
uns_kit/packet.py,sha256=M-JJ0--FVe-iFPGnBUFynx_0iKB9F3NFwvETJ7yKibc,5874
|
|
6
6
|
uns_kit/proxy.py,sha256=H1Afs71rdb7DTHYp_8qeoM8uN5vOvAzYK50u9JszXQQ,2338
|
|
7
7
|
uns_kit/proxy_process.py,sha256=If8HXd_YAf1xYjzy8BA73Jo0DRh0-3WpHHIoVcIbS-Q,3906
|
|
8
8
|
uns_kit/status_monitor.py,sha256=8XXBaUHh8SW7gX4d3EtChnEkgQ7rnQ14tEHb0jDB25I,3022
|
|
9
9
|
uns_kit/templates/default/README.md,sha256=5_o_xowRuzHtn3NzibO-Ysq6iTTAuYbvtTFn27dH-yU,1251
|
|
10
10
|
uns_kit/templates/default/main.py,sha256=aD5o9FYl_5dBS-FQkB7kDXTMErmKQ360Qg9OdanJE0M,851
|
|
11
|
+
uns_kit/templates/default/package.json,sha256=rhmHnWwUUFQq0ZEjTr1uEKv7lkDuQsdvOOKfiwrhkH0,144
|
|
11
12
|
uns_kit/templates/default/pyproject.toml,sha256=KRPBGql4iVgBZIfdpOTNemPUdCBfvea3QHAb-tmh3jw,559
|
|
12
13
|
uns_kit/templates/default/runtime.json,sha256=TqLe6z6z3T4yCu0XfFcAl1B1KCheEcQPi3s1kM0e4CA,54
|
|
13
14
|
uns_kit/templates/default/src/data_example.py,sha256=8D1CyGVsbeKzZV79l8zaX-hqz_gxrA_ps2TA-GwzLQI,4381
|
|
@@ -16,7 +17,7 @@ uns_kit/templates/default/uns_py_app/__init__.py,sha256=3yOo4InP5WD5tN0Lu14mjd90
|
|
|
16
17
|
uns_kit/topic_builder.py,sha256=UYC2SS9ptHopeyQ3ud1HEg1IHr5RJ7X2DEkfZC1CM5Y,1938
|
|
17
18
|
uns_kit/uns_mqtt_proxy.py,sha256=QzG0E42r7n33Z4Ri70-DxTlVoM-wj0_wAtnbMyaet08,9831
|
|
18
19
|
uns_kit/version.py,sha256=vmk-z_o25XOVgX5lSUrECllqau8NL7B_pkKsSmwhmX0,247
|
|
19
|
-
uns_kit-0.0.
|
|
20
|
-
uns_kit-0.0.
|
|
21
|
-
uns_kit-0.0.
|
|
22
|
-
uns_kit-0.0.
|
|
20
|
+
uns_kit-0.0.8.dist-info/METADATA,sha256=kB3y6DwshDixLkCsoiD5L--cgFboYHvLk6KxwKoSGFc,3306
|
|
21
|
+
uns_kit-0.0.8.dist-info/WHEEL,sha256=3ny-bZhpXrU6vSQ1UPG34FoxZBp3lVcvK0LkgUz6VLk,88
|
|
22
|
+
uns_kit-0.0.8.dist-info/entry_points.txt,sha256=sLvTioiJQfGczUD-ODVx2xwwtHcGKjlIOn8t_Lt87Pg,47
|
|
23
|
+
uns_kit-0.0.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|